babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  640. static readonly GEQUAL: number;
  641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. /**
  1375. * Loads an image as an HTMLImageElement.
  1376. * @param input url string, ArrayBuffer, or Blob to load
  1377. * @param onLoad callback called when the image successfully loads
  1378. * @param onError callback called when the image fails to load
  1379. * @param offlineProvider offline provider for caching
  1380. * @returns the HTMLImageElement of the loaded image
  1381. */
  1382. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1383. /**
  1384. * Loads a file
  1385. * @param fileToLoad defines the file to load
  1386. * @param callback defines the callback to call when data is loaded
  1387. * @param progressCallBack defines the callback to call during loading process
  1388. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1392. /**
  1393. * Loads a file
  1394. * @param url url string, ArrayBuffer, or Blob to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Checks if the loaded document was accessed via `file:`-Protocol.
  1405. * @returns boolean
  1406. */
  1407. static IsFileURL(): boolean;
  1408. }
  1409. }
  1410. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1411. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1412. /** @hidden */
  1413. export class ShaderProcessor {
  1414. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1415. private static _ProcessPrecision;
  1416. private static _ExtractOperation;
  1417. private static _BuildSubExpression;
  1418. private static _BuildExpression;
  1419. private static _MoveCursorWithinIf;
  1420. private static _MoveCursor;
  1421. private static _EvaluatePreProcessors;
  1422. private static _PreparePreProcessors;
  1423. private static _ProcessShaderConversion;
  1424. private static _ProcessIncludes;
  1425. }
  1426. }
  1427. declare module "babylonjs/Maths/math.like" {
  1428. import { float, int, DeepImmutable } from "babylonjs/types";
  1429. /**
  1430. * @hidden
  1431. */
  1432. export interface IColor4Like {
  1433. r: float;
  1434. g: float;
  1435. b: float;
  1436. a: float;
  1437. }
  1438. /**
  1439. * @hidden
  1440. */
  1441. export interface IColor3Like {
  1442. r: float;
  1443. g: float;
  1444. b: float;
  1445. }
  1446. /**
  1447. * @hidden
  1448. */
  1449. export interface IVector4Like {
  1450. x: float;
  1451. y: float;
  1452. z: float;
  1453. w: float;
  1454. }
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IVector3Like {
  1459. x: float;
  1460. y: float;
  1461. z: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IVector2Like {
  1467. x: float;
  1468. y: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IMatrixLike {
  1474. toArray(): DeepImmutable<Float32Array>;
  1475. updateFlag: int;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IViewportLike {
  1481. x: float;
  1482. y: float;
  1483. width: float;
  1484. height: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IPlaneLike {
  1490. normal: IVector3Like;
  1491. d: float;
  1492. normalize(): void;
  1493. }
  1494. }
  1495. declare module "babylonjs/Materials/iEffectFallbacks" {
  1496. import { Effect } from "babylonjs/Materials/effect";
  1497. /**
  1498. * Interface used to define common properties for effect fallbacks
  1499. */
  1500. export interface IEffectFallbacks {
  1501. /**
  1502. * Removes the defines that should be removed when falling back.
  1503. * @param currentDefines defines the current define statements for the shader.
  1504. * @param effect defines the current effect we try to compile
  1505. * @returns The resulting defines with defines of the current rank removed.
  1506. */
  1507. reduce(currentDefines: string, effect: Effect): string;
  1508. /**
  1509. * Removes the fallback from the bound mesh.
  1510. */
  1511. unBindMesh(): void;
  1512. /**
  1513. * Checks to see if more fallbacks are still availible.
  1514. */
  1515. hasMoreFallbacks: boolean;
  1516. }
  1517. }
  1518. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1519. /**
  1520. * Class used to evalaute queries containing `and` and `or` operators
  1521. */
  1522. export class AndOrNotEvaluator {
  1523. /**
  1524. * Evaluate a query
  1525. * @param query defines the query to evaluate
  1526. * @param evaluateCallback defines the callback used to filter result
  1527. * @returns true if the query matches
  1528. */
  1529. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1530. private static _HandleParenthesisContent;
  1531. private static _SimplifyNegation;
  1532. }
  1533. }
  1534. declare module "babylonjs/Misc/tags" {
  1535. /**
  1536. * Class used to store custom tags
  1537. */
  1538. export class Tags {
  1539. /**
  1540. * Adds support for tags on the given object
  1541. * @param obj defines the object to use
  1542. */
  1543. static EnableFor(obj: any): void;
  1544. /**
  1545. * Removes tags support
  1546. * @param obj defines the object to use
  1547. */
  1548. static DisableFor(obj: any): void;
  1549. /**
  1550. * Gets a boolean indicating if the given object has tags
  1551. * @param obj defines the object to use
  1552. * @returns a boolean
  1553. */
  1554. static HasTags(obj: any): boolean;
  1555. /**
  1556. * Gets the tags available on a given object
  1557. * @param obj defines the object to use
  1558. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1559. * @returns the tags
  1560. */
  1561. static GetTags(obj: any, asString?: boolean): any;
  1562. /**
  1563. * Adds tags to an object
  1564. * @param obj defines the object to use
  1565. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1566. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1567. */
  1568. static AddTagsTo(obj: any, tagsString: string): void;
  1569. /**
  1570. * @hidden
  1571. */
  1572. static _AddTagTo(obj: any, tag: string): void;
  1573. /**
  1574. * Removes specific tags from a specific object
  1575. * @param obj defines the object to use
  1576. * @param tagsString defines the tags to remove
  1577. */
  1578. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1579. /**
  1580. * @hidden
  1581. */
  1582. static _RemoveTagFrom(obj: any, tag: string): void;
  1583. /**
  1584. * Defines if tags hosted on an object match a given query
  1585. * @param obj defines the object to use
  1586. * @param tagsQuery defines the tag query
  1587. * @returns a boolean
  1588. */
  1589. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1590. }
  1591. }
  1592. declare module "babylonjs/Maths/math.scalar" {
  1593. /**
  1594. * Scalar computation library
  1595. */
  1596. export class Scalar {
  1597. /**
  1598. * Two pi constants convenient for computation.
  1599. */
  1600. static TwoPi: number;
  1601. /**
  1602. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1603. * @param a number
  1604. * @param b number
  1605. * @param epsilon (default = 1.401298E-45)
  1606. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1607. */
  1608. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1609. /**
  1610. * Returns a string : the upper case translation of the number i to hexadecimal.
  1611. * @param i number
  1612. * @returns the upper case translation of the number i to hexadecimal.
  1613. */
  1614. static ToHex(i: number): string;
  1615. /**
  1616. * Returns -1 if value is negative and +1 is value is positive.
  1617. * @param value the value
  1618. * @returns the value itself if it's equal to zero.
  1619. */
  1620. static Sign(value: number): number;
  1621. /**
  1622. * Returns the value itself if it's between min and max.
  1623. * Returns min if the value is lower than min.
  1624. * Returns max if the value is greater than max.
  1625. * @param value the value to clmap
  1626. * @param min the min value to clamp to (default: 0)
  1627. * @param max the max value to clamp to (default: 1)
  1628. * @returns the clamped value
  1629. */
  1630. static Clamp(value: number, min?: number, max?: number): number;
  1631. /**
  1632. * the log2 of value.
  1633. * @param value the value to compute log2 of
  1634. * @returns the log2 of value.
  1635. */
  1636. static Log2(value: number): number;
  1637. /**
  1638. * Loops the value, so that it is never larger than length and never smaller than 0.
  1639. *
  1640. * This is similar to the modulo operator but it works with floating point numbers.
  1641. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1642. * With t = 5 and length = 2.5, the result would be 0.0.
  1643. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1644. * @param value the value
  1645. * @param length the length
  1646. * @returns the looped value
  1647. */
  1648. static Repeat(value: number, length: number): number;
  1649. /**
  1650. * Normalize the value between 0.0 and 1.0 using min and max values
  1651. * @param value value to normalize
  1652. * @param min max to normalize between
  1653. * @param max min to normalize between
  1654. * @returns the normalized value
  1655. */
  1656. static Normalize(value: number, min: number, max: number): number;
  1657. /**
  1658. * Denormalize the value from 0.0 and 1.0 using min and max values
  1659. * @param normalized value to denormalize
  1660. * @param min max to denormalize between
  1661. * @param max min to denormalize between
  1662. * @returns the denormalized value
  1663. */
  1664. static Denormalize(normalized: number, min: number, max: number): number;
  1665. /**
  1666. * Calculates the shortest difference between two given angles given in degrees.
  1667. * @param current current angle in degrees
  1668. * @param target target angle in degrees
  1669. * @returns the delta
  1670. */
  1671. static DeltaAngle(current: number, target: number): number;
  1672. /**
  1673. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1674. * @param tx value
  1675. * @param length length
  1676. * @returns The returned value will move back and forth between 0 and length
  1677. */
  1678. static PingPong(tx: number, length: number): number;
  1679. /**
  1680. * Interpolates between min and max with smoothing at the limits.
  1681. *
  1682. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1683. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1684. * @param from from
  1685. * @param to to
  1686. * @param tx value
  1687. * @returns the smooth stepped value
  1688. */
  1689. static SmoothStep(from: number, to: number, tx: number): number;
  1690. /**
  1691. * Moves a value current towards target.
  1692. *
  1693. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1694. * Negative values of maxDelta pushes the value away from target.
  1695. * @param current current value
  1696. * @param target target value
  1697. * @param maxDelta max distance to move
  1698. * @returns resulting value
  1699. */
  1700. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1701. /**
  1702. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1703. *
  1704. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1705. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1706. * @param current current value
  1707. * @param target target value
  1708. * @param maxDelta max distance to move
  1709. * @returns resulting angle
  1710. */
  1711. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1712. /**
  1713. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1714. * @param start start value
  1715. * @param end target value
  1716. * @param amount amount to lerp between
  1717. * @returns the lerped value
  1718. */
  1719. static Lerp(start: number, end: number, amount: number): number;
  1720. /**
  1721. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1722. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1723. * @param start start value
  1724. * @param end target value
  1725. * @param amount amount to lerp between
  1726. * @returns the lerped value
  1727. */
  1728. static LerpAngle(start: number, end: number, amount: number): number;
  1729. /**
  1730. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1731. * @param a start value
  1732. * @param b target value
  1733. * @param value value between a and b
  1734. * @returns the inverseLerp value
  1735. */
  1736. static InverseLerp(a: number, b: number, value: number): number;
  1737. /**
  1738. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1739. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1740. * @param value1 spline value
  1741. * @param tangent1 spline value
  1742. * @param value2 spline value
  1743. * @param tangent2 spline value
  1744. * @param amount input value
  1745. * @returns hermite result
  1746. */
  1747. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1748. /**
  1749. * Returns a random float number between and min and max values
  1750. * @param min min value of random
  1751. * @param max max value of random
  1752. * @returns random value
  1753. */
  1754. static RandomRange(min: number, max: number): number;
  1755. /**
  1756. * This function returns percentage of a number in a given range.
  1757. *
  1758. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1759. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1760. * @param number to convert to percentage
  1761. * @param min min range
  1762. * @param max max range
  1763. * @returns the percentage
  1764. */
  1765. static RangeToPercent(number: number, min: number, max: number): number;
  1766. /**
  1767. * This function returns number that corresponds to the percentage in a given range.
  1768. *
  1769. * PercentToRange(0.34,0,100) will return 34.
  1770. * @param percent to convert to number
  1771. * @param min min range
  1772. * @param max max range
  1773. * @returns the number
  1774. */
  1775. static PercentToRange(percent: number, min: number, max: number): number;
  1776. /**
  1777. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1778. * @param angle The angle to normalize in radian.
  1779. * @return The converted angle.
  1780. */
  1781. static NormalizeRadians(angle: number): number;
  1782. }
  1783. }
  1784. declare module "babylonjs/Maths/math.constants" {
  1785. /**
  1786. * Constant used to convert a value to gamma space
  1787. * @ignorenaming
  1788. */
  1789. export const ToGammaSpace: number;
  1790. /**
  1791. * Constant used to convert a value to linear space
  1792. * @ignorenaming
  1793. */
  1794. export const ToLinearSpace = 2.2;
  1795. /**
  1796. * Constant used to define the minimal number value in Babylon.js
  1797. * @ignorenaming
  1798. */
  1799. let Epsilon: number;
  1800. export { Epsilon };
  1801. }
  1802. declare module "babylonjs/Maths/math.viewport" {
  1803. /**
  1804. * Class used to represent a viewport on screen
  1805. */
  1806. export class Viewport {
  1807. /** viewport left coordinate */
  1808. x: number;
  1809. /** viewport top coordinate */
  1810. y: number;
  1811. /**viewport width */
  1812. width: number;
  1813. /** viewport height */
  1814. height: number;
  1815. /**
  1816. * Creates a Viewport object located at (x, y) and sized (width, height)
  1817. * @param x defines viewport left coordinate
  1818. * @param y defines viewport top coordinate
  1819. * @param width defines the viewport width
  1820. * @param height defines the viewport height
  1821. */
  1822. constructor(
  1823. /** viewport left coordinate */
  1824. x: number,
  1825. /** viewport top coordinate */
  1826. y: number,
  1827. /**viewport width */
  1828. width: number,
  1829. /** viewport height */
  1830. height: number);
  1831. /**
  1832. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1833. * @param renderWidth defines the rendering width
  1834. * @param renderHeight defines the rendering height
  1835. * @returns a new Viewport
  1836. */
  1837. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1838. /**
  1839. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1840. * @param renderWidth defines the rendering width
  1841. * @param renderHeight defines the rendering height
  1842. * @param ref defines the target viewport
  1843. * @returns the current viewport
  1844. */
  1845. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1846. /**
  1847. * Returns a new Viewport copied from the current one
  1848. * @returns a new Viewport
  1849. */
  1850. clone(): Viewport;
  1851. }
  1852. }
  1853. declare module "babylonjs/Misc/arrayTools" {
  1854. /**
  1855. * Class containing a set of static utilities functions for arrays.
  1856. */
  1857. export class ArrayTools {
  1858. /**
  1859. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1860. * @param size the number of element to construct and put in the array
  1861. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1862. * @returns a new array filled with new objects
  1863. */
  1864. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1865. }
  1866. }
  1867. declare module "babylonjs/Maths/math.vector" {
  1868. import { Viewport } from "babylonjs/Maths/math.viewport";
  1869. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1870. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1871. /**
  1872. * Class representing a vector containing 2 coordinates
  1873. */
  1874. export class Vector2 {
  1875. /** defines the first coordinate */
  1876. x: number;
  1877. /** defines the second coordinate */
  1878. y: number;
  1879. /**
  1880. * Creates a new Vector2 from the given x and y coordinates
  1881. * @param x defines the first coordinate
  1882. * @param y defines the second coordinate
  1883. */
  1884. constructor(
  1885. /** defines the first coordinate */
  1886. x?: number,
  1887. /** defines the second coordinate */
  1888. y?: number);
  1889. /**
  1890. * Gets a string with the Vector2 coordinates
  1891. * @returns a string with the Vector2 coordinates
  1892. */
  1893. toString(): string;
  1894. /**
  1895. * Gets class name
  1896. * @returns the string "Vector2"
  1897. */
  1898. getClassName(): string;
  1899. /**
  1900. * Gets current vector hash code
  1901. * @returns the Vector2 hash code as a number
  1902. */
  1903. getHashCode(): number;
  1904. /**
  1905. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1906. * @param array defines the source array
  1907. * @param index defines the offset in source array
  1908. * @returns the current Vector2
  1909. */
  1910. toArray(array: FloatArray, index?: number): Vector2;
  1911. /**
  1912. * Copy the current vector to an array
  1913. * @returns a new array with 2 elements: the Vector2 coordinates.
  1914. */
  1915. asArray(): number[];
  1916. /**
  1917. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1918. * @param source defines the source Vector2
  1919. * @returns the current updated Vector2
  1920. */
  1921. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1922. /**
  1923. * Sets the Vector2 coordinates with the given floats
  1924. * @param x defines the first coordinate
  1925. * @param y defines the second coordinate
  1926. * @returns the current updated Vector2
  1927. */
  1928. copyFromFloats(x: number, y: number): Vector2;
  1929. /**
  1930. * Sets the Vector2 coordinates with the given floats
  1931. * @param x defines the first coordinate
  1932. * @param y defines the second coordinate
  1933. * @returns the current updated Vector2
  1934. */
  1935. set(x: number, y: number): Vector2;
  1936. /**
  1937. * Add another vector with the current one
  1938. * @param otherVector defines the other vector
  1939. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1940. */
  1941. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1944. * @param otherVector defines the other vector
  1945. * @param result defines the target vector
  1946. * @returns the unmodified current Vector2
  1947. */
  1948. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1949. /**
  1950. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1951. * @param otherVector defines the other vector
  1952. * @returns the current updated Vector2
  1953. */
  1954. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1957. * @param otherVector defines the other vector
  1958. * @returns a new Vector2
  1959. */
  1960. addVector3(otherVector: Vector3): Vector2;
  1961. /**
  1962. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1963. * @param otherVector defines the other vector
  1964. * @returns a new Vector2
  1965. */
  1966. subtract(otherVector: Vector2): Vector2;
  1967. /**
  1968. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1969. * @param otherVector defines the other vector
  1970. * @param result defines the target vector
  1971. * @returns the unmodified current Vector2
  1972. */
  1973. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1974. /**
  1975. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1976. * @param otherVector defines the other vector
  1977. * @returns the current updated Vector2
  1978. */
  1979. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1980. /**
  1981. * Multiplies in place the current Vector2 coordinates by the given ones
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1992. /**
  1993. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @param result defines the target vector
  1996. * @returns the unmodified current Vector2
  1997. */
  1998. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1999. /**
  2000. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2001. * @param x defines the first coordinate
  2002. * @param y defines the second coordinate
  2003. * @returns a new Vector2
  2004. */
  2005. multiplyByFloats(x: number, y: number): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. divide(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Divides the current Vector2 coordinates by the given ones
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Gets a new Vector2 with current Vector2 negated coordinates
  2027. * @returns a new Vector2
  2028. */
  2029. negate(): Vector2;
  2030. /**
  2031. * Multiply the Vector2 coordinates by scale
  2032. * @param scale defines the scaling factor
  2033. * @returns the current updated Vector2
  2034. */
  2035. scaleInPlace(scale: number): Vector2;
  2036. /**
  2037. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2038. * @param scale defines the scaling factor
  2039. * @returns a new Vector2
  2040. */
  2041. scale(scale: number): Vector2;
  2042. /**
  2043. * Scale the current Vector2 values by a factor to a given Vector2
  2044. * @param scale defines the scale factor
  2045. * @param result defines the Vector2 object where to store the result
  2046. * @returns the unmodified current Vector2
  2047. */
  2048. scaleToRef(scale: number, result: Vector2): Vector2;
  2049. /**
  2050. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2051. * @param scale defines the scale factor
  2052. * @param result defines the Vector2 object where to store the result
  2053. * @returns the unmodified current Vector2
  2054. */
  2055. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2056. /**
  2057. * Gets a boolean if two vectors are equals
  2058. * @param otherVector defines the other vector
  2059. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2060. */
  2061. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2062. /**
  2063. * Gets a boolean if two vectors are equals (using an epsilon value)
  2064. * @param otherVector defines the other vector
  2065. * @param epsilon defines the minimal distance to consider equality
  2066. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2067. */
  2068. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2069. /**
  2070. * Gets a new Vector2 from current Vector2 floored values
  2071. * @returns a new Vector2
  2072. */
  2073. floor(): Vector2;
  2074. /**
  2075. * Gets a new Vector2 from current Vector2 floored values
  2076. * @returns a new Vector2
  2077. */
  2078. fract(): Vector2;
  2079. /**
  2080. * Gets the length of the vector
  2081. * @returns the vector length (float)
  2082. */
  2083. length(): number;
  2084. /**
  2085. * Gets the vector squared length
  2086. * @returns the vector squared length (float)
  2087. */
  2088. lengthSquared(): number;
  2089. /**
  2090. * Normalize the vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. normalize(): Vector2;
  2094. /**
  2095. * Gets a new Vector2 copied from the Vector2
  2096. * @returns a new Vector2
  2097. */
  2098. clone(): Vector2;
  2099. /**
  2100. * Gets a new Vector2(0, 0)
  2101. * @returns a new Vector2
  2102. */
  2103. static Zero(): Vector2;
  2104. /**
  2105. * Gets a new Vector2(1, 1)
  2106. * @returns a new Vector2
  2107. */
  2108. static One(): Vector2;
  2109. /**
  2110. * Gets a new Vector2 set from the given index element of the given array
  2111. * @param array defines the data source
  2112. * @param offset defines the offset in the data source
  2113. * @returns a new Vector2
  2114. */
  2115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2116. /**
  2117. * Sets "result" from the given index element of the given array
  2118. * @param array defines the data source
  2119. * @param offset defines the offset in the data source
  2120. * @param result defines the target vector
  2121. */
  2122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2123. /**
  2124. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2125. * @param value1 defines 1st point of control
  2126. * @param value2 defines 2nd point of control
  2127. * @param value3 defines 3rd point of control
  2128. * @param value4 defines 4th point of control
  2129. * @param amount defines the interpolation factor
  2130. * @returns a new Vector2
  2131. */
  2132. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2133. /**
  2134. * 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".
  2135. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2136. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2137. * @param value defines the value to clamp
  2138. * @param min defines the lower limit
  2139. * @param max defines the upper limit
  2140. * @returns a new Vector2
  2141. */
  2142. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2145. * @param value1 defines the 1st control point
  2146. * @param tangent1 defines the outgoing tangent
  2147. * @param value2 defines the 2nd control point
  2148. * @param tangent2 defines the incoming tangent
  2149. * @param amount defines the interpolation factor
  2150. * @returns a new Vector2
  2151. */
  2152. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2153. /**
  2154. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2155. * @param start defines the start vector
  2156. * @param end defines the end vector
  2157. * @param amount defines the interpolation factor
  2158. * @returns a new Vector2
  2159. */
  2160. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2161. /**
  2162. * Gets the dot product of the vector "left" and the vector "right"
  2163. * @param left defines first vector
  2164. * @param right defines second vector
  2165. * @returns the dot product (float)
  2166. */
  2167. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2168. /**
  2169. * Returns a new Vector2 equal to the normalized given vector
  2170. * @param vector defines the vector to normalize
  2171. * @returns a new Vector2
  2172. */
  2173. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2176. * @param left defines 1st vector
  2177. * @param right defines 2nd vector
  2178. * @returns a new Vector2
  2179. */
  2180. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2183. * @param left defines 1st vector
  2184. * @param right defines 2nd vector
  2185. * @returns a new Vector2
  2186. */
  2187. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2190. * @param vector defines the vector to transform
  2191. * @param transformation defines the matrix to apply
  2192. * @returns a new Vector2
  2193. */
  2194. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2195. /**
  2196. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2197. * @param vector defines the vector to transform
  2198. * @param transformation defines the matrix to apply
  2199. * @param result defines the target vector
  2200. */
  2201. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2202. /**
  2203. * Determines if a given vector is included in a triangle
  2204. * @param p defines the vector to test
  2205. * @param p0 defines 1st triangle point
  2206. * @param p1 defines 2nd triangle point
  2207. * @param p2 defines 3rd triangle point
  2208. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2209. */
  2210. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2211. /**
  2212. * Gets the distance between the vectors "value1" and "value2"
  2213. * @param value1 defines first vector
  2214. * @param value2 defines second vector
  2215. * @returns the distance between vectors
  2216. */
  2217. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2218. /**
  2219. * Returns the squared distance between the vectors "value1" and "value2"
  2220. * @param value1 defines first vector
  2221. * @param value2 defines second vector
  2222. * @returns the squared distance between vectors
  2223. */
  2224. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2225. /**
  2226. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2227. * @param value1 defines first vector
  2228. * @param value2 defines second vector
  2229. * @returns a new Vector2
  2230. */
  2231. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2234. * @param p defines the middle point
  2235. * @param segA defines one point of the segment
  2236. * @param segB defines the other point of the segment
  2237. * @returns the shortest distance
  2238. */
  2239. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2240. }
  2241. /**
  2242. * Classed used to store (x,y,z) vector representation
  2243. * A Vector3 is the main object used in 3D geometry
  2244. * It can represent etiher the coordinates of a point the space, either a direction
  2245. * Reminder: js uses a left handed forward facing system
  2246. */
  2247. export class Vector3 {
  2248. /**
  2249. * Defines the first coordinates (on X axis)
  2250. */
  2251. x: number;
  2252. /**
  2253. * Defines the second coordinates (on Y axis)
  2254. */
  2255. y: number;
  2256. /**
  2257. * Defines the third coordinates (on Z axis)
  2258. */
  2259. z: number;
  2260. private static _UpReadOnly;
  2261. private static _ZeroReadOnly;
  2262. /**
  2263. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2264. * @param x defines the first coordinates (on X axis)
  2265. * @param y defines the second coordinates (on Y axis)
  2266. * @param z defines the third coordinates (on Z axis)
  2267. */
  2268. constructor(
  2269. /**
  2270. * Defines the first coordinates (on X axis)
  2271. */
  2272. x?: number,
  2273. /**
  2274. * Defines the second coordinates (on Y axis)
  2275. */
  2276. y?: number,
  2277. /**
  2278. * Defines the third coordinates (on Z axis)
  2279. */
  2280. z?: number);
  2281. /**
  2282. * Creates a string representation of the Vector3
  2283. * @returns a string with the Vector3 coordinates.
  2284. */
  2285. toString(): string;
  2286. /**
  2287. * Gets the class name
  2288. * @returns the string "Vector3"
  2289. */
  2290. getClassName(): string;
  2291. /**
  2292. * Creates the Vector3 hash code
  2293. * @returns a number which tends to be unique between Vector3 instances
  2294. */
  2295. getHashCode(): number;
  2296. /**
  2297. * Creates an array containing three elements : the coordinates of the Vector3
  2298. * @returns a new array of numbers
  2299. */
  2300. asArray(): number[];
  2301. /**
  2302. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2303. * @param array defines the destination array
  2304. * @param index defines the offset in the destination array
  2305. * @returns the current Vector3
  2306. */
  2307. toArray(array: FloatArray, index?: number): Vector3;
  2308. /**
  2309. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2310. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2311. */
  2312. toQuaternion(): Quaternion;
  2313. /**
  2314. * Adds the given vector to the current Vector3
  2315. * @param otherVector defines the second operand
  2316. * @returns the current updated Vector3
  2317. */
  2318. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2319. /**
  2320. * Adds the given coordinates to the current Vector3
  2321. * @param x defines the x coordinate of the operand
  2322. * @param y defines the y coordinate of the operand
  2323. * @param z defines the z coordinate of the operand
  2324. * @returns the current updated Vector3
  2325. */
  2326. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2327. /**
  2328. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2329. * @param otherVector defines the second operand
  2330. * @returns the resulting Vector3
  2331. */
  2332. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2333. /**
  2334. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2335. * @param otherVector defines the second operand
  2336. * @param result defines the Vector3 object where to store the result
  2337. * @returns the current Vector3
  2338. */
  2339. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2340. /**
  2341. * Subtract the given vector from the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the resulting Vector3
  2350. */
  2351. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2354. * @param otherVector defines the second operand
  2355. * @param result defines the Vector3 object where to store the result
  2356. * @returns the current Vector3
  2357. */
  2358. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2359. /**
  2360. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2361. * @param x defines the x coordinate of the operand
  2362. * @param y defines the y coordinate of the operand
  2363. * @param z defines the z coordinate of the operand
  2364. * @returns the resulting Vector3
  2365. */
  2366. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2367. /**
  2368. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2369. * @param x defines the x coordinate of the operand
  2370. * @param y defines the y coordinate of the operand
  2371. * @param z defines the z coordinate of the operand
  2372. * @param result defines the Vector3 object where to store the result
  2373. * @returns the current Vector3
  2374. */
  2375. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2376. /**
  2377. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2378. * @returns a new Vector3
  2379. */
  2380. negate(): Vector3;
  2381. /**
  2382. * Multiplies the Vector3 coordinates by the float "scale"
  2383. * @param scale defines the multiplier factor
  2384. * @returns the current updated Vector3
  2385. */
  2386. scaleInPlace(scale: number): Vector3;
  2387. /**
  2388. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2389. * @param scale defines the multiplier factor
  2390. * @returns a new Vector3
  2391. */
  2392. scale(scale: number): Vector3;
  2393. /**
  2394. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2395. * @param scale defines the multiplier factor
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. scaleToRef(scale: number, result: Vector3): Vector3;
  2400. /**
  2401. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2402. * @param scale defines the scale factor
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the unmodified current Vector3
  2405. */
  2406. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2407. /**
  2408. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2409. * @param otherVector defines the second operand
  2410. * @returns true if both vectors are equals
  2411. */
  2412. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2413. /**
  2414. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2415. * @param otherVector defines the second operand
  2416. * @param epsilon defines the minimal distance to define values as equals
  2417. * @returns true if both vectors are distant less than epsilon
  2418. */
  2419. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2420. /**
  2421. * Returns true if the current Vector3 coordinates equals the given floats
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns true if both vectors are equals
  2426. */
  2427. equalsToFloats(x: number, y: number, z: number): boolean;
  2428. /**
  2429. * Multiplies the current Vector3 coordinates by the given ones
  2430. * @param otherVector defines the second operand
  2431. * @returns the current updated Vector3
  2432. */
  2433. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2434. /**
  2435. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2436. * @param otherVector defines the second operand
  2437. * @returns the new Vector3
  2438. */
  2439. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2440. /**
  2441. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2442. * @param otherVector defines the second operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2447. /**
  2448. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @returns the new Vector3
  2453. */
  2454. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2455. /**
  2456. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2457. * @param otherVector defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2463. * @param otherVector defines the second operand
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the current Vector3
  2466. */
  2467. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2468. /**
  2469. * Divides the current Vector3 coordinates by the given ones.
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. divideInPlace(otherVector: Vector3): Vector3;
  2474. /**
  2475. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2476. * @param other defines the second operand
  2477. * @returns the current updated Vector3
  2478. */
  2479. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2480. /**
  2481. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2482. * @param other defines the second operand
  2483. * @returns the current updated Vector3
  2484. */
  2485. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2488. * @param x defines the x coordinate of the operand
  2489. * @param y defines the y coordinate of the operand
  2490. * @param z defines the z coordinate of the operand
  2491. * @returns the current updated Vector3
  2492. */
  2493. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2494. /**
  2495. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2496. * @param x defines the x coordinate of the operand
  2497. * @param y defines the y coordinate of the operand
  2498. * @param z defines the z coordinate of the operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2502. /**
  2503. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2504. * Check if is non uniform within a certain amount of decimal places to account for this
  2505. * @param epsilon the amount the values can differ
  2506. * @returns if the the vector is non uniform to a certain number of decimal places
  2507. */
  2508. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2509. /**
  2510. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2511. */
  2512. readonly isNonUniform: boolean;
  2513. /**
  2514. * Gets a new Vector3 from current Vector3 floored values
  2515. * @returns a new Vector3
  2516. */
  2517. floor(): Vector3;
  2518. /**
  2519. * Gets a new Vector3 from current Vector3 floored values
  2520. * @returns a new Vector3
  2521. */
  2522. fract(): Vector3;
  2523. /**
  2524. * Gets the length of the Vector3
  2525. * @returns the length of the Vector3
  2526. */
  2527. length(): number;
  2528. /**
  2529. * Gets the squared length of the Vector3
  2530. * @returns squared length of the Vector3
  2531. */
  2532. lengthSquared(): number;
  2533. /**
  2534. * Normalize the current Vector3.
  2535. * Please note that this is an in place operation.
  2536. * @returns the current updated Vector3
  2537. */
  2538. normalize(): Vector3;
  2539. /**
  2540. * Reorders the x y z properties of the vector in place
  2541. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2542. * @returns the current updated vector
  2543. */
  2544. reorderInPlace(order: string): this;
  2545. /**
  2546. * Rotates the vector around 0,0,0 by a quaternion
  2547. * @param quaternion the rotation quaternion
  2548. * @param result vector to store the result
  2549. * @returns the resulting vector
  2550. */
  2551. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2552. /**
  2553. * Rotates a vector around a given point
  2554. * @param quaternion the rotation quaternion
  2555. * @param point the point to rotate around
  2556. * @param result vector to store the result
  2557. * @returns the resulting vector
  2558. */
  2559. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2560. /**
  2561. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2562. * The cross product is then orthogonal to both current and "other"
  2563. * @param other defines the right operand
  2564. * @returns the cross product
  2565. */
  2566. cross(other: Vector3): Vector3;
  2567. /**
  2568. * Normalize the current Vector3 with the given input length.
  2569. * Please note that this is an in place operation.
  2570. * @param len the length of the vector
  2571. * @returns the current updated Vector3
  2572. */
  2573. normalizeFromLength(len: number): Vector3;
  2574. /**
  2575. * Normalize the current Vector3 to a new vector
  2576. * @returns the new Vector3
  2577. */
  2578. normalizeToNew(): Vector3;
  2579. /**
  2580. * Normalize the current Vector3 to the reference
  2581. * @param reference define the Vector3 to update
  2582. * @returns the updated Vector3
  2583. */
  2584. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Creates a new Vector3 copied from the current Vector3
  2587. * @returns the new Vector3
  2588. */
  2589. clone(): Vector3;
  2590. /**
  2591. * Copies the given vector coordinates to the current Vector3 ones
  2592. * @param source defines the source Vector3
  2593. * @returns the current updated Vector3
  2594. */
  2595. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2596. /**
  2597. * Copies the given floats to the current Vector3 coordinates
  2598. * @param x defines the x coordinate of the operand
  2599. * @param y defines the y coordinate of the operand
  2600. * @param z defines the z coordinate of the operand
  2601. * @returns the current updated Vector3
  2602. */
  2603. copyFromFloats(x: number, y: number, z: number): Vector3;
  2604. /**
  2605. * Copies the given floats to the current Vector3 coordinates
  2606. * @param x defines the x coordinate of the operand
  2607. * @param y defines the y coordinate of the operand
  2608. * @param z defines the z coordinate of the operand
  2609. * @returns the current updated Vector3
  2610. */
  2611. set(x: number, y: number, z: number): Vector3;
  2612. /**
  2613. * Copies the given float to the current Vector3 coordinates
  2614. * @param v defines the x, y and z coordinates of the operand
  2615. * @returns the current updated Vector3
  2616. */
  2617. setAll(v: number): Vector3;
  2618. /**
  2619. * Get the clip factor between two vectors
  2620. * @param vector0 defines the first operand
  2621. * @param vector1 defines the second operand
  2622. * @param axis defines the axis to use
  2623. * @param size defines the size along the axis
  2624. * @returns the clip factor
  2625. */
  2626. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2627. /**
  2628. * Get angle between two vectors
  2629. * @param vector0 angle between vector0 and vector1
  2630. * @param vector1 angle between vector0 and vector1
  2631. * @param normal direction of the normal
  2632. * @return the angle between vector0 and vector1
  2633. */
  2634. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2635. /**
  2636. * Returns a new Vector3 set from the index "offset" of the given array
  2637. * @param array defines the source array
  2638. * @param offset defines the offset in the source array
  2639. * @returns the new Vector3
  2640. */
  2641. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2642. /**
  2643. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2644. * This function is deprecated. Use FromArray instead
  2645. * @param array defines the source array
  2646. * @param offset defines the offset in the source array
  2647. * @returns the new Vector3
  2648. */
  2649. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2650. /**
  2651. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2652. * @param array defines the source array
  2653. * @param offset defines the offset in the source array
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2657. /**
  2658. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2659. * This function is deprecated. Use FromArrayToRef instead.
  2660. * @param array defines the source array
  2661. * @param offset defines the offset in the source array
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2665. /**
  2666. * Sets the given vector "result" with the given floats.
  2667. * @param x defines the x coordinate of the source
  2668. * @param y defines the y coordinate of the source
  2669. * @param z defines the z coordinate of the source
  2670. * @param result defines the Vector3 where to store the result
  2671. */
  2672. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2673. /**
  2674. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2675. * @returns a new empty Vector3
  2676. */
  2677. static Zero(): Vector3;
  2678. /**
  2679. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2680. * @returns a new unit Vector3
  2681. */
  2682. static One(): Vector3;
  2683. /**
  2684. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2685. * @returns a new up Vector3
  2686. */
  2687. static Up(): Vector3;
  2688. /**
  2689. * Gets a up Vector3 that must not be updated
  2690. */
  2691. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2692. /**
  2693. * Gets a zero Vector3 that must not be updated
  2694. */
  2695. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2696. /**
  2697. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2698. * @returns a new down Vector3
  2699. */
  2700. static Down(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2703. * @returns a new forward Vector3
  2704. */
  2705. static Forward(): Vector3;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2708. * @returns a new forward Vector3
  2709. */
  2710. static Backward(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2713. * @returns a new right Vector3
  2714. */
  2715. static Right(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2718. * @returns a new left Vector3
  2719. */
  2720. static Left(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2724. * @param vector defines the Vector3 to transform
  2725. * @param transformation defines the transformation matrix
  2726. * @returns the transformed Vector3
  2727. */
  2728. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2729. /**
  2730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2731. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2732. * @param vector defines the Vector3 to transform
  2733. * @param transformation defines the transformation matrix
  2734. * @param result defines the Vector3 where to store the result
  2735. */
  2736. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2737. /**
  2738. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2739. * This method computes tranformed coordinates only, not transformed direction vectors
  2740. * @param x define the x coordinate of the source vector
  2741. * @param y define the y coordinate of the source vector
  2742. * @param z define the z coordinate of the source vector
  2743. * @param transformation defines the transformation matrix
  2744. * @param result defines the Vector3 where to store the result
  2745. */
  2746. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the new Vector3
  2753. */
  2754. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2765. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2775. * @param value1 defines the first control point
  2776. * @param value2 defines the second control point
  2777. * @param value3 defines the third control point
  2778. * @param value4 defines the fourth control point
  2779. * @param amount defines the amount on the spline to use
  2780. * @returns the new Vector3
  2781. */
  2782. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2783. /**
  2784. * 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"
  2785. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2786. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2787. * @param value defines the current value
  2788. * @param min defines the lower range value
  2789. * @param max defines the upper range value
  2790. * @returns the new Vector3
  2791. */
  2792. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2793. /**
  2794. * 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"
  2795. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2796. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2797. * @param value defines the current value
  2798. * @param min defines the lower range value
  2799. * @param max defines the upper range value
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2803. /**
  2804. * Checks if a given vector is inside a specific range
  2805. * @param v defines the vector to test
  2806. * @param min defines the minimum range
  2807. * @param max defines the maximum range
  2808. */
  2809. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2812. * @param value1 defines the first control point
  2813. * @param tangent1 defines the first tangent vector
  2814. * @param value2 defines the second control point
  2815. * @param tangent2 defines the second tangent vector
  2816. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2817. * @returns the new Vector3
  2818. */
  2819. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2820. /**
  2821. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2822. * @param start defines the start value
  2823. * @param end defines the end value
  2824. * @param amount max defines amount between both (between 0 and 1)
  2825. * @returns the new Vector3
  2826. */
  2827. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2828. /**
  2829. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2830. * @param start defines the start value
  2831. * @param end defines the end value
  2832. * @param amount max defines amount between both (between 0 and 1)
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2836. /**
  2837. * Returns the dot product (float) between the vectors "left" and "right"
  2838. * @param left defines the left operand
  2839. * @param right defines the right operand
  2840. * @returns the dot product
  2841. */
  2842. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2843. /**
  2844. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2845. * The cross product is then orthogonal to both "left" and "right"
  2846. * @param left defines the left operand
  2847. * @param right defines the right operand
  2848. * @returns the cross product
  2849. */
  2850. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the cross product of "left" and "right"
  2853. * The cross product is then orthogonal to both "left" and "right"
  2854. * @param left defines the left operand
  2855. * @param right defines the right operand
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 as the normalization of the given vector
  2861. * @param vector defines the Vector3 to normalize
  2862. * @returns the new Vector3
  2863. */
  2864. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2865. /**
  2866. * Sets the given vector "result" with the normalization of the given first vector
  2867. * @param vector defines the Vector3 to normalize
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2871. /**
  2872. * Project a Vector3 onto screen space
  2873. * @param vector defines the Vector3 to project
  2874. * @param world defines the world matrix to use
  2875. * @param transform defines the transform (view x projection) matrix to use
  2876. * @param viewport defines the screen viewport to use
  2877. * @returns the new Vector3
  2878. */
  2879. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2880. /** @hidden */
  2881. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2882. /**
  2883. * Unproject from screen space to object space
  2884. * @param source defines the screen space Vector3 to use
  2885. * @param viewportWidth defines the current width of the viewport
  2886. * @param viewportHeight defines the current height of the viewport
  2887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2888. * @param transform defines the transform (view x projection) matrix to use
  2889. * @returns the new Vector3
  2890. */
  2891. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2892. /**
  2893. * Unproject from screen space to object space
  2894. * @param source defines the screen space Vector3 to use
  2895. * @param viewportWidth defines the current width of the viewport
  2896. * @param viewportHeight defines the current height of the viewport
  2897. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2898. * @param view defines the view matrix to use
  2899. * @param projection defines the projection matrix to use
  2900. * @returns the new Vector3
  2901. */
  2902. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2903. /**
  2904. * Unproject from screen space to object space
  2905. * @param source defines the screen space Vector3 to use
  2906. * @param viewportWidth defines the current width of the viewport
  2907. * @param viewportHeight defines the current height of the viewport
  2908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2909. * @param view defines the view matrix to use
  2910. * @param projection defines the projection matrix to use
  2911. * @param result defines the Vector3 where to store the result
  2912. */
  2913. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2914. /**
  2915. * Unproject from screen space to object space
  2916. * @param sourceX defines the screen space x coordinate to use
  2917. * @param sourceY defines the screen space y coordinate to use
  2918. * @param sourceZ defines the screen space z coordinate to use
  2919. * @param viewportWidth defines the current width of the viewport
  2920. * @param viewportHeight defines the current height of the viewport
  2921. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2922. * @param view defines the view matrix to use
  2923. * @param projection defines the projection matrix to use
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Gets the minimal coordinate values between two Vector3
  2929. * @param left defines the first operand
  2930. * @param right defines the second operand
  2931. * @returns the new Vector3
  2932. */
  2933. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2934. /**
  2935. * Gets the maximal coordinate values between two Vector3
  2936. * @param left defines the first operand
  2937. * @param right defines the second operand
  2938. * @returns the new Vector3
  2939. */
  2940. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns the distance between the vectors "value1" and "value2"
  2943. * @param value1 defines the first operand
  2944. * @param value2 defines the second operand
  2945. * @returns the distance
  2946. */
  2947. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2948. /**
  2949. * Returns the squared distance between the vectors "value1" and "value2"
  2950. * @param value1 defines the first operand
  2951. * @param value2 defines the second operand
  2952. * @returns the squared distance
  2953. */
  2954. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2955. /**
  2956. * Returns a new Vector3 located at the center between "value1" and "value2"
  2957. * @param value1 defines the first operand
  2958. * @param value2 defines the second operand
  2959. * @returns the new Vector3
  2960. */
  2961. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2962. /**
  2963. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2964. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2965. * to something in order to rotate it from its local system to the given target system
  2966. * Note: axis1, axis2 and axis3 are normalized during this operation
  2967. * @param axis1 defines the first axis
  2968. * @param axis2 defines the second axis
  2969. * @param axis3 defines the third axis
  2970. * @returns a new Vector3
  2971. */
  2972. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2975. * @param axis1 defines the first axis
  2976. * @param axis2 defines the second axis
  2977. * @param axis3 defines the third axis
  2978. * @param ref defines the Vector3 where to store the result
  2979. */
  2980. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2981. }
  2982. /**
  2983. * Vector4 class created for EulerAngle class conversion to Quaternion
  2984. */
  2985. export class Vector4 {
  2986. /** x value of the vector */
  2987. x: number;
  2988. /** y value of the vector */
  2989. y: number;
  2990. /** z value of the vector */
  2991. z: number;
  2992. /** w value of the vector */
  2993. w: number;
  2994. /**
  2995. * Creates a Vector4 object from the given floats.
  2996. * @param x x value of the vector
  2997. * @param y y value of the vector
  2998. * @param z z value of the vector
  2999. * @param w w value of the vector
  3000. */
  3001. constructor(
  3002. /** x value of the vector */
  3003. x: number,
  3004. /** y value of the vector */
  3005. y: number,
  3006. /** z value of the vector */
  3007. z: number,
  3008. /** w value of the vector */
  3009. w: number);
  3010. /**
  3011. * Returns the string with the Vector4 coordinates.
  3012. * @returns a string containing all the vector values
  3013. */
  3014. toString(): string;
  3015. /**
  3016. * Returns the string "Vector4".
  3017. * @returns "Vector4"
  3018. */
  3019. getClassName(): string;
  3020. /**
  3021. * Returns the Vector4 hash code.
  3022. * @returns a unique hash code
  3023. */
  3024. getHashCode(): number;
  3025. /**
  3026. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3027. * @returns the resulting array
  3028. */
  3029. asArray(): number[];
  3030. /**
  3031. * Populates the given array from the given index with the Vector4 coordinates.
  3032. * @param array array to populate
  3033. * @param index index of the array to start at (default: 0)
  3034. * @returns the Vector4.
  3035. */
  3036. toArray(array: FloatArray, index?: number): Vector4;
  3037. /**
  3038. * Adds the given vector to the current Vector4.
  3039. * @param otherVector the vector to add
  3040. * @returns the updated Vector4.
  3041. */
  3042. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3043. /**
  3044. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3045. * @param otherVector the vector to add
  3046. * @returns the resulting vector
  3047. */
  3048. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3049. /**
  3050. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3051. * @param otherVector the vector to add
  3052. * @param result the vector to store the result
  3053. * @returns the current Vector4.
  3054. */
  3055. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3056. /**
  3057. * Subtract in place the given vector from the current Vector4.
  3058. * @param otherVector the vector to subtract
  3059. * @returns the updated Vector4.
  3060. */
  3061. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3062. /**
  3063. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3064. * @param otherVector the vector to add
  3065. * @returns the new vector with the result
  3066. */
  3067. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3068. /**
  3069. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3070. * @param otherVector the vector to subtract
  3071. * @param result the vector to store the result
  3072. * @returns the current Vector4.
  3073. */
  3074. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3075. /**
  3076. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3077. */
  3078. /**
  3079. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3080. * @param x value to subtract
  3081. * @param y value to subtract
  3082. * @param z value to subtract
  3083. * @param w value to subtract
  3084. * @returns new vector containing the result
  3085. */
  3086. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3087. /**
  3088. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3089. * @param x value to subtract
  3090. * @param y value to subtract
  3091. * @param z value to subtract
  3092. * @param w value to subtract
  3093. * @param result the vector to store the result in
  3094. * @returns the current Vector4.
  3095. */
  3096. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3097. /**
  3098. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3099. * @returns a new vector with the negated values
  3100. */
  3101. negate(): Vector4;
  3102. /**
  3103. * Multiplies the current Vector4 coordinates by scale (float).
  3104. * @param scale the number to scale with
  3105. * @returns the updated Vector4.
  3106. */
  3107. scaleInPlace(scale: number): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3110. * @param scale the number to scale with
  3111. * @returns a new vector with the result
  3112. */
  3113. scale(scale: number): Vector4;
  3114. /**
  3115. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3116. * @param scale the number to scale with
  3117. * @param result a vector to store the result in
  3118. * @returns the current Vector4.
  3119. */
  3120. scaleToRef(scale: number, result: Vector4): Vector4;
  3121. /**
  3122. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3123. * @param scale defines the scale factor
  3124. * @param result defines the Vector4 object where to store the result
  3125. * @returns the unmodified current Vector4
  3126. */
  3127. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3128. /**
  3129. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3130. * @param otherVector the vector to compare against
  3131. * @returns true if they are equal
  3132. */
  3133. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3134. /**
  3135. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3136. * @param otherVector vector to compare against
  3137. * @param epsilon (Default: very small number)
  3138. * @returns true if they are equal
  3139. */
  3140. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3141. /**
  3142. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3143. * @param x x value to compare against
  3144. * @param y y value to compare against
  3145. * @param z z value to compare against
  3146. * @param w w value to compare against
  3147. * @returns true if equal
  3148. */
  3149. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3150. /**
  3151. * Multiplies in place the current Vector4 by the given one.
  3152. * @param otherVector vector to multiple with
  3153. * @returns the updated Vector4.
  3154. */
  3155. multiplyInPlace(otherVector: Vector4): Vector4;
  3156. /**
  3157. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3158. * @param otherVector vector to multiple with
  3159. * @returns resulting new vector
  3160. */
  3161. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3162. /**
  3163. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3164. * @param otherVector vector to multiple with
  3165. * @param result vector to store the result
  3166. * @returns the current Vector4.
  3167. */
  3168. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3171. * @param x x value multiply with
  3172. * @param y y value multiply with
  3173. * @param z z value multiply with
  3174. * @param w w value multiply with
  3175. * @returns resulting new vector
  3176. */
  3177. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3180. * @param otherVector vector to devide with
  3181. * @returns resulting new vector
  3182. */
  3183. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3184. /**
  3185. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3186. * @param otherVector vector to devide with
  3187. * @param result vector to store the result
  3188. * @returns the current Vector4.
  3189. */
  3190. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3191. /**
  3192. * Divides the current Vector3 coordinates by the given ones.
  3193. * @param otherVector vector to devide with
  3194. * @returns the updated Vector3.
  3195. */
  3196. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3197. /**
  3198. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3199. * @param other defines the second operand
  3200. * @returns the current updated Vector4
  3201. */
  3202. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3203. /**
  3204. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3205. * @param other defines the second operand
  3206. * @returns the current updated Vector4
  3207. */
  3208. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3209. /**
  3210. * Gets a new Vector4 from current Vector4 floored values
  3211. * @returns a new Vector4
  3212. */
  3213. floor(): Vector4;
  3214. /**
  3215. * Gets a new Vector4 from current Vector3 floored values
  3216. * @returns a new Vector4
  3217. */
  3218. fract(): Vector4;
  3219. /**
  3220. * Returns the Vector4 length (float).
  3221. * @returns the length
  3222. */
  3223. length(): number;
  3224. /**
  3225. * Returns the Vector4 squared length (float).
  3226. * @returns the length squared
  3227. */
  3228. lengthSquared(): number;
  3229. /**
  3230. * Normalizes in place the Vector4.
  3231. * @returns the updated Vector4.
  3232. */
  3233. normalize(): Vector4;
  3234. /**
  3235. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3236. * @returns this converted to a new vector3
  3237. */
  3238. toVector3(): Vector3;
  3239. /**
  3240. * Returns a new Vector4 copied from the current one.
  3241. * @returns the new cloned vector
  3242. */
  3243. clone(): Vector4;
  3244. /**
  3245. * Updates the current Vector4 with the given one coordinates.
  3246. * @param source the source vector to copy from
  3247. * @returns the updated Vector4.
  3248. */
  3249. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the current Vector4 coordinates with the given floats.
  3252. * @param x float to copy from
  3253. * @param y float to copy from
  3254. * @param z float to copy from
  3255. * @param w float to copy from
  3256. * @returns the updated Vector4.
  3257. */
  3258. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3259. /**
  3260. * Updates the current Vector4 coordinates with the given floats.
  3261. * @param x float to set from
  3262. * @param y float to set from
  3263. * @param z float to set from
  3264. * @param w float to set from
  3265. * @returns the updated Vector4.
  3266. */
  3267. set(x: number, y: number, z: number, w: number): Vector4;
  3268. /**
  3269. * Copies the given float to the current Vector3 coordinates
  3270. * @param v defines the x, y, z and w coordinates of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. setAll(v: number): Vector4;
  3274. /**
  3275. * Returns a new Vector4 set from the starting index of the given array.
  3276. * @param array the array to pull values from
  3277. * @param offset the offset into the array to start at
  3278. * @returns the new vector
  3279. */
  3280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3281. /**
  3282. * Updates the given vector "result" from the starting index of the given array.
  3283. * @param array the array to pull values from
  3284. * @param offset the offset into the array to start at
  3285. * @param result the vector to store the result in
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3288. /**
  3289. * Updates the given vector "result" from the starting index of the given Float32Array.
  3290. * @param array the array to pull values from
  3291. * @param offset the offset into the array to start at
  3292. * @param result the vector to store the result in
  3293. */
  3294. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3295. /**
  3296. * Updates the given vector "result" coordinates from the given floats.
  3297. * @param x float to set from
  3298. * @param y float to set from
  3299. * @param z float to set from
  3300. * @param w float to set from
  3301. * @param result the vector to the floats in
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3304. /**
  3305. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3306. * @returns the new vector
  3307. */
  3308. static Zero(): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3311. * @returns the new vector
  3312. */
  3313. static One(): Vector4;
  3314. /**
  3315. * Returns a new normalized Vector4 from the given one.
  3316. * @param vector the vector to normalize
  3317. * @returns the vector
  3318. */
  3319. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Updates the given vector "result" from the normalization of the given one.
  3322. * @param vector the vector to normalize
  3323. * @param result the vector to store the result in
  3324. */
  3325. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3326. /**
  3327. * Returns a vector with the minimum values from the left and right vectors
  3328. * @param left left vector to minimize
  3329. * @param right right vector to minimize
  3330. * @returns a new vector with the minimum of the left and right vector values
  3331. */
  3332. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Returns a vector with the maximum values from the left and right vectors
  3335. * @param left left vector to maximize
  3336. * @param right right vector to maximize
  3337. * @returns a new vector with the maximum of the left and right vector values
  3338. */
  3339. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Returns the distance (float) between the vectors "value1" and "value2".
  3342. * @param value1 value to calulate the distance between
  3343. * @param value2 value to calulate the distance between
  3344. * @return the distance between the two vectors
  3345. */
  3346. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3347. /**
  3348. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3349. * @param value1 value to calulate the distance between
  3350. * @param value2 value to calulate the distance between
  3351. * @return the distance between the two vectors squared
  3352. */
  3353. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3354. /**
  3355. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3356. * @param value1 value to calulate the center between
  3357. * @param value2 value to calulate the center between
  3358. * @return the center between the two vectors
  3359. */
  3360. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3361. /**
  3362. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3363. * This methods computes transformed normalized direction vectors only.
  3364. * @param vector the vector to transform
  3365. * @param transformation the transformation matrix to apply
  3366. * @returns the new vector
  3367. */
  3368. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3371. * This methods computes transformed normalized direction vectors only.
  3372. * @param vector the vector to transform
  3373. * @param transformation the transformation matrix to apply
  3374. * @param result the vector to store the result in
  3375. */
  3376. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3379. * This methods computes transformed normalized direction vectors only.
  3380. * @param x value to transform
  3381. * @param y value to transform
  3382. * @param z value to transform
  3383. * @param w value to transform
  3384. * @param transformation the transformation matrix to apply
  3385. * @param result the vector to store the results in
  3386. */
  3387. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3388. /**
  3389. * Creates a new Vector4 from a Vector3
  3390. * @param source defines the source data
  3391. * @param w defines the 4th component (default is 0)
  3392. * @returns a new Vector4
  3393. */
  3394. static FromVector3(source: Vector3, w?: number): Vector4;
  3395. }
  3396. /**
  3397. * Class used to store quaternion data
  3398. * @see https://en.wikipedia.org/wiki/Quaternion
  3399. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3400. */
  3401. export class Quaternion {
  3402. /** defines the first component (0 by default) */
  3403. x: number;
  3404. /** defines the second component (0 by default) */
  3405. y: number;
  3406. /** defines the third component (0 by default) */
  3407. z: number;
  3408. /** defines the fourth component (1.0 by default) */
  3409. w: number;
  3410. /**
  3411. * Creates a new Quaternion from the given floats
  3412. * @param x defines the first component (0 by default)
  3413. * @param y defines the second component (0 by default)
  3414. * @param z defines the third component (0 by default)
  3415. * @param w defines the fourth component (1.0 by default)
  3416. */
  3417. constructor(
  3418. /** defines the first component (0 by default) */
  3419. x?: number,
  3420. /** defines the second component (0 by default) */
  3421. y?: number,
  3422. /** defines the third component (0 by default) */
  3423. z?: number,
  3424. /** defines the fourth component (1.0 by default) */
  3425. w?: number);
  3426. /**
  3427. * Gets a string representation for the current quaternion
  3428. * @returns a string with the Quaternion coordinates
  3429. */
  3430. toString(): string;
  3431. /**
  3432. * Gets the class name of the quaternion
  3433. * @returns the string "Quaternion"
  3434. */
  3435. getClassName(): string;
  3436. /**
  3437. * Gets a hash code for this quaternion
  3438. * @returns the quaternion hash code
  3439. */
  3440. getHashCode(): number;
  3441. /**
  3442. * Copy the quaternion to an array
  3443. * @returns a new array populated with 4 elements from the quaternion coordinates
  3444. */
  3445. asArray(): number[];
  3446. /**
  3447. * Check if two quaternions are equals
  3448. * @param otherQuaternion defines the second operand
  3449. * @return true if the current quaternion and the given one coordinates are strictly equals
  3450. */
  3451. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3452. /**
  3453. * Clone the current quaternion
  3454. * @returns a new quaternion copied from the current one
  3455. */
  3456. clone(): Quaternion;
  3457. /**
  3458. * Copy a quaternion to the current one
  3459. * @param other defines the other quaternion
  3460. * @returns the updated current quaternion
  3461. */
  3462. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3463. /**
  3464. * Updates the current quaternion with the given float coordinates
  3465. * @param x defines the x coordinate
  3466. * @param y defines the y coordinate
  3467. * @param z defines the z coordinate
  3468. * @param w defines the w coordinate
  3469. * @returns the updated current quaternion
  3470. */
  3471. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3472. /**
  3473. * Updates the current quaternion from the given float coordinates
  3474. * @param x defines the x coordinate
  3475. * @param y defines the y coordinate
  3476. * @param z defines the z coordinate
  3477. * @param w defines the w coordinate
  3478. * @returns the updated current quaternion
  3479. */
  3480. set(x: number, y: number, z: number, w: number): Quaternion;
  3481. /**
  3482. * Adds two quaternions
  3483. * @param other defines the second operand
  3484. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3485. */
  3486. add(other: DeepImmutable<Quaternion>): Quaternion;
  3487. /**
  3488. * Add a quaternion to the current one
  3489. * @param other defines the quaternion to add
  3490. * @returns the current quaternion
  3491. */
  3492. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3493. /**
  3494. * Subtract two quaternions
  3495. * @param other defines the second operand
  3496. * @returns a new quaternion as the subtraction result of the given one from the current one
  3497. */
  3498. subtract(other: Quaternion): Quaternion;
  3499. /**
  3500. * Multiplies the current quaternion by a scale factor
  3501. * @param value defines the scale factor
  3502. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3503. */
  3504. scale(value: number): Quaternion;
  3505. /**
  3506. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3507. * @param scale defines the scale factor
  3508. * @param result defines the Quaternion object where to store the result
  3509. * @returns the unmodified current quaternion
  3510. */
  3511. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3512. /**
  3513. * Multiplies in place the current quaternion by a scale factor
  3514. * @param value defines the scale factor
  3515. * @returns the current modified quaternion
  3516. */
  3517. scaleInPlace(value: number): Quaternion;
  3518. /**
  3519. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3520. * @param scale defines the scale factor
  3521. * @param result defines the Quaternion object where to store the result
  3522. * @returns the unmodified current quaternion
  3523. */
  3524. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies two quaternions
  3527. * @param q1 defines the second operand
  3528. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3529. */
  3530. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3531. /**
  3532. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3533. * @param q1 defines the second operand
  3534. * @param result defines the target quaternion
  3535. * @returns the current quaternion
  3536. */
  3537. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3538. /**
  3539. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3540. * @param q1 defines the second operand
  3541. * @returns the currentupdated quaternion
  3542. */
  3543. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3546. * @param ref defines the target quaternion
  3547. * @returns the current quaternion
  3548. */
  3549. conjugateToRef(ref: Quaternion): Quaternion;
  3550. /**
  3551. * Conjugates in place (1-q) the current quaternion
  3552. * @returns the current updated quaternion
  3553. */
  3554. conjugateInPlace(): Quaternion;
  3555. /**
  3556. * Conjugates in place (1-q) the current quaternion
  3557. * @returns a new quaternion
  3558. */
  3559. conjugate(): Quaternion;
  3560. /**
  3561. * Gets length of current quaternion
  3562. * @returns the quaternion length (float)
  3563. */
  3564. length(): number;
  3565. /**
  3566. * Normalize in place the current quaternion
  3567. * @returns the current updated quaternion
  3568. */
  3569. normalize(): Quaternion;
  3570. /**
  3571. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3572. * @param order is a reserved parameter and is ignore for now
  3573. * @returns a new Vector3 containing the Euler angles
  3574. */
  3575. toEulerAngles(order?: string): Vector3;
  3576. /**
  3577. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3578. * @param result defines the vector which will be filled with the Euler angles
  3579. * @param order is a reserved parameter and is ignore for now
  3580. * @returns the current unchanged quaternion
  3581. */
  3582. toEulerAnglesToRef(result: Vector3): Quaternion;
  3583. /**
  3584. * Updates the given rotation matrix with the current quaternion values
  3585. * @param result defines the target matrix
  3586. * @returns the current unchanged quaternion
  3587. */
  3588. toRotationMatrix(result: Matrix): Quaternion;
  3589. /**
  3590. * Updates the current quaternion from the given rotation matrix values
  3591. * @param matrix defines the source matrix
  3592. * @returns the current updated quaternion
  3593. */
  3594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3595. /**
  3596. * Creates a new quaternion from a rotation matrix
  3597. * @param matrix defines the source matrix
  3598. * @returns a new quaternion created from the given rotation matrix values
  3599. */
  3600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3601. /**
  3602. * Updates the given quaternion with the given rotation matrix values
  3603. * @param matrix defines the source matrix
  3604. * @param result defines the target quaternion
  3605. */
  3606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3607. /**
  3608. * Returns the dot product (float) between the quaternions "left" and "right"
  3609. * @param left defines the left operand
  3610. * @param right defines the right operand
  3611. * @returns the dot product
  3612. */
  3613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3614. /**
  3615. * Checks if the two quaternions are close to each other
  3616. * @param quat0 defines the first quaternion to check
  3617. * @param quat1 defines the second quaternion to check
  3618. * @returns true if the two quaternions are close to each other
  3619. */
  3620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3621. /**
  3622. * Creates an empty quaternion
  3623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3624. */
  3625. static Zero(): Quaternion;
  3626. /**
  3627. * Inverse a given quaternion
  3628. * @param q defines the source quaternion
  3629. * @returns a new quaternion as the inverted current quaternion
  3630. */
  3631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3632. /**
  3633. * Inverse a given quaternion
  3634. * @param q defines the source quaternion
  3635. * @param result the quaternion the result will be stored in
  3636. * @returns the result quaternion
  3637. */
  3638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3639. /**
  3640. * Creates an identity quaternion
  3641. * @returns the identity quaternion
  3642. */
  3643. static Identity(): Quaternion;
  3644. /**
  3645. * Gets a boolean indicating if the given quaternion is identity
  3646. * @param quaternion defines the quaternion to check
  3647. * @returns true if the quaternion is identity
  3648. */
  3649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3650. /**
  3651. * Creates a quaternion from a rotation around an axis
  3652. * @param axis defines the axis to use
  3653. * @param angle defines the angle to use
  3654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3655. */
  3656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3657. /**
  3658. * Creates a rotation around an axis and stores it into the given quaternion
  3659. * @param axis defines the axis to use
  3660. * @param angle defines the angle to use
  3661. * @param result defines the target quaternion
  3662. * @returns the target quaternion
  3663. */
  3664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates a new quaternion from data stored into an array
  3667. * @param array defines the data source
  3668. * @param offset defines the offset in the source array where the data starts
  3669. * @returns a new quaternion
  3670. */
  3671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3672. /**
  3673. * Create a quaternion from Euler rotation angles
  3674. * @param x Pitch
  3675. * @param y Yaw
  3676. * @param z Roll
  3677. * @returns the new Quaternion
  3678. */
  3679. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3680. /**
  3681. * Updates a quaternion from Euler rotation angles
  3682. * @param x Pitch
  3683. * @param y Yaw
  3684. * @param z Roll
  3685. * @param result the quaternion to store the result
  3686. * @returns the updated quaternion
  3687. */
  3688. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation vector
  3691. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3692. * @returns the new Quaternion
  3693. */
  3694. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3695. /**
  3696. * Updates a quaternion from Euler rotation vector
  3697. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3698. * @param result the quaternion to store the result
  3699. * @returns the updated quaternion
  3700. */
  3701. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3704. * @param yaw defines the rotation around Y axis
  3705. * @param pitch defines the rotation around X axis
  3706. * @param roll defines the rotation around Z axis
  3707. * @returns the new quaternion
  3708. */
  3709. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3710. /**
  3711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3712. * @param yaw defines the rotation around Y axis
  3713. * @param pitch defines the rotation around X axis
  3714. * @param roll defines the rotation around Z axis
  3715. * @param result defines the target quaternion
  3716. */
  3717. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3718. /**
  3719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3720. * @param alpha defines the rotation around first axis
  3721. * @param beta defines the rotation around second axis
  3722. * @param gamma defines the rotation around third axis
  3723. * @returns the new quaternion
  3724. */
  3725. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3728. * @param alpha defines the rotation around first axis
  3729. * @param beta defines the rotation around second axis
  3730. * @param gamma defines the rotation around third axis
  3731. * @param result defines the target quaternion
  3732. */
  3733. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3734. /**
  3735. * 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)
  3736. * @param axis1 defines the first axis
  3737. * @param axis2 defines the second axis
  3738. * @param axis3 defines the third axis
  3739. * @returns the new quaternion
  3740. */
  3741. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3742. /**
  3743. * 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
  3744. * @param axis1 defines the first axis
  3745. * @param axis2 defines the second axis
  3746. * @param axis3 defines the third axis
  3747. * @param ref defines the target quaternion
  3748. */
  3749. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3750. /**
  3751. * Interpolates between two quaternions
  3752. * @param left defines first quaternion
  3753. * @param right defines second quaternion
  3754. * @param amount defines the gradient to use
  3755. * @returns the new interpolated quaternion
  3756. */
  3757. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3758. /**
  3759. * Interpolates between two quaternions and stores it into a target quaternion
  3760. * @param left defines first quaternion
  3761. * @param right defines second quaternion
  3762. * @param amount defines the gradient to use
  3763. * @param result defines the target quaternion
  3764. */
  3765. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3766. /**
  3767. * Interpolate between two quaternions using Hermite interpolation
  3768. * @param value1 defines first quaternion
  3769. * @param tangent1 defines the incoming tangent
  3770. * @param value2 defines second quaternion
  3771. * @param tangent2 defines the outgoing tangent
  3772. * @param amount defines the target quaternion
  3773. * @returns the new interpolated quaternion
  3774. */
  3775. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3776. }
  3777. /**
  3778. * Class used to store matrix data (4x4)
  3779. */
  3780. export class Matrix {
  3781. private static _updateFlagSeed;
  3782. private static _identityReadOnly;
  3783. private _isIdentity;
  3784. private _isIdentityDirty;
  3785. private _isIdentity3x2;
  3786. private _isIdentity3x2Dirty;
  3787. /**
  3788. * Gets the update flag of the matrix which is an unique number for the matrix.
  3789. * It will be incremented every time the matrix data change.
  3790. * You can use it to speed the comparison between two versions of the same matrix.
  3791. */
  3792. updateFlag: number;
  3793. private readonly _m;
  3794. /**
  3795. * Gets the internal data of the matrix
  3796. */
  3797. readonly m: DeepImmutable<Float32Array>;
  3798. /** @hidden */
  3799. _markAsUpdated(): void;
  3800. /** @hidden */
  3801. private _updateIdentityStatus;
  3802. /**
  3803. * Creates an empty matrix (filled with zeros)
  3804. */
  3805. constructor();
  3806. /**
  3807. * Check if the current matrix is identity
  3808. * @returns true is the matrix is the identity matrix
  3809. */
  3810. isIdentity(): boolean;
  3811. /**
  3812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3813. * @returns true is the matrix is the identity matrix
  3814. */
  3815. isIdentityAs3x2(): boolean;
  3816. /**
  3817. * Gets the determinant of the matrix
  3818. * @returns the matrix determinant
  3819. */
  3820. determinant(): number;
  3821. /**
  3822. * Returns the matrix as a Float32Array
  3823. * @returns the matrix underlying array
  3824. */
  3825. toArray(): DeepImmutable<Float32Array>;
  3826. /**
  3827. * Returns the matrix as a Float32Array
  3828. * @returns the matrix underlying array.
  3829. */
  3830. asArray(): DeepImmutable<Float32Array>;
  3831. /**
  3832. * Inverts the current matrix in place
  3833. * @returns the current inverted matrix
  3834. */
  3835. invert(): Matrix;
  3836. /**
  3837. * Sets all the matrix elements to zero
  3838. * @returns the current matrix
  3839. */
  3840. reset(): Matrix;
  3841. /**
  3842. * Adds the current matrix with a second one
  3843. * @param other defines the matrix to add
  3844. * @returns a new matrix as the addition of the current matrix and the given one
  3845. */
  3846. add(other: DeepImmutable<Matrix>): Matrix;
  3847. /**
  3848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3849. * @param other defines the matrix to add
  3850. * @param result defines the target matrix
  3851. * @returns the current matrix
  3852. */
  3853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3854. /**
  3855. * Adds in place the given matrix to the current matrix
  3856. * @param other defines the second operand
  3857. * @returns the current updated matrix
  3858. */
  3859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3860. /**
  3861. * Sets the given matrix to the current inverted Matrix
  3862. * @param other defines the target matrix
  3863. * @returns the unmodified current matrix
  3864. */
  3865. invertToRef(other: Matrix): Matrix;
  3866. /**
  3867. * add a value at the specified position in the current Matrix
  3868. * @param index the index of the value within the matrix. between 0 and 15.
  3869. * @param value the value to be added
  3870. * @returns the current updated matrix
  3871. */
  3872. addAtIndex(index: number, value: number): Matrix;
  3873. /**
  3874. * mutiply the specified position in the current Matrix by a value
  3875. * @param index the index of the value within the matrix. between 0 and 15.
  3876. * @param value the value to be added
  3877. * @returns the current updated matrix
  3878. */
  3879. multiplyAtIndex(index: number, value: number): Matrix;
  3880. /**
  3881. * Inserts the translation vector (using 3 floats) in the current matrix
  3882. * @param x defines the 1st component of the translation
  3883. * @param y defines the 2nd component of the translation
  3884. * @param z defines the 3rd component of the translation
  3885. * @returns the current updated matrix
  3886. */
  3887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3888. /**
  3889. * Adds the translation vector (using 3 floats) in the current matrix
  3890. * @param x defines the 1st component of the translation
  3891. * @param y defines the 2nd component of the translation
  3892. * @param z defines the 3rd component of the translation
  3893. * @returns the current updated matrix
  3894. */
  3895. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector in the current matrix
  3898. * @param vector3 defines the translation to insert
  3899. * @returns the current updated matrix
  3900. */
  3901. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3902. /**
  3903. * Gets the translation value of the current matrix
  3904. * @returns a new Vector3 as the extracted translation from the matrix
  3905. */
  3906. getTranslation(): Vector3;
  3907. /**
  3908. * Fill a Vector3 with the extracted translation from the matrix
  3909. * @param result defines the Vector3 where to store the translation
  3910. * @returns the current matrix
  3911. */
  3912. getTranslationToRef(result: Vector3): Matrix;
  3913. /**
  3914. * Remove rotation and scaling part from the matrix
  3915. * @returns the updated matrix
  3916. */
  3917. removeRotationAndScaling(): Matrix;
  3918. /**
  3919. * Multiply two matrices
  3920. * @param other defines the second operand
  3921. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3922. */
  3923. multiply(other: DeepImmutable<Matrix>): Matrix;
  3924. /**
  3925. * Copy the current matrix from the given one
  3926. * @param other defines the source matrix
  3927. * @returns the current updated matrix
  3928. */
  3929. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Populates the given array from the starting index with the current matrix values
  3932. * @param array defines the target array
  3933. * @param offset defines the offset in the target array where to start storing values
  3934. * @returns the current matrix
  3935. */
  3936. copyToArray(array: Float32Array, offset?: number): Matrix;
  3937. /**
  3938. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3939. * @param other defines the second operand
  3940. * @param result defines the matrix where to store the multiplication
  3941. * @returns the current matrix
  3942. */
  3943. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3944. /**
  3945. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3946. * @param other defines the second operand
  3947. * @param result defines the array where to store the multiplication
  3948. * @param offset defines the offset in the target array where to start storing values
  3949. * @returns the current matrix
  3950. */
  3951. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3952. /**
  3953. * Check equality between this matrix and a second one
  3954. * @param value defines the second matrix to compare
  3955. * @returns true is the current matrix and the given one values are strictly equal
  3956. */
  3957. equals(value: DeepImmutable<Matrix>): boolean;
  3958. /**
  3959. * Clone the current matrix
  3960. * @returns a new matrix from the current matrix
  3961. */
  3962. clone(): Matrix;
  3963. /**
  3964. * Returns the name of the current matrix class
  3965. * @returns the string "Matrix"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Gets the hash code of the current matrix
  3970. * @returns the hash code
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Decomposes the current Matrix into a translation, rotation and scaling components
  3975. * @param scale defines the scale vector3 given as a reference to update
  3976. * @param rotation defines the rotation quaternion given as a reference to update
  3977. * @param translation defines the translation vector3 given as a reference to update
  3978. * @returns true if operation was successful
  3979. */
  3980. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3981. /**
  3982. * Gets specific row of the matrix
  3983. * @param index defines the number of the row to get
  3984. * @returns the index-th row of the current matrix as a new Vector4
  3985. */
  3986. getRow(index: number): Nullable<Vector4>;
  3987. /**
  3988. * Sets the index-th row of the current matrix to the vector4 values
  3989. * @param index defines the number of the row to set
  3990. * @param row defines the target vector4
  3991. * @returns the updated current matrix
  3992. */
  3993. setRow(index: number, row: Vector4): Matrix;
  3994. /**
  3995. * Compute the transpose of the matrix
  3996. * @returns the new transposed matrix
  3997. */
  3998. transpose(): Matrix;
  3999. /**
  4000. * Compute the transpose of the matrix and store it in a given matrix
  4001. * @param result defines the target matrix
  4002. * @returns the current matrix
  4003. */
  4004. transposeToRef(result: Matrix): Matrix;
  4005. /**
  4006. * Sets the index-th row of the current matrix with the given 4 x float values
  4007. * @param index defines the row index
  4008. * @param x defines the x component to set
  4009. * @param y defines the y component to set
  4010. * @param z defines the z component to set
  4011. * @param w defines the w component to set
  4012. * @returns the updated current matrix
  4013. */
  4014. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4015. /**
  4016. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4017. * @param scale defines the scale factor
  4018. * @returns a new matrix
  4019. */
  4020. scale(scale: number): Matrix;
  4021. /**
  4022. * Scale the current matrix values by a factor to a given result matrix
  4023. * @param scale defines the scale factor
  4024. * @param result defines the matrix to store the result
  4025. * @returns the current matrix
  4026. */
  4027. scaleToRef(scale: number, result: Matrix): Matrix;
  4028. /**
  4029. * Scale the current matrix values by a factor and add the result to a given matrix
  4030. * @param scale defines the scale factor
  4031. * @param result defines the Matrix to store the result
  4032. * @returns the current matrix
  4033. */
  4034. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4035. /**
  4036. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4037. * @param ref matrix to store the result
  4038. */
  4039. toNormalMatrix(ref: Matrix): void;
  4040. /**
  4041. * Gets only rotation part of the current matrix
  4042. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4043. */
  4044. getRotationMatrix(): Matrix;
  4045. /**
  4046. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4047. * @param result defines the target matrix to store data to
  4048. * @returns the current matrix
  4049. */
  4050. getRotationMatrixToRef(result: Matrix): Matrix;
  4051. /**
  4052. * Toggles model matrix from being right handed to left handed in place and vice versa
  4053. */
  4054. toggleModelMatrixHandInPlace(): void;
  4055. /**
  4056. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4057. */
  4058. toggleProjectionMatrixHandInPlace(): void;
  4059. /**
  4060. * Creates a matrix from an array
  4061. * @param array defines the source array
  4062. * @param offset defines an offset in the source array
  4063. * @returns a new Matrix set from the starting index of the given array
  4064. */
  4065. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4066. /**
  4067. * Copy the content of an array into a given matrix
  4068. * @param array defines the source array
  4069. * @param offset defines an offset in the source array
  4070. * @param result defines the target matrix
  4071. */
  4072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4073. /**
  4074. * Stores an array into a matrix after having multiplied each component by a given factor
  4075. * @param array defines the source array
  4076. * @param offset defines the offset in the source array
  4077. * @param scale defines the scaling factor
  4078. * @param result defines the target matrix
  4079. */
  4080. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4081. /**
  4082. * Gets an identity matrix that must not be updated
  4083. */
  4084. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4085. /**
  4086. * Stores a list of values (16) inside a given matrix
  4087. * @param initialM11 defines 1st value of 1st row
  4088. * @param initialM12 defines 2nd value of 1st row
  4089. * @param initialM13 defines 3rd value of 1st row
  4090. * @param initialM14 defines 4th value of 1st row
  4091. * @param initialM21 defines 1st value of 2nd row
  4092. * @param initialM22 defines 2nd value of 2nd row
  4093. * @param initialM23 defines 3rd value of 2nd row
  4094. * @param initialM24 defines 4th value of 2nd row
  4095. * @param initialM31 defines 1st value of 3rd row
  4096. * @param initialM32 defines 2nd value of 3rd row
  4097. * @param initialM33 defines 3rd value of 3rd row
  4098. * @param initialM34 defines 4th value of 3rd row
  4099. * @param initialM41 defines 1st value of 4th row
  4100. * @param initialM42 defines 2nd value of 4th row
  4101. * @param initialM43 defines 3rd value of 4th row
  4102. * @param initialM44 defines 4th value of 4th row
  4103. * @param result defines the target matrix
  4104. */
  4105. 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;
  4106. /**
  4107. * Creates new matrix from a list of values (16)
  4108. * @param initialM11 defines 1st value of 1st row
  4109. * @param initialM12 defines 2nd value of 1st row
  4110. * @param initialM13 defines 3rd value of 1st row
  4111. * @param initialM14 defines 4th value of 1st row
  4112. * @param initialM21 defines 1st value of 2nd row
  4113. * @param initialM22 defines 2nd value of 2nd row
  4114. * @param initialM23 defines 3rd value of 2nd row
  4115. * @param initialM24 defines 4th value of 2nd row
  4116. * @param initialM31 defines 1st value of 3rd row
  4117. * @param initialM32 defines 2nd value of 3rd row
  4118. * @param initialM33 defines 3rd value of 3rd row
  4119. * @param initialM34 defines 4th value of 3rd row
  4120. * @param initialM41 defines 1st value of 4th row
  4121. * @param initialM42 defines 2nd value of 4th row
  4122. * @param initialM43 defines 3rd value of 4th row
  4123. * @param initialM44 defines 4th value of 4th row
  4124. * @returns the new matrix
  4125. */
  4126. 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;
  4127. /**
  4128. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4129. * @param scale defines the scale vector3
  4130. * @param rotation defines the rotation quaternion
  4131. * @param translation defines the translation vector3
  4132. * @returns a new matrix
  4133. */
  4134. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4135. /**
  4136. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4137. * @param scale defines the scale vector3
  4138. * @param rotation defines the rotation quaternion
  4139. * @param translation defines the translation vector3
  4140. * @param result defines the target matrix
  4141. */
  4142. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4143. /**
  4144. * Creates a new identity matrix
  4145. * @returns a new identity matrix
  4146. */
  4147. static Identity(): Matrix;
  4148. /**
  4149. * Creates a new identity matrix and stores the result in a given matrix
  4150. * @param result defines the target matrix
  4151. */
  4152. static IdentityToRef(result: Matrix): void;
  4153. /**
  4154. * Creates a new zero matrix
  4155. * @returns a new zero matrix
  4156. */
  4157. static Zero(): Matrix;
  4158. /**
  4159. * Creates a new rotation matrix for "angle" radians around the X axis
  4160. * @param angle defines the angle (in radians) to use
  4161. * @return the new matrix
  4162. */
  4163. static RotationX(angle: number): Matrix;
  4164. /**
  4165. * Creates a new matrix as the invert of a given matrix
  4166. * @param source defines the source matrix
  4167. * @returns the new matrix
  4168. */
  4169. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4170. /**
  4171. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4172. * @param angle defines the angle (in radians) to use
  4173. * @param result defines the target matrix
  4174. */
  4175. static RotationXToRef(angle: number, result: Matrix): void;
  4176. /**
  4177. * Creates a new rotation matrix for "angle" radians around the Y axis
  4178. * @param angle defines the angle (in radians) to use
  4179. * @return the new matrix
  4180. */
  4181. static RotationY(angle: number): Matrix;
  4182. /**
  4183. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4184. * @param angle defines the angle (in radians) to use
  4185. * @param result defines the target matrix
  4186. */
  4187. static RotationYToRef(angle: number, result: Matrix): void;
  4188. /**
  4189. * Creates a new rotation matrix for "angle" radians around the Z axis
  4190. * @param angle defines the angle (in radians) to use
  4191. * @return the new matrix
  4192. */
  4193. static RotationZ(angle: number): Matrix;
  4194. /**
  4195. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4196. * @param angle defines the angle (in radians) to use
  4197. * @param result defines the target matrix
  4198. */
  4199. static RotationZToRef(angle: number, result: Matrix): void;
  4200. /**
  4201. * Creates a new rotation matrix for "angle" radians around the given axis
  4202. * @param axis defines the axis to use
  4203. * @param angle defines the angle (in radians) to use
  4204. * @return the new matrix
  4205. */
  4206. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4209. * @param axis defines the axis to use
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4214. /**
  4215. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4216. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4217. * @param from defines the vector to align
  4218. * @param to defines the vector to align to
  4219. * @param result defines the target matrix
  4220. */
  4221. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4222. /**
  4223. * Creates a rotation matrix
  4224. * @param yaw defines the yaw angle in radians (Y axis)
  4225. * @param pitch defines the pitch angle in radians (X axis)
  4226. * @param roll defines the roll angle in radians (X axis)
  4227. * @returns the new rotation matrix
  4228. */
  4229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4230. /**
  4231. * Creates a rotation matrix and stores it in a given matrix
  4232. * @param yaw defines the yaw angle in radians (Y axis)
  4233. * @param pitch defines the pitch angle in radians (X axis)
  4234. * @param roll defines the roll angle in radians (X axis)
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4238. /**
  4239. * Creates a scaling matrix
  4240. * @param x defines the scale factor on X axis
  4241. * @param y defines the scale factor on Y axis
  4242. * @param z defines the scale factor on Z axis
  4243. * @returns the new matrix
  4244. */
  4245. static Scaling(x: number, y: number, z: number): Matrix;
  4246. /**
  4247. * Creates a scaling matrix and stores it in a given matrix
  4248. * @param x defines the scale factor on X axis
  4249. * @param y defines the scale factor on Y axis
  4250. * @param z defines the scale factor on Z axis
  4251. * @param result defines the target matrix
  4252. */
  4253. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4254. /**
  4255. * Creates a translation matrix
  4256. * @param x defines the translation on X axis
  4257. * @param y defines the translation on Y axis
  4258. * @param z defines the translationon Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Translation(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a translation matrix and stores it in a given matrix
  4264. * @param x defines the translation on X axis
  4265. * @param y defines the translation on Y axis
  4266. * @param z defines the translationon Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4272. * @param startValue defines the start value
  4273. * @param endValue defines the end value
  4274. * @param gradient defines the gradient factor
  4275. * @returns the new matrix
  4276. */
  4277. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4278. /**
  4279. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4280. * @param startValue defines the start value
  4281. * @param endValue defines the end value
  4282. * @param gradient defines the gradient factor
  4283. * @param result defines the Matrix object where to store data
  4284. */
  4285. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4286. /**
  4287. * Builds a new matrix whose values are computed by:
  4288. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4289. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4290. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4291. * @param startValue defines the first matrix
  4292. * @param endValue defines the second matrix
  4293. * @param gradient defines the gradient between the two matrices
  4294. * @returns the new matrix
  4295. */
  4296. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4297. /**
  4298. * Update a matrix to values which are computed by:
  4299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4302. * @param startValue defines the first matrix
  4303. * @param endValue defines the second matrix
  4304. * @param gradient defines the gradient between the two matrices
  4305. * @param result defines the target matrix
  4306. */
  4307. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4308. /**
  4309. * 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"
  4310. * This function works in left handed mode
  4311. * @param eye defines the final position of the entity
  4312. * @param target defines where the entity should look at
  4313. * @param up defines the up vector for the entity
  4314. * @returns the new matrix
  4315. */
  4316. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4317. /**
  4318. * 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".
  4319. * This function works in left handed mode
  4320. * @param eye defines the final position of the entity
  4321. * @param target defines where the entity should look at
  4322. * @param up defines the up vector for the entity
  4323. * @param result defines the target matrix
  4324. */
  4325. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4326. /**
  4327. * 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"
  4328. * This function works in right handed mode
  4329. * @param eye defines the final position of the entity
  4330. * @param target defines where the entity should look at
  4331. * @param up defines the up vector for the entity
  4332. * @returns the new matrix
  4333. */
  4334. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4335. /**
  4336. * 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".
  4337. * This function works in right handed mode
  4338. * @param eye defines the final position of the entity
  4339. * @param target defines where the entity should look at
  4340. * @param up defines the up vector for the entity
  4341. * @param result defines the target matrix
  4342. */
  4343. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4344. /**
  4345. * Create a left-handed orthographic projection matrix
  4346. * @param width defines the viewport width
  4347. * @param height defines the viewport height
  4348. * @param znear defines the near clip plane
  4349. * @param zfar defines the far clip plane
  4350. * @returns a new matrix as a left-handed orthographic projection matrix
  4351. */
  4352. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4353. /**
  4354. * Store a left-handed orthographic projection to a given matrix
  4355. * @param width defines the viewport width
  4356. * @param height defines the viewport height
  4357. * @param znear defines the near clip plane
  4358. * @param zfar defines the far clip plane
  4359. * @param result defines the target matrix
  4360. */
  4361. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4362. /**
  4363. * Create a left-handed orthographic projection matrix
  4364. * @param left defines the viewport left coordinate
  4365. * @param right defines the viewport right coordinate
  4366. * @param bottom defines the viewport bottom coordinate
  4367. * @param top defines the viewport top coordinate
  4368. * @param znear defines the near clip plane
  4369. * @param zfar defines the far clip plane
  4370. * @returns a new matrix as a left-handed orthographic projection matrix
  4371. */
  4372. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4373. /**
  4374. * Stores a left-handed orthographic projection into a given matrix
  4375. * @param left defines the viewport left coordinate
  4376. * @param right defines the viewport right coordinate
  4377. * @param bottom defines the viewport bottom coordinate
  4378. * @param top defines the viewport top coordinate
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @param result defines the target matrix
  4382. */
  4383. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4384. /**
  4385. * Creates a right-handed orthographic projection matrix
  4386. * @param left defines the viewport left coordinate
  4387. * @param right defines the viewport right coordinate
  4388. * @param bottom defines the viewport bottom coordinate
  4389. * @param top defines the viewport top coordinate
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @returns a new matrix as a right-handed orthographic projection matrix
  4393. */
  4394. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4395. /**
  4396. * Stores a right-handed orthographic projection into a given matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @param result defines the target matrix
  4404. */
  4405. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4406. /**
  4407. * Creates a left-handed perspective projection matrix
  4408. * @param width defines the viewport width
  4409. * @param height defines the viewport height
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @returns a new matrix as a left-handed perspective projection matrix
  4413. */
  4414. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4415. /**
  4416. * Creates a left-handed perspective projection matrix
  4417. * @param fov defines the horizontal field of view
  4418. * @param aspect defines the aspect ratio
  4419. * @param znear defines the near clip plane
  4420. * @param zfar defines the far clip plane
  4421. * @returns a new matrix as a left-handed perspective projection matrix
  4422. */
  4423. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4424. /**
  4425. * Stores a left-handed perspective projection into a given matrix
  4426. * @param fov defines the horizontal field of view
  4427. * @param aspect defines the aspect ratio
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @param result defines the target matrix
  4431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4432. */
  4433. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4434. /**
  4435. * Creates a right-handed perspective projection matrix
  4436. * @param fov defines the horizontal field of view
  4437. * @param aspect defines the aspect ratio
  4438. * @param znear defines the near clip plane
  4439. * @param zfar defines the far clip plane
  4440. * @returns a new matrix as a right-handed perspective projection matrix
  4441. */
  4442. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4443. /**
  4444. * Stores a right-handed perspective projection into a given matrix
  4445. * @param fov defines the horizontal field of view
  4446. * @param aspect defines the aspect ratio
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @param result defines the target matrix
  4450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4451. */
  4452. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4453. /**
  4454. * Stores a perspective projection for WebVR info a given matrix
  4455. * @param fov defines the field of view
  4456. * @param znear defines the near clip plane
  4457. * @param zfar defines the far clip plane
  4458. * @param result defines the target matrix
  4459. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4460. */
  4461. static PerspectiveFovWebVRToRef(fov: {
  4462. upDegrees: number;
  4463. downDegrees: number;
  4464. leftDegrees: number;
  4465. rightDegrees: number;
  4466. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4467. /**
  4468. * Computes a complete transformation matrix
  4469. * @param viewport defines the viewport to use
  4470. * @param world defines the world matrix
  4471. * @param view defines the view matrix
  4472. * @param projection defines the projection matrix
  4473. * @param zmin defines the near clip plane
  4474. * @param zmax defines the far clip plane
  4475. * @returns the transformation matrix
  4476. */
  4477. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4478. /**
  4479. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4480. * @param matrix defines the matrix to use
  4481. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4482. */
  4483. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4484. /**
  4485. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4486. * @param matrix defines the matrix to use
  4487. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4488. */
  4489. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4490. /**
  4491. * Compute the transpose of a given matrix
  4492. * @param matrix defines the matrix to transpose
  4493. * @returns the new matrix
  4494. */
  4495. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Compute the transpose of a matrix and store it in a target matrix
  4498. * @param matrix defines the matrix to transpose
  4499. * @param result defines the target matrix
  4500. */
  4501. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4502. /**
  4503. * Computes a reflection matrix from a plane
  4504. * @param plane defines the reflection plane
  4505. * @returns a new matrix
  4506. */
  4507. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4508. /**
  4509. * Computes a reflection matrix from a plane
  4510. * @param plane defines the reflection plane
  4511. * @param result defines the target matrix
  4512. */
  4513. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4514. /**
  4515. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4516. * @param xaxis defines the value of the 1st axis
  4517. * @param yaxis defines the value of the 2nd axis
  4518. * @param zaxis defines the value of the 3rd axis
  4519. * @param result defines the target matrix
  4520. */
  4521. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4522. /**
  4523. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4524. * @param quat defines the quaternion to use
  4525. * @param result defines the target matrix
  4526. */
  4527. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4528. }
  4529. /**
  4530. * @hidden
  4531. */
  4532. export class TmpVectors {
  4533. static Vector2: Vector2[];
  4534. static Vector3: Vector3[];
  4535. static Vector4: Vector4[];
  4536. static Quaternion: Quaternion[];
  4537. static Matrix: Matrix[];
  4538. }
  4539. }
  4540. declare module "babylonjs/Maths/math.path" {
  4541. import { DeepImmutable, Nullable } from "babylonjs/types";
  4542. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4543. /**
  4544. * Defines potential orientation for back face culling
  4545. */
  4546. export enum Orientation {
  4547. /**
  4548. * Clockwise
  4549. */
  4550. CW = 0,
  4551. /** Counter clockwise */
  4552. CCW = 1
  4553. }
  4554. /** Class used to represent a Bezier curve */
  4555. export class BezierCurve {
  4556. /**
  4557. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4558. * @param t defines the time
  4559. * @param x1 defines the left coordinate on X axis
  4560. * @param y1 defines the left coordinate on Y axis
  4561. * @param x2 defines the right coordinate on X axis
  4562. * @param y2 defines the right coordinate on Y axis
  4563. * @returns the interpolated value
  4564. */
  4565. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4566. }
  4567. /**
  4568. * Defines angle representation
  4569. */
  4570. export class Angle {
  4571. private _radians;
  4572. /**
  4573. * Creates an Angle object of "radians" radians (float).
  4574. * @param radians the angle in radians
  4575. */
  4576. constructor(radians: number);
  4577. /**
  4578. * Get value in degrees
  4579. * @returns the Angle value in degrees (float)
  4580. */
  4581. degrees(): number;
  4582. /**
  4583. * Get value in radians
  4584. * @returns the Angle value in radians (float)
  4585. */
  4586. radians(): number;
  4587. /**
  4588. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4589. * @param a defines first vector
  4590. * @param b defines second vector
  4591. * @returns a new Angle
  4592. */
  4593. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4594. /**
  4595. * Gets a new Angle object from the given float in radians
  4596. * @param radians defines the angle value in radians
  4597. * @returns a new Angle
  4598. */
  4599. static FromRadians(radians: number): Angle;
  4600. /**
  4601. * Gets a new Angle object from the given float in degrees
  4602. * @param degrees defines the angle value in degrees
  4603. * @returns a new Angle
  4604. */
  4605. static FromDegrees(degrees: number): Angle;
  4606. }
  4607. /**
  4608. * This represents an arc in a 2d space.
  4609. */
  4610. export class Arc2 {
  4611. /** Defines the start point of the arc */
  4612. startPoint: Vector2;
  4613. /** Defines the mid point of the arc */
  4614. midPoint: Vector2;
  4615. /** Defines the end point of the arc */
  4616. endPoint: Vector2;
  4617. /**
  4618. * Defines the center point of the arc.
  4619. */
  4620. centerPoint: Vector2;
  4621. /**
  4622. * Defines the radius of the arc.
  4623. */
  4624. radius: number;
  4625. /**
  4626. * Defines the angle of the arc (from mid point to end point).
  4627. */
  4628. angle: Angle;
  4629. /**
  4630. * Defines the start angle of the arc (from start point to middle point).
  4631. */
  4632. startAngle: Angle;
  4633. /**
  4634. * Defines the orientation of the arc (clock wise/counter clock wise).
  4635. */
  4636. orientation: Orientation;
  4637. /**
  4638. * Creates an Arc object from the three given points : start, middle and end.
  4639. * @param startPoint Defines the start point of the arc
  4640. * @param midPoint Defines the midlle point of the arc
  4641. * @param endPoint Defines the end point of the arc
  4642. */
  4643. constructor(
  4644. /** Defines the start point of the arc */
  4645. startPoint: Vector2,
  4646. /** Defines the mid point of the arc */
  4647. midPoint: Vector2,
  4648. /** Defines the end point of the arc */
  4649. endPoint: Vector2);
  4650. }
  4651. /**
  4652. * Represents a 2D path made up of multiple 2D points
  4653. */
  4654. export class Path2 {
  4655. private _points;
  4656. private _length;
  4657. /**
  4658. * If the path start and end point are the same
  4659. */
  4660. closed: boolean;
  4661. /**
  4662. * Creates a Path2 object from the starting 2D coordinates x and y.
  4663. * @param x the starting points x value
  4664. * @param y the starting points y value
  4665. */
  4666. constructor(x: number, y: number);
  4667. /**
  4668. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4669. * @param x the added points x value
  4670. * @param y the added points y value
  4671. * @returns the updated Path2.
  4672. */
  4673. addLineTo(x: number, y: number): Path2;
  4674. /**
  4675. * 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.
  4676. * @param midX middle point x value
  4677. * @param midY middle point y value
  4678. * @param endX end point x value
  4679. * @param endY end point y value
  4680. * @param numberOfSegments (default: 36)
  4681. * @returns the updated Path2.
  4682. */
  4683. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4684. /**
  4685. * Closes the Path2.
  4686. * @returns the Path2.
  4687. */
  4688. close(): Path2;
  4689. /**
  4690. * Gets the sum of the distance between each sequential point in the path
  4691. * @returns the Path2 total length (float).
  4692. */
  4693. length(): number;
  4694. /**
  4695. * Gets the points which construct the path
  4696. * @returns the Path2 internal array of points.
  4697. */
  4698. getPoints(): Vector2[];
  4699. /**
  4700. * Retreives the point at the distance aways from the starting point
  4701. * @param normalizedLengthPosition the length along the path to retreive the point from
  4702. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4703. */
  4704. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4705. /**
  4706. * Creates a new path starting from an x and y position
  4707. * @param x starting x value
  4708. * @param y starting y value
  4709. * @returns a new Path2 starting at the coordinates (x, y).
  4710. */
  4711. static StartingAt(x: number, y: number): Path2;
  4712. }
  4713. /**
  4714. * Represents a 3D path made up of multiple 3D points
  4715. */
  4716. export class Path3D {
  4717. /**
  4718. * an array of Vector3, the curve axis of the Path3D
  4719. */
  4720. path: Vector3[];
  4721. private _curve;
  4722. private _distances;
  4723. private _tangents;
  4724. private _normals;
  4725. private _binormals;
  4726. private _raw;
  4727. /**
  4728. * new Path3D(path, normal, raw)
  4729. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4730. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4731. * @param path an array of Vector3, the curve axis of the Path3D
  4732. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4733. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4734. */
  4735. constructor(
  4736. /**
  4737. * an array of Vector3, the curve axis of the Path3D
  4738. */
  4739. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4740. /**
  4741. * Returns the Path3D array of successive Vector3 designing its curve.
  4742. * @returns the Path3D array of successive Vector3 designing its curve.
  4743. */
  4744. getCurve(): Vector3[];
  4745. /**
  4746. * Returns an array populated with tangent vectors on each Path3D curve point.
  4747. * @returns an array populated with tangent vectors on each Path3D curve point.
  4748. */
  4749. getTangents(): Vector3[];
  4750. /**
  4751. * Returns an array populated with normal vectors on each Path3D curve point.
  4752. * @returns an array populated with normal vectors on each Path3D curve point.
  4753. */
  4754. getNormals(): Vector3[];
  4755. /**
  4756. * Returns an array populated with binormal vectors on each Path3D curve point.
  4757. * @returns an array populated with binormal vectors on each Path3D curve point.
  4758. */
  4759. getBinormals(): Vector3[];
  4760. /**
  4761. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4762. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4763. */
  4764. getDistances(): number[];
  4765. /**
  4766. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4767. * @param path path which all values are copied into the curves points
  4768. * @param firstNormal which should be projected onto the curve
  4769. * @returns the same object updated.
  4770. */
  4771. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4772. private _compute;
  4773. private _getFirstNonNullVector;
  4774. private _getLastNonNullVector;
  4775. private _normalVector;
  4776. }
  4777. /**
  4778. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4779. * A Curve3 is designed from a series of successive Vector3.
  4780. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4781. */
  4782. export class Curve3 {
  4783. private _points;
  4784. private _length;
  4785. /**
  4786. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4787. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4788. * @param v1 (Vector3) the control point
  4789. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4790. * @param nbPoints (integer) the wanted number of points in the curve
  4791. * @returns the created Curve3
  4792. */
  4793. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4794. /**
  4795. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4796. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4797. * @param v1 (Vector3) the first control point
  4798. * @param v2 (Vector3) the second control point
  4799. * @param v3 (Vector3) the end point of the Cubic Bezier
  4800. * @param nbPoints (integer) the wanted number of points in the curve
  4801. * @returns the created Curve3
  4802. */
  4803. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4804. /**
  4805. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4806. * @param p1 (Vector3) the origin point of the Hermite Spline
  4807. * @param t1 (Vector3) the tangent vector at the origin point
  4808. * @param p2 (Vector3) the end point of the Hermite Spline
  4809. * @param t2 (Vector3) the tangent vector at the end point
  4810. * @param nbPoints (integer) the wanted number of points in the curve
  4811. * @returns the created Curve3
  4812. */
  4813. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4814. /**
  4815. * Returns a Curve3 object along a CatmullRom Spline curve :
  4816. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4817. * @param nbPoints (integer) the wanted number of points between each curve control points
  4818. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4819. * @returns the created Curve3
  4820. */
  4821. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4822. /**
  4823. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4824. * A Curve3 is designed from a series of successive Vector3.
  4825. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4826. * @param points points which make up the curve
  4827. */
  4828. constructor(points: Vector3[]);
  4829. /**
  4830. * @returns the Curve3 stored array of successive Vector3
  4831. */
  4832. getPoints(): Vector3[];
  4833. /**
  4834. * @returns the computed length (float) of the curve.
  4835. */
  4836. length(): number;
  4837. /**
  4838. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4839. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4840. * curveA and curveB keep unchanged.
  4841. * @param curve the curve to continue from this curve
  4842. * @returns the newly constructed curve
  4843. */
  4844. continue(curve: DeepImmutable<Curve3>): Curve3;
  4845. private _computeLength;
  4846. }
  4847. }
  4848. declare module "babylonjs/Animations/easing" {
  4849. /**
  4850. * This represents the main contract an easing function should follow.
  4851. * Easing functions are used throughout the animation system.
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. export interface IEasingFunction {
  4855. /**
  4856. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4857. * of the easing function.
  4858. * The link below provides some of the most common examples of easing functions.
  4859. * @see https://easings.net/
  4860. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4861. * @returns the corresponding value on the curve defined by the easing function
  4862. */
  4863. ease(gradient: number): number;
  4864. }
  4865. /**
  4866. * Base class used for every default easing function.
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. export class EasingFunction implements IEasingFunction {
  4870. /**
  4871. * Interpolation follows the mathematical formula associated with the easing function.
  4872. */
  4873. static readonly EASINGMODE_EASEIN: number;
  4874. /**
  4875. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4876. */
  4877. static readonly EASINGMODE_EASEOUT: number;
  4878. /**
  4879. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4880. */
  4881. static readonly EASINGMODE_EASEINOUT: number;
  4882. private _easingMode;
  4883. /**
  4884. * Sets the easing mode of the current function.
  4885. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4886. */
  4887. setEasingMode(easingMode: number): void;
  4888. /**
  4889. * Gets the current easing mode.
  4890. * @returns the easing mode
  4891. */
  4892. getEasingMode(): number;
  4893. /**
  4894. * @hidden
  4895. */
  4896. easeInCore(gradient: number): number;
  4897. /**
  4898. * Given an input gradient between 0 and 1, this returns the corresponding value
  4899. * of the easing function.
  4900. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4901. * @returns the corresponding value on the curve defined by the easing function
  4902. */
  4903. ease(gradient: number): number;
  4904. }
  4905. /**
  4906. * Easing function with a circle shape (see link below).
  4907. * @see https://easings.net/#easeInCirc
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export class CircleEase extends EasingFunction implements IEasingFunction {
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with a ease back shape (see link below).
  4916. * @see https://easings.net/#easeInBack
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. export class BackEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the amplitude of the function */
  4921. amplitude: number;
  4922. /**
  4923. * Instantiates a back ease easing
  4924. * @see https://easings.net/#easeInBack
  4925. * @param amplitude Defines the amplitude of the function
  4926. */
  4927. constructor(
  4928. /** Defines the amplitude of the function */
  4929. amplitude?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a bouncing shape (see link below).
  4935. * @see https://easings.net/#easeInBounce
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class BounceEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the number of bounces */
  4940. bounces: number;
  4941. /** Defines the amplitude of the bounce */
  4942. bounciness: number;
  4943. /**
  4944. * Instantiates a bounce easing
  4945. * @see https://easings.net/#easeInBounce
  4946. * @param bounces Defines the number of bounces
  4947. * @param bounciness Defines the amplitude of the bounce
  4948. */
  4949. constructor(
  4950. /** Defines the number of bounces */
  4951. bounces?: number,
  4952. /** Defines the amplitude of the bounce */
  4953. bounciness?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a power of 3 shape (see link below).
  4959. * @see https://easings.net/#easeInCubic
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class CubicEase extends EasingFunction implements IEasingFunction {
  4963. /** @hidden */
  4964. easeInCore(gradient: number): number;
  4965. }
  4966. /**
  4967. * Easing function with an elastic shape (see link below).
  4968. * @see https://easings.net/#easeInElastic
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4972. /** Defines the number of oscillations*/
  4973. oscillations: number;
  4974. /** Defines the amplitude of the oscillations*/
  4975. springiness: number;
  4976. /**
  4977. * Instantiates an elastic easing function
  4978. * @see https://easings.net/#easeInElastic
  4979. * @param oscillations Defines the number of oscillations
  4980. * @param springiness Defines the amplitude of the oscillations
  4981. */
  4982. constructor(
  4983. /** Defines the number of oscillations*/
  4984. oscillations?: number,
  4985. /** Defines the amplitude of the oscillations*/
  4986. springiness?: number);
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an exponential shape (see link below).
  4992. * @see https://easings.net/#easeInExpo
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the exponent of the function */
  4997. exponent: number;
  4998. /**
  4999. * Instantiates an exponential easing function
  5000. * @see https://easings.net/#easeInExpo
  5001. * @param exponent Defines the exponent of the function
  5002. */
  5003. constructor(
  5004. /** Defines the exponent of the function */
  5005. exponent?: number);
  5006. /** @hidden */
  5007. easeInCore(gradient: number): number;
  5008. }
  5009. /**
  5010. * Easing function with a power shape (see link below).
  5011. * @see https://easings.net/#easeInQuad
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class PowerEase extends EasingFunction implements IEasingFunction {
  5015. /** Defines the power of the function */
  5016. power: number;
  5017. /**
  5018. * Instantiates an power base easing function
  5019. * @see https://easings.net/#easeInQuad
  5020. * @param power Defines the power of the function
  5021. */
  5022. constructor(
  5023. /** Defines the power of the function */
  5024. power?: number);
  5025. /** @hidden */
  5026. easeInCore(gradient: number): number;
  5027. }
  5028. /**
  5029. * Easing function with a power of 2 shape (see link below).
  5030. * @see https://easings.net/#easeInQuad
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5034. /** @hidden */
  5035. easeInCore(gradient: number): number;
  5036. }
  5037. /**
  5038. * Easing function with a power of 4 shape (see link below).
  5039. * @see https://easings.net/#easeInQuart
  5040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5041. */
  5042. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a power of 5 shape (see link below).
  5048. * @see https://easings.net/#easeInQuint
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5052. /** @hidden */
  5053. easeInCore(gradient: number): number;
  5054. }
  5055. /**
  5056. * Easing function with a sin shape (see link below).
  5057. * @see https://easings.net/#easeInSine
  5058. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5059. */
  5060. export class SineEase extends EasingFunction implements IEasingFunction {
  5061. /** @hidden */
  5062. easeInCore(gradient: number): number;
  5063. }
  5064. /**
  5065. * Easing function with a bezier shape (see link below).
  5066. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5070. /** Defines the x component of the start tangent in the bezier curve */
  5071. x1: number;
  5072. /** Defines the y component of the start tangent in the bezier curve */
  5073. y1: number;
  5074. /** Defines the x component of the end tangent in the bezier curve */
  5075. x2: number;
  5076. /** Defines the y component of the end tangent in the bezier curve */
  5077. y2: number;
  5078. /**
  5079. * Instantiates a bezier function
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @param x1 Defines the x component of the start tangent in the bezier curve
  5082. * @param y1 Defines the y component of the start tangent in the bezier curve
  5083. * @param x2 Defines the x component of the end tangent in the bezier curve
  5084. * @param y2 Defines the y component of the end tangent in the bezier curve
  5085. */
  5086. constructor(
  5087. /** Defines the x component of the start tangent in the bezier curve */
  5088. x1?: number,
  5089. /** Defines the y component of the start tangent in the bezier curve */
  5090. y1?: number,
  5091. /** Defines the x component of the end tangent in the bezier curve */
  5092. x2?: number,
  5093. /** Defines the y component of the end tangent in the bezier curve */
  5094. y2?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. }
  5099. declare module "babylonjs/Maths/math.color" {
  5100. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5101. /**
  5102. * Class used to hold a RBG color
  5103. */
  5104. export class Color3 {
  5105. /**
  5106. * Defines the red component (between 0 and 1, default is 0)
  5107. */
  5108. r: number;
  5109. /**
  5110. * Defines the green component (between 0 and 1, default is 0)
  5111. */
  5112. g: number;
  5113. /**
  5114. * Defines the blue component (between 0 and 1, default is 0)
  5115. */
  5116. b: number;
  5117. /**
  5118. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5119. * @param r defines the red component (between 0 and 1, default is 0)
  5120. * @param g defines the green component (between 0 and 1, default is 0)
  5121. * @param b defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. constructor(
  5124. /**
  5125. * Defines the red component (between 0 and 1, default is 0)
  5126. */
  5127. r?: number,
  5128. /**
  5129. * Defines the green component (between 0 and 1, default is 0)
  5130. */
  5131. g?: number,
  5132. /**
  5133. * Defines the blue component (between 0 and 1, default is 0)
  5134. */
  5135. b?: number);
  5136. /**
  5137. * Creates a string with the Color3 current values
  5138. * @returns the string representation of the Color3 object
  5139. */
  5140. toString(): string;
  5141. /**
  5142. * Returns the string "Color3"
  5143. * @returns "Color3"
  5144. */
  5145. getClassName(): string;
  5146. /**
  5147. * Compute the Color3 hash code
  5148. * @returns an unique number that can be used to hash Color3 objects
  5149. */
  5150. getHashCode(): number;
  5151. /**
  5152. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5153. * @param array defines the array where to store the r,g,b components
  5154. * @param index defines an optional index in the target array to define where to start storing values
  5155. * @returns the current Color3 object
  5156. */
  5157. toArray(array: FloatArray, index?: number): Color3;
  5158. /**
  5159. * Returns a new Color4 object from the current Color3 and the given alpha
  5160. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5161. * @returns a new Color4 object
  5162. */
  5163. toColor4(alpha?: number): Color4;
  5164. /**
  5165. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5166. * @returns the new array
  5167. */
  5168. asArray(): number[];
  5169. /**
  5170. * Returns the luminance value
  5171. * @returns a float value
  5172. */
  5173. toLuminance(): number;
  5174. /**
  5175. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5176. * @param otherColor defines the second operand
  5177. * @returns the new Color3 object
  5178. */
  5179. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5180. /**
  5181. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5182. * @param otherColor defines the second operand
  5183. * @param result defines the Color3 object where to store the result
  5184. * @returns the current Color3
  5185. */
  5186. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5187. /**
  5188. * Determines equality between Color3 objects
  5189. * @param otherColor defines the second operand
  5190. * @returns true if the rgb values are equal to the given ones
  5191. */
  5192. equals(otherColor: DeepImmutable<Color3>): boolean;
  5193. /**
  5194. * Determines equality between the current Color3 object and a set of r,b,g values
  5195. * @param r defines the red component to check
  5196. * @param g defines the green component to check
  5197. * @param b defines the blue component to check
  5198. * @returns true if the rgb values are equal to the given ones
  5199. */
  5200. equalsFloats(r: number, g: number, b: number): boolean;
  5201. /**
  5202. * Multiplies in place each rgb value by scale
  5203. * @param scale defines the scaling factor
  5204. * @returns the updated Color3
  5205. */
  5206. scale(scale: number): Color3;
  5207. /**
  5208. * Multiplies the rgb values by scale and stores the result into "result"
  5209. * @param scale defines the scaling factor
  5210. * @param result defines the Color3 object where to store the result
  5211. * @returns the unmodified current Color3
  5212. */
  5213. scaleToRef(scale: number, result: Color3): Color3;
  5214. /**
  5215. * Scale the current Color3 values by a factor and add the result to a given Color3
  5216. * @param scale defines the scale factor
  5217. * @param result defines color to store the result into
  5218. * @returns the unmodified current Color3
  5219. */
  5220. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5221. /**
  5222. * Clamps the rgb values by the min and max values and stores the result into "result"
  5223. * @param min defines minimum clamping value (default is 0)
  5224. * @param max defines maximum clamping value (default is 1)
  5225. * @param result defines color to store the result into
  5226. * @returns the original Color3
  5227. */
  5228. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5229. /**
  5230. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5231. * @param otherColor defines the second operand
  5232. * @returns the new Color3
  5233. */
  5234. add(otherColor: DeepImmutable<Color3>): Color3;
  5235. /**
  5236. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5237. * @param otherColor defines the second operand
  5238. * @param result defines Color3 object to store the result into
  5239. * @returns the unmodified current Color3
  5240. */
  5241. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5242. /**
  5243. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Copy the current object
  5257. * @returns a new Color3 copied the current one
  5258. */
  5259. clone(): Color3;
  5260. /**
  5261. * Copies the rgb values from the source in the current Color3
  5262. * @param source defines the source Color3 object
  5263. * @returns the updated Color3 object
  5264. */
  5265. copyFrom(source: DeepImmutable<Color3>): Color3;
  5266. /**
  5267. * Updates the Color3 rgb values from the given floats
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @returns the current Color3 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number): Color3;
  5274. /**
  5275. * Updates the Color3 rgb values from the given floats
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @returns the current Color3 object
  5280. */
  5281. set(r: number, g: number, b: number): Color3;
  5282. /**
  5283. * Compute the Color3 hexadecimal code as a string
  5284. * @returns a string containing the hexadecimal representation of the Color3 object
  5285. */
  5286. toHexString(): string;
  5287. /**
  5288. * Computes a new Color3 converted from the current one to linear space
  5289. * @returns a new Color3 object
  5290. */
  5291. toLinearSpace(): Color3;
  5292. /**
  5293. * Converts current color in rgb space to HSV values
  5294. * @returns a new color3 representing the HSV values
  5295. */
  5296. toHSV(): Color3;
  5297. /**
  5298. * Converts current color in rgb space to HSV values
  5299. * @param result defines the Color3 where to store the HSV values
  5300. */
  5301. toHSVToRef(result: Color3): void;
  5302. /**
  5303. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5304. * @param convertedColor defines the Color3 object where to store the linear space version
  5305. * @returns the unmodified Color3
  5306. */
  5307. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5308. /**
  5309. * Computes a new Color3 converted from the current one to gamma space
  5310. * @returns a new Color3 object
  5311. */
  5312. toGammaSpace(): Color3;
  5313. /**
  5314. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5315. * @param convertedColor defines the Color3 object where to store the gamma space version
  5316. * @returns the unmodified Color3
  5317. */
  5318. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5319. private static _BlackReadOnly;
  5320. /**
  5321. * Convert Hue, saturation and value to a Color3 (RGB)
  5322. * @param hue defines the hue
  5323. * @param saturation defines the saturation
  5324. * @param value defines the value
  5325. * @param result defines the Color3 where to store the RGB values
  5326. */
  5327. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5328. /**
  5329. * Creates a new Color3 from the string containing valid hexadecimal values
  5330. * @param hex defines a string containing valid hexadecimal values
  5331. * @returns a new Color3 object
  5332. */
  5333. static FromHexString(hex: string): Color3;
  5334. /**
  5335. * Creates a new Color3 from the starting index of the given array
  5336. * @param array defines the source array
  5337. * @param offset defines an offset in the source array
  5338. * @returns a new Color3 object
  5339. */
  5340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5341. /**
  5342. * Creates a new Color3 from integer values (< 256)
  5343. * @param r defines the red component to read from (value between 0 and 255)
  5344. * @param g defines the green component to read from (value between 0 and 255)
  5345. * @param b defines the blue component to read from (value between 0 and 255)
  5346. * @returns a new Color3 object
  5347. */
  5348. static FromInts(r: number, g: number, b: number): Color3;
  5349. /**
  5350. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5351. * @param start defines the start Color3 value
  5352. * @param end defines the end Color3 value
  5353. * @param amount defines the gradient value between start and end
  5354. * @returns a new Color3 object
  5355. */
  5356. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5357. /**
  5358. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color3 object where to store the result
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5365. /**
  5366. * Returns a Color3 value containing a red color
  5367. * @returns a new Color3 object
  5368. */
  5369. static Red(): Color3;
  5370. /**
  5371. * Returns a Color3 value containing a green color
  5372. * @returns a new Color3 object
  5373. */
  5374. static Green(): Color3;
  5375. /**
  5376. * Returns a Color3 value containing a blue color
  5377. * @returns a new Color3 object
  5378. */
  5379. static Blue(): Color3;
  5380. /**
  5381. * Returns a Color3 value containing a black color
  5382. * @returns a new Color3 object
  5383. */
  5384. static Black(): Color3;
  5385. /**
  5386. * Gets a Color3 value containing a black color that must not be updated
  5387. */
  5388. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5389. /**
  5390. * Returns a Color3 value containing a white color
  5391. * @returns a new Color3 object
  5392. */
  5393. static White(): Color3;
  5394. /**
  5395. * Returns a Color3 value containing a purple color
  5396. * @returns a new Color3 object
  5397. */
  5398. static Purple(): Color3;
  5399. /**
  5400. * Returns a Color3 value containing a magenta color
  5401. * @returns a new Color3 object
  5402. */
  5403. static Magenta(): Color3;
  5404. /**
  5405. * Returns a Color3 value containing a yellow color
  5406. * @returns a new Color3 object
  5407. */
  5408. static Yellow(): Color3;
  5409. /**
  5410. * Returns a Color3 value containing a gray color
  5411. * @returns a new Color3 object
  5412. */
  5413. static Gray(): Color3;
  5414. /**
  5415. * Returns a Color3 value containing a teal color
  5416. * @returns a new Color3 object
  5417. */
  5418. static Teal(): Color3;
  5419. /**
  5420. * Returns a Color3 value containing a random color
  5421. * @returns a new Color3 object
  5422. */
  5423. static Random(): Color3;
  5424. }
  5425. /**
  5426. * Class used to hold a RBGA color
  5427. */
  5428. export class Color4 {
  5429. /**
  5430. * Defines the red component (between 0 and 1, default is 0)
  5431. */
  5432. r: number;
  5433. /**
  5434. * Defines the green component (between 0 and 1, default is 0)
  5435. */
  5436. g: number;
  5437. /**
  5438. * Defines the blue component (between 0 and 1, default is 0)
  5439. */
  5440. b: number;
  5441. /**
  5442. * Defines the alpha component (between 0 and 1, default is 1)
  5443. */
  5444. a: number;
  5445. /**
  5446. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5447. * @param r defines the red component (between 0 and 1, default is 0)
  5448. * @param g defines the green component (between 0 and 1, default is 0)
  5449. * @param b defines the blue component (between 0 and 1, default is 0)
  5450. * @param a defines the alpha component (between 0 and 1, default is 1)
  5451. */
  5452. constructor(
  5453. /**
  5454. * Defines the red component (between 0 and 1, default is 0)
  5455. */
  5456. r?: number,
  5457. /**
  5458. * Defines the green component (between 0 and 1, default is 0)
  5459. */
  5460. g?: number,
  5461. /**
  5462. * Defines the blue component (between 0 and 1, default is 0)
  5463. */
  5464. b?: number,
  5465. /**
  5466. * Defines the alpha component (between 0 and 1, default is 1)
  5467. */
  5468. a?: number);
  5469. /**
  5470. * Adds in place the given Color4 values to the current Color4 object
  5471. * @param right defines the second operand
  5472. * @returns the current updated Color4 object
  5473. */
  5474. addInPlace(right: DeepImmutable<Color4>): Color4;
  5475. /**
  5476. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5477. * @returns the new array
  5478. */
  5479. asArray(): number[];
  5480. /**
  5481. * Stores from the starting index in the given array the Color4 successive values
  5482. * @param array defines the array where to store the r,g,b components
  5483. * @param index defines an optional index in the target array to define where to start storing values
  5484. * @returns the current Color4 object
  5485. */
  5486. toArray(array: number[], index?: number): Color4;
  5487. /**
  5488. * Determines equality between Color4 objects
  5489. * @param otherColor defines the second operand
  5490. * @returns true if the rgba values are equal to the given ones
  5491. */
  5492. equals(otherColor: DeepImmutable<Color4>): boolean;
  5493. /**
  5494. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5495. * @param right defines the second operand
  5496. * @returns a new Color4 object
  5497. */
  5498. add(right: DeepImmutable<Color4>): Color4;
  5499. /**
  5500. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5501. * @param right defines the second operand
  5502. * @returns a new Color4 object
  5503. */
  5504. subtract(right: DeepImmutable<Color4>): Color4;
  5505. /**
  5506. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5507. * @param right defines the second operand
  5508. * @param result defines the Color4 object where to store the result
  5509. * @returns the current Color4 object
  5510. */
  5511. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5512. /**
  5513. * Creates a new Color4 with the current Color4 values multiplied by scale
  5514. * @param scale defines the scaling factor to apply
  5515. * @returns a new Color4 object
  5516. */
  5517. scale(scale: number): Color4;
  5518. /**
  5519. * Multiplies the current Color4 values by scale and stores the result in "result"
  5520. * @param scale defines the scaling factor to apply
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current unmodified Color4
  5523. */
  5524. scaleToRef(scale: number, result: Color4): Color4;
  5525. /**
  5526. * Scale the current Color4 values by a factor and add the result to a given Color4
  5527. * @param scale defines the scale factor
  5528. * @param result defines the Color4 object where to store the result
  5529. * @returns the unmodified current Color4
  5530. */
  5531. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5532. /**
  5533. * Clamps the rgb values by the min and max values and stores the result into "result"
  5534. * @param min defines minimum clamping value (default is 0)
  5535. * @param max defines maximum clamping value (default is 1)
  5536. * @param result defines color to store the result into.
  5537. * @returns the cuurent Color4
  5538. */
  5539. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5540. /**
  5541. * Multipy an Color4 value by another and return a new Color4 object
  5542. * @param color defines the Color4 value to multiply by
  5543. * @returns a new Color4 object
  5544. */
  5545. multiply(color: Color4): Color4;
  5546. /**
  5547. * Multipy a Color4 value by another and push the result in a reference value
  5548. * @param color defines the Color4 value to multiply by
  5549. * @param result defines the Color4 to fill the result in
  5550. * @returns the result Color4
  5551. */
  5552. multiplyToRef(color: Color4, result: Color4): Color4;
  5553. /**
  5554. * Creates a string with the Color4 current values
  5555. * @returns the string representation of the Color4 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color4"
  5560. * @returns "Color4"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color4 hash code
  5565. * @returns an unique number that can be used to hash Color4 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Creates a new Color4 copied from the current one
  5570. * @returns a new Color4 object
  5571. */
  5572. clone(): Color4;
  5573. /**
  5574. * Copies the given Color4 values into the current one
  5575. * @param source defines the source Color4 object
  5576. * @returns the current updated Color4 object
  5577. */
  5578. copyFrom(source: Color4): Color4;
  5579. /**
  5580. * Copies the given float values into the current one
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @param a defines the alpha component to read from
  5585. * @returns the current updated Color4 object
  5586. */
  5587. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5588. /**
  5589. * Copies the given float values into the current one
  5590. * @param r defines the red component to read from
  5591. * @param g defines the green component to read from
  5592. * @param b defines the blue component to read from
  5593. * @param a defines the alpha component to read from
  5594. * @returns the current updated Color4 object
  5595. */
  5596. set(r: number, g: number, b: number, a: number): Color4;
  5597. /**
  5598. * Compute the Color4 hexadecimal code as a string
  5599. * @returns a string containing the hexadecimal representation of the Color4 object
  5600. */
  5601. toHexString(): string;
  5602. /**
  5603. * Computes a new Color4 converted from the current one to linear space
  5604. * @returns a new Color4 object
  5605. */
  5606. toLinearSpace(): Color4;
  5607. /**
  5608. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5609. * @param convertedColor defines the Color4 object where to store the linear space version
  5610. * @returns the unmodified Color4
  5611. */
  5612. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5613. /**
  5614. * Computes a new Color4 converted from the current one to gamma space
  5615. * @returns a new Color4 object
  5616. */
  5617. toGammaSpace(): Color4;
  5618. /**
  5619. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5620. * @param convertedColor defines the Color4 object where to store the gamma space version
  5621. * @returns the unmodified Color4
  5622. */
  5623. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 from the string containing valid hexadecimal values
  5626. * @param hex defines a string containing valid hexadecimal values
  5627. * @returns a new Color4 object
  5628. */
  5629. static FromHexString(hex: string): Color4;
  5630. /**
  5631. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5632. * @param left defines the start value
  5633. * @param right defines the end value
  5634. * @param amount defines the gradient factor
  5635. * @returns a new Color4 object
  5636. */
  5637. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5638. /**
  5639. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5640. * @param left defines the start value
  5641. * @param right defines the end value
  5642. * @param amount defines the gradient factor
  5643. * @param result defines the Color4 object where to store data
  5644. */
  5645. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5646. /**
  5647. * Creates a new Color4 from a Color3 and an alpha value
  5648. * @param color3 defines the source Color3 to read from
  5649. * @param alpha defines the alpha component (1.0 by default)
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5653. /**
  5654. * Creates a new Color4 from the starting index element of the given array
  5655. * @param array defines the source array to read from
  5656. * @param offset defines the offset in the source array
  5657. * @returns a new Color4 object
  5658. */
  5659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5660. /**
  5661. * Creates a new Color3 from integer values (< 256)
  5662. * @param r defines the red component to read from (value between 0 and 255)
  5663. * @param g defines the green component to read from (value between 0 and 255)
  5664. * @param b defines the blue component to read from (value between 0 and 255)
  5665. * @param a defines the alpha component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5669. /**
  5670. * Check the content of a given array and convert it to an array containing RGBA data
  5671. * If the original array was already containing count * 4 values then it is returned directly
  5672. * @param colors defines the array to check
  5673. * @param count defines the number of RGBA data to expect
  5674. * @returns an array containing count * 4 values (RGBA)
  5675. */
  5676. static CheckColors4(colors: number[], count: number): number[];
  5677. }
  5678. /**
  5679. * @hidden
  5680. */
  5681. export class TmpColors {
  5682. static Color3: Color3[];
  5683. static Color4: Color4[];
  5684. }
  5685. }
  5686. declare module "babylonjs/Animations/animationKey" {
  5687. /**
  5688. * Defines an interface which represents an animation key frame
  5689. */
  5690. export interface IAnimationKey {
  5691. /**
  5692. * Frame of the key frame
  5693. */
  5694. frame: number;
  5695. /**
  5696. * Value at the specifies key frame
  5697. */
  5698. value: any;
  5699. /**
  5700. * The input tangent for the cubic hermite spline
  5701. */
  5702. inTangent?: any;
  5703. /**
  5704. * The output tangent for the cubic hermite spline
  5705. */
  5706. outTangent?: any;
  5707. /**
  5708. * The animation interpolation type
  5709. */
  5710. interpolation?: AnimationKeyInterpolation;
  5711. }
  5712. /**
  5713. * Enum for the animation key frame interpolation type
  5714. */
  5715. export enum AnimationKeyInterpolation {
  5716. /**
  5717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5718. */
  5719. STEP = 1
  5720. }
  5721. }
  5722. declare module "babylonjs/Animations/animationRange" {
  5723. /**
  5724. * Represents the range of an animation
  5725. */
  5726. export class AnimationRange {
  5727. /**The name of the animation range**/
  5728. name: string;
  5729. /**The starting frame of the animation */
  5730. from: number;
  5731. /**The ending frame of the animation*/
  5732. to: number;
  5733. /**
  5734. * Initializes the range of an animation
  5735. * @param name The name of the animation range
  5736. * @param from The starting frame of the animation
  5737. * @param to The ending frame of the animation
  5738. */
  5739. constructor(
  5740. /**The name of the animation range**/
  5741. name: string,
  5742. /**The starting frame of the animation */
  5743. from: number,
  5744. /**The ending frame of the animation*/
  5745. to: number);
  5746. /**
  5747. * Makes a copy of the animation range
  5748. * @returns A copy of the animation range
  5749. */
  5750. clone(): AnimationRange;
  5751. }
  5752. }
  5753. declare module "babylonjs/Animations/animationEvent" {
  5754. /**
  5755. * Composed of a frame, and an action function
  5756. */
  5757. export class AnimationEvent {
  5758. /** The frame for which the event is triggered **/
  5759. frame: number;
  5760. /** The event to perform when triggered **/
  5761. action: (currentFrame: number) => void;
  5762. /** Specifies if the event should be triggered only once**/
  5763. onlyOnce?: boolean | undefined;
  5764. /**
  5765. * Specifies if the animation event is done
  5766. */
  5767. isDone: boolean;
  5768. /**
  5769. * Initializes the animation event
  5770. * @param frame The frame for which the event is triggered
  5771. * @param action The event to perform when triggered
  5772. * @param onlyOnce Specifies if the event should be triggered only once
  5773. */
  5774. constructor(
  5775. /** The frame for which the event is triggered **/
  5776. frame: number,
  5777. /** The event to perform when triggered **/
  5778. action: (currentFrame: number) => void,
  5779. /** Specifies if the event should be triggered only once**/
  5780. onlyOnce?: boolean | undefined);
  5781. /** @hidden */
  5782. _clone(): AnimationEvent;
  5783. }
  5784. }
  5785. declare module "babylonjs/Behaviors/behavior" {
  5786. import { Nullable } from "babylonjs/types";
  5787. /**
  5788. * Interface used to define a behavior
  5789. */
  5790. export interface Behavior<T> {
  5791. /** gets or sets behavior's name */
  5792. name: string;
  5793. /**
  5794. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5795. */
  5796. init(): void;
  5797. /**
  5798. * Called when the behavior is attached to a target
  5799. * @param target defines the target where the behavior is attached to
  5800. */
  5801. attach(target: T): void;
  5802. /**
  5803. * Called when the behavior is detached from its target
  5804. */
  5805. detach(): void;
  5806. }
  5807. /**
  5808. * Interface implemented by classes supporting behaviors
  5809. */
  5810. export interface IBehaviorAware<T> {
  5811. /**
  5812. * Attach a behavior
  5813. * @param behavior defines the behavior to attach
  5814. * @returns the current host
  5815. */
  5816. addBehavior(behavior: Behavior<T>): T;
  5817. /**
  5818. * Remove a behavior from the current object
  5819. * @param behavior defines the behavior to detach
  5820. * @returns the current host
  5821. */
  5822. removeBehavior(behavior: Behavior<T>): T;
  5823. /**
  5824. * Gets a behavior using its name to search
  5825. * @param name defines the name to search
  5826. * @returns the behavior or null if not found
  5827. */
  5828. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5829. }
  5830. }
  5831. declare module "babylonjs/Misc/smartArray" {
  5832. /**
  5833. * Defines an array and its length.
  5834. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5835. */
  5836. export interface ISmartArrayLike<T> {
  5837. /**
  5838. * The data of the array.
  5839. */
  5840. data: Array<T>;
  5841. /**
  5842. * The active length of the array.
  5843. */
  5844. length: number;
  5845. }
  5846. /**
  5847. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5848. */
  5849. export class SmartArray<T> implements ISmartArrayLike<T> {
  5850. /**
  5851. * The full set of data from the array.
  5852. */
  5853. data: Array<T>;
  5854. /**
  5855. * The active length of the array.
  5856. */
  5857. length: number;
  5858. protected _id: number;
  5859. /**
  5860. * Instantiates a Smart Array.
  5861. * @param capacity defines the default capacity of the array.
  5862. */
  5863. constructor(capacity: number);
  5864. /**
  5865. * Pushes a value at the end of the active data.
  5866. * @param value defines the object to push in the array.
  5867. */
  5868. push(value: T): void;
  5869. /**
  5870. * Iterates over the active data and apply the lambda to them.
  5871. * @param func defines the action to apply on each value.
  5872. */
  5873. forEach(func: (content: T) => void): void;
  5874. /**
  5875. * Sorts the full sets of data.
  5876. * @param compareFn defines the comparison function to apply.
  5877. */
  5878. sort(compareFn: (a: T, b: T) => number): void;
  5879. /**
  5880. * Resets the active data to an empty array.
  5881. */
  5882. reset(): void;
  5883. /**
  5884. * Releases all the data from the array as well as the array.
  5885. */
  5886. dispose(): void;
  5887. /**
  5888. * Concats the active data with a given array.
  5889. * @param array defines the data to concatenate with.
  5890. */
  5891. concat(array: any): void;
  5892. /**
  5893. * Returns the position of a value in the active data.
  5894. * @param value defines the value to find the index for
  5895. * @returns the index if found in the active data otherwise -1
  5896. */
  5897. indexOf(value: T): number;
  5898. /**
  5899. * Returns whether an element is part of the active data.
  5900. * @param value defines the value to look for
  5901. * @returns true if found in the active data otherwise false
  5902. */
  5903. contains(value: T): boolean;
  5904. private static _GlobalId;
  5905. }
  5906. /**
  5907. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5908. * The data in this array can only be present once
  5909. */
  5910. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5911. private _duplicateId;
  5912. /**
  5913. * Pushes a value at the end of the active data.
  5914. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5915. * @param value defines the object to push in the array.
  5916. */
  5917. push(value: T): void;
  5918. /**
  5919. * Pushes a value at the end of the active data.
  5920. * If the data is already present, it won t be added again
  5921. * @param value defines the object to push in the array.
  5922. * @returns true if added false if it was already present
  5923. */
  5924. pushNoDuplicate(value: T): boolean;
  5925. /**
  5926. * Resets the active data to an empty array.
  5927. */
  5928. reset(): void;
  5929. /**
  5930. * Concats the active data with a given array.
  5931. * This ensures no dupplicate will be present in the result.
  5932. * @param array defines the data to concatenate with.
  5933. */
  5934. concatWithNoDuplicate(array: any): void;
  5935. }
  5936. }
  5937. declare module "babylonjs/Cameras/cameraInputsManager" {
  5938. import { Nullable } from "babylonjs/types";
  5939. import { Camera } from "babylonjs/Cameras/camera";
  5940. /**
  5941. * @ignore
  5942. * This is a list of all the different input types that are available in the application.
  5943. * Fo instance: ArcRotateCameraGamepadInput...
  5944. */
  5945. export var CameraInputTypes: {};
  5946. /**
  5947. * This is the contract to implement in order to create a new input class.
  5948. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5949. */
  5950. export interface ICameraInput<TCamera extends Camera> {
  5951. /**
  5952. * Defines the camera the input is attached to.
  5953. */
  5954. camera: Nullable<TCamera>;
  5955. /**
  5956. * Gets the class name of the current intput.
  5957. * @returns the class name
  5958. */
  5959. getClassName(): string;
  5960. /**
  5961. * Get the friendly name associated with the input class.
  5962. * @returns the input friendly name
  5963. */
  5964. getSimpleName(): string;
  5965. /**
  5966. * Attach the input controls to a specific dom element to get the input from.
  5967. * @param element Defines the element the controls should be listened from
  5968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5969. */
  5970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5971. /**
  5972. * Detach the current controls from the specified dom element.
  5973. * @param element Defines the element to stop listening the inputs from
  5974. */
  5975. detachControl(element: Nullable<HTMLElement>): void;
  5976. /**
  5977. * Update the current camera state depending on the inputs that have been used this frame.
  5978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5979. */
  5980. checkInputs?: () => void;
  5981. }
  5982. /**
  5983. * Represents a map of input types to input instance or input index to input instance.
  5984. */
  5985. export interface CameraInputsMap<TCamera extends Camera> {
  5986. /**
  5987. * Accessor to the input by input type.
  5988. */
  5989. [name: string]: ICameraInput<TCamera>;
  5990. /**
  5991. * Accessor to the input by input index.
  5992. */
  5993. [idx: number]: ICameraInput<TCamera>;
  5994. }
  5995. /**
  5996. * This represents the input manager used within a camera.
  5997. * It helps dealing with all the different kind of input attached to a camera.
  5998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5999. */
  6000. export class CameraInputsManager<TCamera extends Camera> {
  6001. /**
  6002. * Defines the list of inputs attahed to the camera.
  6003. */
  6004. attached: CameraInputsMap<TCamera>;
  6005. /**
  6006. * Defines the dom element the camera is collecting inputs from.
  6007. * This is null if the controls have not been attached.
  6008. */
  6009. attachedElement: Nullable<HTMLElement>;
  6010. /**
  6011. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6012. */
  6013. noPreventDefault: boolean;
  6014. /**
  6015. * Defined the camera the input manager belongs to.
  6016. */
  6017. camera: TCamera;
  6018. /**
  6019. * Update the current camera state depending on the inputs that have been used this frame.
  6020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6021. */
  6022. checkInputs: () => void;
  6023. /**
  6024. * Instantiate a new Camera Input Manager.
  6025. * @param camera Defines the camera the input manager blongs to
  6026. */
  6027. constructor(camera: TCamera);
  6028. /**
  6029. * Add an input method to a camera
  6030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6031. * @param input camera input method
  6032. */
  6033. add(input: ICameraInput<TCamera>): void;
  6034. /**
  6035. * Remove a specific input method from a camera
  6036. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6037. * @param inputToRemove camera input method
  6038. */
  6039. remove(inputToRemove: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input type from a camera
  6042. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6043. * @param inputType the type of the input to remove
  6044. */
  6045. removeByType(inputType: string): void;
  6046. private _addCheckInputs;
  6047. /**
  6048. * Attach the input controls to the currently attached dom element to listen the events from.
  6049. * @param input Defines the input to attach
  6050. */
  6051. attachInput(input: ICameraInput<TCamera>): void;
  6052. /**
  6053. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6054. * @param element Defines the dom element to collect the events from
  6055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6056. */
  6057. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6058. /**
  6059. * Detach the current manager inputs controls from a specific dom element.
  6060. * @param element Defines the dom element to collect the events from
  6061. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6062. */
  6063. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6064. /**
  6065. * Rebuild the dynamic inputCheck function from the current list of
  6066. * defined inputs in the manager.
  6067. */
  6068. rebuildInputCheck(): void;
  6069. /**
  6070. * Remove all attached input methods from a camera
  6071. */
  6072. clear(): void;
  6073. /**
  6074. * Serialize the current input manager attached to a camera.
  6075. * This ensures than once parsed,
  6076. * the input associated to the camera will be identical to the current ones
  6077. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6078. */
  6079. serialize(serializedCamera: any): void;
  6080. /**
  6081. * Parses an input manager serialized JSON to restore the previous list of inputs
  6082. * and states associated to a camera.
  6083. * @param parsedCamera Defines the JSON to parse
  6084. */
  6085. parse(parsedCamera: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Meshes/buffer" {
  6089. import { Nullable, DataArray } from "babylonjs/types";
  6090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6091. /**
  6092. * Class used to store data that will be store in GPU memory
  6093. */
  6094. export class Buffer {
  6095. private _engine;
  6096. private _buffer;
  6097. /** @hidden */
  6098. _data: Nullable<DataArray>;
  6099. private _updatable;
  6100. private _instanced;
  6101. /**
  6102. * Gets the byte stride.
  6103. */
  6104. readonly byteStride: number;
  6105. /**
  6106. * Constructor
  6107. * @param engine the engine
  6108. * @param data the data to use for this buffer
  6109. * @param updatable whether the data is updatable
  6110. * @param stride the stride (optional)
  6111. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6112. * @param instanced whether the buffer is instanced (optional)
  6113. * @param useBytes set to true if the stride in in bytes (optional)
  6114. */
  6115. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6116. /**
  6117. * Create a new VertexBuffer based on the current buffer
  6118. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6119. * @param offset defines offset in the buffer (0 by default)
  6120. * @param size defines the size in floats of attributes (position is 3 for instance)
  6121. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6122. * @param instanced defines if the vertex buffer contains indexed data
  6123. * @param useBytes defines if the offset and stride are in bytes
  6124. * @returns the new vertex buffer
  6125. */
  6126. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6127. /**
  6128. * Gets a boolean indicating if the Buffer is updatable?
  6129. * @returns true if the buffer is updatable
  6130. */
  6131. isUpdatable(): boolean;
  6132. /**
  6133. * Gets current buffer's data
  6134. * @returns a DataArray or null
  6135. */
  6136. getData(): Nullable<DataArray>;
  6137. /**
  6138. * Gets underlying native buffer
  6139. * @returns underlying native buffer
  6140. */
  6141. getBuffer(): Nullable<DataBuffer>;
  6142. /**
  6143. * Gets the stride in float32 units (i.e. byte stride / 4).
  6144. * May not be an integer if the byte stride is not divisible by 4.
  6145. * DEPRECATED. Use byteStride instead.
  6146. * @returns the stride in float32 units
  6147. */
  6148. getStrideSize(): number;
  6149. /**
  6150. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6151. * @param data defines the data to store
  6152. */
  6153. create(data?: Nullable<DataArray>): void;
  6154. /** @hidden */
  6155. _rebuild(): void;
  6156. /**
  6157. * Update current buffer data
  6158. * @param data defines the data to store
  6159. */
  6160. update(data: DataArray): void;
  6161. /**
  6162. * Updates the data directly.
  6163. * @param data the new data
  6164. * @param offset the new offset
  6165. * @param vertexCount the vertex count (optional)
  6166. * @param useBytes set to true if the offset is in bytes
  6167. */
  6168. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6169. /**
  6170. * Release all resources
  6171. */
  6172. dispose(): void;
  6173. }
  6174. /**
  6175. * Specialized buffer used to store vertex data
  6176. */
  6177. export class VertexBuffer {
  6178. /** @hidden */
  6179. _buffer: Buffer;
  6180. private _kind;
  6181. private _size;
  6182. private _ownsBuffer;
  6183. private _instanced;
  6184. private _instanceDivisor;
  6185. /**
  6186. * The byte type.
  6187. */
  6188. static readonly BYTE: number;
  6189. /**
  6190. * The unsigned byte type.
  6191. */
  6192. static readonly UNSIGNED_BYTE: number;
  6193. /**
  6194. * The short type.
  6195. */
  6196. static readonly SHORT: number;
  6197. /**
  6198. * The unsigned short type.
  6199. */
  6200. static readonly UNSIGNED_SHORT: number;
  6201. /**
  6202. * The integer type.
  6203. */
  6204. static readonly INT: number;
  6205. /**
  6206. * The unsigned integer type.
  6207. */
  6208. static readonly UNSIGNED_INT: number;
  6209. /**
  6210. * The float type.
  6211. */
  6212. static readonly FLOAT: number;
  6213. /**
  6214. * Gets or sets the instance divisor when in instanced mode
  6215. */
  6216. instanceDivisor: number;
  6217. /**
  6218. * Gets the byte stride.
  6219. */
  6220. readonly byteStride: number;
  6221. /**
  6222. * Gets the byte offset.
  6223. */
  6224. readonly byteOffset: number;
  6225. /**
  6226. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6227. */
  6228. readonly normalized: boolean;
  6229. /**
  6230. * Gets the data type of each component in the array.
  6231. */
  6232. readonly type: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this vertex buffer
  6237. * @param kind the vertex buffer kind
  6238. * @param updatable whether the data is updatable
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param stride the stride (optional)
  6241. * @param instanced whether the buffer is instanced (optional)
  6242. * @param offset the offset of the data (optional)
  6243. * @param size the number of components (optional)
  6244. * @param type the type of the component (optional)
  6245. * @param normalized whether the data contains normalized data (optional)
  6246. * @param useBytes set to true if stride and offset are in bytes (optional)
  6247. */
  6248. 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);
  6249. /** @hidden */
  6250. _rebuild(): void;
  6251. /**
  6252. * Returns the kind of the VertexBuffer (string)
  6253. * @returns a string
  6254. */
  6255. getKind(): string;
  6256. /**
  6257. * Gets a boolean indicating if the VertexBuffer is updatable?
  6258. * @returns true if the buffer is updatable
  6259. */
  6260. isUpdatable(): boolean;
  6261. /**
  6262. * Gets current buffer's data
  6263. * @returns a DataArray or null
  6264. */
  6265. getData(): Nullable<DataArray>;
  6266. /**
  6267. * Gets underlying native buffer
  6268. * @returns underlying native buffer
  6269. */
  6270. getBuffer(): Nullable<DataBuffer>;
  6271. /**
  6272. * Gets the stride in float32 units (i.e. byte stride / 4).
  6273. * May not be an integer if the byte stride is not divisible by 4.
  6274. * DEPRECATED. Use byteStride instead.
  6275. * @returns the stride in float32 units
  6276. */
  6277. getStrideSize(): number;
  6278. /**
  6279. * Returns the offset as a multiple of the type byte length.
  6280. * DEPRECATED. Use byteOffset instead.
  6281. * @returns the offset in bytes
  6282. */
  6283. getOffset(): number;
  6284. /**
  6285. * Returns the number of components per vertex attribute (integer)
  6286. * @returns the size in float
  6287. */
  6288. getSize(): number;
  6289. /**
  6290. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6291. * @returns true if this buffer is instanced
  6292. */
  6293. getIsInstanced(): boolean;
  6294. /**
  6295. * Returns the instancing divisor, zero for non-instanced (integer).
  6296. * @returns a number
  6297. */
  6298. getInstanceDivisor(): number;
  6299. /**
  6300. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6301. * @param data defines the data to store
  6302. */
  6303. create(data?: DataArray): void;
  6304. /**
  6305. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6306. * This function will create a new buffer if the current one is not updatable
  6307. * @param data defines the data to store
  6308. */
  6309. update(data: DataArray): void;
  6310. /**
  6311. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6312. * Returns the directly updated WebGLBuffer.
  6313. * @param data the new data
  6314. * @param offset the new offset
  6315. * @param useBytes set to true if the offset is in bytes
  6316. */
  6317. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6318. /**
  6319. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6320. */
  6321. dispose(): void;
  6322. /**
  6323. * Enumerates each value of this vertex buffer as numbers.
  6324. * @param count the number of values to enumerate
  6325. * @param callback the callback function called for each value
  6326. */
  6327. forEach(count: number, callback: (value: number, index: number) => void): void;
  6328. /**
  6329. * Positions
  6330. */
  6331. static readonly PositionKind: string;
  6332. /**
  6333. * Normals
  6334. */
  6335. static readonly NormalKind: string;
  6336. /**
  6337. * Tangents
  6338. */
  6339. static readonly TangentKind: string;
  6340. /**
  6341. * Texture coordinates
  6342. */
  6343. static readonly UVKind: string;
  6344. /**
  6345. * Texture coordinates 2
  6346. */
  6347. static readonly UV2Kind: string;
  6348. /**
  6349. * Texture coordinates 3
  6350. */
  6351. static readonly UV3Kind: string;
  6352. /**
  6353. * Texture coordinates 4
  6354. */
  6355. static readonly UV4Kind: string;
  6356. /**
  6357. * Texture coordinates 5
  6358. */
  6359. static readonly UV5Kind: string;
  6360. /**
  6361. * Texture coordinates 6
  6362. */
  6363. static readonly UV6Kind: string;
  6364. /**
  6365. * Colors
  6366. */
  6367. static readonly ColorKind: string;
  6368. /**
  6369. * Matrix indices (for bones)
  6370. */
  6371. static readonly MatricesIndicesKind: string;
  6372. /**
  6373. * Matrix weights (for bones)
  6374. */
  6375. static readonly MatricesWeightsKind: string;
  6376. /**
  6377. * Additional matrix indices (for bones)
  6378. */
  6379. static readonly MatricesIndicesExtraKind: string;
  6380. /**
  6381. * Additional matrix weights (for bones)
  6382. */
  6383. static readonly MatricesWeightsExtraKind: string;
  6384. /**
  6385. * Deduces the stride given a kind.
  6386. * @param kind The kind string to deduce
  6387. * @returns The deduced stride
  6388. */
  6389. static DeduceStride(kind: string): number;
  6390. /**
  6391. * Gets the byte length of the given type.
  6392. * @param type the type
  6393. * @returns the number of bytes
  6394. */
  6395. static GetTypeByteLength(type: number): number;
  6396. /**
  6397. * Enumerates each value of the given parameters as numbers.
  6398. * @param data the data to enumerate
  6399. * @param byteOffset the byte offset of the data
  6400. * @param byteStride the byte stride of the data
  6401. * @param componentCount the number of components per element
  6402. * @param componentType the type of the component
  6403. * @param count the number of values to enumerate
  6404. * @param normalized whether the data is normalized
  6405. * @param callback the callback function called for each value
  6406. */
  6407. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6408. private static _GetFloatValue;
  6409. }
  6410. }
  6411. declare module "babylonjs/Collisions/intersectionInfo" {
  6412. import { Nullable } from "babylonjs/types";
  6413. /**
  6414. * @hidden
  6415. */
  6416. export class IntersectionInfo {
  6417. bu: Nullable<number>;
  6418. bv: Nullable<number>;
  6419. distance: number;
  6420. faceId: number;
  6421. subMeshId: number;
  6422. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6423. }
  6424. }
  6425. declare module "babylonjs/Maths/math.plane" {
  6426. import { DeepImmutable } from "babylonjs/types";
  6427. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6428. /**
  6429. * Represens a plane by the equation ax + by + cz + d = 0
  6430. */
  6431. export class Plane {
  6432. private static _TmpMatrix;
  6433. /**
  6434. * Normal of the plane (a,b,c)
  6435. */
  6436. normal: Vector3;
  6437. /**
  6438. * d component of the plane
  6439. */
  6440. d: number;
  6441. /**
  6442. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6443. * @param a a component of the plane
  6444. * @param b b component of the plane
  6445. * @param c c component of the plane
  6446. * @param d d component of the plane
  6447. */
  6448. constructor(a: number, b: number, c: number, d: number);
  6449. /**
  6450. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6451. */
  6452. asArray(): number[];
  6453. /**
  6454. * @returns a new plane copied from the current Plane.
  6455. */
  6456. clone(): Plane;
  6457. /**
  6458. * @returns the string "Plane".
  6459. */
  6460. getClassName(): string;
  6461. /**
  6462. * @returns the Plane hash code.
  6463. */
  6464. getHashCode(): number;
  6465. /**
  6466. * Normalize the current Plane in place.
  6467. * @returns the updated Plane.
  6468. */
  6469. normalize(): Plane;
  6470. /**
  6471. * Applies a transformation the plane and returns the result
  6472. * @param transformation the transformation matrix to be applied to the plane
  6473. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6474. */
  6475. transform(transformation: DeepImmutable<Matrix>): Plane;
  6476. /**
  6477. * Calcualtte the dot product between the point and the plane normal
  6478. * @param point point to calculate the dot product with
  6479. * @returns the dot product (float) of the point coordinates and the plane normal.
  6480. */
  6481. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6482. /**
  6483. * Updates the current Plane from the plane defined by the three given points.
  6484. * @param point1 one of the points used to contruct the plane
  6485. * @param point2 one of the points used to contruct the plane
  6486. * @param point3 one of the points used to contruct the plane
  6487. * @returns the updated Plane.
  6488. */
  6489. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6490. /**
  6491. * Checks if the plane is facing a given direction
  6492. * @param direction the direction to check if the plane is facing
  6493. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6494. * @returns True is the vector "direction" is the same side than the plane normal.
  6495. */
  6496. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6497. /**
  6498. * Calculates the distance to a point
  6499. * @param point point to calculate distance to
  6500. * @returns the signed distance (float) from the given point to the Plane.
  6501. */
  6502. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6503. /**
  6504. * Creates a plane from an array
  6505. * @param array the array to create a plane from
  6506. * @returns a new Plane from the given array.
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6509. /**
  6510. * Creates a plane from three points
  6511. * @param point1 point used to create the plane
  6512. * @param point2 point used to create the plane
  6513. * @param point3 point used to create the plane
  6514. * @returns a new Plane defined by the three given points.
  6515. */
  6516. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6517. /**
  6518. * Creates a plane from an origin point and a normal
  6519. * @param origin origin of the plane to be constructed
  6520. * @param normal normal of the plane to be constructed
  6521. * @returns a new Plane the normal vector to this plane at the given origin point.
  6522. * Note : the vector "normal" is updated because normalized.
  6523. */
  6524. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6525. /**
  6526. * Calculates the distance from a plane and a point
  6527. * @param origin origin of the plane to be constructed
  6528. * @param normal normal of the plane to be constructed
  6529. * @param point point to calculate distance to
  6530. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6531. */
  6532. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6533. }
  6534. }
  6535. declare module "babylonjs/Culling/boundingSphere" {
  6536. import { DeepImmutable } from "babylonjs/types";
  6537. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6538. import { Plane } from "babylonjs/Maths/math.plane";
  6539. /**
  6540. * Class used to store bounding sphere information
  6541. */
  6542. export class BoundingSphere {
  6543. /**
  6544. * Gets the center of the bounding sphere in local space
  6545. */
  6546. readonly center: Vector3;
  6547. /**
  6548. * Radius of the bounding sphere in local space
  6549. */
  6550. radius: number;
  6551. /**
  6552. * Gets the center of the bounding sphere in world space
  6553. */
  6554. readonly centerWorld: Vector3;
  6555. /**
  6556. * Radius of the bounding sphere in world space
  6557. */
  6558. radiusWorld: number;
  6559. /**
  6560. * Gets the minimum vector in local space
  6561. */
  6562. readonly minimum: Vector3;
  6563. /**
  6564. * Gets the maximum vector in local space
  6565. */
  6566. readonly maximum: Vector3;
  6567. private _worldMatrix;
  6568. private static readonly TmpVector3;
  6569. /**
  6570. * Creates a new bounding sphere
  6571. * @param min defines the minimum vector (in local space)
  6572. * @param max defines the maximum vector (in local space)
  6573. * @param worldMatrix defines the new world matrix
  6574. */
  6575. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6576. /**
  6577. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6578. * @param min defines the new minimum vector (in local space)
  6579. * @param max defines the new maximum vector (in local space)
  6580. * @param worldMatrix defines the new world matrix
  6581. */
  6582. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6583. /**
  6584. * Scale the current bounding sphere by applying a scale factor
  6585. * @param factor defines the scale factor to apply
  6586. * @returns the current bounding box
  6587. */
  6588. scale(factor: number): BoundingSphere;
  6589. /**
  6590. * Gets the world matrix of the bounding box
  6591. * @returns a matrix
  6592. */
  6593. getWorldMatrix(): DeepImmutable<Matrix>;
  6594. /** @hidden */
  6595. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module "babylonjs/Culling/boundingBox" {
  6625. import { DeepImmutable } from "babylonjs/types";
  6626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6627. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6628. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6629. import { Plane } from "babylonjs/Maths/math.plane";
  6630. /**
  6631. * Class used to store bounding box information
  6632. */
  6633. export class BoundingBox implements ICullable {
  6634. /**
  6635. * Gets the 8 vectors representing the bounding box in local space
  6636. */
  6637. readonly vectors: Vector3[];
  6638. /**
  6639. * Gets the center of the bounding box in local space
  6640. */
  6641. readonly center: Vector3;
  6642. /**
  6643. * Gets the center of the bounding box in world space
  6644. */
  6645. readonly centerWorld: Vector3;
  6646. /**
  6647. * Gets the extend size in local space
  6648. */
  6649. readonly extendSize: Vector3;
  6650. /**
  6651. * Gets the extend size in world space
  6652. */
  6653. readonly extendSizeWorld: Vector3;
  6654. /**
  6655. * Gets the OBB (object bounding box) directions
  6656. */
  6657. readonly directions: Vector3[];
  6658. /**
  6659. * Gets the 8 vectors representing the bounding box in world space
  6660. */
  6661. readonly vectorsWorld: Vector3[];
  6662. /**
  6663. * Gets the minimum vector in world space
  6664. */
  6665. readonly minimumWorld: Vector3;
  6666. /**
  6667. * Gets the maximum vector in world space
  6668. */
  6669. readonly maximumWorld: Vector3;
  6670. /**
  6671. * Gets the minimum vector in local space
  6672. */
  6673. readonly minimum: Vector3;
  6674. /**
  6675. * Gets the maximum vector in local space
  6676. */
  6677. readonly maximum: Vector3;
  6678. private _worldMatrix;
  6679. private static readonly TmpVector3;
  6680. /**
  6681. * @hidden
  6682. */
  6683. _tag: number;
  6684. /**
  6685. * Creates a new bounding box
  6686. * @param min defines the minimum vector (in local space)
  6687. * @param max defines the maximum vector (in local space)
  6688. * @param worldMatrix defines the new world matrix
  6689. */
  6690. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6691. /**
  6692. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6693. * @param min defines the new minimum vector (in local space)
  6694. * @param max defines the new maximum vector (in local space)
  6695. * @param worldMatrix defines the new world matrix
  6696. */
  6697. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6698. /**
  6699. * Scale the current bounding box by applying a scale factor
  6700. * @param factor defines the scale factor to apply
  6701. * @returns the current bounding box
  6702. */
  6703. scale(factor: number): BoundingBox;
  6704. /**
  6705. * Gets the world matrix of the bounding box
  6706. * @returns a matrix
  6707. */
  6708. getWorldMatrix(): DeepImmutable<Matrix>;
  6709. /** @hidden */
  6710. _update(world: DeepImmutable<Matrix>): void;
  6711. /**
  6712. * Tests if the bounding box is intersecting the frustum planes
  6713. * @param frustumPlanes defines the frustum planes to test
  6714. * @returns true if there is an intersection
  6715. */
  6716. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6717. /**
  6718. * Tests if the bounding box is entirely inside the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an inclusion
  6721. */
  6722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if a point is inside the bounding box
  6725. * @param point defines the point to test
  6726. * @returns true if the point is inside the bounding box
  6727. */
  6728. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6729. /**
  6730. * Tests if the bounding box intersects with a bounding sphere
  6731. * @param sphere defines the sphere to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6737. * @param min defines the min vector to use
  6738. * @param max defines the max vector to use
  6739. * @returns true if there is an intersection
  6740. */
  6741. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6742. /**
  6743. * Tests if two bounding boxes are intersections
  6744. * @param box0 defines the first box to test
  6745. * @param box1 defines the second box to test
  6746. * @returns true if there is an intersection
  6747. */
  6748. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6749. /**
  6750. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6751. * @param minPoint defines the minimum vector of the bounding box
  6752. * @param maxPoint defines the maximum vector of the bounding box
  6753. * @param sphereCenter defines the sphere center
  6754. * @param sphereRadius defines the sphere radius
  6755. * @returns true if there is an intersection
  6756. */
  6757. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an inclusion
  6763. */
  6764. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6767. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6768. * @param frustumPlanes defines the frustum planes to test
  6769. * @return true if there is an intersection
  6770. */
  6771. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6772. }
  6773. }
  6774. declare module "babylonjs/Collisions/collider" {
  6775. import { Nullable, IndicesArray } from "babylonjs/types";
  6776. import { Vector3 } from "babylonjs/Maths/math.vector";
  6777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /** @hidden */
  6780. export class Collider {
  6781. /** Define if a collision was found */
  6782. collisionFound: boolean;
  6783. /**
  6784. * Define last intersection point in local space
  6785. */
  6786. intersectionPoint: Vector3;
  6787. /**
  6788. * Define last collided mesh
  6789. */
  6790. collidedMesh: Nullable<AbstractMesh>;
  6791. private _collisionPoint;
  6792. private _planeIntersectionPoint;
  6793. private _tempVector;
  6794. private _tempVector2;
  6795. private _tempVector3;
  6796. private _tempVector4;
  6797. private _edge;
  6798. private _baseToVertex;
  6799. private _destinationPoint;
  6800. private _slidePlaneNormal;
  6801. private _displacementVector;
  6802. /** @hidden */
  6803. _radius: Vector3;
  6804. /** @hidden */
  6805. _retry: number;
  6806. private _velocity;
  6807. private _basePoint;
  6808. private _epsilon;
  6809. /** @hidden */
  6810. _velocityWorldLength: number;
  6811. /** @hidden */
  6812. _basePointWorld: Vector3;
  6813. private _velocityWorld;
  6814. private _normalizedVelocity;
  6815. /** @hidden */
  6816. _initialVelocity: Vector3;
  6817. /** @hidden */
  6818. _initialPosition: Vector3;
  6819. private _nearestDistance;
  6820. private _collisionMask;
  6821. collisionMask: number;
  6822. /**
  6823. * Gets the plane normal used to compute the sliding response (in local space)
  6824. */
  6825. readonly slidePlaneNormal: Vector3;
  6826. /** @hidden */
  6827. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6828. /** @hidden */
  6829. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6830. /** @hidden */
  6831. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6832. /** @hidden */
  6833. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6834. /** @hidden */
  6835. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _getResponse(pos: Vector3, vel: Vector3): void;
  6838. }
  6839. }
  6840. declare module "babylonjs/Culling/boundingInfo" {
  6841. import { DeepImmutable } from "babylonjs/types";
  6842. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6843. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6844. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6845. import { Plane } from "babylonjs/Maths/math.plane";
  6846. import { Collider } from "babylonjs/Collisions/collider";
  6847. /**
  6848. * Interface for cullable objects
  6849. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6850. */
  6851. export interface ICullable {
  6852. /**
  6853. * Checks if the object or part of the object is in the frustum
  6854. * @param frustumPlanes Camera near/planes
  6855. * @returns true if the object is in frustum otherwise false
  6856. */
  6857. isInFrustum(frustumPlanes: Plane[]): boolean;
  6858. /**
  6859. * Checks if a cullable object (mesh...) is in the camera frustum
  6860. * Unlike isInFrustum this cheks the full bounding box
  6861. * @param frustumPlanes Camera near/planes
  6862. * @returns true if the object is in frustum otherwise false
  6863. */
  6864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6865. }
  6866. /**
  6867. * Info for a bounding data of a mesh
  6868. */
  6869. export class BoundingInfo implements ICullable {
  6870. /**
  6871. * Bounding box for the mesh
  6872. */
  6873. readonly boundingBox: BoundingBox;
  6874. /**
  6875. * Bounding sphere for the mesh
  6876. */
  6877. readonly boundingSphere: BoundingSphere;
  6878. private _isLocked;
  6879. private static readonly TmpVector3;
  6880. /**
  6881. * Constructs bounding info
  6882. * @param minimum min vector of the bounding box/sphere
  6883. * @param maximum max vector of the bounding box/sphere
  6884. * @param worldMatrix defines the new world matrix
  6885. */
  6886. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6887. /**
  6888. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6889. * @param min defines the new minimum vector (in local space)
  6890. * @param max defines the new maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6894. /**
  6895. * min vector of the bounding box/sphere
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * max vector of the bounding box/sphere
  6900. */
  6901. readonly maximum: Vector3;
  6902. /**
  6903. * If the info is locked and won't be updated to avoid perf overhead
  6904. */
  6905. isLocked: boolean;
  6906. /**
  6907. * Updates the bounding sphere and box
  6908. * @param world world matrix to be used to update
  6909. */
  6910. update(world: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6913. * @param center New center of the bounding info
  6914. * @param extend New extend of the bounding info
  6915. * @returns the current bounding info
  6916. */
  6917. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6918. /**
  6919. * Scale the current bounding info by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding info
  6922. */
  6923. scale(factor: number): BoundingInfo;
  6924. /**
  6925. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6926. * @param frustumPlanes defines the frustum to test
  6927. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6928. * @returns true if the bounding info is in the frustum planes
  6929. */
  6930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6931. /**
  6932. * Gets the world distance between the min and max points of the bounding box
  6933. */
  6934. readonly diagonalLength: number;
  6935. /**
  6936. * Checks if a cullable object (mesh...) is in the camera frustum
  6937. * Unlike isInFrustum this cheks the full bounding box
  6938. * @param frustumPlanes Camera near/planes
  6939. * @returns true if the object is in frustum otherwise false
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /** @hidden */
  6943. _checkCollision(collider: Collider): boolean;
  6944. /**
  6945. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6946. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6947. * @param point the point to check intersection with
  6948. * @returns if the point intersects
  6949. */
  6950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6951. /**
  6952. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6953. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6954. * @param boundingInfo the bounding info to check intersection with
  6955. * @param precise if the intersection should be done using OBB
  6956. * @returns if the bounding info intersects
  6957. */
  6958. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Maths/math.functions" {
  6962. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6963. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6964. /**
  6965. * Extracts minimum and maximum values from a list of indexed positions
  6966. * @param positions defines the positions to use
  6967. * @param indices defines the indices to the positions
  6968. * @param indexStart defines the start index
  6969. * @param indexCount defines the end index
  6970. * @param bias defines bias value to add to the result
  6971. * @return minimum and maximum values
  6972. */
  6973. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6974. minimum: Vector3;
  6975. maximum: Vector3;
  6976. };
  6977. /**
  6978. * Extracts minimum and maximum values from a list of positions
  6979. * @param positions defines the positions to use
  6980. * @param start defines the start index in the positions array
  6981. * @param count defines the number of positions to handle
  6982. * @param bias defines bias value to add to the result
  6983. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6984. * @return minimum and maximum values
  6985. */
  6986. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6987. minimum: Vector3;
  6988. maximum: Vector3;
  6989. };
  6990. }
  6991. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6992. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6993. /** @hidden */
  6994. export class WebGLDataBuffer extends DataBuffer {
  6995. private _buffer;
  6996. constructor(resource: WebGLBuffer);
  6997. readonly underlyingResource: any;
  6998. }
  6999. }
  7000. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7002. import { Nullable } from "babylonjs/types";
  7003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7004. /** @hidden */
  7005. export class WebGLPipelineContext implements IPipelineContext {
  7006. engine: ThinEngine;
  7007. program: Nullable<WebGLProgram>;
  7008. context?: WebGLRenderingContext;
  7009. vertexShader?: WebGLShader;
  7010. fragmentShader?: WebGLShader;
  7011. isParallelCompiled: boolean;
  7012. onCompiled?: () => void;
  7013. transformFeedback?: WebGLTransformFeedback | null;
  7014. readonly isAsync: boolean;
  7015. readonly isReady: boolean;
  7016. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7017. }
  7018. }
  7019. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7020. import { FloatArray, Nullable } from "babylonjs/types";
  7021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7022. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7023. module "babylonjs/Engines/thinEngine" {
  7024. interface ThinEngine {
  7025. /**
  7026. * Create an uniform buffer
  7027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7028. * @param elements defines the content of the uniform buffer
  7029. * @returns the webGL uniform buffer
  7030. */
  7031. createUniformBuffer(elements: FloatArray): DataBuffer;
  7032. /**
  7033. * Create a dynamic uniform buffer
  7034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7035. * @param elements defines the content of the uniform buffer
  7036. * @returns the webGL uniform buffer
  7037. */
  7038. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7039. /**
  7040. * Update an existing uniform buffer
  7041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7042. * @param uniformBuffer defines the target uniform buffer
  7043. * @param elements defines the content to update
  7044. * @param offset defines the offset in the uniform buffer where update should start
  7045. * @param count defines the size of the data to update
  7046. */
  7047. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7048. /**
  7049. * Bind an uniform buffer to the current webGL context
  7050. * @param buffer defines the buffer to bind
  7051. */
  7052. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7053. /**
  7054. * Bind a buffer to the current webGL context at a given location
  7055. * @param buffer defines the buffer to bind
  7056. * @param location defines the index where to bind the buffer
  7057. */
  7058. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7059. /**
  7060. * Bind a specific block at a given index in a specific shader program
  7061. * @param pipelineContext defines the pipeline context to use
  7062. * @param blockName defines the block name
  7063. * @param index defines the index where to bind the block
  7064. */
  7065. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7066. }
  7067. }
  7068. }
  7069. declare module "babylonjs/Materials/uniformBuffer" {
  7070. import { Nullable, FloatArray } from "babylonjs/types";
  7071. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7072. import { Engine } from "babylonjs/Engines/engine";
  7073. import { Effect } from "babylonjs/Materials/effect";
  7074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7076. import { Color3 } from "babylonjs/Maths/math.color";
  7077. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7078. /**
  7079. * Uniform buffer objects.
  7080. *
  7081. * Handles blocks of uniform on the GPU.
  7082. *
  7083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7084. *
  7085. * For more information, please refer to :
  7086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7087. */
  7088. export class UniformBuffer {
  7089. private _engine;
  7090. private _buffer;
  7091. private _data;
  7092. private _bufferData;
  7093. private _dynamic?;
  7094. private _uniformLocations;
  7095. private _uniformSizes;
  7096. private _uniformLocationPointer;
  7097. private _needSync;
  7098. private _noUBO;
  7099. private _currentEffect;
  7100. private static _MAX_UNIFORM_SIZE;
  7101. private static _tempBuffer;
  7102. /**
  7103. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7104. * This is dynamic to allow compat with webgl 1 and 2.
  7105. * You will need to pass the name of the uniform as well as the value.
  7106. */
  7107. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7108. /**
  7109. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7110. * This is dynamic to allow compat with webgl 1 and 2.
  7111. * You will need to pass the name of the uniform as well as the value.
  7112. */
  7113. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7114. /**
  7115. * Lambda to Update a single float in a uniform buffer.
  7116. * This is dynamic to allow compat with webgl 1 and 2.
  7117. * You will need to pass the name of the uniform as well as the value.
  7118. */
  7119. updateFloat: (name: string, x: number) => void;
  7120. /**
  7121. * Lambda to Update a vec2 of float in a uniform buffer.
  7122. * This is dynamic to allow compat with webgl 1 and 2.
  7123. * You will need to pass the name of the uniform as well as the value.
  7124. */
  7125. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7126. /**
  7127. * Lambda to Update a vec3 of float in a uniform buffer.
  7128. * This is dynamic to allow compat with webgl 1 and 2.
  7129. * You will need to pass the name of the uniform as well as the value.
  7130. */
  7131. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7132. /**
  7133. * Lambda to Update a vec4 of float in a uniform buffer.
  7134. * This is dynamic to allow compat with webgl 1 and 2.
  7135. * You will need to pass the name of the uniform as well as the value.
  7136. */
  7137. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7138. /**
  7139. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7140. * This is dynamic to allow compat with webgl 1 and 2.
  7141. * You will need to pass the name of the uniform as well as the value.
  7142. */
  7143. updateMatrix: (name: string, mat: Matrix) => void;
  7144. /**
  7145. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7146. * This is dynamic to allow compat with webgl 1 and 2.
  7147. * You will need to pass the name of the uniform as well as the value.
  7148. */
  7149. updateVector3: (name: string, vector: Vector3) => void;
  7150. /**
  7151. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7152. * This is dynamic to allow compat with webgl 1 and 2.
  7153. * You will need to pass the name of the uniform as well as the value.
  7154. */
  7155. updateVector4: (name: string, vector: Vector4) => void;
  7156. /**
  7157. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7158. * This is dynamic to allow compat with webgl 1 and 2.
  7159. * You will need to pass the name of the uniform as well as the value.
  7160. */
  7161. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7162. /**
  7163. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7164. * This is dynamic to allow compat with webgl 1 and 2.
  7165. * You will need to pass the name of the uniform as well as the value.
  7166. */
  7167. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7168. /**
  7169. * Instantiates a new Uniform buffer objects.
  7170. *
  7171. * Handles blocks of uniform on the GPU.
  7172. *
  7173. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7174. *
  7175. * For more information, please refer to :
  7176. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7177. * @param engine Define the engine the buffer is associated with
  7178. * @param data Define the data contained in the buffer
  7179. * @param dynamic Define if the buffer is updatable
  7180. */
  7181. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7182. /**
  7183. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7184. * or just falling back on setUniformXXX calls.
  7185. */
  7186. readonly useUbo: boolean;
  7187. /**
  7188. * Indicates if the WebGL underlying uniform buffer is in sync
  7189. * with the javascript cache data.
  7190. */
  7191. readonly isSync: boolean;
  7192. /**
  7193. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7194. * Also, a dynamic UniformBuffer will disable cache verification and always
  7195. * update the underlying WebGL uniform buffer to the GPU.
  7196. * @returns if Dynamic, otherwise false
  7197. */
  7198. isDynamic(): boolean;
  7199. /**
  7200. * The data cache on JS side.
  7201. * @returns the underlying data as a float array
  7202. */
  7203. getData(): Float32Array;
  7204. /**
  7205. * The underlying WebGL Uniform buffer.
  7206. * @returns the webgl buffer
  7207. */
  7208. getBuffer(): Nullable<DataBuffer>;
  7209. /**
  7210. * std140 layout specifies how to align data within an UBO structure.
  7211. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7212. * for specs.
  7213. */
  7214. private _fillAlignment;
  7215. /**
  7216. * Adds an uniform in the buffer.
  7217. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7218. * for the layout to be correct !
  7219. * @param name Name of the uniform, as used in the uniform block in the shader.
  7220. * @param size Data size, or data directly.
  7221. */
  7222. addUniform(name: string, size: number | number[]): void;
  7223. /**
  7224. * Adds a Matrix 4x4 to the uniform buffer.
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param mat A 4x4 matrix.
  7227. */
  7228. addMatrix(name: string, mat: Matrix): void;
  7229. /**
  7230. * Adds a vec2 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param x Define the x component value of the vec2
  7233. * @param y Define the y component value of the vec2
  7234. */
  7235. addFloat2(name: string, x: number, y: number): void;
  7236. /**
  7237. * Adds a vec3 to the uniform buffer.
  7238. * @param name Name of the uniform, as used in the uniform block in the shader.
  7239. * @param x Define the x component value of the vec3
  7240. * @param y Define the y component value of the vec3
  7241. * @param z Define the z component value of the vec3
  7242. */
  7243. addFloat3(name: string, x: number, y: number, z: number): void;
  7244. /**
  7245. * Adds a vec3 to the uniform buffer.
  7246. * @param name Name of the uniform, as used in the uniform block in the shader.
  7247. * @param color Define the vec3 from a Color
  7248. */
  7249. addColor3(name: string, color: Color3): void;
  7250. /**
  7251. * Adds a vec4 to the uniform buffer.
  7252. * @param name Name of the uniform, as used in the uniform block in the shader.
  7253. * @param color Define the rgb components from a Color
  7254. * @param alpha Define the a component of the vec4
  7255. */
  7256. addColor4(name: string, color: Color3, alpha: number): void;
  7257. /**
  7258. * Adds a vec3 to the uniform buffer.
  7259. * @param name Name of the uniform, as used in the uniform block in the shader.
  7260. * @param vector Define the vec3 components from a Vector
  7261. */
  7262. addVector3(name: string, vector: Vector3): void;
  7263. /**
  7264. * Adds a Matrix 3x3 to the uniform buffer.
  7265. * @param name Name of the uniform, as used in the uniform block in the shader.
  7266. */
  7267. addMatrix3x3(name: string): void;
  7268. /**
  7269. * Adds a Matrix 2x2 to the uniform buffer.
  7270. * @param name Name of the uniform, as used in the uniform block in the shader.
  7271. */
  7272. addMatrix2x2(name: string): void;
  7273. /**
  7274. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7275. */
  7276. create(): void;
  7277. /** @hidden */
  7278. _rebuild(): void;
  7279. /**
  7280. * Updates the WebGL Uniform Buffer on the GPU.
  7281. * If the `dynamic` flag is set to true, no cache comparison is done.
  7282. * Otherwise, the buffer will be updated only if the cache differs.
  7283. */
  7284. update(): void;
  7285. /**
  7286. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7287. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7288. * @param data Define the flattened data
  7289. * @param size Define the size of the data.
  7290. */
  7291. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7292. private _valueCache;
  7293. private _cacheMatrix;
  7294. private _updateMatrix3x3ForUniform;
  7295. private _updateMatrix3x3ForEffect;
  7296. private _updateMatrix2x2ForEffect;
  7297. private _updateMatrix2x2ForUniform;
  7298. private _updateFloatForEffect;
  7299. private _updateFloatForUniform;
  7300. private _updateFloat2ForEffect;
  7301. private _updateFloat2ForUniform;
  7302. private _updateFloat3ForEffect;
  7303. private _updateFloat3ForUniform;
  7304. private _updateFloat4ForEffect;
  7305. private _updateFloat4ForUniform;
  7306. private _updateMatrixForEffect;
  7307. private _updateMatrixForUniform;
  7308. private _updateVector3ForEffect;
  7309. private _updateVector3ForUniform;
  7310. private _updateVector4ForEffect;
  7311. private _updateVector4ForUniform;
  7312. private _updateColor3ForEffect;
  7313. private _updateColor3ForUniform;
  7314. private _updateColor4ForEffect;
  7315. private _updateColor4ForUniform;
  7316. /**
  7317. * Sets a sampler uniform on the effect.
  7318. * @param name Define the name of the sampler.
  7319. * @param texture Define the texture to set in the sampler
  7320. */
  7321. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7322. /**
  7323. * Directly updates the value of the uniform in the cache AND on the GPU.
  7324. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7325. * @param data Define the flattened data
  7326. */
  7327. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7328. /**
  7329. * Binds this uniform buffer to an effect.
  7330. * @param effect Define the effect to bind the buffer to
  7331. * @param name Name of the uniform block in the shader.
  7332. */
  7333. bindToEffect(effect: Effect, name: string): void;
  7334. /**
  7335. * Disposes the uniform buffer.
  7336. */
  7337. dispose(): void;
  7338. }
  7339. }
  7340. declare module "babylonjs/Misc/iInspectable" {
  7341. /**
  7342. * Enum that determines the text-wrapping mode to use.
  7343. */
  7344. export enum InspectableType {
  7345. /**
  7346. * Checkbox for booleans
  7347. */
  7348. Checkbox = 0,
  7349. /**
  7350. * Sliders for numbers
  7351. */
  7352. Slider = 1,
  7353. /**
  7354. * Vector3
  7355. */
  7356. Vector3 = 2,
  7357. /**
  7358. * Quaternions
  7359. */
  7360. Quaternion = 3,
  7361. /**
  7362. * Color3
  7363. */
  7364. Color3 = 4,
  7365. /**
  7366. * String
  7367. */
  7368. String = 5
  7369. }
  7370. /**
  7371. * Interface used to define custom inspectable properties.
  7372. * This interface is used by the inspector to display custom property grids
  7373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7374. */
  7375. export interface IInspectable {
  7376. /**
  7377. * Gets the label to display
  7378. */
  7379. label: string;
  7380. /**
  7381. * Gets the name of the property to edit
  7382. */
  7383. propertyName: string;
  7384. /**
  7385. * Gets the type of the editor to use
  7386. */
  7387. type: InspectableType;
  7388. /**
  7389. * Gets the minimum value of the property when using in "slider" mode
  7390. */
  7391. min?: number;
  7392. /**
  7393. * Gets the maximum value of the property when using in "slider" mode
  7394. */
  7395. max?: number;
  7396. /**
  7397. * Gets the setp to use when using in "slider" mode
  7398. */
  7399. step?: number;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/timingTools" {
  7403. /**
  7404. * Class used to provide helper for timing
  7405. */
  7406. export class TimingTools {
  7407. /**
  7408. * Polyfill for setImmediate
  7409. * @param action defines the action to execute after the current execution block
  7410. */
  7411. static SetImmediate(action: () => void): void;
  7412. }
  7413. }
  7414. declare module "babylonjs/Misc/instantiationTools" {
  7415. /**
  7416. * Class used to enable instatition of objects by class name
  7417. */
  7418. export class InstantiationTools {
  7419. /**
  7420. * Use this object to register external classes like custom textures or material
  7421. * to allow the laoders to instantiate them
  7422. */
  7423. static RegisteredExternalClasses: {
  7424. [key: string]: Object;
  7425. };
  7426. /**
  7427. * Tries to instantiate a new object from a given class name
  7428. * @param className defines the class name to instantiate
  7429. * @returns the new object or null if the system was not able to do the instantiation
  7430. */
  7431. static Instantiate(className: string): any;
  7432. }
  7433. }
  7434. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7435. /**
  7436. * Define options used to create a depth texture
  7437. */
  7438. export class DepthTextureCreationOptions {
  7439. /** Specifies whether or not a stencil should be allocated in the texture */
  7440. generateStencil?: boolean;
  7441. /** Specifies whether or not bilinear filtering is enable on the texture */
  7442. bilinearFiltering?: boolean;
  7443. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7444. comparisonFunction?: number;
  7445. /** Specifies if the created texture is a cube texture */
  7446. isCube?: boolean;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7451. import { Nullable } from "babylonjs/types";
  7452. import { Scene } from "babylonjs/scene";
  7453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7454. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Creates a depth stencil cube texture.
  7459. * This is only available in WebGL 2.
  7460. * @param size The size of face edge in the cube texture.
  7461. * @param options The options defining the cube texture.
  7462. * @returns The cube texture
  7463. */
  7464. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7465. /**
  7466. * Creates a cube texture
  7467. * @param rootUrl defines the url where the files to load is located
  7468. * @param scene defines the current scene
  7469. * @param files defines the list of files to load (1 per face)
  7470. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7471. * @param onLoad defines an optional callback raised when the texture is loaded
  7472. * @param onError defines an optional callback raised if there is an issue to load the texture
  7473. * @param format defines the format of the data
  7474. * @param forcedExtension defines the extension to use to pick the right loader
  7475. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7478. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7479. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7480. * @returns the cube texture as an InternalTexture
  7481. */
  7482. 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;
  7483. /**
  7484. * Creates a cube texture
  7485. * @param rootUrl defines the url where the files to load is located
  7486. * @param scene defines the current scene
  7487. * @param files defines the list of files to load (1 per face)
  7488. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7489. * @param onLoad defines an optional callback raised when the texture is loaded
  7490. * @param onError defines an optional callback raised if there is an issue to load the texture
  7491. * @param format defines the format of the data
  7492. * @param forcedExtension defines the extension to use to pick the right loader
  7493. * @returns the cube texture as an InternalTexture
  7494. */
  7495. 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;
  7496. /**
  7497. * Creates a cube texture
  7498. * @param rootUrl defines the url where the files to load is located
  7499. * @param scene defines the current scene
  7500. * @param files defines the list of files to load (1 per face)
  7501. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7502. * @param onLoad defines an optional callback raised when the texture is loaded
  7503. * @param onError defines an optional callback raised if there is an issue to load the texture
  7504. * @param format defines the format of the data
  7505. * @param forcedExtension defines the extension to use to pick the right loader
  7506. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7507. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7508. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7509. * @returns the cube texture as an InternalTexture
  7510. */
  7511. 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;
  7512. /** @hidden */
  7513. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7514. /** @hidden */
  7515. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7520. }
  7521. }
  7522. }
  7523. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7524. import { Nullable } from "babylonjs/types";
  7525. import { Scene } from "babylonjs/scene";
  7526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7528. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7529. /**
  7530. * Class for creating a cube texture
  7531. */
  7532. export class CubeTexture extends BaseTexture {
  7533. private _delayedOnLoad;
  7534. /**
  7535. * The url of the texture
  7536. */
  7537. url: string;
  7538. /**
  7539. * Gets or sets the center of the bounding box associated with the cube texture.
  7540. * It must define where the camera used to render the texture was set
  7541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7542. */
  7543. boundingBoxPosition: Vector3;
  7544. private _boundingBoxSize;
  7545. /**
  7546. * Gets or sets the size of the bounding box associated with the cube texture
  7547. * When defined, the cubemap will switch to local mode
  7548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7549. * @example https://www.babylonjs-playground.com/#RNASML
  7550. */
  7551. /**
  7552. * Returns the bounding box size
  7553. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7554. */
  7555. boundingBoxSize: Vector3;
  7556. protected _rotationY: number;
  7557. /**
  7558. * Sets texture matrix rotation angle around Y axis in radians.
  7559. */
  7560. /**
  7561. * Gets texture matrix rotation angle around Y axis radians.
  7562. */
  7563. rotationY: number;
  7564. /**
  7565. * Are mip maps generated for this texture or not.
  7566. */
  7567. readonly noMipmap: boolean;
  7568. private _noMipmap;
  7569. private _files;
  7570. protected _forcedExtension: Nullable<string>;
  7571. private _extensions;
  7572. private _textureMatrix;
  7573. private _format;
  7574. private _createPolynomials;
  7575. /** @hidden */
  7576. _prefiltered: boolean;
  7577. /**
  7578. * Creates a cube texture from an array of image urls
  7579. * @param files defines an array of image urls
  7580. * @param scene defines the hosting scene
  7581. * @param noMipmap specifies if mip maps are not used
  7582. * @returns a cube texture
  7583. */
  7584. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7585. /**
  7586. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7587. * @param url defines the url of the prefiltered texture
  7588. * @param scene defines the scene the texture is attached to
  7589. * @param forcedExtension defines the extension of the file if different from the url
  7590. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7591. * @return the prefiltered texture
  7592. */
  7593. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7594. /**
  7595. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7596. * as prefiltered data.
  7597. * @param rootUrl defines the url of the texture or the root name of the six images
  7598. * @param scene defines the scene the texture is attached to
  7599. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7600. * @param noMipmap defines if mipmaps should be created or not
  7601. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7602. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7603. * @param onError defines a callback triggered in case of error during load
  7604. * @param format defines the internal format to use for the texture once loaded
  7605. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7606. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7607. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @return the cube texture
  7611. */
  7612. 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);
  7613. /**
  7614. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7615. */
  7616. readonly isPrefiltered: boolean;
  7617. /**
  7618. * Get the current class name of the texture useful for serialization or dynamic coding.
  7619. * @returns "CubeTexture"
  7620. */
  7621. getClassName(): string;
  7622. /**
  7623. * Update the url (and optional buffer) of this texture if url was null during construction.
  7624. * @param url the url of the texture
  7625. * @param forcedExtension defines the extension to use
  7626. * @param onLoad callback called when the texture is loaded (defaults to null)
  7627. */
  7628. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7629. /**
  7630. * Delays loading of the cube texture
  7631. * @param forcedExtension defines the extension to use
  7632. */
  7633. delayLoad(forcedExtension?: string): void;
  7634. /**
  7635. * Returns the reflection texture matrix
  7636. * @returns the reflection texture matrix
  7637. */
  7638. getReflectionTextureMatrix(): Matrix;
  7639. /**
  7640. * Sets the reflection texture matrix
  7641. * @param value Reflection texture matrix
  7642. */
  7643. setReflectionTextureMatrix(value: Matrix): void;
  7644. /**
  7645. * Parses text to create a cube texture
  7646. * @param parsedTexture define the serialized text to read from
  7647. * @param scene defines the hosting scene
  7648. * @param rootUrl defines the root url of the cube texture
  7649. * @returns a cube texture
  7650. */
  7651. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7652. /**
  7653. * Makes a clone, or deep copy, of the cube texture
  7654. * @returns a new cube texture
  7655. */
  7656. clone(): CubeTexture;
  7657. }
  7658. }
  7659. declare module "babylonjs/Materials/materialDefines" {
  7660. /**
  7661. * Manages the defines for the Material
  7662. */
  7663. export class MaterialDefines {
  7664. /** @hidden */
  7665. protected _keys: string[];
  7666. private _isDirty;
  7667. /** @hidden */
  7668. _renderId: number;
  7669. /** @hidden */
  7670. _areLightsDirty: boolean;
  7671. /** @hidden */
  7672. _areLightsDisposed: boolean;
  7673. /** @hidden */
  7674. _areAttributesDirty: boolean;
  7675. /** @hidden */
  7676. _areTexturesDirty: boolean;
  7677. /** @hidden */
  7678. _areFresnelDirty: boolean;
  7679. /** @hidden */
  7680. _areMiscDirty: boolean;
  7681. /** @hidden */
  7682. _areImageProcessingDirty: boolean;
  7683. /** @hidden */
  7684. _normals: boolean;
  7685. /** @hidden */
  7686. _uvs: boolean;
  7687. /** @hidden */
  7688. _needNormals: boolean;
  7689. /** @hidden */
  7690. _needUVs: boolean;
  7691. [id: string]: any;
  7692. /**
  7693. * Specifies if the material needs to be re-calculated
  7694. */
  7695. readonly isDirty: boolean;
  7696. /**
  7697. * Marks the material to indicate that it has been re-calculated
  7698. */
  7699. markAsProcessed(): void;
  7700. /**
  7701. * Marks the material to indicate that it needs to be re-calculated
  7702. */
  7703. markAsUnprocessed(): void;
  7704. /**
  7705. * Marks the material to indicate all of its defines need to be re-calculated
  7706. */
  7707. markAllAsDirty(): void;
  7708. /**
  7709. * Marks the material to indicate that image processing needs to be re-calculated
  7710. */
  7711. markAsImageProcessingDirty(): void;
  7712. /**
  7713. * Marks the material to indicate the lights need to be re-calculated
  7714. * @param disposed Defines whether the light is dirty due to dispose or not
  7715. */
  7716. markAsLightDirty(disposed?: boolean): void;
  7717. /**
  7718. * Marks the attribute state as changed
  7719. */
  7720. markAsAttributesDirty(): void;
  7721. /**
  7722. * Marks the texture state as changed
  7723. */
  7724. markAsTexturesDirty(): void;
  7725. /**
  7726. * Marks the fresnel state as changed
  7727. */
  7728. markAsFresnelDirty(): void;
  7729. /**
  7730. * Marks the misc state as changed
  7731. */
  7732. markAsMiscDirty(): void;
  7733. /**
  7734. * Rebuilds the material defines
  7735. */
  7736. rebuild(): void;
  7737. /**
  7738. * Specifies if two material defines are equal
  7739. * @param other - A material define instance to compare to
  7740. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7741. */
  7742. isEqual(other: MaterialDefines): boolean;
  7743. /**
  7744. * Clones this instance's defines to another instance
  7745. * @param other - material defines to clone values to
  7746. */
  7747. cloneTo(other: MaterialDefines): void;
  7748. /**
  7749. * Resets the material define values
  7750. */
  7751. reset(): void;
  7752. /**
  7753. * Converts the material define values to a string
  7754. * @returns - String of material define information
  7755. */
  7756. toString(): string;
  7757. }
  7758. }
  7759. declare module "babylonjs/Materials/colorCurves" {
  7760. import { Effect } from "babylonjs/Materials/effect";
  7761. /**
  7762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7764. * 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;
  7765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7766. */
  7767. export class ColorCurves {
  7768. private _dirty;
  7769. private _tempColor;
  7770. private _globalCurve;
  7771. private _highlightsCurve;
  7772. private _midtonesCurve;
  7773. private _shadowsCurve;
  7774. private _positiveCurve;
  7775. private _negativeCurve;
  7776. private _globalHue;
  7777. private _globalDensity;
  7778. private _globalSaturation;
  7779. private _globalExposure;
  7780. /**
  7781. * Gets the global Hue value.
  7782. * 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).
  7783. */
  7784. /**
  7785. * Sets the global Hue value.
  7786. * 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).
  7787. */
  7788. globalHue: number;
  7789. /**
  7790. * Gets the global Density value.
  7791. * 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.
  7792. * Values less than zero provide a filter of opposite hue.
  7793. */
  7794. /**
  7795. * Sets the global Density value.
  7796. * 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.
  7797. * Values less than zero provide a filter of opposite hue.
  7798. */
  7799. globalDensity: number;
  7800. /**
  7801. * Gets the global Saturation value.
  7802. * 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.
  7803. */
  7804. /**
  7805. * Sets the global Saturation value.
  7806. * 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.
  7807. */
  7808. globalSaturation: number;
  7809. /**
  7810. * Gets the global Exposure value.
  7811. * 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.
  7812. */
  7813. /**
  7814. * Sets the global Exposure value.
  7815. * 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.
  7816. */
  7817. globalExposure: number;
  7818. private _highlightsHue;
  7819. private _highlightsDensity;
  7820. private _highlightsSaturation;
  7821. private _highlightsExposure;
  7822. /**
  7823. * Gets the highlights Hue value.
  7824. * 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).
  7825. */
  7826. /**
  7827. * Sets the highlights Hue value.
  7828. * 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).
  7829. */
  7830. highlightsHue: number;
  7831. /**
  7832. * Gets the highlights Density value.
  7833. * 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.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. /**
  7837. * Sets the highlights Density value.
  7838. * 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.
  7839. * Values less than zero provide a filter of opposite hue.
  7840. */
  7841. highlightsDensity: number;
  7842. /**
  7843. * Gets the highlights Saturation value.
  7844. * 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.
  7845. */
  7846. /**
  7847. * Sets the highlights Saturation value.
  7848. * 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.
  7849. */
  7850. highlightsSaturation: number;
  7851. /**
  7852. * Gets the highlights Exposure value.
  7853. * 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.
  7854. */
  7855. /**
  7856. * Sets the highlights Exposure value.
  7857. * 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.
  7858. */
  7859. highlightsExposure: number;
  7860. private _midtonesHue;
  7861. private _midtonesDensity;
  7862. private _midtonesSaturation;
  7863. private _midtonesExposure;
  7864. /**
  7865. * Gets the midtones Hue value.
  7866. * 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).
  7867. */
  7868. /**
  7869. * Sets the midtones Hue value.
  7870. * 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).
  7871. */
  7872. midtonesHue: number;
  7873. /**
  7874. * Gets the midtones Density value.
  7875. * 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.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the midtones Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. midtonesDensity: number;
  7884. /**
  7885. * Gets the midtones Saturation value.
  7886. * 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.
  7887. */
  7888. /**
  7889. * Sets the midtones Saturation value.
  7890. * 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.
  7891. */
  7892. midtonesSaturation: number;
  7893. /**
  7894. * Gets the midtones Exposure value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the midtones Exposure value.
  7899. * 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.
  7900. */
  7901. midtonesExposure: number;
  7902. private _shadowsHue;
  7903. private _shadowsDensity;
  7904. private _shadowsSaturation;
  7905. private _shadowsExposure;
  7906. /**
  7907. * Gets the shadows Hue value.
  7908. * 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).
  7909. */
  7910. /**
  7911. * Sets the shadows Hue value.
  7912. * 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).
  7913. */
  7914. shadowsHue: number;
  7915. /**
  7916. * Gets the shadows Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. /**
  7921. * Sets the shadows Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. shadowsDensity: number;
  7926. /**
  7927. * Gets the shadows Saturation value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the shadows Saturation value.
  7932. * 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.
  7933. */
  7934. shadowsSaturation: number;
  7935. /**
  7936. * Gets the shadows Exposure value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the shadows Exposure value.
  7941. * 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.
  7942. */
  7943. shadowsExposure: number;
  7944. /**
  7945. * Returns the class name
  7946. * @returns The class name
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Binds the color curves to the shader.
  7951. * @param colorCurves The color curve to bind
  7952. * @param effect The effect to bind to
  7953. * @param positiveUniform The positive uniform shader parameter
  7954. * @param neutralUniform The neutral uniform shader parameter
  7955. * @param negativeUniform The negative uniform shader parameter
  7956. */
  7957. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7958. /**
  7959. * Prepare the list of uniforms associated with the ColorCurves effects.
  7960. * @param uniformsList The list of uniforms used in the effect
  7961. */
  7962. static PrepareUniforms(uniformsList: string[]): void;
  7963. /**
  7964. * Returns color grading data based on a hue, density, saturation and exposure value.
  7965. * @param filterHue The hue of the color filter.
  7966. * @param filterDensity The density of the color filter.
  7967. * @param saturation The saturation.
  7968. * @param exposure The exposure.
  7969. * @param result The result data container.
  7970. */
  7971. private getColorGradingDataToRef;
  7972. /**
  7973. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7974. * @param value The input slider value in range [-100,100].
  7975. * @returns Adjusted value.
  7976. */
  7977. private static applyColorGradingSliderNonlinear;
  7978. /**
  7979. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7980. * @param hue The hue (H) input.
  7981. * @param saturation The saturation (S) input.
  7982. * @param brightness The brightness (B) input.
  7983. * @result An RGBA color represented as Vector4.
  7984. */
  7985. private static fromHSBToRef;
  7986. /**
  7987. * Returns a value clamped between min and max
  7988. * @param value The value to clamp
  7989. * @param min The minimum of value
  7990. * @param max The maximum of value
  7991. * @returns The clamped value.
  7992. */
  7993. private static clamp;
  7994. /**
  7995. * Clones the current color curve instance.
  7996. * @return The cloned curves
  7997. */
  7998. clone(): ColorCurves;
  7999. /**
  8000. * Serializes the current color curve instance to a json representation.
  8001. * @return a JSON representation
  8002. */
  8003. serialize(): any;
  8004. /**
  8005. * Parses the color curve from a json representation.
  8006. * @param source the JSON source to parse
  8007. * @return The parsed curves
  8008. */
  8009. static Parse(source: any): ColorCurves;
  8010. }
  8011. }
  8012. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8013. import { Observable } from "babylonjs/Misc/observable";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { Color4 } from "babylonjs/Maths/math.color";
  8016. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8017. import { Effect } from "babylonjs/Materials/effect";
  8018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8019. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8020. /**
  8021. * Interface to follow in your material defines to integrate easily the
  8022. * Image proccessing functions.
  8023. * @hidden
  8024. */
  8025. export interface IImageProcessingConfigurationDefines {
  8026. IMAGEPROCESSING: boolean;
  8027. VIGNETTE: boolean;
  8028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8029. VIGNETTEBLENDMODEOPAQUE: boolean;
  8030. TONEMAPPING: boolean;
  8031. TONEMAPPING_ACES: boolean;
  8032. CONTRAST: boolean;
  8033. EXPOSURE: boolean;
  8034. COLORCURVES: boolean;
  8035. COLORGRADING: boolean;
  8036. COLORGRADING3D: boolean;
  8037. SAMPLER3DGREENDEPTH: boolean;
  8038. SAMPLER3DBGRMAP: boolean;
  8039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8040. }
  8041. /**
  8042. * @hidden
  8043. */
  8044. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. COLORCURVES: boolean;
  8053. COLORGRADING: boolean;
  8054. COLORGRADING3D: boolean;
  8055. SAMPLER3DGREENDEPTH: boolean;
  8056. SAMPLER3DBGRMAP: boolean;
  8057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8058. EXPOSURE: boolean;
  8059. constructor();
  8060. }
  8061. /**
  8062. * This groups together the common properties used for image processing either in direct forward pass
  8063. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8064. * or not.
  8065. */
  8066. export class ImageProcessingConfiguration {
  8067. /**
  8068. * Default tone mapping applied in BabylonJS.
  8069. */
  8070. static readonly TONEMAPPING_STANDARD: number;
  8071. /**
  8072. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8073. * to other engines rendering to increase portability.
  8074. */
  8075. static readonly TONEMAPPING_ACES: number;
  8076. /**
  8077. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8078. */
  8079. colorCurves: Nullable<ColorCurves>;
  8080. private _colorCurvesEnabled;
  8081. /**
  8082. * Gets wether the color curves effect is enabled.
  8083. */
  8084. /**
  8085. * Sets wether the color curves effect is enabled.
  8086. */
  8087. colorCurvesEnabled: boolean;
  8088. private _colorGradingTexture;
  8089. /**
  8090. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8091. */
  8092. /**
  8093. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8094. */
  8095. colorGradingTexture: Nullable<BaseTexture>;
  8096. private _colorGradingEnabled;
  8097. /**
  8098. * Gets wether the color grading effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color grading effect is enabled.
  8102. */
  8103. colorGradingEnabled: boolean;
  8104. private _colorGradingWithGreenDepth;
  8105. /**
  8106. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8107. */
  8108. /**
  8109. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8110. */
  8111. colorGradingWithGreenDepth: boolean;
  8112. private _colorGradingBGR;
  8113. /**
  8114. * Gets wether the color grading texture contains BGR values.
  8115. */
  8116. /**
  8117. * Sets wether the color grading texture contains BGR values.
  8118. */
  8119. colorGradingBGR: boolean;
  8120. /** @hidden */
  8121. _exposure: number;
  8122. /**
  8123. * Gets the Exposure used in the effect.
  8124. */
  8125. /**
  8126. * Sets the Exposure used in the effect.
  8127. */
  8128. exposure: number;
  8129. private _toneMappingEnabled;
  8130. /**
  8131. * Gets wether the tone mapping effect is enabled.
  8132. */
  8133. /**
  8134. * Sets wether the tone mapping effect is enabled.
  8135. */
  8136. toneMappingEnabled: boolean;
  8137. private _toneMappingType;
  8138. /**
  8139. * Gets the type of tone mapping effect.
  8140. */
  8141. /**
  8142. * Sets the type of tone mapping effect used in BabylonJS.
  8143. */
  8144. toneMappingType: number;
  8145. protected _contrast: number;
  8146. /**
  8147. * Gets the contrast used in the effect.
  8148. */
  8149. /**
  8150. * Sets the contrast used in the effect.
  8151. */
  8152. contrast: number;
  8153. /**
  8154. * Vignette stretch size.
  8155. */
  8156. vignetteStretch: number;
  8157. /**
  8158. * Vignette centre X Offset.
  8159. */
  8160. vignetteCentreX: number;
  8161. /**
  8162. * Vignette centre Y Offset.
  8163. */
  8164. vignetteCentreY: number;
  8165. /**
  8166. * Vignette weight or intensity of the vignette effect.
  8167. */
  8168. vignetteWeight: number;
  8169. /**
  8170. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8171. * if vignetteEnabled is set to true.
  8172. */
  8173. vignetteColor: Color4;
  8174. /**
  8175. * Camera field of view used by the Vignette effect.
  8176. */
  8177. vignetteCameraFov: number;
  8178. private _vignetteBlendMode;
  8179. /**
  8180. * Gets the vignette blend mode allowing different kind of effect.
  8181. */
  8182. /**
  8183. * Sets the vignette blend mode allowing different kind of effect.
  8184. */
  8185. vignetteBlendMode: number;
  8186. private _vignetteEnabled;
  8187. /**
  8188. * Gets wether the vignette effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the vignette effect is enabled.
  8192. */
  8193. vignetteEnabled: boolean;
  8194. private _applyByPostProcess;
  8195. /**
  8196. * Gets wether the image processing is applied through a post process or not.
  8197. */
  8198. /**
  8199. * Sets wether the image processing is applied through a post process or not.
  8200. */
  8201. applyByPostProcess: boolean;
  8202. private _isEnabled;
  8203. /**
  8204. * Gets wether the image processing is enabled or not.
  8205. */
  8206. /**
  8207. * Sets wether the image processing is enabled or not.
  8208. */
  8209. isEnabled: boolean;
  8210. /**
  8211. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8212. */
  8213. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8214. /**
  8215. * Method called each time the image processing information changes requires to recompile the effect.
  8216. */
  8217. protected _updateParameters(): void;
  8218. /**
  8219. * Gets the current class name.
  8220. * @return "ImageProcessingConfiguration"
  8221. */
  8222. getClassName(): string;
  8223. /**
  8224. * Prepare the list of uniforms associated with the Image Processing effects.
  8225. * @param uniforms The list of uniforms used in the effect
  8226. * @param defines the list of defines currently in use
  8227. */
  8228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8229. /**
  8230. * Prepare the list of samplers associated with the Image Processing effects.
  8231. * @param samplersList The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of defines associated to the shader.
  8237. * @param defines the list of defines to complete
  8238. * @param forPostProcess Define if we are currently in post process mode or not
  8239. */
  8240. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8241. /**
  8242. * Returns true if all the image processing information are ready.
  8243. * @returns True if ready, otherwise, false
  8244. */
  8245. isReady(): boolean;
  8246. /**
  8247. * Binds the image processing to the shader.
  8248. * @param effect The effect to bind to
  8249. * @param aspectRatio Define the current aspect ratio of the effect
  8250. */
  8251. bind(effect: Effect, aspectRatio?: number): void;
  8252. /**
  8253. * Clones the current image processing instance.
  8254. * @return The cloned image processing
  8255. */
  8256. clone(): ImageProcessingConfiguration;
  8257. /**
  8258. * Serializes the current image processing instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the image processing from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed image processing
  8266. */
  8267. static Parse(source: any): ImageProcessingConfiguration;
  8268. private static _VIGNETTEMODE_MULTIPLY;
  8269. private static _VIGNETTEMODE_OPAQUE;
  8270. /**
  8271. * Used to apply the vignette as a mix with the pixel color.
  8272. */
  8273. static readonly VIGNETTEMODE_MULTIPLY: number;
  8274. /**
  8275. * Used to apply the vignette as a replacement of the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_OPAQUE: number;
  8278. }
  8279. }
  8280. declare module "babylonjs/Shaders/postprocess.vertex" {
  8281. /** @hidden */
  8282. export var postprocessVertexShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8289. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8290. module "babylonjs/Engines/thinEngine" {
  8291. interface ThinEngine {
  8292. /**
  8293. * Creates a new render target texture
  8294. * @param size defines the size of the texture
  8295. * @param options defines the options used to create the texture
  8296. * @returns a new render target texture stored in an InternalTexture
  8297. */
  8298. createRenderTargetTexture(size: number | {
  8299. width: number;
  8300. height: number;
  8301. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8302. }
  8303. }
  8304. }
  8305. declare module "babylonjs/Maths/math.axis" {
  8306. import { Vector3 } from "babylonjs/Maths/math.vector";
  8307. /** Defines supported spaces */
  8308. export enum Space {
  8309. /** Local (object) space */
  8310. LOCAL = 0,
  8311. /** World space */
  8312. WORLD = 1,
  8313. /** Bone space */
  8314. BONE = 2
  8315. }
  8316. /** Defines the 3 main axes */
  8317. export class Axis {
  8318. /** X axis */
  8319. static X: Vector3;
  8320. /** Y axis */
  8321. static Y: Vector3;
  8322. /** Z axis */
  8323. static Z: Vector3;
  8324. }
  8325. }
  8326. declare module "babylonjs/Cameras/targetCamera" {
  8327. import { Nullable } from "babylonjs/types";
  8328. import { Camera } from "babylonjs/Cameras/camera";
  8329. import { Scene } from "babylonjs/scene";
  8330. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8331. /**
  8332. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8333. * This is the base of the follow, arc rotate cameras and Free camera
  8334. * @see http://doc.babylonjs.com/features/cameras
  8335. */
  8336. export class TargetCamera extends Camera {
  8337. private static _RigCamTransformMatrix;
  8338. private static _TargetTransformMatrix;
  8339. private static _TargetFocalPoint;
  8340. /**
  8341. * Define the current direction the camera is moving to
  8342. */
  8343. cameraDirection: Vector3;
  8344. /**
  8345. * Define the current rotation the camera is rotating to
  8346. */
  8347. cameraRotation: Vector2;
  8348. /**
  8349. * When set, the up vector of the camera will be updated by the rotation of the camera
  8350. */
  8351. updateUpVectorFromRotation: boolean;
  8352. private _tmpQuaternion;
  8353. /**
  8354. * Define the current rotation of the camera
  8355. */
  8356. rotation: Vector3;
  8357. /**
  8358. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8359. */
  8360. rotationQuaternion: Quaternion;
  8361. /**
  8362. * Define the current speed of the camera
  8363. */
  8364. speed: number;
  8365. /**
  8366. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8367. * around all axis.
  8368. */
  8369. noRotationConstraint: boolean;
  8370. /**
  8371. * Define the current target of the camera as an object or a position.
  8372. */
  8373. lockedTarget: any;
  8374. /** @hidden */
  8375. _currentTarget: Vector3;
  8376. /** @hidden */
  8377. _initialFocalDistance: number;
  8378. /** @hidden */
  8379. _viewMatrix: Matrix;
  8380. /** @hidden */
  8381. _camMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraTransformMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraRotationMatrix: Matrix;
  8386. /** @hidden */
  8387. _referencePoint: Vector3;
  8388. /** @hidden */
  8389. _transformedReferencePoint: Vector3;
  8390. protected _globalCurrentTarget: Vector3;
  8391. protected _globalCurrentUpVector: Vector3;
  8392. /** @hidden */
  8393. _reset: () => void;
  8394. private _defaultUp;
  8395. /**
  8396. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. * @param name Defines the name of the camera in the scene
  8400. * @param position Defines the start position of the camera in the scene
  8401. * @param scene Defines the scene the camera belongs to
  8402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8403. */
  8404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8405. /**
  8406. * Gets the position in front of the camera at a given distance.
  8407. * @param distance The distance from the camera we want the position to be
  8408. * @returns the position
  8409. */
  8410. getFrontPosition(distance: number): Vector3;
  8411. /** @hidden */
  8412. _getLockedTargetPosition(): Nullable<Vector3>;
  8413. private _storedPosition;
  8414. private _storedRotation;
  8415. private _storedRotationQuaternion;
  8416. /**
  8417. * Store current camera state of the camera (fov, position, rotation, etc..)
  8418. * @returns the camera
  8419. */
  8420. storeState(): Camera;
  8421. /**
  8422. * Restored camera state. You must call storeState() first
  8423. * @returns whether it was successful or not
  8424. * @hidden
  8425. */
  8426. _restoreStateValues(): boolean;
  8427. /** @hidden */
  8428. _initCache(): void;
  8429. /** @hidden */
  8430. _updateCache(ignoreParentClass?: boolean): void;
  8431. /** @hidden */
  8432. _isSynchronizedViewMatrix(): boolean;
  8433. /** @hidden */
  8434. _computeLocalCameraSpeed(): number;
  8435. /**
  8436. * Defines the target the camera should look at.
  8437. * @param target Defines the new target as a Vector or a mesh
  8438. */
  8439. setTarget(target: Vector3): void;
  8440. /**
  8441. * Return the current target position of the camera. This value is expressed in local space.
  8442. * @returns the target position
  8443. */
  8444. getTarget(): Vector3;
  8445. /** @hidden */
  8446. _decideIfNeedsToMove(): boolean;
  8447. /** @hidden */
  8448. _updatePosition(): void;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. protected _updateCameraRotationMatrix(): void;
  8452. /**
  8453. * 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)
  8454. * @returns the current camera
  8455. */
  8456. private _rotateUpVectorWithCameraRotationMatrix;
  8457. private _cachedRotationZ;
  8458. private _cachedQuaternionRotationZ;
  8459. /** @hidden */
  8460. _getViewMatrix(): Matrix;
  8461. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8462. /**
  8463. * @hidden
  8464. */
  8465. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8466. /**
  8467. * @hidden
  8468. */
  8469. _updateRigCameras(): void;
  8470. private _getRigCamPositionAndTarget;
  8471. /**
  8472. * Gets the current object class name.
  8473. * @return the class name
  8474. */
  8475. getClassName(): string;
  8476. }
  8477. }
  8478. declare module "babylonjs/Events/keyboardEvents" {
  8479. /**
  8480. * Gather the list of keyboard event types as constants.
  8481. */
  8482. export class KeyboardEventTypes {
  8483. /**
  8484. * The keydown event is fired when a key becomes active (pressed).
  8485. */
  8486. static readonly KEYDOWN: number;
  8487. /**
  8488. * The keyup event is fired when a key has been released.
  8489. */
  8490. static readonly KEYUP: number;
  8491. }
  8492. /**
  8493. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8494. */
  8495. export class KeyboardInfo {
  8496. /**
  8497. * Defines the type of event (KeyboardEventTypes)
  8498. */
  8499. type: number;
  8500. /**
  8501. * Defines the related dom event
  8502. */
  8503. event: KeyboardEvent;
  8504. /**
  8505. * Instantiates a new keyboard info.
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. * @param type Defines the type of event (KeyboardEventTypes)
  8508. * @param event Defines the related dom event
  8509. */
  8510. constructor(
  8511. /**
  8512. * Defines the type of event (KeyboardEventTypes)
  8513. */
  8514. type: number,
  8515. /**
  8516. * Defines the related dom event
  8517. */
  8518. event: KeyboardEvent);
  8519. }
  8520. /**
  8521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8522. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8523. */
  8524. export class KeyboardInfoPre extends KeyboardInfo {
  8525. /**
  8526. * Defines the type of event (KeyboardEventTypes)
  8527. */
  8528. type: number;
  8529. /**
  8530. * Defines the related dom event
  8531. */
  8532. event: KeyboardEvent;
  8533. /**
  8534. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8535. */
  8536. skipOnPointerObservable: boolean;
  8537. /**
  8538. * Instantiates a new keyboard pre info.
  8539. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8540. * @param type Defines the type of event (KeyboardEventTypes)
  8541. * @param event Defines the related dom event
  8542. */
  8543. constructor(
  8544. /**
  8545. * Defines the type of event (KeyboardEventTypes)
  8546. */
  8547. type: number,
  8548. /**
  8549. * Defines the related dom event
  8550. */
  8551. event: KeyboardEvent);
  8552. }
  8553. }
  8554. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8555. import { Nullable } from "babylonjs/types";
  8556. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8557. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8558. /**
  8559. * Manage the keyboard inputs to control the movement of a free camera.
  8560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8561. */
  8562. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8563. /**
  8564. * Defines the camera the input is attached to.
  8565. */
  8566. camera: FreeCamera;
  8567. /**
  8568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8569. */
  8570. keysUp: number[];
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8573. */
  8574. keysDown: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8577. */
  8578. keysLeft: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8581. */
  8582. keysRight: number[];
  8583. private _keys;
  8584. private _onCanvasBlurObserver;
  8585. private _onKeyboardObserver;
  8586. private _engine;
  8587. private _scene;
  8588. /**
  8589. * Attach the input controls to a specific dom element to get the input from.
  8590. * @param element Defines the element the controls should be listened from
  8591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8592. */
  8593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8594. /**
  8595. * Detach the current controls from the specified dom element.
  8596. * @param element Defines the element to stop listening the inputs from
  8597. */
  8598. detachControl(element: Nullable<HTMLElement>): void;
  8599. /**
  8600. * Update the current camera state depending on the inputs that have been used this frame.
  8601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8602. */
  8603. checkInputs(): void;
  8604. /**
  8605. * Gets the class name of the current intput.
  8606. * @returns the class name
  8607. */
  8608. getClassName(): string;
  8609. /** @hidden */
  8610. _onLostFocus(): void;
  8611. /**
  8612. * Get the friendly name associated with the input class.
  8613. * @returns the input friendly name
  8614. */
  8615. getSimpleName(): string;
  8616. }
  8617. }
  8618. declare module "babylonjs/Lights/shadowLight" {
  8619. import { Camera } from "babylonjs/Cameras/camera";
  8620. import { Scene } from "babylonjs/scene";
  8621. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8623. import { Light } from "babylonjs/Lights/light";
  8624. /**
  8625. * Interface describing all the common properties and methods a shadow light needs to implement.
  8626. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8627. * as well as binding the different shadow properties to the effects.
  8628. */
  8629. export interface IShadowLight extends Light {
  8630. /**
  8631. * The light id in the scene (used in scene.findLighById for instance)
  8632. */
  8633. id: string;
  8634. /**
  8635. * The position the shdow will be casted from.
  8636. */
  8637. position: Vector3;
  8638. /**
  8639. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8640. */
  8641. direction: Vector3;
  8642. /**
  8643. * The transformed position. Position of the light in world space taking parenting in account.
  8644. */
  8645. transformedPosition: Vector3;
  8646. /**
  8647. * The transformed direction. Direction of the light in world space taking parenting in account.
  8648. */
  8649. transformedDirection: Vector3;
  8650. /**
  8651. * The friendly name of the light in the scene.
  8652. */
  8653. name: string;
  8654. /**
  8655. * Defines the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. /**
  8659. * Defines the shadow projection clipping maximum z value.
  8660. */
  8661. shadowMaxZ: number;
  8662. /**
  8663. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8664. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8665. */
  8666. computeTransformedInformation(): boolean;
  8667. /**
  8668. * Gets the scene the light belongs to.
  8669. * @returns The scene
  8670. */
  8671. getScene(): Scene;
  8672. /**
  8673. * Callback defining a custom Projection Matrix Builder.
  8674. * This can be used to override the default projection matrix computation.
  8675. */
  8676. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8677. /**
  8678. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8679. * @param matrix The materix to updated with the projection information
  8680. * @param viewMatrix The transform matrix of the light
  8681. * @param renderList The list of mesh to render in the map
  8682. * @returns The current light
  8683. */
  8684. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8685. /**
  8686. * Gets the current depth scale used in ESM.
  8687. * @returns The scale
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8692. * @returns true if a cube texture needs to be use
  8693. */
  8694. needCube(): boolean;
  8695. /**
  8696. * Detects if the projection matrix requires to be recomputed this frame.
  8697. * @returns true if it requires to be recomputed otherwise, false.
  8698. */
  8699. needProjectionMatrixCompute(): boolean;
  8700. /**
  8701. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8702. */
  8703. forceProjectionMatrixCompute(): void;
  8704. /**
  8705. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8708. */
  8709. getShadowDirection(faceIndex?: number): Vector3;
  8710. /**
  8711. * Gets the minZ used for shadow according to both the scene and the light.
  8712. * @param activeCamera The camera we are returning the min for
  8713. * @returns the depth min z
  8714. */
  8715. getDepthMinZ(activeCamera: Camera): number;
  8716. /**
  8717. * Gets the maxZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the max for
  8719. * @returns the depth max z
  8720. */
  8721. getDepthMaxZ(activeCamera: Camera): number;
  8722. }
  8723. /**
  8724. * Base implementation IShadowLight
  8725. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8726. */
  8727. export abstract class ShadowLight extends Light implements IShadowLight {
  8728. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8729. protected _position: Vector3;
  8730. protected _setPosition(value: Vector3): void;
  8731. /**
  8732. * Sets the position the shadow will be casted from. Also use as the light position for both
  8733. * point and spot lights.
  8734. */
  8735. /**
  8736. * Sets the position the shadow will be casted from. Also use as the light position for both
  8737. * point and spot lights.
  8738. */
  8739. position: Vector3;
  8740. protected _direction: Vector3;
  8741. protected _setDirection(value: Vector3): void;
  8742. /**
  8743. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8744. * Also use as the light direction on spot and directional lights.
  8745. */
  8746. /**
  8747. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8748. * Also use as the light direction on spot and directional lights.
  8749. */
  8750. direction: Vector3;
  8751. private _shadowMinZ;
  8752. /**
  8753. * Gets the shadow projection clipping minimum z value.
  8754. */
  8755. /**
  8756. * Sets the shadow projection clipping minimum z value.
  8757. */
  8758. shadowMinZ: number;
  8759. private _shadowMaxZ;
  8760. /**
  8761. * Sets the shadow projection clipping maximum z value.
  8762. */
  8763. /**
  8764. * Gets the shadow projection clipping maximum z value.
  8765. */
  8766. shadowMaxZ: number;
  8767. /**
  8768. * Callback defining a custom Projection Matrix Builder.
  8769. * This can be used to override the default projection matrix computation.
  8770. */
  8771. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8772. /**
  8773. * The transformed position. Position of the light in world space taking parenting in account.
  8774. */
  8775. transformedPosition: Vector3;
  8776. /**
  8777. * The transformed direction. Direction of the light in world space taking parenting in account.
  8778. */
  8779. transformedDirection: Vector3;
  8780. private _needProjectionMatrixCompute;
  8781. /**
  8782. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8783. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8784. */
  8785. computeTransformedInformation(): boolean;
  8786. /**
  8787. * Return the depth scale used for the shadow map.
  8788. * @returns the depth scale.
  8789. */
  8790. getDepthScale(): number;
  8791. /**
  8792. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8795. */
  8796. getShadowDirection(faceIndex?: number): Vector3;
  8797. /**
  8798. * Returns the ShadowLight absolute position in the World.
  8799. * @returns the position vector in world space
  8800. */
  8801. getAbsolutePosition(): Vector3;
  8802. /**
  8803. * Sets the ShadowLight direction toward the passed target.
  8804. * @param target The point to target in local space
  8805. * @returns the updated ShadowLight direction
  8806. */
  8807. setDirectionToTarget(target: Vector3): Vector3;
  8808. /**
  8809. * Returns the light rotation in euler definition.
  8810. * @returns the x y z rotation in local space.
  8811. */
  8812. getRotation(): Vector3;
  8813. /**
  8814. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8815. * @returns true if a cube texture needs to be use
  8816. */
  8817. needCube(): boolean;
  8818. /**
  8819. * Detects if the projection matrix requires to be recomputed this frame.
  8820. * @returns true if it requires to be recomputed otherwise, false.
  8821. */
  8822. needProjectionMatrixCompute(): boolean;
  8823. /**
  8824. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8825. */
  8826. forceProjectionMatrixCompute(): void;
  8827. /** @hidden */
  8828. _initCache(): void;
  8829. /** @hidden */
  8830. _isSynchronized(): boolean;
  8831. /**
  8832. * Computes the world matrix of the node
  8833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8834. * @returns the world matrix
  8835. */
  8836. computeWorldMatrix(force?: boolean): Matrix;
  8837. /**
  8838. * Gets the minZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the min for
  8840. * @returns the depth min z
  8841. */
  8842. getDepthMinZ(activeCamera: Camera): number;
  8843. /**
  8844. * Gets the maxZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the max for
  8846. * @returns the depth max z
  8847. */
  8848. getDepthMaxZ(activeCamera: Camera): number;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. }
  8858. }
  8859. declare module "babylonjs/Materials/effectFallbacks" {
  8860. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8861. import { Effect } from "babylonjs/Materials/effect";
  8862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8863. /**
  8864. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8865. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8866. */
  8867. export class EffectFallbacks implements IEffectFallbacks {
  8868. private _defines;
  8869. private _currentRank;
  8870. private _maxRank;
  8871. private _mesh;
  8872. /**
  8873. * Removes the fallback from the bound mesh.
  8874. */
  8875. unBindMesh(): void;
  8876. /**
  8877. * Adds a fallback on the specified property.
  8878. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8879. * @param define The name of the define in the shader
  8880. */
  8881. addFallback(rank: number, define: string): void;
  8882. /**
  8883. * Sets the mesh to use CPU skinning when needing to fallback.
  8884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8885. * @param mesh The mesh to use the fallbacks.
  8886. */
  8887. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8888. /**
  8889. * Checks to see if more fallbacks are still availible.
  8890. */
  8891. readonly hasMoreFallbacks: boolean;
  8892. /**
  8893. * Removes the defines that should be removed when falling back.
  8894. * @param currentDefines defines the current define statements for the shader.
  8895. * @param effect defines the current effect we try to compile
  8896. * @returns The resulting defines with defines of the current rank removed.
  8897. */
  8898. reduce(currentDefines: string, effect: Effect): string;
  8899. }
  8900. }
  8901. declare module "babylonjs/Materials/materialHelper" {
  8902. import { Nullable } from "babylonjs/types";
  8903. import { Scene } from "babylonjs/scene";
  8904. import { Engine } from "babylonjs/Engines/engine";
  8905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8906. import { Light } from "babylonjs/Lights/light";
  8907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8908. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8910. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8912. /**
  8913. * "Static Class" containing the most commonly used helper while dealing with material for
  8914. * rendering purpose.
  8915. *
  8916. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8917. *
  8918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8919. */
  8920. export class MaterialHelper {
  8921. /**
  8922. * Bind the current view position to an effect.
  8923. * @param effect The effect to be bound
  8924. * @param scene The scene the eyes position is used from
  8925. */
  8926. static BindEyePosition(effect: Effect, scene: Scene): void;
  8927. /**
  8928. * Helps preparing the defines values about the UVs in used in the effect.
  8929. * UVs are shared as much as we can accross channels in the shaders.
  8930. * @param texture The texture we are preparing the UVs for
  8931. * @param defines The defines to update
  8932. * @param key The channel key "diffuse", "specular"... used in the shader
  8933. */
  8934. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8935. /**
  8936. * Binds a texture matrix value to its corrsponding uniform
  8937. * @param texture The texture to bind the matrix for
  8938. * @param uniformBuffer The uniform buffer receivin the data
  8939. * @param key The channel key "diffuse", "specular"... used in the shader
  8940. */
  8941. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8942. /**
  8943. * Gets the current status of the fog (should it be enabled?)
  8944. * @param mesh defines the mesh to evaluate for fog support
  8945. * @param scene defines the hosting scene
  8946. * @returns true if fog must be enabled
  8947. */
  8948. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8949. /**
  8950. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8951. * @param mesh defines the current mesh
  8952. * @param scene defines the current scene
  8953. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8954. * @param pointsCloud defines if point cloud rendering has to be turned on
  8955. * @param fogEnabled defines if fog has to be turned on
  8956. * @param alphaTest defines if alpha testing has to be turned on
  8957. * @param defines defines the current list of defines
  8958. */
  8959. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8960. /**
  8961. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8962. * @param scene defines the current scene
  8963. * @param engine defines the current engine
  8964. * @param defines specifies the list of active defines
  8965. * @param useInstances defines if instances have to be turned on
  8966. * @param useClipPlane defines if clip plane have to be turned on
  8967. */
  8968. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8969. /**
  8970. * Prepares the defines for bones
  8971. * @param mesh The mesh containing the geometry data we will draw
  8972. * @param defines The defines to update
  8973. */
  8974. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8975. /**
  8976. * Prepares the defines for morph targets
  8977. * @param mesh The mesh containing the geometry data we will draw
  8978. * @param defines The defines to update
  8979. */
  8980. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8981. /**
  8982. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8983. * @param mesh The mesh containing the geometry data we will draw
  8984. * @param defines The defines to update
  8985. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8986. * @param useBones Precise whether bones should be used or not (override mesh info)
  8987. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8988. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8989. * @returns false if defines are considered not dirty and have not been checked
  8990. */
  8991. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8992. /**
  8993. * Prepares the defines related to multiview
  8994. * @param scene The scene we are intending to draw
  8995. * @param defines The defines to update
  8996. */
  8997. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8998. /**
  8999. * Prepares the defines related to the light information passed in parameter
  9000. * @param scene The scene we are intending to draw
  9001. * @param mesh The mesh the effect is compiling for
  9002. * @param light The light the effect is compiling for
  9003. * @param lightIndex The index of the light
  9004. * @param defines The defines to update
  9005. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9006. * @param state Defines the current state regarding what is needed (normals, etc...)
  9007. */
  9008. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9009. needNormals: boolean;
  9010. needRebuild: boolean;
  9011. shadowEnabled: boolean;
  9012. specularEnabled: boolean;
  9013. lightmapMode: boolean;
  9014. }): void;
  9015. /**
  9016. * Prepares the defines related to the light information passed in parameter
  9017. * @param scene The scene we are intending to draw
  9018. * @param mesh The mesh the effect is compiling for
  9019. * @param defines The defines to update
  9020. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9021. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9022. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9023. * @returns true if normals will be required for the rest of the effect
  9024. */
  9025. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9026. /**
  9027. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9028. * @param lightIndex defines the light index
  9029. * @param uniformsList The uniform list
  9030. * @param samplersList The sampler list
  9031. * @param projectedLightTexture defines if projected texture must be used
  9032. * @param uniformBuffersList defines an optional list of uniform buffers
  9033. */
  9034. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect
  9037. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9038. * @param samplersList The sampler list
  9039. * @param defines The defines helping in the list generation
  9040. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9041. */
  9042. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9043. /**
  9044. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9045. * @param defines The defines to update while falling back
  9046. * @param fallbacks The authorized effect fallbacks
  9047. * @param maxSimultaneousLights The maximum number of lights allowed
  9048. * @param rank the current rank of the Effect
  9049. * @returns The newly affected rank
  9050. */
  9051. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9052. private static _TmpMorphInfluencers;
  9053. /**
  9054. * Prepares the list of attributes required for morph targets according to the effect defines.
  9055. * @param attribs The current list of supported attribs
  9056. * @param mesh The mesh to prepare the morph targets attributes for
  9057. * @param influencers The number of influencers
  9058. */
  9059. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9060. /**
  9061. * Prepares the list of attributes required for morph targets according to the effect defines.
  9062. * @param attribs The current list of supported attribs
  9063. * @param mesh The mesh to prepare the morph targets attributes for
  9064. * @param defines The current Defines of the effect
  9065. */
  9066. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9067. /**
  9068. * Prepares the list of attributes required for bones according to the effect defines.
  9069. * @param attribs The current list of supported attribs
  9070. * @param mesh The mesh to prepare the bones attributes for
  9071. * @param defines The current Defines of the effect
  9072. * @param fallbacks The current efffect fallback strategy
  9073. */
  9074. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9075. /**
  9076. * Check and prepare the list of attributes required for instances according to the effect defines.
  9077. * @param attribs The current list of supported attribs
  9078. * @param defines The current MaterialDefines of the effect
  9079. */
  9080. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9081. /**
  9082. * Add the list of attributes required for instances to the attribs array.
  9083. * @param attribs The current list of supported attribs
  9084. */
  9085. static PushAttributesForInstances(attribs: string[]): void;
  9086. /**
  9087. * Binds the light shadow information to the effect for the given mesh.
  9088. * @param light The light containing the generator
  9089. * @param scene The scene the lights belongs to
  9090. * @param mesh The mesh we are binding the information to render
  9091. * @param lightIndex The light index in the effect used to render the mesh
  9092. * @param effect The effect we are binding the data to
  9093. */
  9094. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9095. /**
  9096. * Binds the light information to the effect.
  9097. * @param light The light containing the generator
  9098. * @param effect The effect we are binding the data to
  9099. * @param lightIndex The light index in the effect used to render
  9100. */
  9101. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9102. /**
  9103. * Binds the lights information from the scene to the effect for the given mesh.
  9104. * @param light Light to bind
  9105. * @param lightIndex Light index
  9106. * @param scene The scene where the light belongs to
  9107. * @param mesh The mesh we are binding the information to render
  9108. * @param effect The effect we are binding the data to
  9109. * @param useSpecular Defines if specular is supported
  9110. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9111. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9112. */
  9113. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9114. /**
  9115. * Binds the lights information from the scene to the effect for the given mesh.
  9116. * @param scene The scene the lights belongs to
  9117. * @param mesh The mesh we are binding the information to render
  9118. * @param effect The effect we are binding the data to
  9119. * @param defines The generated defines for the effect
  9120. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9121. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9122. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9123. */
  9124. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9125. private static _tempFogColor;
  9126. /**
  9127. * Binds the fog information from the scene to the effect for the given mesh.
  9128. * @param scene The scene the lights belongs to
  9129. * @param mesh The mesh we are binding the information to render
  9130. * @param effect The effect we are binding the data to
  9131. * @param linearSpace Defines if the fog effect is applied in linear space
  9132. */
  9133. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9134. /**
  9135. * Binds the bones information from the mesh to the effect.
  9136. * @param mesh The mesh we are binding the information to render
  9137. * @param effect The effect we are binding the data to
  9138. */
  9139. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9140. /**
  9141. * Binds the morph targets information from the mesh to the effect.
  9142. * @param abstractMesh The mesh we are binding the information to render
  9143. * @param effect The effect we are binding the data to
  9144. */
  9145. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9146. /**
  9147. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9148. * @param defines The generated defines used in the effect
  9149. * @param effect The effect we are binding the data to
  9150. * @param scene The scene we are willing to render with logarithmic scale for
  9151. */
  9152. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9153. /**
  9154. * Binds the clip plane information from the scene to the effect.
  9155. * @param scene The scene the clip plane information are extracted from
  9156. * @param effect The effect we are binding the data to
  9157. */
  9158. static BindClipPlane(effect: Effect, scene: Scene): void;
  9159. }
  9160. }
  9161. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9162. /** @hidden */
  9163. export var packingFunctions: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9169. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9170. /** @hidden */
  9171. export var shadowMapPixelShader: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9177. /** @hidden */
  9178. export var bonesDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9184. /** @hidden */
  9185. export var morphTargetsVertexGlobalDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9191. /** @hidden */
  9192. export var morphTargetsVertexDeclaration: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9198. /** @hidden */
  9199. export var instancesDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9205. /** @hidden */
  9206. export var helperFunctions: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9239. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9240. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9255. import { Nullable } from "babylonjs/types";
  9256. import { Scene } from "babylonjs/scene";
  9257. import { Matrix } from "babylonjs/Maths/math.vector";
  9258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9260. import { Mesh } from "babylonjs/Meshes/mesh";
  9261. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9262. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9263. import { Effect } from "babylonjs/Materials/effect";
  9264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9265. import "babylonjs/Shaders/shadowMap.fragment";
  9266. import "babylonjs/Shaders/shadowMap.vertex";
  9267. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9268. import { Observable } from "babylonjs/Misc/observable";
  9269. /**
  9270. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9271. */
  9272. export interface ICustomShaderOptions {
  9273. /**
  9274. * Gets or sets the custom shader name to use
  9275. */
  9276. shaderName: string;
  9277. /**
  9278. * The list of attribute names used in the shader
  9279. */
  9280. attributes?: string[];
  9281. /**
  9282. * The list of unifrom names used in the shader
  9283. */
  9284. uniforms?: string[];
  9285. /**
  9286. * The list of sampler names used in the shader
  9287. */
  9288. samplers?: string[];
  9289. /**
  9290. * The list of defines used in the shader
  9291. */
  9292. defines?: string[];
  9293. }
  9294. /**
  9295. * Interface to implement to create a shadow generator compatible with BJS.
  9296. */
  9297. export interface IShadowGenerator {
  9298. /**
  9299. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9300. * @returns The render target texture if present otherwise, null
  9301. */
  9302. getShadowMap(): Nullable<RenderTargetTexture>;
  9303. /**
  9304. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9305. * @returns The render target texture if the shadow map is present otherwise, null
  9306. */
  9307. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9308. /**
  9309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9310. * @param subMesh The submesh we want to render in the shadow map
  9311. * @param useInstances Defines wether will draw in the map using instances
  9312. * @returns true if ready otherwise, false
  9313. */
  9314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9315. /**
  9316. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9317. * @param defines Defines of the material we want to update
  9318. * @param lightIndex Index of the light in the enabled light list of the material
  9319. */
  9320. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9321. /**
  9322. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9323. * defined in the generator but impacting the effect).
  9324. * It implies the unifroms available on the materials are the standard BJS ones.
  9325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9326. * @param effect The effect we are binfing the information for
  9327. */
  9328. bindShadowLight(lightIndex: string, effect: Effect): void;
  9329. /**
  9330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9331. * (eq to shadow prjection matrix * light transform matrix)
  9332. * @returns The transform matrix used to create the shadow map
  9333. */
  9334. getTransformMatrix(): Matrix;
  9335. /**
  9336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9337. * Cube and 2D textures for instance.
  9338. */
  9339. recreateShadowMap(): void;
  9340. /**
  9341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9342. * @param onCompiled Callback triggered at the and of the effects compilation
  9343. * @param options Sets of optional options forcing the compilation with different modes
  9344. */
  9345. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9346. useInstances: boolean;
  9347. }>): void;
  9348. /**
  9349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9350. * @param options Sets of optional options forcing the compilation with different modes
  9351. * @returns A promise that resolves when the compilation completes
  9352. */
  9353. forceCompilationAsync(options?: Partial<{
  9354. useInstances: boolean;
  9355. }>): Promise<void>;
  9356. /**
  9357. * Serializes the shadow generator setup to a json object.
  9358. * @returns The serialized JSON object
  9359. */
  9360. serialize(): any;
  9361. /**
  9362. * Disposes the Shadow map and related Textures and effects.
  9363. */
  9364. dispose(): void;
  9365. }
  9366. /**
  9367. * Default implementation IShadowGenerator.
  9368. * This is the main object responsible of generating shadows in the framework.
  9369. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9370. */
  9371. export class ShadowGenerator implements IShadowGenerator {
  9372. /**
  9373. * Shadow generator mode None: no filtering applied.
  9374. */
  9375. static readonly FILTER_NONE: number;
  9376. /**
  9377. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9379. */
  9380. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9381. /**
  9382. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9383. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9384. */
  9385. static readonly FILTER_POISSONSAMPLING: number;
  9386. /**
  9387. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9393. * edge artifacts on steep falloff.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9399. * edge artifacts on steep falloff.
  9400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9401. */
  9402. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9403. /**
  9404. * Shadow generator mode PCF: Percentage Closer Filtering
  9405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9406. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9407. */
  9408. static readonly FILTER_PCF: number;
  9409. /**
  9410. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9412. * Contact Hardening
  9413. */
  9414. static readonly FILTER_PCSS: number;
  9415. /**
  9416. * Reserved for PCF and PCSS
  9417. * Highest Quality.
  9418. *
  9419. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9420. *
  9421. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9422. */
  9423. static readonly QUALITY_HIGH: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Good tradeoff for quality/perf cross devices
  9427. *
  9428. * Execute PCF on a 3*3 kernel.
  9429. *
  9430. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9431. */
  9432. static readonly QUALITY_MEDIUM: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * The lowest quality but the fastest.
  9436. *
  9437. * Execute PCF on a 1*1 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9440. */
  9441. static readonly QUALITY_LOW: number;
  9442. /** Gets or sets the custom shader name to use */
  9443. customShaderOptions: ICustomShaderOptions;
  9444. /**
  9445. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9446. */
  9447. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9448. /**
  9449. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9450. */
  9451. onAfterShadowMapRenderObservable: Observable<Effect>;
  9452. /**
  9453. * Observable triggered before a mesh is rendered in the shadow map.
  9454. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9455. */
  9456. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9457. /**
  9458. * Observable triggered after a mesh is rendered in the shadow map.
  9459. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9460. */
  9461. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9462. private _bias;
  9463. /**
  9464. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9465. */
  9466. /**
  9467. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9468. */
  9469. bias: number;
  9470. private _normalBias;
  9471. /**
  9472. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9473. */
  9474. /**
  9475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9476. */
  9477. normalBias: number;
  9478. private _blurBoxOffset;
  9479. /**
  9480. * Gets the blur box offset: offset applied during the blur pass.
  9481. * Only useful if useKernelBlur = false
  9482. */
  9483. /**
  9484. * Sets the blur box offset: offset applied during the blur pass.
  9485. * Only useful if useKernelBlur = false
  9486. */
  9487. blurBoxOffset: number;
  9488. private _blurScale;
  9489. /**
  9490. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9491. * 2 means half of the size.
  9492. */
  9493. /**
  9494. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9495. * 2 means half of the size.
  9496. */
  9497. blurScale: number;
  9498. private _blurKernel;
  9499. /**
  9500. * Gets the blur kernel: kernel size of the blur pass.
  9501. * Only useful if useKernelBlur = true
  9502. */
  9503. /**
  9504. * Sets the blur kernel: kernel size of the blur pass.
  9505. * Only useful if useKernelBlur = true
  9506. */
  9507. blurKernel: number;
  9508. private _useKernelBlur;
  9509. /**
  9510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9512. */
  9513. /**
  9514. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9515. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9516. */
  9517. useKernelBlur: boolean;
  9518. private _depthScale;
  9519. /**
  9520. * Gets the depth scale used in ESM mode.
  9521. */
  9522. /**
  9523. * Sets the depth scale used in ESM mode.
  9524. * This can override the scale stored on the light.
  9525. */
  9526. depthScale: number;
  9527. private _filter;
  9528. /**
  9529. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9531. */
  9532. /**
  9533. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9534. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9535. */
  9536. filter: number;
  9537. /**
  9538. * Gets if the current filter is set to Poisson Sampling.
  9539. */
  9540. /**
  9541. * Sets the current filter to Poisson Sampling.
  9542. */
  9543. usePoissonSampling: boolean;
  9544. /**
  9545. * Gets if the current filter is set to ESM.
  9546. */
  9547. /**
  9548. * Sets the current filter is to ESM.
  9549. */
  9550. useExponentialShadowMap: boolean;
  9551. /**
  9552. * Gets if the current filter is set to filtered ESM.
  9553. */
  9554. /**
  9555. * Gets if the current filter is set to filtered ESM.
  9556. */
  9557. useBlurExponentialShadowMap: boolean;
  9558. /**
  9559. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9560. * exponential to prevent steep falloff artifacts).
  9561. */
  9562. /**
  9563. * Sets the current filter to "close ESM" (using the inverse of the
  9564. * exponential to prevent steep falloff artifacts).
  9565. */
  9566. useCloseExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useBlurCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9578. */
  9579. /**
  9580. * Sets the current filter to "PCF" (percentage closer filtering).
  9581. */
  9582. usePercentageCloserFiltering: boolean;
  9583. private _filteringQuality;
  9584. /**
  9585. * Gets the PCF or PCSS Quality.
  9586. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9587. */
  9588. /**
  9589. * Sets the PCF or PCSS Quality.
  9590. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9591. */
  9592. filteringQuality: number;
  9593. /**
  9594. * Gets if the current filter is set to "PCSS" (contact hardening).
  9595. */
  9596. /**
  9597. * Sets the current filter to "PCSS" (contact hardening).
  9598. */
  9599. useContactHardeningShadow: boolean;
  9600. private _contactHardeningLightSizeUVRatio;
  9601. /**
  9602. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9603. * Using a ratio helps keeping shape stability independently of the map size.
  9604. *
  9605. * It does not account for the light projection as it was having too much
  9606. * instability during the light setup or during light position changes.
  9607. *
  9608. * Only valid if useContactHardeningShadow is true.
  9609. */
  9610. /**
  9611. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. contactHardeningLightSizeUVRatio: number;
  9620. private _darkness;
  9621. /** Gets or sets the actual darkness of a shadow */
  9622. darkness: number;
  9623. /**
  9624. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9625. * 0 means strongest and 1 would means no shadow.
  9626. * @returns the darkness.
  9627. */
  9628. getDarkness(): number;
  9629. /**
  9630. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9631. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9632. * @returns the shadow generator allowing fluent coding.
  9633. */
  9634. setDarkness(darkness: number): ShadowGenerator;
  9635. private _transparencyShadow;
  9636. /** Gets or sets the ability to have transparent shadow */
  9637. transparencyShadow: boolean;
  9638. /**
  9639. * Sets the ability to have transparent shadow (boolean).
  9640. * @param transparent True if transparent else False
  9641. * @returns the shadow generator allowing fluent coding
  9642. */
  9643. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9644. private _shadowMap;
  9645. private _shadowMap2;
  9646. /**
  9647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9648. * @returns The render target texture if present otherwise, null
  9649. */
  9650. getShadowMap(): Nullable<RenderTargetTexture>;
  9651. /**
  9652. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9653. * @returns The render target texture if the shadow map is present otherwise, null
  9654. */
  9655. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the class name of that object
  9658. * @returns "ShadowGenerator"
  9659. */
  9660. getClassName(): string;
  9661. /**
  9662. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9663. * @param mesh Mesh to add
  9664. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9665. * @returns the Shadow Generator itself
  9666. */
  9667. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9668. /**
  9669. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9670. * @param mesh Mesh to remove
  9671. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9672. * @returns the Shadow Generator itself
  9673. */
  9674. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9675. /**
  9676. * Controls the extent to which the shadows fade out at the edge of the frustum
  9677. * Used only by directionals and spots
  9678. */
  9679. frustumEdgeFalloff: number;
  9680. private _light;
  9681. /**
  9682. * Returns the associated light object.
  9683. * @returns the light generating the shadow
  9684. */
  9685. getLight(): IShadowLight;
  9686. /**
  9687. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9688. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9689. * It might on the other hand introduce peter panning.
  9690. */
  9691. forceBackFacesOnly: boolean;
  9692. private _scene;
  9693. private _lightDirection;
  9694. private _effect;
  9695. private _viewMatrix;
  9696. private _projectionMatrix;
  9697. private _transformMatrix;
  9698. private _cachedPosition;
  9699. private _cachedDirection;
  9700. private _cachedDefines;
  9701. private _currentRenderID;
  9702. private _boxBlurPostprocess;
  9703. private _kernelBlurXPostprocess;
  9704. private _kernelBlurYPostprocess;
  9705. private _blurPostProcesses;
  9706. private _mapSize;
  9707. private _currentFaceIndex;
  9708. private _currentFaceIndexCache;
  9709. private _textureType;
  9710. private _defaultTextureMatrix;
  9711. private _storedUniqueId;
  9712. /** @hidden */
  9713. static _SceneComponentInitialization: (scene: Scene) => void;
  9714. /**
  9715. * Creates a ShadowGenerator object.
  9716. * A ShadowGenerator is the required tool to use the shadows.
  9717. * Each light casting shadows needs to use its own ShadowGenerator.
  9718. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9720. * @param light The light object generating the shadows.
  9721. * @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.
  9722. */
  9723. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9724. private _initializeGenerator;
  9725. private _initializeShadowMap;
  9726. private _initializeBlurRTTAndPostProcesses;
  9727. private _renderForShadowMap;
  9728. private _renderSubMeshForShadowMap;
  9729. private _applyFilterValues;
  9730. /**
  9731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9732. * @param onCompiled Callback triggered at the and of the effects compilation
  9733. * @param options Sets of optional options forcing the compilation with different modes
  9734. */
  9735. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9736. useInstances: boolean;
  9737. }>): void;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param options Sets of optional options forcing the compilation with different modes
  9741. * @returns A promise that resolves when the compilation completes
  9742. */
  9743. forceCompilationAsync(options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): Promise<void>;
  9746. /**
  9747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9748. * @param subMesh The submesh we want to render in the shadow map
  9749. * @param useInstances Defines wether will draw in the map using instances
  9750. * @returns true if ready otherwise, false
  9751. */
  9752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9753. /**
  9754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9755. * @param defines Defines of the material we want to update
  9756. * @param lightIndex Index of the light in the enabled light list of the material
  9757. */
  9758. prepareDefines(defines: any, lightIndex: number): void;
  9759. /**
  9760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9761. * defined in the generator but impacting the effect).
  9762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9763. * @param effect The effect we are binfing the information for
  9764. */
  9765. bindShadowLight(lightIndex: string, effect: Effect): void;
  9766. /**
  9767. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9768. * (eq to shadow prjection matrix * light transform matrix)
  9769. * @returns The transform matrix used to create the shadow map
  9770. */
  9771. getTransformMatrix(): Matrix;
  9772. /**
  9773. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9774. * Cube and 2D textures for instance.
  9775. */
  9776. recreateShadowMap(): void;
  9777. private _disposeBlurPostProcesses;
  9778. private _disposeRTTandPostProcesses;
  9779. /**
  9780. * Disposes the ShadowGenerator.
  9781. * Returns nothing.
  9782. */
  9783. dispose(): void;
  9784. /**
  9785. * Serializes the shadow generator setup to a json object.
  9786. * @returns The serialized JSON object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9791. * @param parsedShadowGenerator The JSON object to parse
  9792. * @param scene The scene to create the shadow map for
  9793. * @returns The parsed shadow generator
  9794. */
  9795. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9796. }
  9797. }
  9798. declare module "babylonjs/Lights/light" {
  9799. import { Nullable } from "babylonjs/types";
  9800. import { Scene } from "babylonjs/scene";
  9801. import { Vector3 } from "babylonjs/Maths/math.vector";
  9802. import { Color3 } from "babylonjs/Maths/math.color";
  9803. import { Node } from "babylonjs/node";
  9804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9805. import { Effect } from "babylonjs/Materials/effect";
  9806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9807. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9808. /**
  9809. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9810. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9811. * 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.
  9812. */
  9813. export abstract class Light extends Node {
  9814. /**
  9815. * Falloff Default: light is falling off following the material specification:
  9816. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9817. */
  9818. static readonly FALLOFF_DEFAULT: number;
  9819. /**
  9820. * Falloff Physical: light is falling off following the inverse squared distance law.
  9821. */
  9822. static readonly FALLOFF_PHYSICAL: number;
  9823. /**
  9824. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9825. * to enhance interoperability with other engines.
  9826. */
  9827. static readonly FALLOFF_GLTF: number;
  9828. /**
  9829. * Falloff Standard: light is falling off like in the standard material
  9830. * to enhance interoperability with other materials.
  9831. */
  9832. static readonly FALLOFF_STANDARD: number;
  9833. /**
  9834. * If every light affecting the material is in this lightmapMode,
  9835. * material.lightmapTexture adds or multiplies
  9836. * (depends on material.useLightmapAsShadowmap)
  9837. * after every other light calculations.
  9838. */
  9839. static readonly LIGHTMAP_DEFAULT: number;
  9840. /**
  9841. * material.lightmapTexture as only diffuse lighting from this light
  9842. * adds only specular lighting from this light
  9843. * adds dynamic shadows
  9844. */
  9845. static readonly LIGHTMAP_SPECULAR: number;
  9846. /**
  9847. * material.lightmapTexture as only lighting
  9848. * no light calculation from this light
  9849. * only adds dynamic shadows from this light
  9850. */
  9851. static readonly LIGHTMAP_SHADOWSONLY: number;
  9852. /**
  9853. * Each light type uses the default quantity according to its type:
  9854. * point/spot lights use luminous intensity
  9855. * directional lights use illuminance
  9856. */
  9857. static readonly INTENSITYMODE_AUTOMATIC: number;
  9858. /**
  9859. * lumen (lm)
  9860. */
  9861. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9862. /**
  9863. * candela (lm/sr)
  9864. */
  9865. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9866. /**
  9867. * lux (lm/m^2)
  9868. */
  9869. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9870. /**
  9871. * nit (cd/m^2)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINANCE: number;
  9874. /**
  9875. * Light type const id of the point light.
  9876. */
  9877. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9878. /**
  9879. * Light type const id of the directional light.
  9880. */
  9881. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9882. /**
  9883. * Light type const id of the spot light.
  9884. */
  9885. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9886. /**
  9887. * Light type const id of the hemispheric light.
  9888. */
  9889. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9890. /**
  9891. * Diffuse gives the basic color to an object.
  9892. */
  9893. diffuse: Color3;
  9894. /**
  9895. * Specular produces a highlight color on an object.
  9896. * Note: This is note affecting PBR materials.
  9897. */
  9898. specular: Color3;
  9899. /**
  9900. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9901. * falling off base on range or angle.
  9902. * This can be set to any values in Light.FALLOFF_x.
  9903. *
  9904. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9905. * other types of materials.
  9906. */
  9907. falloffType: number;
  9908. /**
  9909. * Strength of the light.
  9910. * Note: By default it is define in the framework own unit.
  9911. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9912. */
  9913. intensity: number;
  9914. private _range;
  9915. protected _inverseSquaredRange: number;
  9916. /**
  9917. * Defines how far from the source the light is impacting in scene units.
  9918. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9919. */
  9920. /**
  9921. * Defines how far from the source the light is impacting in scene units.
  9922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9923. */
  9924. range: number;
  9925. /**
  9926. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9927. * of light.
  9928. */
  9929. private _photometricScale;
  9930. private _intensityMode;
  9931. /**
  9932. * Gets the photometric scale used to interpret the intensity.
  9933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9934. */
  9935. /**
  9936. * Sets the photometric scale used to interpret the intensity.
  9937. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9938. */
  9939. intensityMode: number;
  9940. private _radius;
  9941. /**
  9942. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9943. */
  9944. /**
  9945. * sets the light radius used by PBR Materials to simulate soft area lights.
  9946. */
  9947. radius: number;
  9948. private _renderPriority;
  9949. /**
  9950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9951. * exceeding the number allowed of the materials.
  9952. */
  9953. renderPriority: number;
  9954. private _shadowEnabled;
  9955. /**
  9956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9957. * the current shadow generator.
  9958. */
  9959. /**
  9960. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9961. * the current shadow generator.
  9962. */
  9963. shadowEnabled: boolean;
  9964. private _includedOnlyMeshes;
  9965. /**
  9966. * Gets the only meshes impacted by this light.
  9967. */
  9968. /**
  9969. * Sets the only meshes impacted by this light.
  9970. */
  9971. includedOnlyMeshes: AbstractMesh[];
  9972. private _excludedMeshes;
  9973. /**
  9974. * Gets the meshes not impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the meshes not impacted by this light.
  9978. */
  9979. excludedMeshes: AbstractMesh[];
  9980. private _excludeWithLayerMask;
  9981. /**
  9982. * Gets the layer id use to find what meshes are not impacted by the light.
  9983. * Inactive if 0
  9984. */
  9985. /**
  9986. * Sets the layer id use to find what meshes are not impacted by the light.
  9987. * Inactive if 0
  9988. */
  9989. excludeWithLayerMask: number;
  9990. private _includeOnlyWithLayerMask;
  9991. /**
  9992. * Gets the layer id use to find what meshes are impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. /**
  9996. * Sets the layer id use to find what meshes are impacted by the light.
  9997. * Inactive if 0
  9998. */
  9999. includeOnlyWithLayerMask: number;
  10000. private _lightmapMode;
  10001. /**
  10002. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10003. */
  10004. /**
  10005. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10006. */
  10007. lightmapMode: number;
  10008. /**
  10009. * Shadow generator associted to the light.
  10010. * @hidden Internal use only.
  10011. */
  10012. _shadowGenerator: Nullable<IShadowGenerator>;
  10013. /**
  10014. * @hidden Internal use only.
  10015. */
  10016. _excludedMeshesIds: string[];
  10017. /**
  10018. * @hidden Internal use only.
  10019. */
  10020. _includedOnlyMeshesIds: string[];
  10021. /**
  10022. * The current light unifom buffer.
  10023. * @hidden Internal use only.
  10024. */
  10025. _uniformBuffer: UniformBuffer;
  10026. /**
  10027. * Creates a Light object in the scene.
  10028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10029. * @param name The firendly name of the light
  10030. * @param scene The scene the light belongs too
  10031. */
  10032. constructor(name: string, scene: Scene);
  10033. protected abstract _buildUniformLayout(): void;
  10034. /**
  10035. * Sets the passed Effect "effect" with the Light information.
  10036. * @param effect The effect to update
  10037. * @param lightIndex The index of the light in the effect to update
  10038. * @returns The light
  10039. */
  10040. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10041. /**
  10042. * Sets the passed Effect "effect" with the Light information.
  10043. * @param effect The effect to update
  10044. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10045. * @returns The light
  10046. */
  10047. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10048. /**
  10049. * Returns the string "Light".
  10050. * @returns the class name
  10051. */
  10052. getClassName(): string;
  10053. /** @hidden */
  10054. readonly _isLight: boolean;
  10055. /**
  10056. * Converts the light information to a readable string for debug purpose.
  10057. * @param fullDetails Supports for multiple levels of logging within scene loading
  10058. * @returns the human readable light info
  10059. */
  10060. toString(fullDetails?: boolean): string;
  10061. /** @hidden */
  10062. protected _syncParentEnabledState(): void;
  10063. /**
  10064. * Set the enabled state of this node.
  10065. * @param value - the new enabled state
  10066. */
  10067. setEnabled(value: boolean): void;
  10068. /**
  10069. * Returns the Light associated shadow generator if any.
  10070. * @return the associated shadow generator.
  10071. */
  10072. getShadowGenerator(): Nullable<IShadowGenerator>;
  10073. /**
  10074. * Returns a Vector3, the absolute light position in the World.
  10075. * @returns the world space position of the light
  10076. */
  10077. getAbsolutePosition(): Vector3;
  10078. /**
  10079. * Specifies if the light will affect the passed mesh.
  10080. * @param mesh The mesh to test against the light
  10081. * @return true the mesh is affected otherwise, false.
  10082. */
  10083. canAffectMesh(mesh: AbstractMesh): boolean;
  10084. /**
  10085. * Sort function to order lights for rendering.
  10086. * @param a First Light object to compare to second.
  10087. * @param b Second Light object to compare first.
  10088. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10089. */
  10090. static CompareLightsPriority(a: Light, b: Light): number;
  10091. /**
  10092. * Releases resources associated with this node.
  10093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10095. */
  10096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10097. /**
  10098. * Returns the light type ID (integer).
  10099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10100. */
  10101. getTypeID(): number;
  10102. /**
  10103. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10104. * @returns the scaled intensity in intensity mode unit
  10105. */
  10106. getScaledIntensity(): number;
  10107. /**
  10108. * Returns a new Light object, named "name", from the current one.
  10109. * @param name The name of the cloned light
  10110. * @returns the new created light
  10111. */
  10112. clone(name: string): Nullable<Light>;
  10113. /**
  10114. * Serializes the current light into a Serialization object.
  10115. * @returns the serialized object.
  10116. */
  10117. serialize(): any;
  10118. /**
  10119. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10120. * This new light is named "name" and added to the passed scene.
  10121. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10122. * @param name The friendly name of the light
  10123. * @param scene The scene the new light will belong to
  10124. * @returns the constructor function
  10125. */
  10126. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10127. /**
  10128. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10129. * @param parsedLight The JSON representation of the light
  10130. * @param scene The scene to create the parsed light in
  10131. * @returns the created light after parsing
  10132. */
  10133. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10134. private _hookArrayForExcluded;
  10135. private _hookArrayForIncludedOnly;
  10136. private _resyncMeshes;
  10137. /**
  10138. * Forces the meshes to update their light related information in their rendering used effects
  10139. * @hidden Internal Use Only
  10140. */
  10141. _markMeshesAsLightDirty(): void;
  10142. /**
  10143. * Recomputes the cached photometric scale if needed.
  10144. */
  10145. private _computePhotometricScale;
  10146. /**
  10147. * Returns the Photometric Scale according to the light type and intensity mode.
  10148. */
  10149. private _getPhotometricScale;
  10150. /**
  10151. * Reorder the light in the scene according to their defined priority.
  10152. * @hidden Internal Use Only
  10153. */
  10154. _reorderLightsInScene(): void;
  10155. /**
  10156. * Prepares the list of defines specific to the light type.
  10157. * @param defines the list of defines
  10158. * @param lightIndex defines the index of the light for the effect
  10159. */
  10160. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10161. }
  10162. }
  10163. declare module "babylonjs/Actions/action" {
  10164. import { Observable } from "babylonjs/Misc/observable";
  10165. import { Condition } from "babylonjs/Actions/condition";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. import { ActionManager } from "babylonjs/Actions/actionManager";
  10168. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10169. /**
  10170. * Interface used to define Action
  10171. */
  10172. export interface IAction {
  10173. /**
  10174. * Trigger for the action
  10175. */
  10176. trigger: number;
  10177. /** Options of the trigger */
  10178. triggerOptions: any;
  10179. /**
  10180. * Gets the trigger parameters
  10181. * @returns the trigger parameters
  10182. */
  10183. getTriggerParameter(): any;
  10184. /**
  10185. * Internal only - executes current action event
  10186. * @hidden
  10187. */
  10188. _executeCurrent(evt?: ActionEvent): void;
  10189. /**
  10190. * Serialize placeholder for child classes
  10191. * @param parent of child
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: AbstractActionManager;
  10205. /**
  10206. * Adds action to chain of actions, may be a DoNothingAction
  10207. * @param action defines the next action to execute
  10208. * @returns The action passed in
  10209. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10210. */
  10211. then(action: IAction): IAction;
  10212. }
  10213. /**
  10214. * The action to be carried out following a trigger
  10215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10216. */
  10217. export class Action implements IAction {
  10218. /** the trigger, with or without parameters, for the action */
  10219. triggerOptions: any;
  10220. /**
  10221. * Trigger for the action
  10222. */
  10223. trigger: number;
  10224. /**
  10225. * Internal only - manager for action
  10226. * @hidden
  10227. */
  10228. _actionManager: ActionManager;
  10229. private _nextActiveAction;
  10230. private _child;
  10231. private _condition?;
  10232. private _triggerParameter;
  10233. /**
  10234. * An event triggered prior to action being executed.
  10235. */
  10236. onBeforeExecuteObservable: Observable<Action>;
  10237. /**
  10238. * Creates a new Action
  10239. * @param triggerOptions the trigger, with or without parameters, for the action
  10240. * @param condition an optional determinant of action
  10241. */
  10242. constructor(
  10243. /** the trigger, with or without parameters, for the action */
  10244. triggerOptions: any, condition?: Condition);
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _prepare(): void;
  10250. /**
  10251. * Gets the trigger parameters
  10252. * @returns the trigger parameters
  10253. */
  10254. getTriggerParameter(): any;
  10255. /**
  10256. * Internal only - executes current action event
  10257. * @hidden
  10258. */
  10259. _executeCurrent(evt?: ActionEvent): void;
  10260. /**
  10261. * Execute placeholder for child classes
  10262. * @param evt optional action event
  10263. */
  10264. execute(evt?: ActionEvent): void;
  10265. /**
  10266. * Skips to next active action
  10267. */
  10268. skipToNextActiveAction(): void;
  10269. /**
  10270. * Adds action to chain of actions, may be a DoNothingAction
  10271. * @param action defines the next action to execute
  10272. * @returns The action passed in
  10273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10274. */
  10275. then(action: Action): Action;
  10276. /**
  10277. * Internal only
  10278. * @hidden
  10279. */
  10280. _getProperty(propertyPath: string): string;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /**
  10287. * Serialize placeholder for child classes
  10288. * @param parent of child
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. /**
  10293. * Internal only called by serialize
  10294. * @hidden
  10295. */
  10296. protected _serialize(serializedAction: any, parent?: any): any;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. static _SerializeValueAsString: (value: any) => string;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10307. name: string;
  10308. targetType: string;
  10309. value: string;
  10310. };
  10311. }
  10312. }
  10313. declare module "babylonjs/Actions/condition" {
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. /**
  10316. * A Condition applied to an Action
  10317. */
  10318. export class Condition {
  10319. /**
  10320. * Internal only - manager for action
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. _evaluationId: number;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. _currentResult: boolean;
  10334. /**
  10335. * Creates a new Condition
  10336. * @param actionManager the manager of the action the condition is applied to
  10337. */
  10338. constructor(actionManager: ActionManager);
  10339. /**
  10340. * Check if the current condition is valid
  10341. * @returns a boolean
  10342. */
  10343. isValid(): boolean;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _getProperty(propertyPath: string): string;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _getEffectiveTarget(target: any, propertyPath: string): any;
  10354. /**
  10355. * Serialize placeholder for child classes
  10356. * @returns the serialized object
  10357. */
  10358. serialize(): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. protected _serialize(serializedCondition: any): any;
  10364. }
  10365. /**
  10366. * Defines specific conditional operators as extensions of Condition
  10367. */
  10368. export class ValueCondition extends Condition {
  10369. /** path to specify the property of the target the conditional operator uses */
  10370. propertyPath: string;
  10371. /** the value compared by the conditional operator against the current value of the property */
  10372. value: any;
  10373. /** the conditional operator, default ValueCondition.IsEqual */
  10374. operator: number;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private static _IsEqual;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. private static _IsDifferent;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private static _IsGreater;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private static _IsLesser;
  10395. /**
  10396. * returns the number for IsEqual
  10397. */
  10398. static readonly IsEqual: number;
  10399. /**
  10400. * Returns the number for IsDifferent
  10401. */
  10402. static readonly IsDifferent: number;
  10403. /**
  10404. * Returns the number for IsGreater
  10405. */
  10406. static readonly IsGreater: number;
  10407. /**
  10408. * Returns the number for IsLesser
  10409. */
  10410. static readonly IsLesser: number;
  10411. /**
  10412. * Internal only The action manager for the condition
  10413. * @hidden
  10414. */
  10415. _actionManager: ActionManager;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. private _target;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. private _effectiveTarget;
  10426. /**
  10427. * Internal only
  10428. * @hidden
  10429. */
  10430. private _property;
  10431. /**
  10432. * Creates a new ValueCondition
  10433. * @param actionManager manager for the action the condition applies to
  10434. * @param target for the action
  10435. * @param propertyPath path to specify the property of the target the conditional operator uses
  10436. * @param value the value compared by the conditional operator against the current value of the property
  10437. * @param operator the conditional operator, default ValueCondition.IsEqual
  10438. */
  10439. constructor(actionManager: ActionManager, target: any,
  10440. /** path to specify the property of the target the conditional operator uses */
  10441. propertyPath: string,
  10442. /** the value compared by the conditional operator against the current value of the property */
  10443. value: any,
  10444. /** the conditional operator, default ValueCondition.IsEqual */
  10445. operator?: number);
  10446. /**
  10447. * Compares the given value with the property value for the specified conditional operator
  10448. * @returns the result of the comparison
  10449. */
  10450. isValid(): boolean;
  10451. /**
  10452. * Serialize the ValueCondition into a JSON compatible object
  10453. * @returns serialization object
  10454. */
  10455. serialize(): any;
  10456. /**
  10457. * Gets the name of the conditional operator for the ValueCondition
  10458. * @param operator the conditional operator
  10459. * @returns the name
  10460. */
  10461. static GetOperatorName(operator: number): string;
  10462. }
  10463. /**
  10464. * Defines a predicate condition as an extension of Condition
  10465. */
  10466. export class PredicateCondition extends Condition {
  10467. /** defines the predicate function used to validate the condition */
  10468. predicate: () => boolean;
  10469. /**
  10470. * Internal only - manager for action
  10471. * @hidden
  10472. */
  10473. _actionManager: ActionManager;
  10474. /**
  10475. * Creates a new PredicateCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param predicate defines the predicate function used to validate the condition
  10478. */
  10479. constructor(actionManager: ActionManager,
  10480. /** defines the predicate function used to validate the condition */
  10481. predicate: () => boolean);
  10482. /**
  10483. * @returns the validity of the predicate condition
  10484. */
  10485. isValid(): boolean;
  10486. }
  10487. /**
  10488. * Defines a state condition as an extension of Condition
  10489. */
  10490. export class StateCondition extends Condition {
  10491. /** Value to compare with target state */
  10492. value: string;
  10493. /**
  10494. * Internal only - manager for action
  10495. * @hidden
  10496. */
  10497. _actionManager: ActionManager;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. private _target;
  10503. /**
  10504. * Creates a new StateCondition
  10505. * @param actionManager manager for the action the condition applies to
  10506. * @param target of the condition
  10507. * @param value to compare with target state
  10508. */
  10509. constructor(actionManager: ActionManager, target: any,
  10510. /** Value to compare with target state */
  10511. value: string);
  10512. /**
  10513. * Gets a boolean indicating if the current condition is met
  10514. * @returns the validity of the state
  10515. */
  10516. isValid(): boolean;
  10517. /**
  10518. * Serialize the StateCondition into a JSON compatible object
  10519. * @returns serialization object
  10520. */
  10521. serialize(): any;
  10522. }
  10523. }
  10524. declare module "babylonjs/Actions/directActions" {
  10525. import { Action } from "babylonjs/Actions/action";
  10526. import { Condition } from "babylonjs/Actions/condition";
  10527. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10528. /**
  10529. * This defines an action responsible to toggle a boolean once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class SwitchBooleanAction extends Action {
  10533. /**
  10534. * The path to the boolean property in the target object
  10535. */
  10536. propertyPath: string;
  10537. private _target;
  10538. private _effectiveTarget;
  10539. private _property;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the object containing the boolean
  10544. * @param propertyPath defines the path to the boolean property in the target object
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10548. /** @hidden */
  10549. _prepare(): void;
  10550. /**
  10551. * Execute the action toggle the boolean value.
  10552. */
  10553. execute(): void;
  10554. /**
  10555. * Serializes the actions and its related information.
  10556. * @param parent defines the object to serialize in
  10557. * @returns the serialized object
  10558. */
  10559. serialize(parent: any): any;
  10560. }
  10561. /**
  10562. * This defines an action responsible to set a the state field of the target
  10563. * to a desired value once triggered.
  10564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10565. */
  10566. export class SetStateAction extends Action {
  10567. /**
  10568. * The value to store in the state field.
  10569. */
  10570. value: string;
  10571. private _target;
  10572. /**
  10573. * Instantiate the action
  10574. * @param triggerOptions defines the trigger options
  10575. * @param target defines the object containing the state property
  10576. * @param value defines the value to store in the state field
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10580. /**
  10581. * Execute the action and store the value on the target state property.
  10582. */
  10583. execute(): void;
  10584. /**
  10585. * Serializes the actions and its related information.
  10586. * @param parent defines the object to serialize in
  10587. * @returns the serialized object
  10588. */
  10589. serialize(parent: any): any;
  10590. }
  10591. /**
  10592. * This defines an action responsible to set a property of the target
  10593. * to a desired value once triggered.
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10595. */
  10596. export class SetValueAction extends Action {
  10597. /**
  10598. * The path of the property to set in the target.
  10599. */
  10600. propertyPath: string;
  10601. /**
  10602. * The value to set in the property
  10603. */
  10604. value: any;
  10605. private _target;
  10606. private _effectiveTarget;
  10607. private _property;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the property
  10612. * @param propertyPath defines the path of the property to set in the target
  10613. * @param value defines the value to set in the property
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10617. /** @hidden */
  10618. _prepare(): void;
  10619. /**
  10620. * Execute the action and set the targetted property to the desired value.
  10621. */
  10622. execute(): void;
  10623. /**
  10624. * Serializes the actions and its related information.
  10625. * @param parent defines the object to serialize in
  10626. * @returns the serialized object
  10627. */
  10628. serialize(parent: any): any;
  10629. }
  10630. /**
  10631. * This defines an action responsible to increment the target value
  10632. * to a desired value once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class IncrementValueAction extends Action {
  10636. /**
  10637. * The path of the property to increment in the target.
  10638. */
  10639. propertyPath: string;
  10640. /**
  10641. * The value we should increment the property by.
  10642. */
  10643. value: any;
  10644. private _target;
  10645. private _effectiveTarget;
  10646. private _property;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the property
  10651. * @param propertyPath defines the path of the property to increment in the target
  10652. * @param value defines the value value we should increment the property by
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and increment the target of the value amount.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to start an animation once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class PlayAnimationAction extends Action {
  10674. /**
  10675. * Where the animation should start (animation frame)
  10676. */
  10677. from: number;
  10678. /**
  10679. * Where the animation should stop (animation frame)
  10680. */
  10681. to: number;
  10682. /**
  10683. * Define if the animation should loop or stop after the first play.
  10684. */
  10685. loop?: boolean;
  10686. private _target;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the target animation or animation name
  10691. * @param from defines from where the animation should start (animation frame)
  10692. * @param end defines where the animation should stop (animation frame)
  10693. * @param loop defines if the animation should loop or stop after the first play
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10697. /** @hidden */
  10698. _prepare(): void;
  10699. /**
  10700. * Execute the action and play the animation.
  10701. */
  10702. execute(): void;
  10703. /**
  10704. * Serializes the actions and its related information.
  10705. * @param parent defines the object to serialize in
  10706. * @returns the serialized object
  10707. */
  10708. serialize(parent: any): any;
  10709. }
  10710. /**
  10711. * This defines an action responsible to stop an animation once triggered.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export class StopAnimationAction extends Action {
  10715. private _target;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the target animation or animation name
  10720. * @param condition defines the trigger related conditions
  10721. */
  10722. constructor(triggerOptions: any, target: any, condition?: Condition);
  10723. /** @hidden */
  10724. _prepare(): void;
  10725. /**
  10726. * Execute the action and stop the animation.
  10727. */
  10728. execute(): void;
  10729. /**
  10730. * Serializes the actions and its related information.
  10731. * @param parent defines the object to serialize in
  10732. * @returns the serialized object
  10733. */
  10734. serialize(parent: any): any;
  10735. }
  10736. /**
  10737. * This defines an action responsible that does nothing once triggered.
  10738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10739. */
  10740. export class DoNothingAction extends Action {
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param condition defines the trigger related conditions
  10745. */
  10746. constructor(triggerOptions?: any, condition?: Condition);
  10747. /**
  10748. * Execute the action and do nothing.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to trigger several actions once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class CombineAction extends Action {
  10763. /**
  10764. * The list of aggregated animations to run.
  10765. */
  10766. children: Action[];
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param children defines the list of aggregated animations to run
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and executes all the aggregated actions.
  10778. */
  10779. execute(evt: ActionEvent): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to run code (external event) once triggered.
  10789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10790. */
  10791. export class ExecuteCodeAction extends Action {
  10792. /**
  10793. * The callback function to run.
  10794. */
  10795. func: (evt: ActionEvent) => void;
  10796. /**
  10797. * Instantiate the action
  10798. * @param triggerOptions defines the trigger options
  10799. * @param func defines the callback function to run
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10803. /**
  10804. * Execute the action and run the attached code.
  10805. */
  10806. execute(evt: ActionEvent): void;
  10807. }
  10808. /**
  10809. * This defines an action responsible to set the parent property of the target once triggered.
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class SetParentAction extends Action {
  10813. private _parent;
  10814. private _target;
  10815. /**
  10816. * Instantiate the action
  10817. * @param triggerOptions defines the trigger options
  10818. * @param target defines the target containing the parent property
  10819. * @param parent defines from where the animation should start (animation frame)
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the parent property.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. }
  10837. declare module "babylonjs/Actions/actionManager" {
  10838. import { Nullable } from "babylonjs/types";
  10839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10840. import { Scene } from "babylonjs/scene";
  10841. import { IAction } from "babylonjs/Actions/action";
  10842. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10843. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10844. /**
  10845. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10846. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class ActionManager extends AbstractActionManager {
  10850. /**
  10851. * Nothing
  10852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10853. */
  10854. static readonly NothingTrigger: number;
  10855. /**
  10856. * On pick
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10858. */
  10859. static readonly OnPickTrigger: number;
  10860. /**
  10861. * On left pick
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnLeftPickTrigger: number;
  10865. /**
  10866. * On right pick
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnRightPickTrigger: number;
  10870. /**
  10871. * On center pick
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnCenterPickTrigger: number;
  10875. /**
  10876. * On pick down
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPickDownTrigger: number;
  10880. /**
  10881. * On double pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnDoublePickTrigger: number;
  10885. /**
  10886. * On pick up
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickUpTrigger: number;
  10890. /**
  10891. * On pick out.
  10892. * This trigger will only be raised if you also declared a OnPickDown
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickOutTrigger: number;
  10896. /**
  10897. * On long press
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnLongPressTrigger: number;
  10901. /**
  10902. * On pointer over
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPointerOverTrigger: number;
  10906. /**
  10907. * On pointer out
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnPointerOutTrigger: number;
  10911. /**
  10912. * On every frame
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnEveryFrameTrigger: number;
  10916. /**
  10917. * On intersection enter
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnIntersectionEnterTrigger: number;
  10921. /**
  10922. * On intersection exit
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnIntersectionExitTrigger: number;
  10926. /**
  10927. * On key down
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnKeyDownTrigger: number;
  10931. /**
  10932. * On key up
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnKeyUpTrigger: number;
  10936. private _scene;
  10937. /**
  10938. * Creates a new action manager
  10939. * @param scene defines the hosting scene
  10940. */
  10941. constructor(scene: Scene);
  10942. /**
  10943. * Releases all associated resources
  10944. */
  10945. dispose(): void;
  10946. /**
  10947. * Gets hosting scene
  10948. * @returns the hosting scene
  10949. */
  10950. getScene(): Scene;
  10951. /**
  10952. * Does this action manager handles actions of any of the given triggers
  10953. * @param triggers defines the triggers to be tested
  10954. * @return a boolean indicating whether one (or more) of the triggers is handled
  10955. */
  10956. hasSpecificTriggers(triggers: number[]): boolean;
  10957. /**
  10958. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10959. * speed.
  10960. * @param triggerA defines the trigger to be tested
  10961. * @param triggerB defines the trigger to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10965. /**
  10966. * Does this action manager handles actions of a given trigger
  10967. * @param trigger defines the trigger to be tested
  10968. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10969. * @return whether the trigger is handled
  10970. */
  10971. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10972. /**
  10973. * Does this action manager has pointer triggers
  10974. */
  10975. readonly hasPointerTriggers: boolean;
  10976. /**
  10977. * Does this action manager has pick triggers
  10978. */
  10979. readonly hasPickTriggers: boolean;
  10980. /**
  10981. * Registers an action to this action manager
  10982. * @param action defines the action to be registered
  10983. * @return the action amended (prepared) after registration
  10984. */
  10985. registerAction(action: IAction): Nullable<IAction>;
  10986. /**
  10987. * Unregisters an action to this action manager
  10988. * @param action defines the action to be unregistered
  10989. * @return a boolean indicating whether the action has been unregistered
  10990. */
  10991. unregisterAction(action: IAction): Boolean;
  10992. /**
  10993. * Process a specific trigger
  10994. * @param trigger defines the trigger to process
  10995. * @param evt defines the event details to be processed
  10996. */
  10997. processTrigger(trigger: number, evt?: IActionEvent): void;
  10998. /** @hidden */
  10999. _getEffectiveTarget(target: any, propertyPath: string): any;
  11000. /** @hidden */
  11001. _getProperty(propertyPath: string): string;
  11002. /**
  11003. * Serialize this manager to a JSON object
  11004. * @param name defines the property name to store this manager
  11005. * @returns a JSON representation of this manager
  11006. */
  11007. serialize(name: string): any;
  11008. /**
  11009. * Creates a new ActionManager from a JSON data
  11010. * @param parsedActions defines the JSON data to read from
  11011. * @param object defines the hosting mesh
  11012. * @param scene defines the hosting scene
  11013. */
  11014. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11015. /**
  11016. * Get a trigger name by index
  11017. * @param trigger defines the trigger index
  11018. * @returns a trigger name
  11019. */
  11020. static GetTriggerName(trigger: number): string;
  11021. }
  11022. }
  11023. declare module "babylonjs/Culling/ray" {
  11024. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11028. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11029. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11031. import { Plane } from "babylonjs/Maths/math.plane";
  11032. /**
  11033. * Class representing a ray with position and direction
  11034. */
  11035. export class Ray {
  11036. /** origin point */
  11037. origin: Vector3;
  11038. /** direction */
  11039. direction: Vector3;
  11040. /** length of the ray */
  11041. length: number;
  11042. private static readonly TmpVector3;
  11043. private _tmpRay;
  11044. /**
  11045. * Creates a new ray
  11046. * @param origin origin point
  11047. * @param direction direction
  11048. * @param length length of the ray
  11049. */
  11050. constructor(
  11051. /** origin point */
  11052. origin: Vector3,
  11053. /** direction */
  11054. direction: Vector3,
  11055. /** length of the ray */
  11056. length?: number);
  11057. /**
  11058. * Checks if the ray intersects a box
  11059. * @param minimum bound of the box
  11060. * @param maximum bound of the box
  11061. * @param intersectionTreshold extra extend to be added to the box in all direction
  11062. * @returns if the box was hit
  11063. */
  11064. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param box the bounding box to check
  11068. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11069. * @returns if the box was hit
  11070. */
  11071. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11072. /**
  11073. * If the ray hits a sphere
  11074. * @param sphere the bounding sphere to check
  11075. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11076. * @returns true if it hits the sphere
  11077. */
  11078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11079. /**
  11080. * If the ray hits a triange
  11081. * @param vertex0 triangle vertex
  11082. * @param vertex1 triangle vertex
  11083. * @param vertex2 triangle vertex
  11084. * @returns intersection information if hit
  11085. */
  11086. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11087. /**
  11088. * Checks if ray intersects a plane
  11089. * @param plane the plane to check
  11090. * @returns the distance away it was hit
  11091. */
  11092. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11093. /**
  11094. * Calculate the intercept of a ray on a given axis
  11095. * @param axis to check 'x' | 'y' | 'z'
  11096. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11097. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11098. */
  11099. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11100. /**
  11101. * Checks if ray intersects a mesh
  11102. * @param mesh the mesh to check
  11103. * @param fastCheck if only the bounding box should checked
  11104. * @returns picking info of the intersecton
  11105. */
  11106. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11107. /**
  11108. * Checks if ray intersects a mesh
  11109. * @param meshes the meshes to check
  11110. * @param fastCheck if only the bounding box should checked
  11111. * @param results array to store result in
  11112. * @returns Array of picking infos
  11113. */
  11114. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11115. private _comparePickingInfo;
  11116. private static smallnum;
  11117. private static rayl;
  11118. /**
  11119. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11120. * @param sega the first point of the segment to test the intersection against
  11121. * @param segb the second point of the segment to test the intersection against
  11122. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11123. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11124. */
  11125. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11126. /**
  11127. * Update the ray from viewport position
  11128. * @param x position
  11129. * @param y y position
  11130. * @param viewportWidth viewport width
  11131. * @param viewportHeight viewport height
  11132. * @param world world matrix
  11133. * @param view view matrix
  11134. * @param projection projection matrix
  11135. * @returns this ray updated
  11136. */
  11137. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11138. /**
  11139. * Creates a ray with origin and direction of 0,0,0
  11140. * @returns the new ray
  11141. */
  11142. static Zero(): Ray;
  11143. /**
  11144. * Creates a new ray from screen space and viewport
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns new ray
  11153. */
  11154. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * 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
  11157. * transformed to the given world matrix.
  11158. * @param origin The origin point
  11159. * @param end The end point
  11160. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11161. * @returns the new ray
  11162. */
  11163. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11164. /**
  11165. * Transforms a ray by a matrix
  11166. * @param ray ray to transform
  11167. * @param matrix matrix to apply
  11168. * @returns the resulting new ray
  11169. */
  11170. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11171. /**
  11172. * Transforms a ray by a matrix
  11173. * @param ray ray to transform
  11174. * @param matrix matrix to apply
  11175. * @param result ray to store result in
  11176. */
  11177. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11178. /**
  11179. * Unproject a ray from screen space to object space
  11180. * @param sourceX defines the screen space x coordinate to use
  11181. * @param sourceY defines the screen space y coordinate to use
  11182. * @param viewportWidth defines the current width of the viewport
  11183. * @param viewportHeight defines the current height of the viewport
  11184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11185. * @param view defines the view matrix to use
  11186. * @param projection defines the projection matrix to use
  11187. */
  11188. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11189. }
  11190. /**
  11191. * Type used to define predicate used to select faces when a mesh intersection is detected
  11192. */
  11193. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11194. module "babylonjs/scene" {
  11195. interface Scene {
  11196. /** @hidden */
  11197. _tempPickingRay: Nullable<Ray>;
  11198. /** @hidden */
  11199. _cachedRayForTransform: Ray;
  11200. /** @hidden */
  11201. _pickWithRayInverseMatrix: Matrix;
  11202. /** @hidden */
  11203. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11204. /** @hidden */
  11205. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11206. }
  11207. }
  11208. }
  11209. declare module "babylonjs/sceneComponent" {
  11210. import { Scene } from "babylonjs/scene";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11213. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11214. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11215. import { Nullable } from "babylonjs/types";
  11216. import { Camera } from "babylonjs/Cameras/camera";
  11217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11219. import { AbstractScene } from "babylonjs/abstractScene";
  11220. /**
  11221. * Groups all the scene component constants in one place to ease maintenance.
  11222. * @hidden
  11223. */
  11224. export class SceneComponentConstants {
  11225. static readonly NAME_EFFECTLAYER: string;
  11226. static readonly NAME_LAYER: string;
  11227. static readonly NAME_LENSFLARESYSTEM: string;
  11228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11229. static readonly NAME_PARTICLESYSTEM: string;
  11230. static readonly NAME_GAMEPAD: string;
  11231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11233. static readonly NAME_DEPTHRENDERER: string;
  11234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11235. static readonly NAME_SPRITE: string;
  11236. static readonly NAME_OUTLINERENDERER: string;
  11237. static readonly NAME_PROCEDURALTEXTURE: string;
  11238. static readonly NAME_SHADOWGENERATOR: string;
  11239. static readonly NAME_OCTREE: string;
  11240. static readonly NAME_PHYSICSENGINE: string;
  11241. static readonly NAME_AUDIO: string;
  11242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11262. static readonly STEP_AFTERRENDER_AUDIO: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_POINTERMOVE_SPRITE: number;
  11269. static readonly STEP_POINTERDOWN_SPRITE: number;
  11270. static readonly STEP_POINTERUP_SPRITE: number;
  11271. }
  11272. /**
  11273. * This represents a scene component.
  11274. *
  11275. * This is used to decouple the dependency the scene is having on the different workloads like
  11276. * layers, post processes...
  11277. */
  11278. export interface ISceneComponent {
  11279. /**
  11280. * The name of the component. Each component must have a unique name.
  11281. */
  11282. name: string;
  11283. /**
  11284. * The scene the component belongs to.
  11285. */
  11286. scene: Scene;
  11287. /**
  11288. * Register the component to one instance of a scene.
  11289. */
  11290. register(): void;
  11291. /**
  11292. * Rebuilds the elements related to this component in case of
  11293. * context lost for instance.
  11294. */
  11295. rebuild(): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * This represents a SERIALIZABLE scene component.
  11303. *
  11304. * This extends Scene Component to add Serialization methods on top.
  11305. */
  11306. export interface ISceneSerializableComponent extends ISceneComponent {
  11307. /**
  11308. * Adds all the elements from the container to the scene
  11309. * @param container the container holding the elements
  11310. */
  11311. addFromContainer(container: AbstractScene): void;
  11312. /**
  11313. * Removes all the elements in the container from the scene
  11314. * @param container contains the elements to remove
  11315. * @param dispose if the removed element should be disposed (default: false)
  11316. */
  11317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11318. /**
  11319. * Serializes the component data to the specified json object
  11320. * @param serializationObject The object to serialize to
  11321. */
  11322. serialize(serializationObject: any): void;
  11323. }
  11324. /**
  11325. * Strong typing of a Mesh related stage step action
  11326. */
  11327. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11328. /**
  11329. * Strong typing of a Evaluate Sub Mesh related stage step action
  11330. */
  11331. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11332. /**
  11333. * Strong typing of a Active Mesh related stage step action
  11334. */
  11335. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11336. /**
  11337. * Strong typing of a Camera related stage step action
  11338. */
  11339. export type CameraStageAction = (camera: Camera) => void;
  11340. /**
  11341. * Strong typing of a Camera Frame buffer related stage step action
  11342. */
  11343. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11344. /**
  11345. * Strong typing of a Render Target related stage step action
  11346. */
  11347. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11348. /**
  11349. * Strong typing of a RenderingGroup related stage step action
  11350. */
  11351. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11352. /**
  11353. * Strong typing of a Mesh Render related stage step action
  11354. */
  11355. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11356. /**
  11357. * Strong typing of a simple stage step action
  11358. */
  11359. export type SimpleStageAction = () => void;
  11360. /**
  11361. * Strong typing of a render target action.
  11362. */
  11363. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11364. /**
  11365. * Strong typing of a pointer move action.
  11366. */
  11367. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11368. /**
  11369. * Strong typing of a pointer up/down action.
  11370. */
  11371. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11372. /**
  11373. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11374. * @hidden
  11375. */
  11376. export class Stage<T extends Function> extends Array<{
  11377. index: number;
  11378. component: ISceneComponent;
  11379. action: T;
  11380. }> {
  11381. /**
  11382. * Hide ctor from the rest of the world.
  11383. * @param items The items to add.
  11384. */
  11385. private constructor();
  11386. /**
  11387. * Creates a new Stage.
  11388. * @returns A new instance of a Stage
  11389. */
  11390. static Create<T extends Function>(): Stage<T>;
  11391. /**
  11392. * Registers a step in an ordered way in the targeted stage.
  11393. * @param index Defines the position to register the step in
  11394. * @param component Defines the component attached to the step
  11395. * @param action Defines the action to launch during the step
  11396. */
  11397. registerStep(index: number, component: ISceneComponent, action: T): void;
  11398. /**
  11399. * Clears all the steps from the stage.
  11400. */
  11401. clear(): void;
  11402. }
  11403. }
  11404. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11405. import { Nullable } from "babylonjs/types";
  11406. import { Observable } from "babylonjs/Misc/observable";
  11407. import { Scene } from "babylonjs/scene";
  11408. import { Sprite } from "babylonjs/Sprites/sprite";
  11409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11410. import { Ray } from "babylonjs/Culling/ray";
  11411. import { Camera } from "babylonjs/Cameras/camera";
  11412. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11413. import { ISceneComponent } from "babylonjs/sceneComponent";
  11414. module "babylonjs/scene" {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. }
  11485. /**
  11486. * Defines the sprite scene component responsible to manage sprites
  11487. * in a given scene.
  11488. */
  11489. export class SpriteSceneComponent implements ISceneComponent {
  11490. /**
  11491. * The component name helpfull to identify the component in the list of scene components.
  11492. */
  11493. readonly name: string;
  11494. /**
  11495. * The scene the component belongs to.
  11496. */
  11497. scene: Scene;
  11498. /** @hidden */
  11499. private _spritePredicate;
  11500. /**
  11501. * Creates a new instance of the component for the given scene
  11502. * @param scene Defines the scene to register the component in
  11503. */
  11504. constructor(scene: Scene);
  11505. /**
  11506. * Registers the component in a given scene
  11507. */
  11508. register(): void;
  11509. /**
  11510. * Rebuilds the elements related to this component in case of
  11511. * context lost for instance.
  11512. */
  11513. rebuild(): void;
  11514. /**
  11515. * Disposes the component and the associated ressources.
  11516. */
  11517. dispose(): void;
  11518. private _pickSpriteButKeepRay;
  11519. private _pointerMove;
  11520. private _pointerDown;
  11521. private _pointerUp;
  11522. }
  11523. }
  11524. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11525. /** @hidden */
  11526. export var fogFragmentDeclaration: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11532. /** @hidden */
  11533. export var fogFragment: {
  11534. name: string;
  11535. shader: string;
  11536. };
  11537. }
  11538. declare module "babylonjs/Shaders/sprites.fragment" {
  11539. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11540. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11541. /** @hidden */
  11542. export var spritesPixelShader: {
  11543. name: string;
  11544. shader: string;
  11545. };
  11546. }
  11547. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11548. /** @hidden */
  11549. export var fogVertexDeclaration: {
  11550. name: string;
  11551. shader: string;
  11552. };
  11553. }
  11554. declare module "babylonjs/Shaders/sprites.vertex" {
  11555. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11556. /** @hidden */
  11557. export var spritesVertexShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Sprites/spriteManager" {
  11563. import { IDisposable, Scene } from "babylonjs/scene";
  11564. import { Nullable } from "babylonjs/types";
  11565. import { Observable } from "babylonjs/Misc/observable";
  11566. import { Sprite } from "babylonjs/Sprites/sprite";
  11567. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11568. import { Camera } from "babylonjs/Cameras/camera";
  11569. import { Texture } from "babylonjs/Materials/Textures/texture";
  11570. import "babylonjs/Shaders/sprites.fragment";
  11571. import "babylonjs/Shaders/sprites.vertex";
  11572. import { Ray } from "babylonjs/Culling/ray";
  11573. /**
  11574. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11575. */
  11576. export interface ISpriteManager extends IDisposable {
  11577. /**
  11578. * Restricts the camera to viewing objects with the same layerMask.
  11579. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11580. */
  11581. layerMask: number;
  11582. /**
  11583. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11584. */
  11585. isPickable: boolean;
  11586. /**
  11587. * Specifies the rendering group id for this mesh (0 by default)
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11589. */
  11590. renderingGroupId: number;
  11591. /**
  11592. * Defines the list of sprites managed by the manager.
  11593. */
  11594. sprites: Array<Sprite>;
  11595. /**
  11596. * Tests the intersection of a sprite with a specific ray.
  11597. * @param ray The ray we are sending to test the collision
  11598. * @param camera The camera space we are sending rays in
  11599. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11600. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11601. * @returns picking info or null.
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Intersects the sprites with a ray
  11606. * @param ray defines the ray to intersect with
  11607. * @param camera defines the current active camera
  11608. * @param predicate defines a predicate used to select candidate sprites
  11609. * @returns null if no hit or a PickingInfo array
  11610. */
  11611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11612. /**
  11613. * Renders the list of sprites on screen.
  11614. */
  11615. render(): void;
  11616. }
  11617. /**
  11618. * Class used to manage multiple sprites on the same spritesheet
  11619. * @see http://doc.babylonjs.com/babylon101/sprites
  11620. */
  11621. export class SpriteManager implements ISpriteManager {
  11622. /** defines the manager's name */
  11623. name: string;
  11624. /** Gets the list of sprites */
  11625. sprites: Sprite[];
  11626. /** Gets or sets the rendering group id (0 by default) */
  11627. renderingGroupId: number;
  11628. /** Gets or sets camera layer mask */
  11629. layerMask: number;
  11630. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11631. fogEnabled: boolean;
  11632. /** Gets or sets a boolean indicating if the sprites are pickable */
  11633. isPickable: boolean;
  11634. /** Defines the default width of a cell in the spritesheet */
  11635. cellWidth: number;
  11636. /** Defines the default height of a cell in the spritesheet */
  11637. cellHeight: number;
  11638. /** Associative array from JSON sprite data file */
  11639. private _cellData;
  11640. /** Array of sprite names from JSON sprite data file */
  11641. private _spriteMap;
  11642. /** True when packed cell data from JSON file is ready*/
  11643. private _packedAndReady;
  11644. /**
  11645. * An event triggered when the manager is disposed.
  11646. */
  11647. onDisposeObservable: Observable<SpriteManager>;
  11648. private _onDisposeObserver;
  11649. /**
  11650. * Callback called when the manager is disposed
  11651. */
  11652. onDispose: () => void;
  11653. private _capacity;
  11654. private _fromPacked;
  11655. private _spriteTexture;
  11656. private _epsilon;
  11657. private _scene;
  11658. private _vertexData;
  11659. private _buffer;
  11660. private _vertexBuffers;
  11661. private _indexBuffer;
  11662. private _effectBase;
  11663. private _effectFog;
  11664. /**
  11665. * Gets or sets the spritesheet texture
  11666. */
  11667. texture: Texture;
  11668. /**
  11669. * Creates a new sprite manager
  11670. * @param name defines the manager's name
  11671. * @param imgUrl defines the sprite sheet url
  11672. * @param capacity defines the maximum allowed number of sprites
  11673. * @param cellSize defines the size of a sprite cell
  11674. * @param scene defines the hosting scene
  11675. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11676. * @param samplingMode defines the smapling mode to use with spritesheet
  11677. * @param fromPacked set to false; do not alter
  11678. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11679. */
  11680. constructor(
  11681. /** defines the manager's name */
  11682. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11683. private _makePacked;
  11684. private _appendSpriteVertex;
  11685. /**
  11686. * Intersects the sprites with a ray
  11687. * @param ray defines the ray to intersect with
  11688. * @param camera defines the current active camera
  11689. * @param predicate defines a predicate used to select candidate sprites
  11690. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11691. * @returns null if no hit or a PickingInfo
  11692. */
  11693. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11694. /**
  11695. * Intersects the sprites with a ray
  11696. * @param ray defines the ray to intersect with
  11697. * @param camera defines the current active camera
  11698. * @param predicate defines a predicate used to select candidate sprites
  11699. * @returns null if no hit or a PickingInfo array
  11700. */
  11701. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11702. /**
  11703. * Render all child sprites
  11704. */
  11705. render(): void;
  11706. /**
  11707. * Release associated resources
  11708. */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Sprites/sprite" {
  11713. import { Vector3 } from "babylonjs/Maths/math.vector";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { ActionManager } from "babylonjs/Actions/actionManager";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Color4 } from "babylonjs/Maths/math.color";
  11718. /**
  11719. * Class used to represent a sprite
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class Sprite {
  11723. /** defines the name */
  11724. name: string;
  11725. /** Gets or sets the current world position */
  11726. position: Vector3;
  11727. /** Gets or sets the main color */
  11728. color: Color4;
  11729. /** Gets or sets the width */
  11730. width: number;
  11731. /** Gets or sets the height */
  11732. height: number;
  11733. /** Gets or sets rotation angle */
  11734. angle: number;
  11735. /** Gets or sets the cell index in the sprite sheet */
  11736. cellIndex: number;
  11737. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11738. cellRef: string;
  11739. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11740. invertU: number;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11742. invertV: number;
  11743. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11744. disposeWhenFinishedAnimating: boolean;
  11745. /** Gets the list of attached animations */
  11746. animations: Animation[];
  11747. /** Gets or sets a boolean indicating if the sprite can be picked */
  11748. isPickable: boolean;
  11749. /**
  11750. * Gets or sets the associated action manager
  11751. */
  11752. actionManager: Nullable<ActionManager>;
  11753. private _animationStarted;
  11754. private _loopAnimation;
  11755. private _fromIndex;
  11756. private _toIndex;
  11757. private _delay;
  11758. private _direction;
  11759. private _manager;
  11760. private _time;
  11761. private _onAnimationEnd;
  11762. /**
  11763. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11764. */
  11765. isVisible: boolean;
  11766. /**
  11767. * Gets or sets the sprite size
  11768. */
  11769. size: number;
  11770. /**
  11771. * Creates a new Sprite
  11772. * @param name defines the name
  11773. * @param manager defines the manager
  11774. */
  11775. constructor(
  11776. /** defines the name */
  11777. name: string, manager: ISpriteManager);
  11778. /**
  11779. * Starts an animation
  11780. * @param from defines the initial key
  11781. * @param to defines the end key
  11782. * @param loop defines if the animation must loop
  11783. * @param delay defines the start delay (in ms)
  11784. * @param onAnimationEnd defines a callback to call when animation ends
  11785. */
  11786. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11787. /** Stops current animation (if any) */
  11788. stopAnimation(): void;
  11789. /** @hidden */
  11790. _animate(deltaTime: number): void;
  11791. /** Release associated resources */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module "babylonjs/Collisions/pickingInfo" {
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11799. import { Sprite } from "babylonjs/Sprites/sprite";
  11800. import { Ray } from "babylonjs/Culling/ray";
  11801. /**
  11802. * Information about the result of picking within a scene
  11803. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11804. */
  11805. export class PickingInfo {
  11806. /** @hidden */
  11807. _pickingUnavailable: boolean;
  11808. /**
  11809. * If the pick collided with an object
  11810. */
  11811. hit: boolean;
  11812. /**
  11813. * Distance away where the pick collided
  11814. */
  11815. distance: number;
  11816. /**
  11817. * The location of pick collision
  11818. */
  11819. pickedPoint: Nullable<Vector3>;
  11820. /**
  11821. * The mesh corresponding the the pick collision
  11822. */
  11823. pickedMesh: Nullable<AbstractMesh>;
  11824. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11825. bu: number;
  11826. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bv: number;
  11828. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11829. faceId: number;
  11830. /** Id of the the submesh that was picked */
  11831. subMeshId: number;
  11832. /** If a sprite was picked, this will be the sprite the pick collided with */
  11833. pickedSprite: Nullable<Sprite>;
  11834. /**
  11835. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11836. */
  11837. originMesh: Nullable<AbstractMesh>;
  11838. /**
  11839. * The ray that was used to perform the picking.
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Gets the normal correspodning to the face the pick collided with
  11844. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11845. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11846. * @returns The normal correspodning to the face the pick collided with
  11847. */
  11848. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11849. /**
  11850. * Gets the texture coordinates of where the pick occured
  11851. * @returns the vector containing the coordnates of the texture
  11852. */
  11853. getTextureCoordinates(): Nullable<Vector2>;
  11854. }
  11855. }
  11856. declare module "babylonjs/Events/pointerEvents" {
  11857. import { Nullable } from "babylonjs/types";
  11858. import { Vector2 } from "babylonjs/Maths/math.vector";
  11859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11860. import { Ray } from "babylonjs/Culling/ray";
  11861. /**
  11862. * Gather the list of pointer event types as constants.
  11863. */
  11864. export class PointerEventTypes {
  11865. /**
  11866. * 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.
  11867. */
  11868. static readonly POINTERDOWN: number;
  11869. /**
  11870. * The pointerup event is fired when a pointer is no longer active.
  11871. */
  11872. static readonly POINTERUP: number;
  11873. /**
  11874. * The pointermove event is fired when a pointer changes coordinates.
  11875. */
  11876. static readonly POINTERMOVE: number;
  11877. /**
  11878. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11879. */
  11880. static readonly POINTERWHEEL: number;
  11881. /**
  11882. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11883. */
  11884. static readonly POINTERPICK: number;
  11885. /**
  11886. * The pointertap event is fired when a the object has been touched and released without drag.
  11887. */
  11888. static readonly POINTERTAP: number;
  11889. /**
  11890. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11891. */
  11892. static readonly POINTERDOUBLETAP: number;
  11893. }
  11894. /**
  11895. * Base class of pointer info types.
  11896. */
  11897. export class PointerInfoBase {
  11898. /**
  11899. * Defines the type of event (PointerEventTypes)
  11900. */
  11901. type: number;
  11902. /**
  11903. * Defines the related dom event
  11904. */
  11905. event: PointerEvent | MouseWheelEvent;
  11906. /**
  11907. * Instantiates the base class of pointers info.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. */
  11911. constructor(
  11912. /**
  11913. * Defines the type of event (PointerEventTypes)
  11914. */
  11915. type: number,
  11916. /**
  11917. * Defines the related dom event
  11918. */
  11919. event: PointerEvent | MouseWheelEvent);
  11920. }
  11921. /**
  11922. * This class is used to store pointer related info for the onPrePointerObservable event.
  11923. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11924. */
  11925. export class PointerInfoPre extends PointerInfoBase {
  11926. /**
  11927. * Ray from a pointer if availible (eg. 6dof controller)
  11928. */
  11929. ray: Nullable<Ray>;
  11930. /**
  11931. * Defines the local position of the pointer on the canvas.
  11932. */
  11933. localPosition: Vector2;
  11934. /**
  11935. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11936. */
  11937. skipOnPointerObservable: boolean;
  11938. /**
  11939. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11940. * @param type Defines the type of event (PointerEventTypes)
  11941. * @param event Defines the related dom event
  11942. * @param localX Defines the local x coordinates of the pointer when the event occured
  11943. * @param localY Defines the local y coordinates of the pointer when the event occured
  11944. */
  11945. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11946. }
  11947. /**
  11948. * This type contains all the data related to a pointer event in Babylon.js.
  11949. * 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.
  11950. */
  11951. export class PointerInfo extends PointerInfoBase {
  11952. /**
  11953. * Defines the picking info associated to the info (if any)\
  11954. */
  11955. pickInfo: Nullable<PickingInfo>;
  11956. /**
  11957. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11958. * @param type Defines the type of event (PointerEventTypes)
  11959. * @param event Defines the related dom event
  11960. * @param pickInfo Defines the picking info associated to the info (if any)\
  11961. */
  11962. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11963. /**
  11964. * Defines the picking info associated to the info (if any)\
  11965. */
  11966. pickInfo: Nullable<PickingInfo>);
  11967. }
  11968. /**
  11969. * Data relating to a touch event on the screen.
  11970. */
  11971. export interface PointerTouch {
  11972. /**
  11973. * X coordinate of touch.
  11974. */
  11975. x: number;
  11976. /**
  11977. * Y coordinate of touch.
  11978. */
  11979. y: number;
  11980. /**
  11981. * Id of touch. Unique for each finger.
  11982. */
  11983. pointerId: number;
  11984. /**
  11985. * Event type passed from DOM.
  11986. */
  11987. type: any;
  11988. }
  11989. }
  11990. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11991. import { Observable } from "babylonjs/Misc/observable";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11994. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. */
  11999. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled: boolean;
  12004. /**
  12005. * Defines the camera the input is attached to.
  12006. */
  12007. camera: FreeCamera;
  12008. /**
  12009. * Defines the buttons associated with the input to handle camera move.
  12010. */
  12011. buttons: number[];
  12012. /**
  12013. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12014. */
  12015. angularSensibility: number;
  12016. private _pointerInput;
  12017. private _onMouseMove;
  12018. private _observer;
  12019. private previousPosition;
  12020. /**
  12021. * Observable for when a pointer move event occurs containing the move offset
  12022. */
  12023. onPointerMovedObservable: Observable<{
  12024. offsetX: number;
  12025. offsetY: number;
  12026. }>;
  12027. /**
  12028. * @hidden
  12029. * If the camera should be rotated automatically based on pointer movement
  12030. */
  12031. _allowCameraRotation: boolean;
  12032. /**
  12033. * Manage the mouse inputs to control the movement of a free camera.
  12034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12035. * @param touchEnabled Defines if touch is enabled or not
  12036. */
  12037. constructor(
  12038. /**
  12039. * Define if touch is enabled in the mouse input
  12040. */
  12041. touchEnabled?: boolean);
  12042. /**
  12043. * Attach the input controls to a specific dom element to get the input from.
  12044. * @param element Defines the element the controls should be listened from
  12045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12046. */
  12047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12048. /**
  12049. * Called on JS contextmenu event.
  12050. * Override this method to provide functionality.
  12051. */
  12052. protected onContextMenu(evt: PointerEvent): void;
  12053. /**
  12054. * Detach the current controls from the specified dom element.
  12055. * @param element Defines the element to stop listening the inputs from
  12056. */
  12057. detachControl(element: Nullable<HTMLElement>): void;
  12058. /**
  12059. * Gets the class name of the current intput.
  12060. * @returns the class name
  12061. */
  12062. getClassName(): string;
  12063. /**
  12064. * Get the friendly name associated with the input class.
  12065. * @returns the input friendly name
  12066. */
  12067. getSimpleName(): string;
  12068. }
  12069. }
  12070. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12071. import { Nullable } from "babylonjs/types";
  12072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12074. /**
  12075. * Manage the touch inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. */
  12078. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12079. /**
  12080. * Defines the camera the input is attached to.
  12081. */
  12082. camera: FreeCamera;
  12083. /**
  12084. * Defines the touch sensibility for rotation.
  12085. * The higher the faster.
  12086. */
  12087. touchAngularSensibility: number;
  12088. /**
  12089. * Defines the touch sensibility for move.
  12090. * The higher the faster.
  12091. */
  12092. touchMoveSensibility: number;
  12093. private _offsetX;
  12094. private _offsetY;
  12095. private _pointerPressed;
  12096. private _pointerInput;
  12097. private _observer;
  12098. private _onLostFocus;
  12099. /**
  12100. * Attach the input controls to a specific dom element to get the input from.
  12101. * @param element Defines the element the controls should be listened from
  12102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12103. */
  12104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12105. /**
  12106. * Detach the current controls from the specified dom element.
  12107. * @param element Defines the element to stop listening the inputs from
  12108. */
  12109. detachControl(element: Nullable<HTMLElement>): void;
  12110. /**
  12111. * Update the current camera state depending on the inputs that have been used this frame.
  12112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12113. */
  12114. checkInputs(): void;
  12115. /**
  12116. * Gets the class name of the current intput.
  12117. * @returns the class name
  12118. */
  12119. getClassName(): string;
  12120. /**
  12121. * Get the friendly name associated with the input class.
  12122. * @returns the input friendly name
  12123. */
  12124. getSimpleName(): string;
  12125. }
  12126. }
  12127. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12129. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12130. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12131. import { Nullable } from "babylonjs/types";
  12132. /**
  12133. * Default Inputs manager for the FreeCamera.
  12134. * It groups all the default supported inputs for ease of use.
  12135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12136. */
  12137. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12138. /**
  12139. * @hidden
  12140. */
  12141. _mouseInput: Nullable<FreeCameraMouseInput>;
  12142. /**
  12143. * Instantiates a new FreeCameraInputsManager.
  12144. * @param camera Defines the camera the inputs belong to
  12145. */
  12146. constructor(camera: FreeCamera);
  12147. /**
  12148. * Add keyboard input support to the input manager.
  12149. * @returns the current input manager
  12150. */
  12151. addKeyboard(): FreeCameraInputsManager;
  12152. /**
  12153. * Add mouse input support to the input manager.
  12154. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12155. * @returns the current input manager
  12156. */
  12157. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12158. /**
  12159. * Removes the mouse input support from the manager
  12160. * @returns the current input manager
  12161. */
  12162. removeMouse(): FreeCameraInputsManager;
  12163. /**
  12164. * Add touch input support to the input manager.
  12165. * @returns the current input manager
  12166. */
  12167. addTouch(): FreeCameraInputsManager;
  12168. /**
  12169. * Remove all attached input methods from a camera
  12170. */
  12171. clear(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Cameras/freeCamera" {
  12175. import { Vector3 } from "babylonjs/Maths/math.vector";
  12176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12177. import { Scene } from "babylonjs/scene";
  12178. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12179. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12180. /**
  12181. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12182. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12184. */
  12185. export class FreeCamera extends TargetCamera {
  12186. /**
  12187. * Define the collision ellipsoid of the camera.
  12188. * This is helpful to simulate a camera body like the player body around the camera
  12189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12190. */
  12191. ellipsoid: Vector3;
  12192. /**
  12193. * Define an offset for the position of the ellipsoid around the camera.
  12194. * This can be helpful to determine the center of the body near the gravity center of the body
  12195. * instead of its head.
  12196. */
  12197. ellipsoidOffset: Vector3;
  12198. /**
  12199. * Enable or disable collisions of the camera with the rest of the scene objects.
  12200. */
  12201. checkCollisions: boolean;
  12202. /**
  12203. * Enable or disable gravity on the camera.
  12204. */
  12205. applyGravity: boolean;
  12206. /**
  12207. * Define the input manager associated to the camera.
  12208. */
  12209. inputs: FreeCameraInputsManager;
  12210. /**
  12211. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12212. * Higher values reduce sensitivity.
  12213. */
  12214. /**
  12215. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12216. * Higher values reduce sensitivity.
  12217. */
  12218. angularSensibility: number;
  12219. /**
  12220. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12221. */
  12222. keysUp: number[];
  12223. /**
  12224. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12225. */
  12226. keysDown: number[];
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12229. */
  12230. keysLeft: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12233. */
  12234. keysRight: number[];
  12235. /**
  12236. * Event raised when the camera collide with a mesh in the scene.
  12237. */
  12238. onCollide: (collidedMesh: AbstractMesh) => void;
  12239. private _collider;
  12240. private _needMoveForGravity;
  12241. private _oldPosition;
  12242. private _diffPosition;
  12243. private _newPosition;
  12244. /** @hidden */
  12245. _localDirection: Vector3;
  12246. /** @hidden */
  12247. _transformedDirection: Vector3;
  12248. /**
  12249. * Instantiates a Free Camera.
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. * @param name Define the name of the camera in the scene
  12254. * @param position Define the start position of the camera in the scene
  12255. * @param scene Define the scene the camera belongs to
  12256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12257. */
  12258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12259. /**
  12260. * Attached controls to the current camera.
  12261. * @param element Defines the element the controls should be listened from
  12262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12263. */
  12264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12265. /**
  12266. * Detach the current controls from the camera.
  12267. * The camera will stop reacting to inputs.
  12268. * @param element Defines the element to stop listening the inputs from
  12269. */
  12270. detachControl(element: HTMLElement): void;
  12271. private _collisionMask;
  12272. /**
  12273. * Define a collision mask to limit the list of object the camera can collide with
  12274. */
  12275. collisionMask: number;
  12276. /** @hidden */
  12277. _collideWithWorld(displacement: Vector3): void;
  12278. private _onCollisionPositionChange;
  12279. /** @hidden */
  12280. _checkInputs(): void;
  12281. /** @hidden */
  12282. _decideIfNeedsToMove(): boolean;
  12283. /** @hidden */
  12284. _updatePosition(): void;
  12285. /**
  12286. * Destroy the camera and release the current resources hold by it.
  12287. */
  12288. dispose(): void;
  12289. /**
  12290. * Gets the current object class name.
  12291. * @return the class name
  12292. */
  12293. getClassName(): string;
  12294. }
  12295. }
  12296. declare module "babylonjs/Gamepads/gamepad" {
  12297. import { Observable } from "babylonjs/Misc/observable";
  12298. /**
  12299. * Represents a gamepad control stick position
  12300. */
  12301. export class StickValues {
  12302. /**
  12303. * The x component of the control stick
  12304. */
  12305. x: number;
  12306. /**
  12307. * The y component of the control stick
  12308. */
  12309. y: number;
  12310. /**
  12311. * Initializes the gamepad x and y control stick values
  12312. * @param x The x component of the gamepad control stick value
  12313. * @param y The y component of the gamepad control stick value
  12314. */
  12315. constructor(
  12316. /**
  12317. * The x component of the control stick
  12318. */
  12319. x: number,
  12320. /**
  12321. * The y component of the control stick
  12322. */
  12323. y: number);
  12324. }
  12325. /**
  12326. * An interface which manages callbacks for gamepad button changes
  12327. */
  12328. export interface GamepadButtonChanges {
  12329. /**
  12330. * Called when a gamepad has been changed
  12331. */
  12332. changed: boolean;
  12333. /**
  12334. * Called when a gamepad press event has been triggered
  12335. */
  12336. pressChanged: boolean;
  12337. /**
  12338. * Called when a touch event has been triggered
  12339. */
  12340. touchChanged: boolean;
  12341. /**
  12342. * Called when a value has changed
  12343. */
  12344. valueChanged: boolean;
  12345. }
  12346. /**
  12347. * Represents a gamepad
  12348. */
  12349. export class Gamepad {
  12350. /**
  12351. * The id of the gamepad
  12352. */
  12353. id: string;
  12354. /**
  12355. * The index of the gamepad
  12356. */
  12357. index: number;
  12358. /**
  12359. * The browser gamepad
  12360. */
  12361. browserGamepad: any;
  12362. /**
  12363. * Specifies what type of gamepad this represents
  12364. */
  12365. type: number;
  12366. private _leftStick;
  12367. private _rightStick;
  12368. /** @hidden */
  12369. _isConnected: boolean;
  12370. private _leftStickAxisX;
  12371. private _leftStickAxisY;
  12372. private _rightStickAxisX;
  12373. private _rightStickAxisY;
  12374. /**
  12375. * Triggered when the left control stick has been changed
  12376. */
  12377. private _onleftstickchanged;
  12378. /**
  12379. * Triggered when the right control stick has been changed
  12380. */
  12381. private _onrightstickchanged;
  12382. /**
  12383. * Represents a gamepad controller
  12384. */
  12385. static GAMEPAD: number;
  12386. /**
  12387. * Represents a generic controller
  12388. */
  12389. static GENERIC: number;
  12390. /**
  12391. * Represents an XBox controller
  12392. */
  12393. static XBOX: number;
  12394. /**
  12395. * Represents a pose-enabled controller
  12396. */
  12397. static POSE_ENABLED: number;
  12398. /**
  12399. * Represents an Dual Shock controller
  12400. */
  12401. static DUALSHOCK: number;
  12402. /**
  12403. * Specifies whether the left control stick should be Y-inverted
  12404. */
  12405. protected _invertLeftStickY: boolean;
  12406. /**
  12407. * Specifies if the gamepad has been connected
  12408. */
  12409. readonly isConnected: boolean;
  12410. /**
  12411. * Initializes the gamepad
  12412. * @param id The id of the gamepad
  12413. * @param index The index of the gamepad
  12414. * @param browserGamepad The browser gamepad
  12415. * @param leftStickX The x component of the left joystick
  12416. * @param leftStickY The y component of the left joystick
  12417. * @param rightStickX The x component of the right joystick
  12418. * @param rightStickY The y component of the right joystick
  12419. */
  12420. constructor(
  12421. /**
  12422. * The id of the gamepad
  12423. */
  12424. id: string,
  12425. /**
  12426. * The index of the gamepad
  12427. */
  12428. index: number,
  12429. /**
  12430. * The browser gamepad
  12431. */
  12432. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12433. /**
  12434. * Callback triggered when the left joystick has changed
  12435. * @param callback
  12436. */
  12437. onleftstickchanged(callback: (values: StickValues) => void): void;
  12438. /**
  12439. * Callback triggered when the right joystick has changed
  12440. * @param callback
  12441. */
  12442. onrightstickchanged(callback: (values: StickValues) => void): void;
  12443. /**
  12444. * Gets the left joystick
  12445. */
  12446. /**
  12447. * Sets the left joystick values
  12448. */
  12449. leftStick: StickValues;
  12450. /**
  12451. * Gets the right joystick
  12452. */
  12453. /**
  12454. * Sets the right joystick value
  12455. */
  12456. rightStick: StickValues;
  12457. /**
  12458. * Updates the gamepad joystick positions
  12459. */
  12460. update(): void;
  12461. /**
  12462. * Disposes the gamepad
  12463. */
  12464. dispose(): void;
  12465. }
  12466. /**
  12467. * Represents a generic gamepad
  12468. */
  12469. export class GenericPad extends Gamepad {
  12470. private _buttons;
  12471. private _onbuttondown;
  12472. private _onbuttonup;
  12473. /**
  12474. * Observable triggered when a button has been pressed
  12475. */
  12476. onButtonDownObservable: Observable<number>;
  12477. /**
  12478. * Observable triggered when a button has been released
  12479. */
  12480. onButtonUpObservable: Observable<number>;
  12481. /**
  12482. * Callback triggered when a button has been pressed
  12483. * @param callback Called when a button has been pressed
  12484. */
  12485. onbuttondown(callback: (buttonPressed: number) => void): void;
  12486. /**
  12487. * Callback triggered when a button has been released
  12488. * @param callback Called when a button has been released
  12489. */
  12490. onbuttonup(callback: (buttonReleased: number) => void): void;
  12491. /**
  12492. * Initializes the generic gamepad
  12493. * @param id The id of the generic gamepad
  12494. * @param index The index of the generic gamepad
  12495. * @param browserGamepad The browser gamepad
  12496. */
  12497. constructor(id: string, index: number, browserGamepad: any);
  12498. private _setButtonValue;
  12499. /**
  12500. * Updates the generic gamepad
  12501. */
  12502. update(): void;
  12503. /**
  12504. * Disposes the generic gamepad
  12505. */
  12506. dispose(): void;
  12507. }
  12508. }
  12509. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12510. import { Nullable } from "babylonjs/types";
  12511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12512. import { Scene } from "babylonjs/scene";
  12513. module "babylonjs/Engines/engine" {
  12514. interface Engine {
  12515. /**
  12516. * Creates a raw texture
  12517. * @param data defines the data to store in the texture
  12518. * @param width defines the width of the texture
  12519. * @param height defines the height of the texture
  12520. * @param format defines the format of the data
  12521. * @param generateMipMaps defines if the engine should generate the mip levels
  12522. * @param invertY defines if data must be stored with Y axis inverted
  12523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12524. * @param compression defines the compression used (null by default)
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @returns the raw texture inside an InternalTexture
  12527. */
  12528. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12529. /**
  12530. * Update a raw texture
  12531. * @param texture defines the texture to update
  12532. * @param data defines the data to store in the texture
  12533. * @param format defines the format of the data
  12534. * @param invertY defines if data must be stored with Y axis inverted
  12535. */
  12536. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param compression defines the compression used (null by default)
  12544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12545. */
  12546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12547. /**
  12548. * Creates a new raw cube texture
  12549. * @param data defines the array of data to use to create each face
  12550. * @param size defines the size of the textures
  12551. * @param format defines the format of the data
  12552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12553. * @param generateMipMaps defines if the engine should generate the mip levels
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12556. * @param compression defines the compression used (null by default)
  12557. * @returns the cube texture as an InternalTexture
  12558. */
  12559. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12560. /**
  12561. * Update a raw cube texture
  12562. * @param texture defines the texture to udpdate
  12563. * @param data defines the data to store
  12564. * @param format defines the data format
  12565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12566. * @param invertY defines if data must be stored with Y axis inverted
  12567. */
  12568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12569. /**
  12570. * Update a raw cube texture
  12571. * @param texture defines the texture to udpdate
  12572. * @param data defines the data to store
  12573. * @param format defines the data format
  12574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. */
  12578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12579. /**
  12580. * Update a raw cube texture
  12581. * @param texture defines the texture to udpdate
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12585. * @param invertY defines if data must be stored with Y axis inverted
  12586. * @param compression defines the compression used (null by default)
  12587. * @param level defines which level of the texture to update
  12588. */
  12589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12590. /**
  12591. * Creates a new raw cube texture from a specified url
  12592. * @param url defines the url where the data is located
  12593. * @param scene defines the current scene
  12594. * @param size defines the size of the textures
  12595. * @param format defines the format of the data
  12596. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12597. * @param noMipmap defines if the engine should avoid generating the mip levels
  12598. * @param callback defines a callback used to extract texture data from loaded data
  12599. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12600. * @param onLoad defines a callback called when texture is loaded
  12601. * @param onError defines a callback called if there is an error
  12602. * @returns the cube texture as an InternalTexture
  12603. */
  12604. 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;
  12605. /**
  12606. * Creates a new raw cube texture from a specified url
  12607. * @param url defines the url where the data is located
  12608. * @param scene defines the current scene
  12609. * @param size defines the size of the textures
  12610. * @param format defines the format of the data
  12611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12612. * @param noMipmap defines if the engine should avoid generating the mip levels
  12613. * @param callback defines a callback used to extract texture data from loaded data
  12614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12615. * @param onLoad defines a callback called when texture is loaded
  12616. * @param onError defines a callback called if there is an error
  12617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @returns the cube texture as an InternalTexture
  12620. */
  12621. 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;
  12622. /**
  12623. * Creates a new raw 3D texture
  12624. * @param data defines the data used to create the texture
  12625. * @param width defines the width of the texture
  12626. * @param height defines the height of the texture
  12627. * @param depth defines the depth of the texture
  12628. * @param format defines the format of the texture
  12629. * @param generateMipMaps defines if the engine must generate mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compressed used (can be null)
  12633. * @param textureType defines the compressed used (can be null)
  12634. * @returns a new raw 3D texture (stored in an InternalTexture)
  12635. */
  12636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12637. /**
  12638. * Update a raw 3D texture
  12639. * @param texture defines the texture to update
  12640. * @param data defines the data to store
  12641. * @param format defines the data format
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. * @param compression defines the used compression (can be null)
  12652. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12653. */
  12654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12655. }
  12656. }
  12657. }
  12658. declare module "babylonjs/Materials/Textures/rawTexture" {
  12659. import { Scene } from "babylonjs/scene";
  12660. import { Texture } from "babylonjs/Materials/Textures/texture";
  12661. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12662. /**
  12663. * Raw texture can help creating a texture directly from an array of data.
  12664. * This can be super useful if you either get the data from an uncompressed source or
  12665. * if you wish to create your texture pixel by pixel.
  12666. */
  12667. export class RawTexture extends Texture {
  12668. /**
  12669. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12670. */
  12671. format: number;
  12672. private _engine;
  12673. /**
  12674. * Instantiates a new RawTexture.
  12675. * Raw texture can help creating a texture directly from an array of data.
  12676. * This can be super useful if you either get the data from an uncompressed source or
  12677. * if you wish to create your texture pixel by pixel.
  12678. * @param data define the array of data to use to create the texture
  12679. * @param width define the width of the texture
  12680. * @param height define the height of the texture
  12681. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12682. * @param scene define the scene the texture belongs to
  12683. * @param generateMipMaps define whether mip maps should be generated or not
  12684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12687. */
  12688. constructor(data: ArrayBufferView, width: number, height: number,
  12689. /**
  12690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12691. */
  12692. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12693. /**
  12694. * Updates the texture underlying data.
  12695. * @param data Define the new data of the texture
  12696. */
  12697. update(data: ArrayBufferView): void;
  12698. /**
  12699. * Creates a luminance texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @returns the luminance texture
  12708. */
  12709. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12710. /**
  12711. * Creates a luminance alpha texture from some data.
  12712. * @param data Define the texture data
  12713. * @param width Define the width of the texture
  12714. * @param height Define the height of the texture
  12715. * @param scene Define the scene the texture belongs to
  12716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12719. * @returns the luminance alpha texture
  12720. */
  12721. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12722. /**
  12723. * Creates an alpha texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @returns the alpha texture
  12732. */
  12733. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12734. /**
  12735. * Creates a RGB texture from some data.
  12736. * @param data Define the texture data
  12737. * @param width Define the width of the texture
  12738. * @param height Define the height of the texture
  12739. * @param scene Define the scene the texture belongs to
  12740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12744. * @returns the RGB alpha texture
  12745. */
  12746. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12747. /**
  12748. * Creates a RGBA texture from some data.
  12749. * @param data Define the texture data
  12750. * @param width Define the width of the texture
  12751. * @param height Define the height of the texture
  12752. * @param scene Define the scene the texture belongs to
  12753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12757. * @returns the RGBA texture
  12758. */
  12759. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12760. /**
  12761. * Creates a R texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12770. * @returns the R texture
  12771. */
  12772. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12773. }
  12774. }
  12775. declare module "babylonjs/Maths/math.size" {
  12776. /**
  12777. * Interface for the size containing width and height
  12778. */
  12779. export interface ISize {
  12780. /**
  12781. * Width
  12782. */
  12783. width: number;
  12784. /**
  12785. * Heighht
  12786. */
  12787. height: number;
  12788. }
  12789. /**
  12790. * Size containing widht and height
  12791. */
  12792. export class Size implements ISize {
  12793. /**
  12794. * Width
  12795. */
  12796. width: number;
  12797. /**
  12798. * Height
  12799. */
  12800. height: number;
  12801. /**
  12802. * Creates a Size object from the given width and height (floats).
  12803. * @param width width of the new size
  12804. * @param height height of the new size
  12805. */
  12806. constructor(width: number, height: number);
  12807. /**
  12808. * Returns a string with the Size width and height
  12809. * @returns a string with the Size width and height
  12810. */
  12811. toString(): string;
  12812. /**
  12813. * "Size"
  12814. * @returns the string "Size"
  12815. */
  12816. getClassName(): string;
  12817. /**
  12818. * Returns the Size hash code.
  12819. * @returns a hash code for a unique width and height
  12820. */
  12821. getHashCode(): number;
  12822. /**
  12823. * Updates the current size from the given one.
  12824. * @param src the given size
  12825. */
  12826. copyFrom(src: Size): void;
  12827. /**
  12828. * Updates in place the current Size from the given floats.
  12829. * @param width width of the new size
  12830. * @param height height of the new size
  12831. * @returns the updated Size.
  12832. */
  12833. copyFromFloats(width: number, height: number): Size;
  12834. /**
  12835. * Updates in place the current Size from the given floats.
  12836. * @param width width to set
  12837. * @param height height to set
  12838. * @returns the updated Size.
  12839. */
  12840. set(width: number, height: number): Size;
  12841. /**
  12842. * Multiplies the width and height by numbers
  12843. * @param w factor to multiple the width by
  12844. * @param h factor to multiple the height by
  12845. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12846. */
  12847. multiplyByFloats(w: number, h: number): Size;
  12848. /**
  12849. * Clones the size
  12850. * @returns a new Size copied from the given one.
  12851. */
  12852. clone(): Size;
  12853. /**
  12854. * True if the current Size and the given one width and height are strictly equal.
  12855. * @param other the other size to compare against
  12856. * @returns True if the current Size and the given one width and height are strictly equal.
  12857. */
  12858. equals(other: Size): boolean;
  12859. /**
  12860. * The surface of the Size : width * height (float).
  12861. */
  12862. readonly surface: number;
  12863. /**
  12864. * Create a new size of zero
  12865. * @returns a new Size set to (0.0, 0.0)
  12866. */
  12867. static Zero(): Size;
  12868. /**
  12869. * Sums the width and height of two sizes
  12870. * @param otherSize size to add to this size
  12871. * @returns a new Size set as the addition result of the current Size and the given one.
  12872. */
  12873. add(otherSize: Size): Size;
  12874. /**
  12875. * Subtracts the width and height of two
  12876. * @param otherSize size to subtract to this size
  12877. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12878. */
  12879. subtract(otherSize: Size): Size;
  12880. /**
  12881. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12882. * @param start starting size to lerp between
  12883. * @param end end size to lerp between
  12884. * @param amount amount to lerp between the start and end values
  12885. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12886. */
  12887. static Lerp(start: Size, end: Size, amount: number): Size;
  12888. }
  12889. }
  12890. declare module "babylonjs/Animations/runtimeAnimation" {
  12891. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12892. import { Animatable } from "babylonjs/Animations/animatable";
  12893. import { Scene } from "babylonjs/scene";
  12894. /**
  12895. * Defines a runtime animation
  12896. */
  12897. export class RuntimeAnimation {
  12898. private _events;
  12899. /**
  12900. * The current frame of the runtime animation
  12901. */
  12902. private _currentFrame;
  12903. /**
  12904. * The animation used by the runtime animation
  12905. */
  12906. private _animation;
  12907. /**
  12908. * The target of the runtime animation
  12909. */
  12910. private _target;
  12911. /**
  12912. * The initiating animatable
  12913. */
  12914. private _host;
  12915. /**
  12916. * The original value of the runtime animation
  12917. */
  12918. private _originalValue;
  12919. /**
  12920. * The original blend value of the runtime animation
  12921. */
  12922. private _originalBlendValue;
  12923. /**
  12924. * The offsets cache of the runtime animation
  12925. */
  12926. private _offsetsCache;
  12927. /**
  12928. * The high limits cache of the runtime animation
  12929. */
  12930. private _highLimitsCache;
  12931. /**
  12932. * Specifies if the runtime animation has been stopped
  12933. */
  12934. private _stopped;
  12935. /**
  12936. * The blending factor of the runtime animation
  12937. */
  12938. private _blendingFactor;
  12939. /**
  12940. * The BabylonJS scene
  12941. */
  12942. private _scene;
  12943. /**
  12944. * The current value of the runtime animation
  12945. */
  12946. private _currentValue;
  12947. /** @hidden */
  12948. _animationState: _IAnimationState;
  12949. /**
  12950. * The active target of the runtime animation
  12951. */
  12952. private _activeTargets;
  12953. private _currentActiveTarget;
  12954. private _directTarget;
  12955. /**
  12956. * The target path of the runtime animation
  12957. */
  12958. private _targetPath;
  12959. /**
  12960. * The weight of the runtime animation
  12961. */
  12962. private _weight;
  12963. /**
  12964. * The ratio offset of the runtime animation
  12965. */
  12966. private _ratioOffset;
  12967. /**
  12968. * The previous delay of the runtime animation
  12969. */
  12970. private _previousDelay;
  12971. /**
  12972. * The previous ratio of the runtime animation
  12973. */
  12974. private _previousRatio;
  12975. private _enableBlending;
  12976. private _keys;
  12977. private _minFrame;
  12978. private _maxFrame;
  12979. private _minValue;
  12980. private _maxValue;
  12981. private _targetIsArray;
  12982. /**
  12983. * Gets the current frame of the runtime animation
  12984. */
  12985. readonly currentFrame: number;
  12986. /**
  12987. * Gets the weight of the runtime animation
  12988. */
  12989. readonly weight: number;
  12990. /**
  12991. * Gets the current value of the runtime animation
  12992. */
  12993. readonly currentValue: any;
  12994. /**
  12995. * Gets the target path of the runtime animation
  12996. */
  12997. readonly targetPath: string;
  12998. /**
  12999. * Gets the actual target of the runtime animation
  13000. */
  13001. readonly target: any;
  13002. /** @hidden */
  13003. _onLoop: () => void;
  13004. /**
  13005. * Create a new RuntimeAnimation object
  13006. * @param target defines the target of the animation
  13007. * @param animation defines the source animation object
  13008. * @param scene defines the hosting scene
  13009. * @param host defines the initiating Animatable
  13010. */
  13011. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13012. private _preparePath;
  13013. /**
  13014. * Gets the animation from the runtime animation
  13015. */
  13016. readonly animation: Animation;
  13017. /**
  13018. * Resets the runtime animation to the beginning
  13019. * @param restoreOriginal defines whether to restore the target property to the original value
  13020. */
  13021. reset(restoreOriginal?: boolean): void;
  13022. /**
  13023. * Specifies if the runtime animation is stopped
  13024. * @returns Boolean specifying if the runtime animation is stopped
  13025. */
  13026. isStopped(): boolean;
  13027. /**
  13028. * Disposes of the runtime animation
  13029. */
  13030. dispose(): void;
  13031. /**
  13032. * Apply the interpolated value to the target
  13033. * @param currentValue defines the value computed by the animation
  13034. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13035. */
  13036. setValue(currentValue: any, weight: number): void;
  13037. private _getOriginalValues;
  13038. private _setValue;
  13039. /**
  13040. * Gets the loop pmode of the runtime animation
  13041. * @returns Loop Mode
  13042. */
  13043. private _getCorrectLoopMode;
  13044. /**
  13045. * Move the current animation to a given frame
  13046. * @param frame defines the frame to move to
  13047. */
  13048. goToFrame(frame: number): void;
  13049. /**
  13050. * @hidden Internal use only
  13051. */
  13052. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13053. /**
  13054. * Execute the current animation
  13055. * @param delay defines the delay to add to the current frame
  13056. * @param from defines the lower bound of the animation range
  13057. * @param to defines the upper bound of the animation range
  13058. * @param loop defines if the current animation must loop
  13059. * @param speedRatio defines the current speed ratio
  13060. * @param weight defines the weight of the animation (default is -1 so no weight)
  13061. * @param onLoop optional callback called when animation loops
  13062. * @returns a boolean indicating if the animation is running
  13063. */
  13064. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13065. }
  13066. }
  13067. declare module "babylonjs/Animations/animatable" {
  13068. import { Animation } from "babylonjs/Animations/animation";
  13069. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13070. import { Nullable } from "babylonjs/types";
  13071. import { Observable } from "babylonjs/Misc/observable";
  13072. import { Scene } from "babylonjs/scene";
  13073. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13074. import { Node } from "babylonjs/node";
  13075. /**
  13076. * Class used to store an actual running animation
  13077. */
  13078. export class Animatable {
  13079. /** defines the target object */
  13080. target: any;
  13081. /** defines the starting frame number (default is 0) */
  13082. fromFrame: number;
  13083. /** defines the ending frame number (default is 100) */
  13084. toFrame: number;
  13085. /** defines if the animation must loop (default is false) */
  13086. loopAnimation: boolean;
  13087. /** defines a callback to call when animation ends if it is not looping */
  13088. onAnimationEnd?: (() => void) | null | undefined;
  13089. /** defines a callback to call when animation loops */
  13090. onAnimationLoop?: (() => void) | null | undefined;
  13091. private _localDelayOffset;
  13092. private _pausedDelay;
  13093. private _runtimeAnimations;
  13094. private _paused;
  13095. private _scene;
  13096. private _speedRatio;
  13097. private _weight;
  13098. private _syncRoot;
  13099. /**
  13100. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13101. * This will only apply for non looping animation (default is true)
  13102. */
  13103. disposeOnEnd: boolean;
  13104. /**
  13105. * Gets a boolean indicating if the animation has started
  13106. */
  13107. animationStarted: boolean;
  13108. /**
  13109. * Observer raised when the animation ends
  13110. */
  13111. onAnimationEndObservable: Observable<Animatable>;
  13112. /**
  13113. * Observer raised when the animation loops
  13114. */
  13115. onAnimationLoopObservable: Observable<Animatable>;
  13116. /**
  13117. * Gets the root Animatable used to synchronize and normalize animations
  13118. */
  13119. readonly syncRoot: Nullable<Animatable>;
  13120. /**
  13121. * Gets the current frame of the first RuntimeAnimation
  13122. * Used to synchronize Animatables
  13123. */
  13124. readonly masterFrame: number;
  13125. /**
  13126. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13127. */
  13128. weight: number;
  13129. /**
  13130. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13131. */
  13132. speedRatio: number;
  13133. /**
  13134. * Creates a new Animatable
  13135. * @param scene defines the hosting scene
  13136. * @param target defines the target object
  13137. * @param fromFrame defines the starting frame number (default is 0)
  13138. * @param toFrame defines the ending frame number (default is 100)
  13139. * @param loopAnimation defines if the animation must loop (default is false)
  13140. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13141. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13142. * @param animations defines a group of animation to add to the new Animatable
  13143. * @param onAnimationLoop defines a callback to call when animation loops
  13144. */
  13145. constructor(scene: Scene,
  13146. /** defines the target object */
  13147. target: any,
  13148. /** defines the starting frame number (default is 0) */
  13149. fromFrame?: number,
  13150. /** defines the ending frame number (default is 100) */
  13151. toFrame?: number,
  13152. /** defines if the animation must loop (default is false) */
  13153. loopAnimation?: boolean, speedRatio?: number,
  13154. /** defines a callback to call when animation ends if it is not looping */
  13155. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13156. /** defines a callback to call when animation loops */
  13157. onAnimationLoop?: (() => void) | null | undefined);
  13158. /**
  13159. * Synchronize and normalize current Animatable with a source Animatable
  13160. * This is useful when using animation weights and when animations are not of the same length
  13161. * @param root defines the root Animatable to synchronize with
  13162. * @returns the current Animatable
  13163. */
  13164. syncWith(root: Animatable): Animatable;
  13165. /**
  13166. * Gets the list of runtime animations
  13167. * @returns an array of RuntimeAnimation
  13168. */
  13169. getAnimations(): RuntimeAnimation[];
  13170. /**
  13171. * Adds more animations to the current animatable
  13172. * @param target defines the target of the animations
  13173. * @param animations defines the new animations to add
  13174. */
  13175. appendAnimations(target: any, animations: Animation[]): void;
  13176. /**
  13177. * Gets the source animation for a specific property
  13178. * @param property defines the propertyu to look for
  13179. * @returns null or the source animation for the given property
  13180. */
  13181. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13182. /**
  13183. * Gets the runtime animation for a specific property
  13184. * @param property defines the propertyu to look for
  13185. * @returns null or the runtime animation for the given property
  13186. */
  13187. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13188. /**
  13189. * Resets the animatable to its original state
  13190. */
  13191. reset(): void;
  13192. /**
  13193. * Allows the animatable to blend with current running animations
  13194. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13195. * @param blendingSpeed defines the blending speed to use
  13196. */
  13197. enableBlending(blendingSpeed: number): void;
  13198. /**
  13199. * Disable animation blending
  13200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13201. */
  13202. disableBlending(): void;
  13203. /**
  13204. * Jump directly to a given frame
  13205. * @param frame defines the frame to jump to
  13206. */
  13207. goToFrame(frame: number): void;
  13208. /**
  13209. * Pause the animation
  13210. */
  13211. pause(): void;
  13212. /**
  13213. * Restart the animation
  13214. */
  13215. restart(): void;
  13216. private _raiseOnAnimationEnd;
  13217. /**
  13218. * Stop and delete the current animation
  13219. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13220. * @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)
  13221. */
  13222. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13223. /**
  13224. * Wait asynchronously for the animation to end
  13225. * @returns a promise which will be fullfilled when the animation ends
  13226. */
  13227. waitAsync(): Promise<Animatable>;
  13228. /** @hidden */
  13229. _animate(delay: number): boolean;
  13230. }
  13231. module "babylonjs/scene" {
  13232. interface Scene {
  13233. /** @hidden */
  13234. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13235. /** @hidden */
  13236. _processLateAnimationBindingsForMatrices(holder: {
  13237. totalWeight: number;
  13238. animations: RuntimeAnimation[];
  13239. originalValue: Matrix;
  13240. }): any;
  13241. /** @hidden */
  13242. _processLateAnimationBindingsForQuaternions(holder: {
  13243. totalWeight: number;
  13244. animations: RuntimeAnimation[];
  13245. originalValue: Quaternion;
  13246. }, refQuaternion: Quaternion): Quaternion;
  13247. /** @hidden */
  13248. _processLateAnimationBindings(): void;
  13249. /**
  13250. * Will start the animation sequence of a given target
  13251. * @param target defines the target
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param weight defines the weight to apply to the animation (1.0 by default)
  13255. * @param loop defines if the animation loops
  13256. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13257. * @param onAnimationEnd defines the function to be executed when the animation ends
  13258. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the animatable object created for this animation
  13262. */
  13263. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13264. /**
  13265. * Will start the animation sequence of a given target
  13266. * @param target defines the target
  13267. * @param from defines from which frame should animation start
  13268. * @param to defines until which frame should animation run.
  13269. * @param loop defines if the animation loops
  13270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13271. * @param onAnimationEnd defines the function to be executed when the animation ends
  13272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13274. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13275. * @param onAnimationLoop defines the callback to call when an animation loops
  13276. * @returns the animatable object created for this animation
  13277. */
  13278. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13279. /**
  13280. * Will start the animation sequence of a given target and its hierarchy
  13281. * @param target defines the target
  13282. * @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.
  13283. * @param from defines from which frame should animation start
  13284. * @param to defines until which frame should animation run.
  13285. * @param loop defines if the animation loops
  13286. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13287. * @param onAnimationEnd defines the function to be executed when the animation ends
  13288. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13289. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13290. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13291. * @param onAnimationLoop defines the callback to call when an animation loops
  13292. * @returns the list of created animatables
  13293. */
  13294. 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[];
  13295. /**
  13296. * Begin a new animation on a given node
  13297. * @param target defines the target where the animation will take place
  13298. * @param animations defines the list of animations to start
  13299. * @param from defines the initial value
  13300. * @param to defines the final value
  13301. * @param loop defines if you want animation to loop (off by default)
  13302. * @param speedRatio defines the speed ratio to apply to all animations
  13303. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13304. * @param onAnimationLoop defines the callback to call when an animation loops
  13305. * @returns the list of created animatables
  13306. */
  13307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13308. /**
  13309. * Begin a new animation on a given node and its hierarchy
  13310. * @param target defines the root node where the animation will take place
  13311. * @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.
  13312. * @param animations defines the list of animations to start
  13313. * @param from defines the initial value
  13314. * @param to defines the final value
  13315. * @param loop defines if you want animation to loop (off by default)
  13316. * @param speedRatio defines the speed ratio to apply to all animations
  13317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13318. * @param onAnimationLoop defines the callback to call when an animation loops
  13319. * @returns the list of animatables created for all nodes
  13320. */
  13321. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13322. /**
  13323. * Gets the animatable associated with a specific target
  13324. * @param target defines the target of the animatable
  13325. * @returns the required animatable if found
  13326. */
  13327. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13328. /**
  13329. * Gets all animatables associated with a given target
  13330. * @param target defines the target to look animatables for
  13331. * @returns an array of Animatables
  13332. */
  13333. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13334. /**
  13335. * Stops and removes all animations that have been applied to the scene
  13336. */
  13337. stopAllAnimations(): void;
  13338. /**
  13339. * Gets the current delta time used by animation engine
  13340. */
  13341. deltaTime: number;
  13342. }
  13343. }
  13344. module "babylonjs/Bones/bone" {
  13345. interface Bone {
  13346. /**
  13347. * Copy an animation range from another bone
  13348. * @param source defines the source bone
  13349. * @param rangeName defines the range name to copy
  13350. * @param frameOffset defines the frame offset
  13351. * @param rescaleAsRequired defines if rescaling must be applied if required
  13352. * @param skelDimensionsRatio defines the scaling ratio
  13353. * @returns true if operation was successful
  13354. */
  13355. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13356. }
  13357. }
  13358. }
  13359. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13360. /**
  13361. * Class used to override all child animations of a given target
  13362. */
  13363. export class AnimationPropertiesOverride {
  13364. /**
  13365. * Gets or sets a value indicating if animation blending must be used
  13366. */
  13367. enableBlending: boolean;
  13368. /**
  13369. * Gets or sets the blending speed to use when enableBlending is true
  13370. */
  13371. blendingSpeed: number;
  13372. /**
  13373. * Gets or sets the default loop mode to use
  13374. */
  13375. loopMode: number;
  13376. }
  13377. }
  13378. declare module "babylonjs/Bones/skeleton" {
  13379. import { Bone } from "babylonjs/Bones/bone";
  13380. import { Observable } from "babylonjs/Misc/observable";
  13381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13382. import { Scene } from "babylonjs/scene";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13386. import { Animatable } from "babylonjs/Animations/animatable";
  13387. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13388. import { Animation } from "babylonjs/Animations/animation";
  13389. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13392. /**
  13393. * Class used to handle skinning animations
  13394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13395. */
  13396. export class Skeleton implements IAnimatable {
  13397. /** defines the skeleton name */
  13398. name: string;
  13399. /** defines the skeleton Id */
  13400. id: string;
  13401. /**
  13402. * Defines the list of child bones
  13403. */
  13404. bones: Bone[];
  13405. /**
  13406. * Defines an estimate of the dimension of the skeleton at rest
  13407. */
  13408. dimensionsAtRest: Vector3;
  13409. /**
  13410. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13411. */
  13412. needInitialSkinMatrix: boolean;
  13413. /**
  13414. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13415. */
  13416. overrideMesh: Nullable<AbstractMesh>;
  13417. /**
  13418. * Gets the list of animations attached to this skeleton
  13419. */
  13420. animations: Array<Animation>;
  13421. private _scene;
  13422. private _isDirty;
  13423. private _transformMatrices;
  13424. private _transformMatrixTexture;
  13425. private _meshesWithPoseMatrix;
  13426. private _animatables;
  13427. private _identity;
  13428. private _synchronizedWithMesh;
  13429. private _ranges;
  13430. private _lastAbsoluteTransformsUpdateId;
  13431. private _canUseTextureForBones;
  13432. private _uniqueId;
  13433. /** @hidden */
  13434. _numBonesWithLinkedTransformNode: number;
  13435. /** @hidden */
  13436. _hasWaitingData: Nullable<boolean>;
  13437. /**
  13438. * Specifies if the skeleton should be serialized
  13439. */
  13440. doNotSerialize: boolean;
  13441. private _useTextureToStoreBoneMatrices;
  13442. /**
  13443. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13444. * Please note that this option is not available if the hardware does not support it
  13445. */
  13446. useTextureToStoreBoneMatrices: boolean;
  13447. private _animationPropertiesOverride;
  13448. /**
  13449. * Gets or sets the animation properties override
  13450. */
  13451. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13452. /**
  13453. * List of inspectable custom properties (used by the Inspector)
  13454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13455. */
  13456. inspectableCustomProperties: IInspectable[];
  13457. /**
  13458. * An observable triggered before computing the skeleton's matrices
  13459. */
  13460. onBeforeComputeObservable: Observable<Skeleton>;
  13461. /**
  13462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13463. */
  13464. readonly isUsingTextureForMatrices: boolean;
  13465. /**
  13466. * Gets the unique ID of this skeleton
  13467. */
  13468. readonly uniqueId: number;
  13469. /**
  13470. * Creates a new skeleton
  13471. * @param name defines the skeleton name
  13472. * @param id defines the skeleton Id
  13473. * @param scene defines the hosting scene
  13474. */
  13475. constructor(
  13476. /** defines the skeleton name */
  13477. name: string,
  13478. /** defines the skeleton Id */
  13479. id: string, scene: Scene);
  13480. /**
  13481. * Gets the current object class name.
  13482. * @return the class name
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Returns an array containing the root bones
  13487. * @returns an array containing the root bones
  13488. */
  13489. getChildren(): Array<Bone>;
  13490. /**
  13491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13493. * @returns a Float32Array containing matrices data
  13494. */
  13495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13496. /**
  13497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13499. * @returns a raw texture containing the data
  13500. */
  13501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13502. /**
  13503. * Gets the current hosting scene
  13504. * @returns a scene object
  13505. */
  13506. getScene(): Scene;
  13507. /**
  13508. * Gets a string representing the current skeleton data
  13509. * @param fullDetails defines a boolean indicating if we want a verbose version
  13510. * @returns a string representing the current skeleton data
  13511. */
  13512. toString(fullDetails?: boolean): string;
  13513. /**
  13514. * Get bone's index searching by name
  13515. * @param name defines bone's name to search for
  13516. * @return the indice of the bone. Returns -1 if not found
  13517. */
  13518. getBoneIndexByName(name: string): number;
  13519. /**
  13520. * Creater a new animation range
  13521. * @param name defines the name of the range
  13522. * @param from defines the start key
  13523. * @param to defines the end key
  13524. */
  13525. createAnimationRange(name: string, from: number, to: number): void;
  13526. /**
  13527. * Delete a specific animation range
  13528. * @param name defines the name of the range
  13529. * @param deleteFrames defines if frames must be removed as well
  13530. */
  13531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13532. /**
  13533. * Gets a specific animation range
  13534. * @param name defines the name of the range to look for
  13535. * @returns the requested animation range or null if not found
  13536. */
  13537. getAnimationRange(name: string): Nullable<AnimationRange>;
  13538. /**
  13539. * Gets the list of all animation ranges defined on this skeleton
  13540. * @returns an array
  13541. */
  13542. getAnimationRanges(): Nullable<AnimationRange>[];
  13543. /**
  13544. * Copy animation range from a source skeleton.
  13545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13546. * @param source defines the source skeleton
  13547. * @param name defines the name of the range to copy
  13548. * @param rescaleAsRequired defines if rescaling must be applied if required
  13549. * @returns true if operation was successful
  13550. */
  13551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13552. /**
  13553. * Forces the skeleton to go to rest pose
  13554. */
  13555. returnToRest(): void;
  13556. private _getHighestAnimationFrame;
  13557. /**
  13558. * Begin a specific animation range
  13559. * @param name defines the name of the range to start
  13560. * @param loop defines if looping must be turned on (false by default)
  13561. * @param speedRatio defines the speed ratio to apply (1 by default)
  13562. * @param onAnimationEnd defines a callback which will be called when animation will end
  13563. * @returns a new animatable
  13564. */
  13565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13566. /** @hidden */
  13567. _markAsDirty(): void;
  13568. /** @hidden */
  13569. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13570. /** @hidden */
  13571. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. private _computeTransformMatrices;
  13573. /**
  13574. * Build all resources required to render a skeleton
  13575. */
  13576. prepare(): void;
  13577. /**
  13578. * Gets the list of animatables currently running for this skeleton
  13579. * @returns an array of animatables
  13580. */
  13581. getAnimatables(): IAnimatable[];
  13582. /**
  13583. * Clone the current skeleton
  13584. * @param name defines the name of the new skeleton
  13585. * @param id defines the id of the new skeleton
  13586. * @returns the new skeleton
  13587. */
  13588. clone(name: string, id: string): Skeleton;
  13589. /**
  13590. * Enable animation blending for this skeleton
  13591. * @param blendingSpeed defines the blending speed to apply
  13592. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13593. */
  13594. enableBlending(blendingSpeed?: number): void;
  13595. /**
  13596. * Releases all resources associated with the current skeleton
  13597. */
  13598. dispose(): void;
  13599. /**
  13600. * Serialize the skeleton in a JSON object
  13601. * @returns a JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Creates a new skeleton from serialized data
  13606. * @param parsedSkeleton defines the serialized data
  13607. * @param scene defines the hosting scene
  13608. * @returns a new skeleton
  13609. */
  13610. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13611. /**
  13612. * Compute all node absolute transforms
  13613. * @param forceUpdate defines if computation must be done even if cache is up to date
  13614. */
  13615. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13616. /**
  13617. * Gets the root pose matrix
  13618. * @returns a matrix
  13619. */
  13620. getPoseMatrix(): Nullable<Matrix>;
  13621. /**
  13622. * Sorts bones per internal index
  13623. */
  13624. sortBones(): void;
  13625. private _sortBones;
  13626. }
  13627. }
  13628. declare module "babylonjs/Bones/bone" {
  13629. import { Skeleton } from "babylonjs/Bones/skeleton";
  13630. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13631. import { Nullable } from "babylonjs/types";
  13632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13634. import { Node } from "babylonjs/node";
  13635. import { Space } from "babylonjs/Maths/math.axis";
  13636. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13637. /**
  13638. * Class used to store bone information
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13640. */
  13641. export class Bone extends Node {
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string;
  13646. private static _tmpVecs;
  13647. private static _tmpQuat;
  13648. private static _tmpMats;
  13649. /**
  13650. * Gets the list of child bones
  13651. */
  13652. children: Bone[];
  13653. /** Gets the animations associated with this bone */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Gets or sets bone length
  13657. */
  13658. length: number;
  13659. /**
  13660. * @hidden Internal only
  13661. * Set this value to map this bone to a different index in the transform matrices
  13662. * Set this value to -1 to exclude the bone from the transform matrices
  13663. */
  13664. _index: Nullable<number>;
  13665. private _skeleton;
  13666. private _localMatrix;
  13667. private _restPose;
  13668. private _baseMatrix;
  13669. private _absoluteTransform;
  13670. private _invertedAbsoluteTransform;
  13671. private _parent;
  13672. private _scalingDeterminant;
  13673. private _worldTransform;
  13674. private _localScaling;
  13675. private _localRotation;
  13676. private _localPosition;
  13677. private _needToDecompose;
  13678. private _needToCompose;
  13679. /** @hidden */
  13680. _linkedTransformNode: Nullable<TransformNode>;
  13681. /** @hidden */
  13682. _waitingTransformNodeId: Nullable<string>;
  13683. /** @hidden */
  13684. /** @hidden */
  13685. _matrix: Matrix;
  13686. /**
  13687. * Create a new bone
  13688. * @param name defines the bone name
  13689. * @param skeleton defines the parent skeleton
  13690. * @param parentBone defines the parent (can be null if the bone is the root)
  13691. * @param localMatrix defines the local matrix
  13692. * @param restPose defines the rest pose matrix
  13693. * @param baseMatrix defines the base matrix
  13694. * @param index defines index of the bone in the hiearchy
  13695. */
  13696. constructor(
  13697. /**
  13698. * defines the bone name
  13699. */
  13700. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13701. /**
  13702. * Gets the current object class name.
  13703. * @return the class name
  13704. */
  13705. getClassName(): string;
  13706. /**
  13707. * Gets the parent skeleton
  13708. * @returns a skeleton
  13709. */
  13710. getSkeleton(): Skeleton;
  13711. /**
  13712. * Gets parent bone
  13713. * @returns a bone or null if the bone is the root of the bone hierarchy
  13714. */
  13715. getParent(): Nullable<Bone>;
  13716. /**
  13717. * Returns an array containing the root bones
  13718. * @returns an array containing the root bones
  13719. */
  13720. getChildren(): Array<Bone>;
  13721. /**
  13722. * Sets the parent bone
  13723. * @param parent defines the parent (can be null if the bone is the root)
  13724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13725. */
  13726. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13727. /**
  13728. * Gets the local matrix
  13729. * @returns a matrix
  13730. */
  13731. getLocalMatrix(): Matrix;
  13732. /**
  13733. * Gets the base matrix (initial matrix which remains unchanged)
  13734. * @returns a matrix
  13735. */
  13736. getBaseMatrix(): Matrix;
  13737. /**
  13738. * Gets the rest pose matrix
  13739. * @returns a matrix
  13740. */
  13741. getRestPose(): Matrix;
  13742. /**
  13743. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13744. */
  13745. getWorldMatrix(): Matrix;
  13746. /**
  13747. * Sets the local matrix to rest pose matrix
  13748. */
  13749. returnToRest(): void;
  13750. /**
  13751. * Gets the inverse of the absolute transform matrix.
  13752. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13753. * @returns a matrix
  13754. */
  13755. getInvertedAbsoluteTransform(): Matrix;
  13756. /**
  13757. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13758. * @returns a matrix
  13759. */
  13760. getAbsoluteTransform(): Matrix;
  13761. /**
  13762. * Links with the given transform node.
  13763. * The local matrix of this bone is copied from the transform node every frame.
  13764. * @param transformNode defines the transform node to link to
  13765. */
  13766. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13767. /**
  13768. * Gets the node used to drive the bone's transformation
  13769. * @returns a transform node or null
  13770. */
  13771. getTransformNode(): Nullable<TransformNode>;
  13772. /** Gets or sets current position (in local space) */
  13773. position: Vector3;
  13774. /** Gets or sets current rotation (in local space) */
  13775. rotation: Vector3;
  13776. /** Gets or sets current rotation quaternion (in local space) */
  13777. rotationQuaternion: Quaternion;
  13778. /** Gets or sets current scaling (in local space) */
  13779. scaling: Vector3;
  13780. /**
  13781. * Gets the animation properties override
  13782. */
  13783. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13784. private _decompose;
  13785. private _compose;
  13786. /**
  13787. * Update the base and local matrices
  13788. * @param matrix defines the new base or local matrix
  13789. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13790. * @param updateLocalMatrix defines if the local matrix should be updated
  13791. */
  13792. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13793. /** @hidden */
  13794. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13795. /**
  13796. * Flag the bone as dirty (Forcing it to update everything)
  13797. */
  13798. markAsDirty(): void;
  13799. /** @hidden */
  13800. _markAsDirtyAndCompose(): void;
  13801. private _markAsDirtyAndDecompose;
  13802. /**
  13803. * Translate the bone in local or world space
  13804. * @param vec The amount to translate the bone
  13805. * @param space The space that the translation is in
  13806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13807. */
  13808. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13809. /**
  13810. * Set the postion of the bone in local or world space
  13811. * @param position The position to set the bone
  13812. * @param space The space that the position is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the absolute position of the bone (world space)
  13818. * @param position The position to set the bone
  13819. * @param mesh The mesh that this bone is attached to
  13820. */
  13821. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Scale the bone on the x, y and z axes (in local space)
  13824. * @param x The amount to scale the bone on the x axis
  13825. * @param y The amount to scale the bone on the y axis
  13826. * @param z The amount to scale the bone on the z axis
  13827. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13828. */
  13829. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13830. /**
  13831. * Set the bone scaling in local space
  13832. * @param scale defines the scaling vector
  13833. */
  13834. setScale(scale: Vector3): void;
  13835. /**
  13836. * Gets the current scaling in local space
  13837. * @returns the current scaling vector
  13838. */
  13839. getScale(): Vector3;
  13840. /**
  13841. * Gets the current scaling in local space and stores it in a target vector
  13842. * @param result defines the target vector
  13843. */
  13844. getScaleToRef(result: Vector3): void;
  13845. /**
  13846. * Set the yaw, pitch, and roll of the bone in local or world space
  13847. * @param yaw The rotation of the bone on the y axis
  13848. * @param pitch The rotation of the bone on the x axis
  13849. * @param roll The rotation of the bone on the z axis
  13850. * @param space The space that the axes of rotation are in
  13851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13852. */
  13853. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13854. /**
  13855. * Add a rotation to the bone on an axis in local or world space
  13856. * @param axis The axis to rotate the bone on
  13857. * @param amount The amount to rotate the bone
  13858. * @param space The space that the axis is in
  13859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13860. */
  13861. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13862. /**
  13863. * Set the rotation of the bone to a particular axis angle in local or world space
  13864. * @param axis The axis to rotate the bone on
  13865. * @param angle The angle that the bone should be rotated to
  13866. * @param space The space that the axis is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the euler rotation of the bone in local of world space
  13872. * @param rotation The euler rotation that the bone should be set to
  13873. * @param space The space that the rotation is in
  13874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13875. */
  13876. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13877. /**
  13878. * Set the quaternion rotation of the bone in local of world space
  13879. * @param quat The quaternion rotation that the bone should be set to
  13880. * @param space The space that the rotation is in
  13881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13882. */
  13883. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13884. /**
  13885. * Set the rotation matrix of the bone in local of world space
  13886. * @param rotMat The rotation matrix that the bone should be set to
  13887. * @param space The space that the rotation is in
  13888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13889. */
  13890. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13891. private _rotateWithMatrix;
  13892. private _getNegativeRotationToRef;
  13893. /**
  13894. * Get the position of the bone in local or world space
  13895. * @param space The space that the returned position is in
  13896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13897. * @returns The position of the bone
  13898. */
  13899. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13900. /**
  13901. * Copy the position of the bone to a vector3 in local or world space
  13902. * @param space The space that the returned position is in
  13903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13904. * @param result The vector3 to copy the position to
  13905. */
  13906. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13907. /**
  13908. * Get the absolute position of the bone (world space)
  13909. * @param mesh The mesh that this bone is attached to
  13910. * @returns The absolute position of the bone
  13911. */
  13912. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13913. /**
  13914. * Copy the absolute position of the bone (world space) to the result param
  13915. * @param mesh The mesh that this bone is attached to
  13916. * @param result The vector3 to copy the absolute position to
  13917. */
  13918. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13919. /**
  13920. * Compute the absolute transforms of this bone and its children
  13921. */
  13922. computeAbsoluteTransforms(): void;
  13923. /**
  13924. * Get the world direction from an axis that is in the local space of the bone
  13925. * @param localAxis The local direction that is used to compute the world direction
  13926. * @param mesh The mesh that this bone is attached to
  13927. * @returns The world direction
  13928. */
  13929. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13930. /**
  13931. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13932. * @param localAxis The local direction that is used to compute the world direction
  13933. * @param mesh The mesh that this bone is attached to
  13934. * @param result The vector3 that the world direction will be copied to
  13935. */
  13936. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13937. /**
  13938. * Get the euler rotation of the bone in local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @returns The euler rotation
  13942. */
  13943. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13946. * @param space The space that the rotation should be in
  13947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13948. * @param result The vector3 that the rotation should be copied to
  13949. */
  13950. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the quaternion rotation of the bone in either local or world space
  13953. * @param space The space that the rotation should be in
  13954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13955. * @returns The quaternion rotation
  13956. */
  13957. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13958. /**
  13959. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13960. * @param space The space that the rotation should be in
  13961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13962. * @param result The quaternion that the rotation should be copied to
  13963. */
  13964. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13965. /**
  13966. * Get the rotation matrix of the bone in local or world space
  13967. * @param space The space that the rotation should be in
  13968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13969. * @returns The rotation matrix
  13970. */
  13971. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13972. /**
  13973. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13974. * @param space The space that the rotation should be in
  13975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13976. * @param result The quaternion that the rotation should be copied to
  13977. */
  13978. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13979. /**
  13980. * Get the world position of a point that is in the local space of the bone
  13981. * @param position The local position
  13982. * @param mesh The mesh that this bone is attached to
  13983. * @returns The world position
  13984. */
  13985. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13986. /**
  13987. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13988. * @param position The local position
  13989. * @param mesh The mesh that this bone is attached to
  13990. * @param result The vector3 that the world position should be copied to
  13991. */
  13992. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13993. /**
  13994. * Get the local position of a point that is in world space
  13995. * @param position The world position
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @returns The local position
  13998. */
  13999. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14000. /**
  14001. * Get the local position of a point that is in world space and copy it to the result param
  14002. * @param position The world position
  14003. * @param mesh The mesh that this bone is attached to
  14004. * @param result The vector3 that the local position should be copied to
  14005. */
  14006. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14007. }
  14008. }
  14009. declare module "babylonjs/Meshes/transformNode" {
  14010. import { DeepImmutable } from "babylonjs/types";
  14011. import { Observable } from "babylonjs/Misc/observable";
  14012. import { Nullable } from "babylonjs/types";
  14013. import { Camera } from "babylonjs/Cameras/camera";
  14014. import { Scene } from "babylonjs/scene";
  14015. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14016. import { Node } from "babylonjs/node";
  14017. import { Bone } from "babylonjs/Bones/bone";
  14018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14019. import { Space } from "babylonjs/Maths/math.axis";
  14020. /**
  14021. * 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.
  14022. * @see https://doc.babylonjs.com/how_to/transformnode
  14023. */
  14024. export class TransformNode extends Node {
  14025. /**
  14026. * Object will not rotate to face the camera
  14027. */
  14028. static BILLBOARDMODE_NONE: number;
  14029. /**
  14030. * Object will rotate to face the camera but only on the x axis
  14031. */
  14032. static BILLBOARDMODE_X: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the y axis
  14035. */
  14036. static BILLBOARDMODE_Y: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the z axis
  14039. */
  14040. static BILLBOARDMODE_Z: number;
  14041. /**
  14042. * Object will rotate to face the camera
  14043. */
  14044. static BILLBOARDMODE_ALL: number;
  14045. /**
  14046. * Object will rotate to face the camera's position instead of orientation
  14047. */
  14048. static BILLBOARDMODE_USE_POSITION: number;
  14049. private _forward;
  14050. private _forwardInverted;
  14051. private _up;
  14052. private _right;
  14053. private _rightInverted;
  14054. private _position;
  14055. private _rotation;
  14056. private _rotationQuaternion;
  14057. protected _scaling: Vector3;
  14058. protected _isDirty: boolean;
  14059. private _transformToBoneReferal;
  14060. private _isAbsoluteSynced;
  14061. private _billboardMode;
  14062. /**
  14063. * Gets or sets the billboard mode. Default is 0.
  14064. *
  14065. * | Value | Type | Description |
  14066. * | --- | --- | --- |
  14067. * | 0 | BILLBOARDMODE_NONE | |
  14068. * | 1 | BILLBOARDMODE_X | |
  14069. * | 2 | BILLBOARDMODE_Y | |
  14070. * | 4 | BILLBOARDMODE_Z | |
  14071. * | 7 | BILLBOARDMODE_ALL | |
  14072. *
  14073. */
  14074. billboardMode: number;
  14075. private _preserveParentRotationForBillboard;
  14076. /**
  14077. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14078. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14079. */
  14080. preserveParentRotationForBillboard: boolean;
  14081. /**
  14082. * 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
  14083. */
  14084. scalingDeterminant: number;
  14085. private _infiniteDistance;
  14086. /**
  14087. * Gets or sets the distance of the object to max, often used by skybox
  14088. */
  14089. infiniteDistance: boolean;
  14090. /**
  14091. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14092. * By default the system will update normals to compensate
  14093. */
  14094. ignoreNonUniformScaling: boolean;
  14095. /**
  14096. * 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
  14097. */
  14098. reIntegrateRotationIntoRotationQuaternion: boolean;
  14099. /** @hidden */
  14100. _poseMatrix: Nullable<Matrix>;
  14101. /** @hidden */
  14102. _localMatrix: Matrix;
  14103. private _usePivotMatrix;
  14104. private _absolutePosition;
  14105. private _absoluteScaling;
  14106. private _absoluteRotationQuaternion;
  14107. private _pivotMatrix;
  14108. private _pivotMatrixInverse;
  14109. protected _postMultiplyPivotMatrix: boolean;
  14110. protected _isWorldMatrixFrozen: boolean;
  14111. /** @hidden */
  14112. _indexInSceneTransformNodesArray: number;
  14113. /**
  14114. * An event triggered after the world matrix is updated
  14115. */
  14116. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14117. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14118. /**
  14119. * Gets a string identifying the name of the class
  14120. * @returns "TransformNode" string
  14121. */
  14122. getClassName(): string;
  14123. /**
  14124. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14125. */
  14126. position: Vector3;
  14127. /**
  14128. * 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)).
  14129. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14130. */
  14131. rotation: Vector3;
  14132. /**
  14133. * 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)).
  14134. */
  14135. scaling: Vector3;
  14136. /**
  14137. * 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).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. rotationQuaternion: Nullable<Quaternion>;
  14141. /**
  14142. * The forward direction of that transform in world space.
  14143. */
  14144. readonly forward: Vector3;
  14145. /**
  14146. * The up direction of that transform in world space.
  14147. */
  14148. readonly up: Vector3;
  14149. /**
  14150. * The right direction of that transform in world space.
  14151. */
  14152. readonly right: Vector3;
  14153. /**
  14154. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14155. * @param matrix the matrix to copy the pose from
  14156. * @returns this TransformNode.
  14157. */
  14158. updatePoseMatrix(matrix: Matrix): TransformNode;
  14159. /**
  14160. * Returns the mesh Pose matrix.
  14161. * @returns the pose matrix
  14162. */
  14163. getPoseMatrix(): Matrix;
  14164. /** @hidden */
  14165. _isSynchronized(): boolean;
  14166. /** @hidden */
  14167. _initCache(): void;
  14168. /**
  14169. * Flag the transform node as dirty (Forcing it to update everything)
  14170. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14171. * @returns this transform node
  14172. */
  14173. markAsDirty(property: string): TransformNode;
  14174. /**
  14175. * Returns the current mesh absolute position.
  14176. * Returns a Vector3.
  14177. */
  14178. readonly absolutePosition: Vector3;
  14179. /**
  14180. * Returns the current mesh absolute scaling.
  14181. * Returns a Vector3.
  14182. */
  14183. readonly absoluteScaling: Vector3;
  14184. /**
  14185. * Returns the current mesh absolute rotation.
  14186. * Returns a Quaternion.
  14187. */
  14188. readonly absoluteRotationQuaternion: Quaternion;
  14189. /**
  14190. * Sets a new matrix to apply before all other transformation
  14191. * @param matrix defines the transform matrix
  14192. * @returns the current TransformNode
  14193. */
  14194. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14195. /**
  14196. * Sets a new pivot matrix to the current node
  14197. * @param matrix defines the new pivot matrix to use
  14198. * @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
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14202. /**
  14203. * Returns the mesh pivot matrix.
  14204. * Default : Identity.
  14205. * @returns the matrix
  14206. */
  14207. getPivotMatrix(): Matrix;
  14208. /**
  14209. * Instantiate (when possible) or clone that node with its hierarchy
  14210. * @param newParent defines the new parent to use for the instance (or clone)
  14211. * @returns an instance (or a clone) of the current node with its hiearchy
  14212. */
  14213. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14214. /**
  14215. * Prevents the World matrix to be computed any longer
  14216. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14217. * @returns the TransformNode.
  14218. */
  14219. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14220. /**
  14221. * Allows back the World matrix computation.
  14222. * @returns the TransformNode.
  14223. */
  14224. unfreezeWorldMatrix(): this;
  14225. /**
  14226. * True if the World matrix has been frozen.
  14227. */
  14228. readonly isWorldMatrixFrozen: boolean;
  14229. /**
  14230. * Retuns the mesh absolute position in the World.
  14231. * @returns a Vector3.
  14232. */
  14233. getAbsolutePosition(): Vector3;
  14234. /**
  14235. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14236. * @param absolutePosition the absolute position to set
  14237. * @returns the TransformNode.
  14238. */
  14239. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14240. /**
  14241. * Sets the mesh position in its local space.
  14242. * @param vector3 the position to set in localspace
  14243. * @returns the TransformNode.
  14244. */
  14245. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14246. /**
  14247. * Returns the mesh position in the local space from the current World matrix values.
  14248. * @returns a new Vector3.
  14249. */
  14250. getPositionExpressedInLocalSpace(): Vector3;
  14251. /**
  14252. * Translates the mesh along the passed Vector3 in its local space.
  14253. * @param vector3 the distance to translate in localspace
  14254. * @returns the TransformNode.
  14255. */
  14256. locallyTranslate(vector3: Vector3): TransformNode;
  14257. private static _lookAtVectorCache;
  14258. /**
  14259. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14260. * @param targetPoint the position (must be in same space as current mesh) to look at
  14261. * @param yawCor optional yaw (y-axis) correction in radians
  14262. * @param pitchCor optional pitch (x-axis) correction in radians
  14263. * @param rollCor optional roll (z-axis) correction in radians
  14264. * @param space the choosen space of the target
  14265. * @returns the TransformNode.
  14266. */
  14267. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14268. /**
  14269. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14270. * This Vector3 is expressed in the World space.
  14271. * @param localAxis axis to rotate
  14272. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14273. */
  14274. getDirection(localAxis: Vector3): Vector3;
  14275. /**
  14276. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14277. * localAxis is expressed in the mesh local space.
  14278. * result is computed in the Wordl space from the mesh World matrix.
  14279. * @param localAxis axis to rotate
  14280. * @param result the resulting transformnode
  14281. * @returns this TransformNode.
  14282. */
  14283. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14284. /**
  14285. * Sets this transform node rotation to the given local axis.
  14286. * @param localAxis the axis in local space
  14287. * @param yawCor optional yaw (y-axis) correction in radians
  14288. * @param pitchCor optional pitch (x-axis) correction in radians
  14289. * @param rollCor optional roll (z-axis) correction in radians
  14290. * @returns this TransformNode
  14291. */
  14292. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14293. /**
  14294. * Sets a new pivot point to the current node
  14295. * @param point defines the new pivot point to use
  14296. * @param space defines if the point is in world or local space (local by default)
  14297. * @returns the current TransformNode
  14298. */
  14299. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14300. /**
  14301. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14302. * @returns the pivot point
  14303. */
  14304. getPivotPoint(): Vector3;
  14305. /**
  14306. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14307. * @param result the vector3 to store the result
  14308. * @returns this TransformNode.
  14309. */
  14310. getPivotPointToRef(result: Vector3): TransformNode;
  14311. /**
  14312. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14313. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14314. */
  14315. getAbsolutePivotPoint(): Vector3;
  14316. /**
  14317. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14318. * @param result vector3 to store the result
  14319. * @returns this TransformNode.
  14320. */
  14321. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14322. /**
  14323. * Defines the passed node as the parent of the current node.
  14324. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14325. * @see https://doc.babylonjs.com/how_to/parenting
  14326. * @param node the node ot set as the parent
  14327. * @returns this TransformNode.
  14328. */
  14329. setParent(node: Nullable<Node>): TransformNode;
  14330. private _nonUniformScaling;
  14331. /**
  14332. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14333. */
  14334. readonly nonUniformScaling: boolean;
  14335. /** @hidden */
  14336. _updateNonUniformScalingState(value: boolean): boolean;
  14337. /**
  14338. * Attach the current TransformNode to another TransformNode associated with a bone
  14339. * @param bone Bone affecting the TransformNode
  14340. * @param affectedTransformNode TransformNode associated with the bone
  14341. * @returns this object
  14342. */
  14343. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14344. /**
  14345. * Detach the transform node if its associated with a bone
  14346. * @returns this object
  14347. */
  14348. detachFromBone(): TransformNode;
  14349. private static _rotationAxisCache;
  14350. /**
  14351. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14353. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14354. * The passed axis is also normalized.
  14355. * @param axis the axis to rotate around
  14356. * @param amount the amount to rotate in radians
  14357. * @param space Space to rotate in (Default: local)
  14358. * @returns the TransformNode.
  14359. */
  14360. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14361. /**
  14362. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14363. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14364. * The passed axis is also normalized. .
  14365. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14366. * @param point the point to rotate around
  14367. * @param axis the axis to rotate around
  14368. * @param amount the amount to rotate in radians
  14369. * @returns the TransformNode
  14370. */
  14371. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14372. /**
  14373. * Translates the mesh along the axis vector for the passed distance in the given space.
  14374. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14375. * @param axis the axis to translate in
  14376. * @param distance the distance to translate
  14377. * @param space Space to rotate in (Default: local)
  14378. * @returns the TransformNode.
  14379. */
  14380. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14381. /**
  14382. * Adds a rotation step to the mesh current rotation.
  14383. * x, y, z are Euler angles expressed in radians.
  14384. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14385. * This means this rotation is made in the mesh local space only.
  14386. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14387. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14388. * ```javascript
  14389. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14390. * ```
  14391. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14392. * 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.
  14393. * @param x Rotation to add
  14394. * @param y Rotation to add
  14395. * @param z Rotation to add
  14396. * @returns the TransformNode.
  14397. */
  14398. addRotation(x: number, y: number, z: number): TransformNode;
  14399. /**
  14400. * @hidden
  14401. */
  14402. protected _getEffectiveParent(): Nullable<Node>;
  14403. /**
  14404. * Computes the world matrix of the node
  14405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14406. * @returns the world matrix
  14407. */
  14408. computeWorldMatrix(force?: boolean): Matrix;
  14409. protected _afterComputeWorldMatrix(): void;
  14410. /**
  14411. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14412. * @param func callback function to add
  14413. *
  14414. * @returns the TransformNode.
  14415. */
  14416. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14417. /**
  14418. * Removes a registered callback function.
  14419. * @param func callback function to remove
  14420. * @returns the TransformNode.
  14421. */
  14422. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14423. /**
  14424. * Gets the position of the current mesh in camera space
  14425. * @param camera defines the camera to use
  14426. * @returns a position
  14427. */
  14428. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14429. /**
  14430. * Returns the distance from the mesh to the active camera
  14431. * @param camera defines the camera to use
  14432. * @returns the distance
  14433. */
  14434. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14435. /**
  14436. * Clone the current transform node
  14437. * @param name Name of the new clone
  14438. * @param newParent New parent for the clone
  14439. * @param doNotCloneChildren Do not clone children hierarchy
  14440. * @returns the new transform node
  14441. */
  14442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14443. /**
  14444. * Serializes the objects information.
  14445. * @param currentSerializationObject defines the object to serialize in
  14446. * @returns the serialized object
  14447. */
  14448. serialize(currentSerializationObject?: any): any;
  14449. /**
  14450. * Returns a new TransformNode object parsed from the source provided.
  14451. * @param parsedTransformNode is the source.
  14452. * @param scene the scne the object belongs to
  14453. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14454. * @returns a new TransformNode object parsed from the source provided.
  14455. */
  14456. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14457. /**
  14458. * Get all child-transformNodes of this node
  14459. * @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
  14460. * @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
  14461. * @returns an array of TransformNode
  14462. */
  14463. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14464. /**
  14465. * Releases resources associated with this transform node.
  14466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14468. */
  14469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14470. /**
  14471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14475. * @returns the current mesh
  14476. */
  14477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14478. private _syncAbsoluteScalingAndRotation;
  14479. }
  14480. }
  14481. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14487. import { Ray } from "babylonjs/Culling/ray";
  14488. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14489. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14491. /**
  14492. * Defines the types of pose enabled controllers that are supported
  14493. */
  14494. export enum PoseEnabledControllerType {
  14495. /**
  14496. * HTC Vive
  14497. */
  14498. VIVE = 0,
  14499. /**
  14500. * Oculus Rift
  14501. */
  14502. OCULUS = 1,
  14503. /**
  14504. * Windows mixed reality
  14505. */
  14506. WINDOWS = 2,
  14507. /**
  14508. * Samsung gear VR
  14509. */
  14510. GEAR_VR = 3,
  14511. /**
  14512. * Google Daydream
  14513. */
  14514. DAYDREAM = 4,
  14515. /**
  14516. * Generic
  14517. */
  14518. GENERIC = 5
  14519. }
  14520. /**
  14521. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14522. */
  14523. export interface MutableGamepadButton {
  14524. /**
  14525. * Value of the button/trigger
  14526. */
  14527. value: number;
  14528. /**
  14529. * If the button/trigger is currently touched
  14530. */
  14531. touched: boolean;
  14532. /**
  14533. * If the button/trigger is currently pressed
  14534. */
  14535. pressed: boolean;
  14536. }
  14537. /**
  14538. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14539. * @hidden
  14540. */
  14541. export interface ExtendedGamepadButton extends GamepadButton {
  14542. /**
  14543. * If the button/trigger is currently pressed
  14544. */
  14545. readonly pressed: boolean;
  14546. /**
  14547. * If the button/trigger is currently touched
  14548. */
  14549. readonly touched: boolean;
  14550. /**
  14551. * Value of the button/trigger
  14552. */
  14553. readonly value: number;
  14554. }
  14555. /** @hidden */
  14556. export interface _GamePadFactory {
  14557. /**
  14558. * Returns wether or not the current gamepad can be created for this type of controller.
  14559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14560. * @returns true if it can be created, otherwise false
  14561. */
  14562. canCreate(gamepadInfo: any): boolean;
  14563. /**
  14564. * Creates a new instance of the Gamepad.
  14565. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14566. * @returns the new gamepad instance
  14567. */
  14568. create(gamepadInfo: any): Gamepad;
  14569. }
  14570. /**
  14571. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14572. */
  14573. export class PoseEnabledControllerHelper {
  14574. /** @hidden */
  14575. static _ControllerFactories: _GamePadFactory[];
  14576. /** @hidden */
  14577. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14578. /**
  14579. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14580. * @param vrGamepad the gamepad to initialized
  14581. * @returns a vr controller of the type the gamepad identified as
  14582. */
  14583. static InitiateController(vrGamepad: any): Gamepad;
  14584. }
  14585. /**
  14586. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14587. */
  14588. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14589. /**
  14590. * If the controller is used in a webXR session
  14591. */
  14592. isXR: boolean;
  14593. private _deviceRoomPosition;
  14594. private _deviceRoomRotationQuaternion;
  14595. /**
  14596. * The device position in babylon space
  14597. */
  14598. devicePosition: Vector3;
  14599. /**
  14600. * The device rotation in babylon space
  14601. */
  14602. deviceRotationQuaternion: Quaternion;
  14603. /**
  14604. * The scale factor of the device in babylon space
  14605. */
  14606. deviceScaleFactor: number;
  14607. /**
  14608. * (Likely devicePosition should be used instead) The device position in its room space
  14609. */
  14610. position: Vector3;
  14611. /**
  14612. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14613. */
  14614. rotationQuaternion: Quaternion;
  14615. /**
  14616. * The type of controller (Eg. Windows mixed reality)
  14617. */
  14618. controllerType: PoseEnabledControllerType;
  14619. protected _calculatedPosition: Vector3;
  14620. private _calculatedRotation;
  14621. /**
  14622. * The raw pose from the device
  14623. */
  14624. rawPose: DevicePose;
  14625. private _trackPosition;
  14626. private _maxRotationDistFromHeadset;
  14627. private _draggedRoomRotation;
  14628. /**
  14629. * @hidden
  14630. */
  14631. _disableTrackPosition(fixedPosition: Vector3): void;
  14632. /**
  14633. * Internal, the mesh attached to the controller
  14634. * @hidden
  14635. */
  14636. _mesh: Nullable<AbstractMesh>;
  14637. private _poseControlledCamera;
  14638. private _leftHandSystemQuaternion;
  14639. /**
  14640. * Internal, matrix used to convert room space to babylon space
  14641. * @hidden
  14642. */
  14643. _deviceToWorld: Matrix;
  14644. /**
  14645. * Node to be used when casting a ray from the controller
  14646. * @hidden
  14647. */
  14648. _pointingPoseNode: Nullable<TransformNode>;
  14649. /**
  14650. * Name of the child mesh that can be used to cast a ray from the controller
  14651. */
  14652. static readonly POINTING_POSE: string;
  14653. /**
  14654. * Creates a new PoseEnabledController from a gamepad
  14655. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14656. */
  14657. constructor(browserGamepad: any);
  14658. private _workingMatrix;
  14659. /**
  14660. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14661. */
  14662. update(): void;
  14663. /**
  14664. * Updates only the pose device and mesh without doing any button event checking
  14665. */
  14666. protected _updatePoseAndMesh(): void;
  14667. /**
  14668. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14669. * @param poseData raw pose fromthe device
  14670. */
  14671. updateFromDevice(poseData: DevicePose): void;
  14672. /**
  14673. * @hidden
  14674. */
  14675. _meshAttachedObservable: Observable<AbstractMesh>;
  14676. /**
  14677. * Attaches a mesh to the controller
  14678. * @param mesh the mesh to be attached
  14679. */
  14680. attachToMesh(mesh: AbstractMesh): void;
  14681. /**
  14682. * Attaches the controllers mesh to a camera
  14683. * @param camera the camera the mesh should be attached to
  14684. */
  14685. attachToPoseControlledCamera(camera: TargetCamera): void;
  14686. /**
  14687. * Disposes of the controller
  14688. */
  14689. dispose(): void;
  14690. /**
  14691. * The mesh that is attached to the controller
  14692. */
  14693. readonly mesh: Nullable<AbstractMesh>;
  14694. /**
  14695. * Gets the ray of the controller in the direction the controller is pointing
  14696. * @param length the length the resulting ray should be
  14697. * @returns a ray in the direction the controller is pointing
  14698. */
  14699. getForwardRay(length?: number): Ray;
  14700. }
  14701. }
  14702. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14703. import { Observable } from "babylonjs/Misc/observable";
  14704. import { Scene } from "babylonjs/scene";
  14705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14706. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14707. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14708. import { Nullable } from "babylonjs/types";
  14709. /**
  14710. * Defines the WebVRController object that represents controllers tracked in 3D space
  14711. */
  14712. export abstract class WebVRController extends PoseEnabledController {
  14713. /**
  14714. * Internal, the default controller model for the controller
  14715. */
  14716. protected _defaultModel: Nullable<AbstractMesh>;
  14717. /**
  14718. * Fired when the trigger state has changed
  14719. */
  14720. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14721. /**
  14722. * Fired when the main button state has changed
  14723. */
  14724. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the secondary button state has changed
  14727. */
  14728. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when the pad state has changed
  14731. */
  14732. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14733. /**
  14734. * Fired when controllers stick values have changed
  14735. */
  14736. onPadValuesChangedObservable: Observable<StickValues>;
  14737. /**
  14738. * Array of button availible on the controller
  14739. */
  14740. protected _buttons: Array<MutableGamepadButton>;
  14741. private _onButtonStateChange;
  14742. /**
  14743. * Fired when a controller button's state has changed
  14744. * @param callback the callback containing the button that was modified
  14745. */
  14746. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14747. /**
  14748. * X and Y axis corresponding to the controllers joystick
  14749. */
  14750. pad: StickValues;
  14751. /**
  14752. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14753. */
  14754. hand: string;
  14755. /**
  14756. * The default controller model for the controller
  14757. */
  14758. readonly defaultModel: Nullable<AbstractMesh>;
  14759. /**
  14760. * Creates a new WebVRController from a gamepad
  14761. * @param vrGamepad the gamepad that the WebVRController should be created from
  14762. */
  14763. constructor(vrGamepad: any);
  14764. /**
  14765. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14766. */
  14767. update(): void;
  14768. /**
  14769. * Function to be called when a button is modified
  14770. */
  14771. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14772. /**
  14773. * Loads a mesh and attaches it to the controller
  14774. * @param scene the scene the mesh should be added to
  14775. * @param meshLoaded callback for when the mesh has been loaded
  14776. */
  14777. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14778. private _setButtonValue;
  14779. private _changes;
  14780. private _checkChanges;
  14781. /**
  14782. * Disposes of th webVRCOntroller
  14783. */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Lights/hemisphericLight" {
  14788. import { Nullable } from "babylonjs/types";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14791. import { Color3 } from "babylonjs/Maths/math.color";
  14792. import { Effect } from "babylonjs/Materials/effect";
  14793. import { Light } from "babylonjs/Lights/light";
  14794. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14795. /**
  14796. * The HemisphericLight simulates the ambient environment light,
  14797. * so the passed direction is the light reflection direction, not the incoming direction.
  14798. */
  14799. export class HemisphericLight extends Light {
  14800. /**
  14801. * The groundColor is the light in the opposite direction to the one specified during creation.
  14802. * 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.
  14803. */
  14804. groundColor: Color3;
  14805. /**
  14806. * The light reflection direction, not the incoming direction.
  14807. */
  14808. direction: Vector3;
  14809. /**
  14810. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14811. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14812. * The HemisphericLight can't cast shadows.
  14813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14814. * @param name The friendly name of the light
  14815. * @param direction The direction of the light reflection
  14816. * @param scene The scene the light belongs to
  14817. */
  14818. constructor(name: string, direction: Vector3, scene: Scene);
  14819. protected _buildUniformLayout(): void;
  14820. /**
  14821. * Returns the string "HemisphericLight".
  14822. * @return The class name
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14827. * Returns the updated direction.
  14828. * @param target The target the direction should point to
  14829. * @return The computed direction
  14830. */
  14831. setDirectionToTarget(target: Vector3): Vector3;
  14832. /**
  14833. * Returns the shadow generator associated to the light.
  14834. * @returns Always null for hemispheric lights because it does not support shadows.
  14835. */
  14836. getShadowGenerator(): Nullable<IShadowGenerator>;
  14837. /**
  14838. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14839. * @param effect The effect to update
  14840. * @param lightIndex The index of the light in the effect to update
  14841. * @returns The hemispheric light
  14842. */
  14843. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14844. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14845. /**
  14846. * Computes the world matrix of the node
  14847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14848. * @param useWasUpdatedFlag defines a reserved property
  14849. * @returns the world matrix
  14850. */
  14851. computeWorldMatrix(): Matrix;
  14852. /**
  14853. * Returns the integer 3.
  14854. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14855. */
  14856. getTypeID(): number;
  14857. /**
  14858. * Prepares the list of defines specific to the light type.
  14859. * @param defines the list of defines
  14860. * @param lightIndex defines the index of the light for the effect
  14861. */
  14862. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14863. }
  14864. }
  14865. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14866. /** @hidden */
  14867. export var vrMultiviewToSingleviewPixelShader: {
  14868. name: string;
  14869. shader: string;
  14870. };
  14871. }
  14872. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14874. import { Scene } from "babylonjs/scene";
  14875. /**
  14876. * Renders to multiple views with a single draw call
  14877. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14878. */
  14879. export class MultiviewRenderTarget extends RenderTargetTexture {
  14880. /**
  14881. * Creates a multiview render target
  14882. * @param scene scene used with the render target
  14883. * @param size the size of the render target (used for each view)
  14884. */
  14885. constructor(scene: Scene, size?: number | {
  14886. width: number;
  14887. height: number;
  14888. } | {
  14889. ratio: number;
  14890. });
  14891. /**
  14892. * @hidden
  14893. * @param faceIndex the face index, if its a cube texture
  14894. */
  14895. _bindFrameBuffer(faceIndex?: number): void;
  14896. /**
  14897. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14898. * @returns the view count
  14899. */
  14900. getViewCount(): number;
  14901. }
  14902. }
  14903. declare module "babylonjs/Maths/math.frustum" {
  14904. import { Matrix } from "babylonjs/Maths/math.vector";
  14905. import { DeepImmutable } from "babylonjs/types";
  14906. import { Plane } from "babylonjs/Maths/math.plane";
  14907. /**
  14908. * Represents a camera frustum
  14909. */
  14910. export class Frustum {
  14911. /**
  14912. * Gets the planes representing the frustum
  14913. * @param transform matrix to be applied to the returned planes
  14914. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14915. */
  14916. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14917. /**
  14918. * Gets the near frustum plane transformed by the transform matrix
  14919. * @param transform transformation matrix to be applied to the resulting frustum plane
  14920. * @param frustumPlane the resuling frustum plane
  14921. */
  14922. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14923. /**
  14924. * Gets the far frustum plane transformed by the transform matrix
  14925. * @param transform transformation matrix to be applied to the resulting frustum plane
  14926. * @param frustumPlane the resuling frustum plane
  14927. */
  14928. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14929. /**
  14930. * Gets the left frustum plane transformed by the transform matrix
  14931. * @param transform transformation matrix to be applied to the resulting frustum plane
  14932. * @param frustumPlane the resuling frustum plane
  14933. */
  14934. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14935. /**
  14936. * Gets the right frustum plane transformed by the transform matrix
  14937. * @param transform transformation matrix to be applied to the resulting frustum plane
  14938. * @param frustumPlane the resuling frustum plane
  14939. */
  14940. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14941. /**
  14942. * Gets the top frustum plane transformed by the transform matrix
  14943. * @param transform transformation matrix to be applied to the resulting frustum plane
  14944. * @param frustumPlane the resuling frustum plane
  14945. */
  14946. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14947. /**
  14948. * Gets the bottom frustum plane transformed by the transform matrix
  14949. * @param transform transformation matrix to be applied to the resulting frustum plane
  14950. * @param frustumPlane the resuling frustum plane
  14951. */
  14952. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14953. /**
  14954. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14955. * @param transform transformation matrix to be applied to the resulting frustum planes
  14956. * @param frustumPlanes the resuling frustum planes
  14957. */
  14958. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14959. }
  14960. }
  14961. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14962. import { Camera } from "babylonjs/Cameras/camera";
  14963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14964. import { Nullable } from "babylonjs/types";
  14965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14966. import { Matrix } from "babylonjs/Maths/math.vector";
  14967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14968. module "babylonjs/Engines/engine" {
  14969. interface Engine {
  14970. /**
  14971. * Creates a new multiview render target
  14972. * @param width defines the width of the texture
  14973. * @param height defines the height of the texture
  14974. * @returns the created multiview texture
  14975. */
  14976. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14977. /**
  14978. * Binds a multiview framebuffer to be drawn to
  14979. * @param multiviewTexture texture to bind
  14980. */
  14981. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14982. }
  14983. }
  14984. module "babylonjs/Cameras/camera" {
  14985. interface Camera {
  14986. /**
  14987. * @hidden
  14988. * 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)
  14989. */
  14990. _useMultiviewToSingleView: boolean;
  14991. /**
  14992. * @hidden
  14993. * 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)
  14994. */
  14995. _multiviewTexture: Nullable<RenderTargetTexture>;
  14996. /**
  14997. * @hidden
  14998. * ensures the multiview texture of the camera exists and has the specified width/height
  14999. * @param width height to set on the multiview texture
  15000. * @param height width to set on the multiview texture
  15001. */
  15002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15003. }
  15004. }
  15005. module "babylonjs/scene" {
  15006. interface Scene {
  15007. /** @hidden */
  15008. _transformMatrixR: Matrix;
  15009. /** @hidden */
  15010. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15011. /** @hidden */
  15012. _createMultiviewUbo(): void;
  15013. /** @hidden */
  15014. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15015. /** @hidden */
  15016. _renderMultiviewToSingleView(camera: Camera): void;
  15017. }
  15018. }
  15019. }
  15020. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15021. import { Camera } from "babylonjs/Cameras/camera";
  15022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15023. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15024. import "babylonjs/Engines/Extensions/engine.multiview";
  15025. /**
  15026. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15027. * This will not be used for webXR as it supports displaying texture arrays directly
  15028. */
  15029. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15030. /**
  15031. * Initializes a VRMultiviewToSingleview
  15032. * @param name name of the post process
  15033. * @param camera camera to be applied to
  15034. * @param scaleFactor scaling factor to the size of the output texture
  15035. */
  15036. constructor(name: string, camera: Camera, scaleFactor: number);
  15037. }
  15038. }
  15039. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15040. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15041. import { Nullable } from "babylonjs/types";
  15042. import { Size } from "babylonjs/Maths/math.size";
  15043. import { Observable } from "babylonjs/Misc/observable";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /** @hidden */
  15047. _vrDisplay: any;
  15048. /** @hidden */
  15049. _vrSupported: boolean;
  15050. /** @hidden */
  15051. _oldSize: Size;
  15052. /** @hidden */
  15053. _oldHardwareScaleFactor: number;
  15054. /** @hidden */
  15055. _vrExclusivePointerMode: boolean;
  15056. /** @hidden */
  15057. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _onVRDisplayPointerRestricted: () => void;
  15060. /** @hidden */
  15061. _onVRDisplayPointerUnrestricted: () => void;
  15062. /** @hidden */
  15063. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15064. /** @hidden */
  15065. _onVrDisplayDisconnect: Nullable<() => void>;
  15066. /** @hidden */
  15067. _onVrDisplayPresentChange: Nullable<() => void>;
  15068. /**
  15069. * Observable signaled when VR display mode changes
  15070. */
  15071. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15072. /**
  15073. * Observable signaled when VR request present is complete
  15074. */
  15075. onVRRequestPresentComplete: Observable<boolean>;
  15076. /**
  15077. * Observable signaled when VR request present starts
  15078. */
  15079. onVRRequestPresentStart: Observable<Engine>;
  15080. /**
  15081. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15082. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15083. */
  15084. isInVRExclusivePointerMode: boolean;
  15085. /**
  15086. * Gets a boolean indicating if a webVR device was detected
  15087. * @returns true if a webVR device was detected
  15088. */
  15089. isVRDevicePresent(): boolean;
  15090. /**
  15091. * Gets the current webVR device
  15092. * @returns the current webVR device (or null)
  15093. */
  15094. getVRDevice(): any;
  15095. /**
  15096. * Initializes a webVR display and starts listening to display change events
  15097. * The onVRDisplayChangedObservable will be notified upon these changes
  15098. * @returns A promise containing a VRDisplay and if vr is supported
  15099. */
  15100. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15101. /** @hidden */
  15102. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /**
  15104. * Call this function to switch to webVR mode
  15105. * Will do nothing if webVR is not supported or if there is no webVR device
  15106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15107. */
  15108. enableVR(): void;
  15109. /** @hidden */
  15110. _onVRFullScreenTriggered(): void;
  15111. }
  15112. }
  15113. }
  15114. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15115. import { Nullable } from "babylonjs/types";
  15116. import { Observable } from "babylonjs/Misc/observable";
  15117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15118. import { Scene } from "babylonjs/scene";
  15119. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15121. import { Node } from "babylonjs/node";
  15122. import { Ray } from "babylonjs/Culling/ray";
  15123. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15124. import "babylonjs/Engines/Extensions/engine.webVR";
  15125. /**
  15126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15127. * IMPORTANT!! The data is right-hand data.
  15128. * @export
  15129. * @interface DevicePose
  15130. */
  15131. export interface DevicePose {
  15132. /**
  15133. * The position of the device, values in array are [x,y,z].
  15134. */
  15135. readonly position: Nullable<Float32Array>;
  15136. /**
  15137. * The linearVelocity of the device, values in array are [x,y,z].
  15138. */
  15139. readonly linearVelocity: Nullable<Float32Array>;
  15140. /**
  15141. * The linearAcceleration of the device, values in array are [x,y,z].
  15142. */
  15143. readonly linearAcceleration: Nullable<Float32Array>;
  15144. /**
  15145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15146. */
  15147. readonly orientation: Nullable<Float32Array>;
  15148. /**
  15149. * The angularVelocity of the device, values in array are [x,y,z].
  15150. */
  15151. readonly angularVelocity: Nullable<Float32Array>;
  15152. /**
  15153. * The angularAcceleration of the device, values in array are [x,y,z].
  15154. */
  15155. readonly angularAcceleration: Nullable<Float32Array>;
  15156. }
  15157. /**
  15158. * Interface representing a pose controlled object in Babylon.
  15159. * A pose controlled object has both regular pose values as well as pose values
  15160. * from an external device such as a VR head mounted display
  15161. */
  15162. export interface PoseControlled {
  15163. /**
  15164. * The position of the object in babylon space.
  15165. */
  15166. position: Vector3;
  15167. /**
  15168. * The rotation quaternion of the object in babylon space.
  15169. */
  15170. rotationQuaternion: Quaternion;
  15171. /**
  15172. * The position of the device in babylon space.
  15173. */
  15174. devicePosition?: Vector3;
  15175. /**
  15176. * The rotation quaternion of the device in babylon space.
  15177. */
  15178. deviceRotationQuaternion: Quaternion;
  15179. /**
  15180. * The raw pose coming from the device.
  15181. */
  15182. rawPose: Nullable<DevicePose>;
  15183. /**
  15184. * The scale of the device to be used when translating from device space to babylon space.
  15185. */
  15186. deviceScaleFactor: number;
  15187. /**
  15188. * Updates the poseControlled values based on the input device pose.
  15189. * @param poseData the pose data to update the object with
  15190. */
  15191. updateFromDevice(poseData: DevicePose): void;
  15192. }
  15193. /**
  15194. * Set of options to customize the webVRCamera
  15195. */
  15196. export interface WebVROptions {
  15197. /**
  15198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15199. */
  15200. trackPosition?: boolean;
  15201. /**
  15202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15203. */
  15204. positionScale?: number;
  15205. /**
  15206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15207. */
  15208. displayName?: string;
  15209. /**
  15210. * Should the native controller meshes be initialized. (default: true)
  15211. */
  15212. controllerMeshes?: boolean;
  15213. /**
  15214. * Creating a default HemiLight only on controllers. (default: true)
  15215. */
  15216. defaultLightingOnControllers?: boolean;
  15217. /**
  15218. * If you don't want to use the default VR button of the helper. (default: false)
  15219. */
  15220. useCustomVRButton?: boolean;
  15221. /**
  15222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15223. */
  15224. customVRButton?: HTMLButtonElement;
  15225. /**
  15226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15227. */
  15228. rayLength?: number;
  15229. /**
  15230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15231. */
  15232. defaultHeight?: number;
  15233. /**
  15234. * If multiview should be used if availible (default: false)
  15235. */
  15236. useMultiview?: boolean;
  15237. }
  15238. /**
  15239. * This represents a WebVR camera.
  15240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15241. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15244. private webVROptions;
  15245. /**
  15246. * @hidden
  15247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15248. */
  15249. _vrDevice: any;
  15250. /**
  15251. * The rawPose of the vrDevice.
  15252. */
  15253. rawPose: Nullable<DevicePose>;
  15254. private _onVREnabled;
  15255. private _specsVersion;
  15256. private _attached;
  15257. private _frameData;
  15258. protected _descendants: Array<Node>;
  15259. private _deviceRoomPosition;
  15260. /** @hidden */
  15261. _deviceRoomRotationQuaternion: Quaternion;
  15262. private _standingMatrix;
  15263. /**
  15264. * Represents device position in babylon space.
  15265. */
  15266. devicePosition: Vector3;
  15267. /**
  15268. * Represents device rotation in babylon space.
  15269. */
  15270. deviceRotationQuaternion: Quaternion;
  15271. /**
  15272. * The scale of the device to be used when translating from device space to babylon space.
  15273. */
  15274. deviceScaleFactor: number;
  15275. private _deviceToWorld;
  15276. private _worldToDevice;
  15277. /**
  15278. * References to the webVR controllers for the vrDevice.
  15279. */
  15280. controllers: Array<WebVRController>;
  15281. /**
  15282. * Emits an event when a controller is attached.
  15283. */
  15284. onControllersAttachedObservable: Observable<WebVRController[]>;
  15285. /**
  15286. * Emits an event when a controller's mesh has been loaded;
  15287. */
  15288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15289. /**
  15290. * Emits an event when the HMD's pose has been updated.
  15291. */
  15292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15293. private _poseSet;
  15294. /**
  15295. * If the rig cameras be used as parent instead of this camera.
  15296. */
  15297. rigParenting: boolean;
  15298. private _lightOnControllers;
  15299. private _defaultHeight?;
  15300. /**
  15301. * Instantiates a WebVRFreeCamera.
  15302. * @param name The name of the WebVRFreeCamera
  15303. * @param position The starting anchor position for the camera
  15304. * @param scene The scene the camera belongs to
  15305. * @param webVROptions a set of customizable options for the webVRCamera
  15306. */
  15307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15308. /**
  15309. * Gets the device distance from the ground in meters.
  15310. * @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.
  15311. */
  15312. deviceDistanceToRoomGround(): number;
  15313. /**
  15314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15316. */
  15317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15318. /**
  15319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15320. * @returns A promise with a boolean set to if the standing matrix is supported.
  15321. */
  15322. useStandingMatrixAsync(): Promise<boolean>;
  15323. /**
  15324. * Disposes the camera
  15325. */
  15326. dispose(): void;
  15327. /**
  15328. * Gets a vrController by name.
  15329. * @param name The name of the controller to retreive
  15330. * @returns the controller matching the name specified or null if not found
  15331. */
  15332. getControllerByName(name: string): Nullable<WebVRController>;
  15333. private _leftController;
  15334. /**
  15335. * The controller corresponding to the users left hand.
  15336. */
  15337. readonly leftController: Nullable<WebVRController>;
  15338. private _rightController;
  15339. /**
  15340. * The controller corresponding to the users right hand.
  15341. */
  15342. readonly rightController: Nullable<WebVRController>;
  15343. /**
  15344. * Casts a ray forward from the vrCamera's gaze.
  15345. * @param length Length of the ray (default: 100)
  15346. * @returns the ray corresponding to the gaze
  15347. */
  15348. getForwardRay(length?: number): Ray;
  15349. /**
  15350. * @hidden
  15351. * Updates the camera based on device's frame data
  15352. */
  15353. _checkInputs(): void;
  15354. /**
  15355. * Updates the poseControlled values based on the input device pose.
  15356. * @param poseData Pose coming from the device
  15357. */
  15358. updateFromDevice(poseData: DevicePose): void;
  15359. private _htmlElementAttached;
  15360. private _detachIfAttached;
  15361. /**
  15362. * WebVR's attach control will start broadcasting frames to the device.
  15363. * Note that in certain browsers (chrome for example) this function must be called
  15364. * within a user-interaction callback. Example:
  15365. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15366. *
  15367. * @param element html element to attach the vrDevice to
  15368. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15369. */
  15370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15371. /**
  15372. * Detaches the camera from the html element and disables VR
  15373. *
  15374. * @param element html element to detach from
  15375. */
  15376. detachControl(element: HTMLElement): void;
  15377. /**
  15378. * @returns the name of this class
  15379. */
  15380. getClassName(): string;
  15381. /**
  15382. * Calls resetPose on the vrDisplay
  15383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15384. */
  15385. resetToCurrentRotation(): void;
  15386. /**
  15387. * @hidden
  15388. * Updates the rig cameras (left and right eye)
  15389. */
  15390. _updateRigCameras(): void;
  15391. private _workingVector;
  15392. private _oneVector;
  15393. private _workingMatrix;
  15394. private updateCacheCalled;
  15395. private _correctPositionIfNotTrackPosition;
  15396. /**
  15397. * @hidden
  15398. * Updates the cached values of the camera
  15399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15400. */
  15401. _updateCache(ignoreParentClass?: boolean): void;
  15402. /**
  15403. * @hidden
  15404. * Get current device position in babylon world
  15405. */
  15406. _computeDevicePosition(): void;
  15407. /**
  15408. * Updates the current device position and rotation in the babylon world
  15409. */
  15410. update(): void;
  15411. /**
  15412. * @hidden
  15413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15414. * @returns an identity matrix
  15415. */
  15416. _getViewMatrix(): Matrix;
  15417. private _tmpMatrix;
  15418. /**
  15419. * This function is called by the two RIG cameras.
  15420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15421. * @hidden
  15422. */
  15423. _getWebVRViewMatrix(): Matrix;
  15424. /** @hidden */
  15425. _getWebVRProjectionMatrix(): Matrix;
  15426. private _onGamepadConnectedObserver;
  15427. private _onGamepadDisconnectedObserver;
  15428. private _updateCacheWhenTrackingDisabledObserver;
  15429. /**
  15430. * Initializes the controllers and their meshes
  15431. */
  15432. initControllers(): void;
  15433. }
  15434. }
  15435. declare module "babylonjs/PostProcesses/postProcess" {
  15436. import { Nullable } from "babylonjs/types";
  15437. import { SmartArray } from "babylonjs/Misc/smartArray";
  15438. import { Observable } from "babylonjs/Misc/observable";
  15439. import { Vector2 } from "babylonjs/Maths/math.vector";
  15440. import { Camera } from "babylonjs/Cameras/camera";
  15441. import { Effect } from "babylonjs/Materials/effect";
  15442. import "babylonjs/Shaders/postprocess.vertex";
  15443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15444. import { Engine } from "babylonjs/Engines/engine";
  15445. import { Color4 } from "babylonjs/Maths/math.color";
  15446. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15448. /**
  15449. * Size options for a post process
  15450. */
  15451. export type PostProcessOptions = {
  15452. width: number;
  15453. height: number;
  15454. };
  15455. /**
  15456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15458. */
  15459. export class PostProcess {
  15460. /** Name of the PostProcess. */
  15461. name: string;
  15462. /**
  15463. * Gets or sets the unique id of the post process
  15464. */
  15465. uniqueId: number;
  15466. /**
  15467. * Width of the texture to apply the post process on
  15468. */
  15469. width: number;
  15470. /**
  15471. * Height of the texture to apply the post process on
  15472. */
  15473. height: number;
  15474. /**
  15475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15476. * @hidden
  15477. */
  15478. _outputTexture: Nullable<InternalTexture>;
  15479. /**
  15480. * Sampling mode used by the shader
  15481. * See https://doc.babylonjs.com/classes/3.1/texture
  15482. */
  15483. renderTargetSamplingMode: number;
  15484. /**
  15485. * Clear color to use when screen clearing
  15486. */
  15487. clearColor: Color4;
  15488. /**
  15489. * If the buffer needs to be cleared before applying the post process. (default: true)
  15490. * Should be set to false if shader will overwrite all previous pixels.
  15491. */
  15492. autoClear: boolean;
  15493. /**
  15494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15495. */
  15496. alphaMode: number;
  15497. /**
  15498. * Sets the setAlphaBlendConstants of the babylon engine
  15499. */
  15500. alphaConstants: Color4;
  15501. /**
  15502. * Animations to be used for the post processing
  15503. */
  15504. animations: import("babylonjs/Animations/animation").Animation[];
  15505. /**
  15506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15508. */
  15509. enablePixelPerfectMode: boolean;
  15510. /**
  15511. * Force the postprocess to be applied without taking in account viewport
  15512. */
  15513. forceFullscreenViewport: boolean;
  15514. /**
  15515. * List of inspectable custom properties (used by the Inspector)
  15516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15517. */
  15518. inspectableCustomProperties: IInspectable[];
  15519. /**
  15520. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15521. *
  15522. * | Value | Type | Description |
  15523. * | ----- | ----------------------------------- | ----------- |
  15524. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15525. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15526. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15527. *
  15528. */
  15529. scaleMode: number;
  15530. /**
  15531. * Force textures to be a power of two (default: false)
  15532. */
  15533. alwaysForcePOT: boolean;
  15534. private _samples;
  15535. /**
  15536. * Number of sample textures (default: 1)
  15537. */
  15538. samples: number;
  15539. /**
  15540. * Modify the scale of the post process to be the same as the viewport (default: false)
  15541. */
  15542. adaptScaleToCurrentViewport: boolean;
  15543. private _camera;
  15544. private _scene;
  15545. private _engine;
  15546. private _options;
  15547. private _reusable;
  15548. private _textureType;
  15549. /**
  15550. * Smart array of input and output textures for the post process.
  15551. * @hidden
  15552. */
  15553. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15554. /**
  15555. * The index in _textures that corresponds to the output texture.
  15556. * @hidden
  15557. */
  15558. _currentRenderTextureInd: number;
  15559. private _effect;
  15560. private _samplers;
  15561. private _fragmentUrl;
  15562. private _vertexUrl;
  15563. private _parameters;
  15564. private _scaleRatio;
  15565. protected _indexParameters: any;
  15566. private _shareOutputWithPostProcess;
  15567. private _texelSize;
  15568. private _forcedOutputTexture;
  15569. /**
  15570. * Returns the fragment url or shader name used in the post process.
  15571. * @returns the fragment url or name in the shader store.
  15572. */
  15573. getEffectName(): string;
  15574. /**
  15575. * An event triggered when the postprocess is activated.
  15576. */
  15577. onActivateObservable: Observable<Camera>;
  15578. private _onActivateObserver;
  15579. /**
  15580. * A function that is added to the onActivateObservable
  15581. */
  15582. onActivate: Nullable<(camera: Camera) => void>;
  15583. /**
  15584. * An event triggered when the postprocess changes its size.
  15585. */
  15586. onSizeChangedObservable: Observable<PostProcess>;
  15587. private _onSizeChangedObserver;
  15588. /**
  15589. * A function that is added to the onSizeChangedObservable
  15590. */
  15591. onSizeChanged: (postProcess: PostProcess) => void;
  15592. /**
  15593. * An event triggered when the postprocess applies its effect.
  15594. */
  15595. onApplyObservable: Observable<Effect>;
  15596. private _onApplyObserver;
  15597. /**
  15598. * A function that is added to the onApplyObservable
  15599. */
  15600. onApply: (effect: Effect) => void;
  15601. /**
  15602. * An event triggered before rendering the postprocess
  15603. */
  15604. onBeforeRenderObservable: Observable<Effect>;
  15605. private _onBeforeRenderObserver;
  15606. /**
  15607. * A function that is added to the onBeforeRenderObservable
  15608. */
  15609. onBeforeRender: (effect: Effect) => void;
  15610. /**
  15611. * An event triggered after rendering the postprocess
  15612. */
  15613. onAfterRenderObservable: Observable<Effect>;
  15614. private _onAfterRenderObserver;
  15615. /**
  15616. * A function that is added to the onAfterRenderObservable
  15617. */
  15618. onAfterRender: (efect: Effect) => void;
  15619. /**
  15620. * 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
  15621. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15622. */
  15623. inputTexture: InternalTexture;
  15624. /**
  15625. * Gets the camera which post process is applied to.
  15626. * @returns The camera the post process is applied to.
  15627. */
  15628. getCamera(): Camera;
  15629. /**
  15630. * Gets the texel size of the postprocess.
  15631. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15632. */
  15633. readonly texelSize: Vector2;
  15634. /**
  15635. * Creates a new instance PostProcess
  15636. * @param name The name of the PostProcess.
  15637. * @param fragmentUrl The url of the fragment shader to be used.
  15638. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15639. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15640. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15641. * @param camera The camera to apply the render pass to.
  15642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15643. * @param engine The engine which the post process will be applied. (default: current engine)
  15644. * @param reusable If the post process can be reused on the same frame. (default: false)
  15645. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15646. * @param textureType Type of textures used when performing the post process. (default: 0)
  15647. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15648. * @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
  15649. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15650. */
  15651. constructor(
  15652. /** Name of the PostProcess. */
  15653. 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);
  15654. /**
  15655. * Gets a string idenfifying the name of the class
  15656. * @returns "PostProcess" string
  15657. */
  15658. getClassName(): string;
  15659. /**
  15660. * Gets the engine which this post process belongs to.
  15661. * @returns The engine the post process was enabled with.
  15662. */
  15663. getEngine(): Engine;
  15664. /**
  15665. * The effect that is created when initializing the post process.
  15666. * @returns The created effect corresponding the the postprocess.
  15667. */
  15668. getEffect(): Effect;
  15669. /**
  15670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15671. * @param postProcess The post process to share the output with.
  15672. * @returns This post process.
  15673. */
  15674. shareOutputWith(postProcess: PostProcess): PostProcess;
  15675. /**
  15676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15678. */
  15679. useOwnOutput(): void;
  15680. /**
  15681. * Updates the effect with the current post process compile time values and recompiles the shader.
  15682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15685. * @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
  15686. * @param onCompiled Called when the shader has been compiled.
  15687. * @param onError Called if there is an error when compiling a shader.
  15688. */
  15689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15690. /**
  15691. * The post process is reusable if it can be used multiple times within one frame.
  15692. * @returns If the post process is reusable
  15693. */
  15694. isReusable(): boolean;
  15695. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15696. markTextureDirty(): void;
  15697. /**
  15698. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15699. * 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.
  15700. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15701. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15702. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15703. * @returns The target texture that was bound to be written to.
  15704. */
  15705. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15706. /**
  15707. * If the post process is supported.
  15708. */
  15709. readonly isSupported: boolean;
  15710. /**
  15711. * The aspect ratio of the output texture.
  15712. */
  15713. readonly aspectRatio: number;
  15714. /**
  15715. * Get a value indicating if the post-process is ready to be used
  15716. * @returns true if the post-process is ready (shader is compiled)
  15717. */
  15718. isReady(): boolean;
  15719. /**
  15720. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15721. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15722. */
  15723. apply(): Nullable<Effect>;
  15724. private _disposeTextures;
  15725. /**
  15726. * Disposes the post process.
  15727. * @param camera The camera to dispose the post process on.
  15728. */
  15729. dispose(camera?: Camera): void;
  15730. }
  15731. }
  15732. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15733. /** @hidden */
  15734. export var kernelBlurVaryingDeclaration: {
  15735. name: string;
  15736. shader: string;
  15737. };
  15738. }
  15739. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15740. /** @hidden */
  15741. export var kernelBlurFragment: {
  15742. name: string;
  15743. shader: string;
  15744. };
  15745. }
  15746. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15747. /** @hidden */
  15748. export var kernelBlurFragment2: {
  15749. name: string;
  15750. shader: string;
  15751. };
  15752. }
  15753. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15754. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15755. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15757. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15758. /** @hidden */
  15759. export var kernelBlurPixelShader: {
  15760. name: string;
  15761. shader: string;
  15762. };
  15763. }
  15764. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15765. /** @hidden */
  15766. export var kernelBlurVertex: {
  15767. name: string;
  15768. shader: string;
  15769. };
  15770. }
  15771. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15772. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15773. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15774. /** @hidden */
  15775. export var kernelBlurVertexShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15781. import { Vector2 } from "babylonjs/Maths/math.vector";
  15782. import { Nullable } from "babylonjs/types";
  15783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15784. import { Camera } from "babylonjs/Cameras/camera";
  15785. import { Effect } from "babylonjs/Materials/effect";
  15786. import { Engine } from "babylonjs/Engines/engine";
  15787. import "babylonjs/Shaders/kernelBlur.fragment";
  15788. import "babylonjs/Shaders/kernelBlur.vertex";
  15789. /**
  15790. * The Blur Post Process which blurs an image based on a kernel and direction.
  15791. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15792. */
  15793. export class BlurPostProcess extends PostProcess {
  15794. /** The direction in which to blur the image. */
  15795. direction: Vector2;
  15796. private blockCompilation;
  15797. protected _kernel: number;
  15798. protected _idealKernel: number;
  15799. protected _packedFloat: boolean;
  15800. private _staticDefines;
  15801. /**
  15802. * Sets the length in pixels of the blur sample region
  15803. */
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. kernel: number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. /**
  15812. * Gets wether or not the blur is unpacking/repacking floats
  15813. */
  15814. packedFloat: boolean;
  15815. /**
  15816. * Creates a new instance BlurPostProcess
  15817. * @param name The name of the effect.
  15818. * @param direction The direction in which to blur the image.
  15819. * @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.
  15820. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15821. * @param camera The camera to apply the render pass to.
  15822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15823. * @param engine The engine which the post process will be applied. (default: current engine)
  15824. * @param reusable If the post process can be reused on the same frame. (default: false)
  15825. * @param textureType Type of textures used when performing the post process. (default: 0)
  15826. * @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)
  15827. */
  15828. constructor(name: string,
  15829. /** The direction in which to blur the image. */
  15830. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15831. /**
  15832. * Updates the effect with the current post process compile time values and recompiles the shader.
  15833. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15834. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15835. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15836. * @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
  15837. * @param onCompiled Called when the shader has been compiled.
  15838. * @param onError Called if there is an error when compiling a shader.
  15839. */
  15840. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15841. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. /**
  15843. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15844. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15845. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15846. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15847. * The gaps between physical kernels are compensated for in the weighting of the samples
  15848. * @param idealKernel Ideal blur kernel.
  15849. * @return Nearest best kernel.
  15850. */
  15851. protected _nearestBestKernel(idealKernel: number): number;
  15852. /**
  15853. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15854. * @param x The point on the Gaussian distribution to sample.
  15855. * @return the value of the Gaussian function at x.
  15856. */
  15857. protected _gaussianWeight(x: number): number;
  15858. /**
  15859. * Generates a string that can be used as a floating point number in GLSL.
  15860. * @param x Value to print.
  15861. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15862. * @return GLSL float string.
  15863. */
  15864. protected _glslFloat(x: number, decimalFigures?: number): string;
  15865. }
  15866. }
  15867. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15868. import { Scene } from "babylonjs/scene";
  15869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15870. import { Plane } from "babylonjs/Maths/math.plane";
  15871. /**
  15872. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15873. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15874. * You can then easily use it as a reflectionTexture on a flat surface.
  15875. * In case the surface is not a plane, please consider relying on reflection probes.
  15876. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15877. */
  15878. export class MirrorTexture extends RenderTargetTexture {
  15879. private scene;
  15880. /**
  15881. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15882. * 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.
  15883. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15884. */
  15885. mirrorPlane: Plane;
  15886. /**
  15887. * Define the blur ratio used to blur the reflection if needed.
  15888. */
  15889. blurRatio: number;
  15890. /**
  15891. * Define the adaptive blur kernel used to blur the reflection if needed.
  15892. * This will autocompute the closest best match for the `blurKernel`
  15893. */
  15894. adaptiveBlurKernel: number;
  15895. /**
  15896. * Define the blur kernel used to blur the reflection if needed.
  15897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15898. */
  15899. blurKernel: number;
  15900. /**
  15901. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15902. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15903. */
  15904. blurKernelX: number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. blurKernelY: number;
  15910. private _autoComputeBlurKernel;
  15911. protected _onRatioRescale(): void;
  15912. private _updateGammaSpace;
  15913. private _imageProcessingConfigChangeObserver;
  15914. private _transformMatrix;
  15915. private _mirrorMatrix;
  15916. private _savedViewMatrix;
  15917. private _blurX;
  15918. private _blurY;
  15919. private _adaptiveBlurKernel;
  15920. private _blurKernelX;
  15921. private _blurKernelY;
  15922. private _blurRatio;
  15923. /**
  15924. * Instantiates a Mirror Texture.
  15925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15927. * You can then easily use it as a reflectionTexture on a flat surface.
  15928. * In case the surface is not a plane, please consider relying on reflection probes.
  15929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15930. * @param name
  15931. * @param size
  15932. * @param scene
  15933. * @param generateMipMaps
  15934. * @param type
  15935. * @param samplingMode
  15936. * @param generateDepthBuffer
  15937. */
  15938. constructor(name: string, size: number | {
  15939. width: number;
  15940. height: number;
  15941. } | {
  15942. ratio: number;
  15943. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15944. private _preparePostProcesses;
  15945. /**
  15946. * Clone the mirror texture.
  15947. * @returns the cloned texture
  15948. */
  15949. clone(): MirrorTexture;
  15950. /**
  15951. * Serialize the texture to a JSON representation you could use in Parse later on
  15952. * @returns the serialized JSON representation
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Dispose the texture and release its associated resources.
  15957. */
  15958. dispose(): void;
  15959. }
  15960. }
  15961. declare module "babylonjs/Materials/Textures/texture" {
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Nullable } from "babylonjs/types";
  15964. import { Matrix } from "babylonjs/Maths/math.vector";
  15965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15966. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15967. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15968. import { Scene } from "babylonjs/scene";
  15969. /**
  15970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15972. */
  15973. export class Texture extends BaseTexture {
  15974. /**
  15975. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15976. */
  15977. static SerializeBuffers: boolean;
  15978. /** @hidden */
  15979. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15980. /** @hidden */
  15981. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15982. /** @hidden */
  15983. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15984. /** nearest is mag = nearest and min = nearest and mip = linear */
  15985. static readonly NEAREST_SAMPLINGMODE: number;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15989. static readonly BILINEAR_SAMPLINGMODE: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15992. /** Trilinear is mag = linear and min = linear and mip = linear */
  15993. static readonly TRILINEAR_SAMPLINGMODE: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = nearest and mip = nearest */
  15997. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15998. /** mag = nearest and min = linear and mip = nearest */
  15999. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = linear */
  16001. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16002. /** mag = nearest and min = linear and mip = none */
  16003. static readonly NEAREST_LINEAR: number;
  16004. /** mag = nearest and min = nearest and mip = none */
  16005. static readonly NEAREST_NEAREST: number;
  16006. /** mag = linear and min = nearest and mip = nearest */
  16007. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16008. /** mag = linear and min = nearest and mip = linear */
  16009. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16010. /** mag = linear and min = linear and mip = none */
  16011. static readonly LINEAR_LINEAR: number;
  16012. /** mag = linear and min = nearest and mip = none */
  16013. static readonly LINEAR_NEAREST: number;
  16014. /** Explicit coordinates mode */
  16015. static readonly EXPLICIT_MODE: number;
  16016. /** Spherical coordinates mode */
  16017. static readonly SPHERICAL_MODE: number;
  16018. /** Planar coordinates mode */
  16019. static readonly PLANAR_MODE: number;
  16020. /** Cubic coordinates mode */
  16021. static readonly CUBIC_MODE: number;
  16022. /** Projection coordinates mode */
  16023. static readonly PROJECTION_MODE: number;
  16024. /** Inverse Cubic coordinates mode */
  16025. static readonly SKYBOX_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly INVCUBIC_MODE: number;
  16028. /** Equirectangular coordinates mode */
  16029. static readonly EQUIRECTANGULAR_MODE: number;
  16030. /** Equirectangular Fixed coordinates mode */
  16031. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed Mirrored coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16034. /** Texture is not repeating outside of 0..1 UVs */
  16035. static readonly CLAMP_ADDRESSMODE: number;
  16036. /** Texture is repeating outside of 0..1 UVs */
  16037. static readonly WRAP_ADDRESSMODE: number;
  16038. /** Texture is repeating and mirrored */
  16039. static readonly MIRROR_ADDRESSMODE: number;
  16040. /**
  16041. * 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
  16042. */
  16043. static UseSerializedUrlIfAny: boolean;
  16044. /**
  16045. * Define the url of the texture.
  16046. */
  16047. url: Nullable<string>;
  16048. /**
  16049. * Define an offset on the texture to offset the u coordinates of the UVs
  16050. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16051. */
  16052. uOffset: number;
  16053. /**
  16054. * Define an offset on the texture to offset the v coordinates of the UVs
  16055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16056. */
  16057. vOffset: number;
  16058. /**
  16059. * Define an offset on the texture to scale the u coordinates of the UVs
  16060. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16061. */
  16062. uScale: number;
  16063. /**
  16064. * Define an offset on the texture to scale the v coordinates of the UVs
  16065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16066. */
  16067. vScale: number;
  16068. /**
  16069. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16070. * @see http://doc.babylonjs.com/how_to/more_materials
  16071. */
  16072. uAng: number;
  16073. /**
  16074. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16075. * @see http://doc.babylonjs.com/how_to/more_materials
  16076. */
  16077. vAng: number;
  16078. /**
  16079. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16080. * @see http://doc.babylonjs.com/how_to/more_materials
  16081. */
  16082. wAng: number;
  16083. /**
  16084. * Defines the center of rotation (U)
  16085. */
  16086. uRotationCenter: number;
  16087. /**
  16088. * Defines the center of rotation (V)
  16089. */
  16090. vRotationCenter: number;
  16091. /**
  16092. * Defines the center of rotation (W)
  16093. */
  16094. wRotationCenter: number;
  16095. /**
  16096. * Are mip maps generated for this texture or not.
  16097. */
  16098. readonly noMipmap: boolean;
  16099. /**
  16100. * List of inspectable custom properties (used by the Inspector)
  16101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16102. */
  16103. inspectableCustomProperties: Nullable<IInspectable[]>;
  16104. private _noMipmap;
  16105. /** @hidden */
  16106. _invertY: boolean;
  16107. private _rowGenerationMatrix;
  16108. private _cachedTextureMatrix;
  16109. private _projectionModeMatrix;
  16110. private _t0;
  16111. private _t1;
  16112. private _t2;
  16113. private _cachedUOffset;
  16114. private _cachedVOffset;
  16115. private _cachedUScale;
  16116. private _cachedVScale;
  16117. private _cachedUAng;
  16118. private _cachedVAng;
  16119. private _cachedWAng;
  16120. private _cachedProjectionMatrixId;
  16121. private _cachedCoordinatesMode;
  16122. /** @hidden */
  16123. protected _initialSamplingMode: number;
  16124. /** @hidden */
  16125. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16126. private _deleteBuffer;
  16127. protected _format: Nullable<number>;
  16128. private _delayedOnLoad;
  16129. private _delayedOnError;
  16130. /**
  16131. * Observable triggered once the texture has been loaded.
  16132. */
  16133. onLoadObservable: Observable<Texture>;
  16134. protected _isBlocking: boolean;
  16135. /**
  16136. * Is the texture preventing material to render while loading.
  16137. * If false, a default texture will be used instead of the loading one during the preparation step.
  16138. */
  16139. isBlocking: boolean;
  16140. /**
  16141. * Get the current sampling mode associated with the texture.
  16142. */
  16143. readonly samplingMode: number;
  16144. /**
  16145. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16146. */
  16147. readonly invertY: boolean;
  16148. /**
  16149. * Instantiates a new texture.
  16150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16152. * @param url define the url of the picture to load as a texture
  16153. * @param scene define the scene or engine the texture will belong to
  16154. * @param noMipmap define if the texture will require mip maps or not
  16155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16156. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16157. * @param onLoad define a callback triggered when the texture has been loaded
  16158. * @param onError define a callback triggered when an error occurred during the loading session
  16159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16162. */
  16163. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16164. /**
  16165. * Update the url (and optional buffer) of this texture if url was null during construction.
  16166. * @param url the url of the texture
  16167. * @param buffer the buffer of the texture (defaults to null)
  16168. * @param onLoad callback called when the texture is loaded (defaults to null)
  16169. */
  16170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16171. /**
  16172. * Finish the loading sequence of a texture flagged as delayed load.
  16173. * @hidden
  16174. */
  16175. delayLoad(): void;
  16176. private _prepareRowForTextureGeneration;
  16177. /**
  16178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16179. * @returns the transform matrix of the texture.
  16180. */
  16181. getTextureMatrix(): Matrix;
  16182. /**
  16183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16184. * @returns The reflection texture transform
  16185. */
  16186. getReflectionTextureMatrix(): Matrix;
  16187. /**
  16188. * Clones the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): Texture;
  16192. /**
  16193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16194. * @returns The JSON representation of the texture
  16195. */
  16196. serialize(): any;
  16197. /**
  16198. * Get the current class name of the texture useful for serialization or dynamic coding.
  16199. * @returns "Texture"
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Dispose the texture and release its associated resources.
  16204. */
  16205. dispose(): void;
  16206. /**
  16207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16208. * @param parsedTexture Define the JSON representation of the texture
  16209. * @param scene Define the scene the parsed texture should be instantiated in
  16210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16211. * @returns The parsed texture if successful
  16212. */
  16213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16214. /**
  16215. * Creates a texture from its base 64 representation.
  16216. * @param data Define the base64 payload without the data: prefix
  16217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16218. * @param scene Define the scene the texture should belong to
  16219. * @param noMipmap Forces the texture to not create mip map information if true
  16220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad define a callback triggered when the texture has been loaded
  16223. * @param onError define a callback triggered when an error occurred during the loading session
  16224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16225. * @returns the created texture
  16226. */
  16227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16228. /**
  16229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16230. * @param data Define the base64 payload without the data: prefix
  16231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16233. * @param scene Define the scene the texture should belong to
  16234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16235. * @param noMipmap Forces the texture to not create mip map information if true
  16236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16238. * @param onLoad define a callback triggered when the texture has been loaded
  16239. * @param onError define a callback triggered when an error occurred during the loading session
  16240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16241. * @returns the created texture
  16242. */
  16243. 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;
  16244. }
  16245. }
  16246. declare module "babylonjs/PostProcesses/postProcessManager" {
  16247. import { Nullable } from "babylonjs/types";
  16248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16250. import { Scene } from "babylonjs/scene";
  16251. /**
  16252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16254. */
  16255. export class PostProcessManager {
  16256. private _scene;
  16257. private _indexBuffer;
  16258. private _vertexBuffers;
  16259. /**
  16260. * Creates a new instance PostProcess
  16261. * @param scene The scene that the post process is associated with.
  16262. */
  16263. constructor(scene: Scene);
  16264. private _prepareBuffers;
  16265. private _buildIndexBuffer;
  16266. /**
  16267. * Rebuilds the vertex buffers of the manager.
  16268. * @hidden
  16269. */
  16270. _rebuild(): void;
  16271. /**
  16272. * Prepares a frame to be run through a post process.
  16273. * @param sourceTexture The input texture to the post procesess. (default: null)
  16274. * @param postProcesses An array of post processes to be run. (default: null)
  16275. * @returns True if the post processes were able to be run.
  16276. * @hidden
  16277. */
  16278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16279. /**
  16280. * Manually render a set of post processes to a texture.
  16281. * @param postProcesses An array of post processes to be run.
  16282. * @param targetTexture The target texture to render to.
  16283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16285. * @param lodLevel defines which lod of the texture to render to
  16286. */
  16287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16288. /**
  16289. * Finalize the result of the output of the postprocesses.
  16290. * @param doNotPresent If true the result will not be displayed to the screen.
  16291. * @param targetTexture The target texture to render to.
  16292. * @param faceIndex The index of the face to bind the target texture to.
  16293. * @param postProcesses The array of post processes to render.
  16294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16295. * @hidden
  16296. */
  16297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16298. /**
  16299. * Disposes of the post process manager.
  16300. */
  16301. dispose(): void;
  16302. }
  16303. }
  16304. declare module "babylonjs/Misc/gradients" {
  16305. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16306. /** Interface used by value gradients (color, factor, ...) */
  16307. export interface IValueGradient {
  16308. /**
  16309. * Gets or sets the gradient value (between 0 and 1)
  16310. */
  16311. gradient: number;
  16312. }
  16313. /** Class used to store color4 gradient */
  16314. export class ColorGradient implements IValueGradient {
  16315. /**
  16316. * Gets or sets the gradient value (between 0 and 1)
  16317. */
  16318. gradient: number;
  16319. /**
  16320. * Gets or sets first associated color
  16321. */
  16322. color1: Color4;
  16323. /**
  16324. * Gets or sets second associated color
  16325. */
  16326. color2?: Color4;
  16327. /**
  16328. * Will get a color picked randomly between color1 and color2.
  16329. * If color2 is undefined then color1 will be used
  16330. * @param result defines the target Color4 to store the result in
  16331. */
  16332. getColorToRef(result: Color4): void;
  16333. }
  16334. /** Class used to store color 3 gradient */
  16335. export class Color3Gradient implements IValueGradient {
  16336. /**
  16337. * Gets or sets the gradient value (between 0 and 1)
  16338. */
  16339. gradient: number;
  16340. /**
  16341. * Gets or sets the associated color
  16342. */
  16343. color: Color3;
  16344. }
  16345. /** Class used to store factor gradient */
  16346. export class FactorGradient implements IValueGradient {
  16347. /**
  16348. * Gets or sets the gradient value (between 0 and 1)
  16349. */
  16350. gradient: number;
  16351. /**
  16352. * Gets or sets first associated factor
  16353. */
  16354. factor1: number;
  16355. /**
  16356. * Gets or sets second associated factor
  16357. */
  16358. factor2?: number;
  16359. /**
  16360. * Will get a number picked randomly between factor1 and factor2.
  16361. * If factor2 is undefined then factor1 will be used
  16362. * @returns the picked number
  16363. */
  16364. getFactor(): number;
  16365. }
  16366. /**
  16367. * Helper used to simplify some generic gradient tasks
  16368. */
  16369. export class GradientHelper {
  16370. /**
  16371. * Gets the current gradient from an array of IValueGradient
  16372. * @param ratio defines the current ratio to get
  16373. * @param gradients defines the array of IValueGradient
  16374. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16375. */
  16376. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16377. }
  16378. }
  16379. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16381. import { Nullable } from "babylonjs/types";
  16382. module "babylonjs/Engines/thinEngine" {
  16383. interface ThinEngine {
  16384. /**
  16385. * Creates a dynamic texture
  16386. * @param width defines the width of the texture
  16387. * @param height defines the height of the texture
  16388. * @param generateMipMaps defines if the engine should generate the mip levels
  16389. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16390. * @returns the dynamic texture inside an InternalTexture
  16391. */
  16392. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16393. /**
  16394. * Update the content of a dynamic texture
  16395. * @param texture defines the texture to update
  16396. * @param canvas defines the canvas containing the source
  16397. * @param invertY defines if data must be stored with Y axis inverted
  16398. * @param premulAlpha defines if alpha is stored as premultiplied
  16399. * @param format defines the format of the data
  16400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16401. */
  16402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16403. }
  16404. }
  16405. }
  16406. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16407. import { Scene } from "babylonjs/scene";
  16408. import { Texture } from "babylonjs/Materials/Textures/texture";
  16409. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16410. /**
  16411. * A class extending Texture allowing drawing on a texture
  16412. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16413. */
  16414. export class DynamicTexture extends Texture {
  16415. private _generateMipMaps;
  16416. private _canvas;
  16417. private _context;
  16418. private _engine;
  16419. /**
  16420. * Creates a DynamicTexture
  16421. * @param name defines the name of the texture
  16422. * @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
  16423. * @param scene defines the scene where you want the texture
  16424. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16425. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16426. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16427. */
  16428. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16429. /**
  16430. * Get the current class name of the texture useful for serialization or dynamic coding.
  16431. * @returns "DynamicTexture"
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Gets the current state of canRescale
  16436. */
  16437. readonly canRescale: boolean;
  16438. private _recreate;
  16439. /**
  16440. * Scales the texture
  16441. * @param ratio the scale factor to apply to both width and height
  16442. */
  16443. scale(ratio: number): void;
  16444. /**
  16445. * Resizes the texture
  16446. * @param width the new width
  16447. * @param height the new height
  16448. */
  16449. scaleTo(width: number, height: number): void;
  16450. /**
  16451. * Gets the context of the canvas used by the texture
  16452. * @returns the canvas context of the dynamic texture
  16453. */
  16454. getContext(): CanvasRenderingContext2D;
  16455. /**
  16456. * Clears the texture
  16457. */
  16458. clear(): void;
  16459. /**
  16460. * Updates the texture
  16461. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16462. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16463. */
  16464. update(invertY?: boolean, premulAlpha?: boolean): void;
  16465. /**
  16466. * Draws text onto the texture
  16467. * @param text defines the text to be drawn
  16468. * @param x defines the placement of the text from the left
  16469. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16470. * @param font defines the font to be used with font-style, font-size, font-name
  16471. * @param color defines the color used for the text
  16472. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param update defines whether texture is immediately update (default is true)
  16475. */
  16476. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16477. /**
  16478. * Clones the texture
  16479. * @returns the clone of the texture.
  16480. */
  16481. clone(): DynamicTexture;
  16482. /**
  16483. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16484. * @returns a serialized dynamic texture object
  16485. */
  16486. serialize(): any;
  16487. /** @hidden */
  16488. _rebuild(): void;
  16489. }
  16490. }
  16491. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16492. import { Scene } from "babylonjs/scene";
  16493. import { ISceneComponent } from "babylonjs/sceneComponent";
  16494. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16495. module "babylonjs/abstractScene" {
  16496. interface AbstractScene {
  16497. /**
  16498. * The list of procedural textures added to the scene
  16499. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16500. */
  16501. proceduralTextures: Array<ProceduralTexture>;
  16502. }
  16503. }
  16504. /**
  16505. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16506. * in a given scene.
  16507. */
  16508. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16509. /**
  16510. * The component name helpfull to identify the component in the list of scene components.
  16511. */
  16512. readonly name: string;
  16513. /**
  16514. * The scene the component belongs to.
  16515. */
  16516. scene: Scene;
  16517. /**
  16518. * Creates a new instance of the component for the given scene
  16519. * @param scene Defines the scene to register the component in
  16520. */
  16521. constructor(scene: Scene);
  16522. /**
  16523. * Registers the component in a given scene
  16524. */
  16525. register(): void;
  16526. /**
  16527. * Rebuilds the elements related to this component in case of
  16528. * context lost for instance.
  16529. */
  16530. rebuild(): void;
  16531. /**
  16532. * Disposes the component and the associated ressources.
  16533. */
  16534. dispose(): void;
  16535. private _beforeClear;
  16536. }
  16537. }
  16538. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16540. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16541. module "babylonjs/Engines/thinEngine" {
  16542. interface ThinEngine {
  16543. /**
  16544. * Creates a new render target cube texture
  16545. * @param size defines the size of the texture
  16546. * @param options defines the options used to create the texture
  16547. * @returns a new render target cube texture stored in an InternalTexture
  16548. */
  16549. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16550. }
  16551. }
  16552. }
  16553. declare module "babylonjs/Shaders/procedural.vertex" {
  16554. /** @hidden */
  16555. export var proceduralVertexShader: {
  16556. name: string;
  16557. shader: string;
  16558. };
  16559. }
  16560. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16561. import { Observable } from "babylonjs/Misc/observable";
  16562. import { Nullable } from "babylonjs/types";
  16563. import { Scene } from "babylonjs/scene";
  16564. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16566. import { Effect } from "babylonjs/Materials/effect";
  16567. import { Texture } from "babylonjs/Materials/Textures/texture";
  16568. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16569. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16570. import "babylonjs/Shaders/procedural.vertex";
  16571. /**
  16572. * 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.
  16573. * This is the base class of any Procedural texture and contains most of the shareable code.
  16574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16575. */
  16576. export class ProceduralTexture extends Texture {
  16577. isCube: boolean;
  16578. /**
  16579. * Define if the texture is enabled or not (disabled texture will not render)
  16580. */
  16581. isEnabled: boolean;
  16582. /**
  16583. * Define if the texture must be cleared before rendering (default is true)
  16584. */
  16585. autoClear: boolean;
  16586. /**
  16587. * Callback called when the texture is generated
  16588. */
  16589. onGenerated: () => void;
  16590. /**
  16591. * Event raised when the texture is generated
  16592. */
  16593. onGeneratedObservable: Observable<ProceduralTexture>;
  16594. /** @hidden */
  16595. _generateMipMaps: boolean;
  16596. /** @hidden **/
  16597. _effect: Effect;
  16598. /** @hidden */
  16599. _textures: {
  16600. [key: string]: Texture;
  16601. };
  16602. private _size;
  16603. private _currentRefreshId;
  16604. private _refreshRate;
  16605. private _vertexBuffers;
  16606. private _indexBuffer;
  16607. private _uniforms;
  16608. private _samplers;
  16609. private _fragment;
  16610. private _floats;
  16611. private _ints;
  16612. private _floatsArrays;
  16613. private _colors3;
  16614. private _colors4;
  16615. private _vectors2;
  16616. private _vectors3;
  16617. private _matrices;
  16618. private _fallbackTexture;
  16619. private _fallbackTextureUsed;
  16620. private _engine;
  16621. private _cachedDefines;
  16622. private _contentUpdateId;
  16623. private _contentData;
  16624. /**
  16625. * Instantiates a new procedural texture.
  16626. * 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.
  16627. * This is the base class of any Procedural texture and contains most of the shareable code.
  16628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16629. * @param name Define the name of the texture
  16630. * @param size Define the size of the texture to create
  16631. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16632. * @param scene Define the scene the texture belongs to
  16633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16634. * @param generateMipMaps Define if the texture should creates mip maps or not
  16635. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16636. */
  16637. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16638. /**
  16639. * The effect that is created when initializing the post process.
  16640. * @returns The created effect corresponding the the postprocess.
  16641. */
  16642. getEffect(): Effect;
  16643. /**
  16644. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16645. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16646. */
  16647. getContent(): Nullable<ArrayBufferView>;
  16648. private _createIndexBuffer;
  16649. /** @hidden */
  16650. _rebuild(): void;
  16651. /**
  16652. * Resets the texture in order to recreate its associated resources.
  16653. * This can be called in case of context loss
  16654. */
  16655. reset(): void;
  16656. protected _getDefines(): string;
  16657. /**
  16658. * Is the texture ready to be used ? (rendered at least once)
  16659. * @returns true if ready, otherwise, false.
  16660. */
  16661. isReady(): boolean;
  16662. /**
  16663. * Resets the refresh counter of the texture and start bak from scratch.
  16664. * Could be useful to regenerate the texture if it is setup to render only once.
  16665. */
  16666. resetRefreshCounter(): void;
  16667. /**
  16668. * Set the fragment shader to use in order to render the texture.
  16669. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16670. */
  16671. setFragment(fragment: any): void;
  16672. /**
  16673. * Define the refresh rate of the texture or the rendering frequency.
  16674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16675. */
  16676. refreshRate: number;
  16677. /** @hidden */
  16678. _shouldRender(): boolean;
  16679. /**
  16680. * Get the size the texture is rendering at.
  16681. * @returns the size (texture is always squared)
  16682. */
  16683. getRenderSize(): number;
  16684. /**
  16685. * Resize the texture to new value.
  16686. * @param size Define the new size the texture should have
  16687. * @param generateMipMaps Define whether the new texture should create mip maps
  16688. */
  16689. resize(size: number, generateMipMaps: boolean): void;
  16690. private _checkUniform;
  16691. /**
  16692. * Set a texture in the shader program used to render.
  16693. * @param name Define the name of the uniform samplers as defined in the shader
  16694. * @param texture Define the texture to bind to this sampler
  16695. * @return the texture itself allowing "fluent" like uniform updates
  16696. */
  16697. setTexture(name: string, texture: Texture): ProceduralTexture;
  16698. /**
  16699. * Set a float in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the texture itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloat(name: string, value: number): ProceduralTexture;
  16705. /**
  16706. * Set a int in the shader.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the texture itself allowing "fluent" like uniform updates
  16710. */
  16711. setInt(name: string, value: number): ProceduralTexture;
  16712. /**
  16713. * Set an array of floats in the shader.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the texture itself allowing "fluent" like uniform updates
  16717. */
  16718. setFloats(name: string, value: number[]): ProceduralTexture;
  16719. /**
  16720. * Set a vec3 in the shader from a Color3.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the texture itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor3(name: string, value: Color3): ProceduralTexture;
  16726. /**
  16727. * Set a vec4 in the shader from a Color4.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the texture itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4(name: string, value: Color4): ProceduralTexture;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the texture itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ProceduralTexture;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the texture itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ProceduralTexture;
  16747. /**
  16748. * Set a mat4 in the shader from a MAtrix.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the texture itself allowing "fluent" like uniform updates
  16752. */
  16753. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16754. /**
  16755. * Render the texture to its associated render target.
  16756. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16757. */
  16758. render(useCameraPostProcess?: boolean): void;
  16759. /**
  16760. * Clone the texture.
  16761. * @returns the cloned texture
  16762. */
  16763. clone(): ProceduralTexture;
  16764. /**
  16765. * Dispose the texture and release its asoociated resources.
  16766. */
  16767. dispose(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Particles/baseParticleSystem" {
  16771. import { Nullable } from "babylonjs/types";
  16772. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16774. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16775. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16776. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16777. import { Scene } from "babylonjs/scene";
  16778. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16779. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16780. import { Texture } from "babylonjs/Materials/Textures/texture";
  16781. import { Color4 } from "babylonjs/Maths/math.color";
  16782. import { Animation } from "babylonjs/Animations/animation";
  16783. /**
  16784. * This represents the base class for particle system in Babylon.
  16785. * 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.
  16786. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16787. * @example https://doc.babylonjs.com/babylon101/particles
  16788. */
  16789. export class BaseParticleSystem {
  16790. /**
  16791. * Source color is added to the destination color without alpha affecting the result
  16792. */
  16793. static BLENDMODE_ONEONE: number;
  16794. /**
  16795. * Blend current color and particle color using particle’s alpha
  16796. */
  16797. static BLENDMODE_STANDARD: number;
  16798. /**
  16799. * Add current color and particle color multiplied by particle’s alpha
  16800. */
  16801. static BLENDMODE_ADD: number;
  16802. /**
  16803. * Multiply current color with particle color
  16804. */
  16805. static BLENDMODE_MULTIPLY: number;
  16806. /**
  16807. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16808. */
  16809. static BLENDMODE_MULTIPLYADD: number;
  16810. /**
  16811. * List of animations used by the particle system.
  16812. */
  16813. animations: Animation[];
  16814. /**
  16815. * The id of the Particle system.
  16816. */
  16817. id: string;
  16818. /**
  16819. * The friendly name of the Particle system.
  16820. */
  16821. name: string;
  16822. /**
  16823. * The rendering group used by the Particle system to chose when to render.
  16824. */
  16825. renderingGroupId: number;
  16826. /**
  16827. * The emitter represents the Mesh or position we are attaching the particle system to.
  16828. */
  16829. emitter: Nullable<AbstractMesh | Vector3>;
  16830. /**
  16831. * The maximum number of particles to emit per frame
  16832. */
  16833. emitRate: number;
  16834. /**
  16835. * If you want to launch only a few particles at once, that can be done, as well.
  16836. */
  16837. manualEmitCount: number;
  16838. /**
  16839. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16840. */
  16841. updateSpeed: number;
  16842. /**
  16843. * The amount of time the particle system is running (depends of the overall update speed).
  16844. */
  16845. targetStopDuration: number;
  16846. /**
  16847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16848. */
  16849. disposeOnStop: boolean;
  16850. /**
  16851. * Minimum power of emitting particles.
  16852. */
  16853. minEmitPower: number;
  16854. /**
  16855. * Maximum power of emitting particles.
  16856. */
  16857. maxEmitPower: number;
  16858. /**
  16859. * Minimum life time of emitting particles.
  16860. */
  16861. minLifeTime: number;
  16862. /**
  16863. * Maximum life time of emitting particles.
  16864. */
  16865. maxLifeTime: number;
  16866. /**
  16867. * Minimum Size of emitting particles.
  16868. */
  16869. minSize: number;
  16870. /**
  16871. * Maximum Size of emitting particles.
  16872. */
  16873. maxSize: number;
  16874. /**
  16875. * Minimum scale of emitting particles on X axis.
  16876. */
  16877. minScaleX: number;
  16878. /**
  16879. * Maximum scale of emitting particles on X axis.
  16880. */
  16881. maxScaleX: number;
  16882. /**
  16883. * Minimum scale of emitting particles on Y axis.
  16884. */
  16885. minScaleY: number;
  16886. /**
  16887. * Maximum scale of emitting particles on Y axis.
  16888. */
  16889. maxScaleY: number;
  16890. /**
  16891. * Gets or sets the minimal initial rotation in radians.
  16892. */
  16893. minInitialRotation: number;
  16894. /**
  16895. * Gets or sets the maximal initial rotation in radians.
  16896. */
  16897. maxInitialRotation: number;
  16898. /**
  16899. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16900. */
  16901. minAngularSpeed: number;
  16902. /**
  16903. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. maxAngularSpeed: number;
  16906. /**
  16907. * The texture used to render each particle. (this can be a spritesheet)
  16908. */
  16909. particleTexture: Nullable<Texture>;
  16910. /**
  16911. * The layer mask we are rendering the particles through.
  16912. */
  16913. layerMask: number;
  16914. /**
  16915. * This can help using your own shader to render the particle system.
  16916. * The according effect will be created
  16917. */
  16918. customShader: any;
  16919. /**
  16920. * By default particle system starts as soon as they are created. This prevents the
  16921. * automatic start to happen and let you decide when to start emitting particles.
  16922. */
  16923. preventAutoStart: boolean;
  16924. private _noiseTexture;
  16925. /**
  16926. * Gets or sets a texture used to add random noise to particle positions
  16927. */
  16928. noiseTexture: Nullable<ProceduralTexture>;
  16929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16930. noiseStrength: Vector3;
  16931. /**
  16932. * Callback triggered when the particle animation is ending.
  16933. */
  16934. onAnimationEnd: Nullable<() => void>;
  16935. /**
  16936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16937. */
  16938. blendMode: number;
  16939. /**
  16940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16941. * to override the particles.
  16942. */
  16943. forceDepthWrite: boolean;
  16944. /** 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 */
  16945. preWarmCycles: number;
  16946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16947. preWarmStepOffset: number;
  16948. /**
  16949. * 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)
  16950. */
  16951. spriteCellChangeSpeed: number;
  16952. /**
  16953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16954. */
  16955. startSpriteCellID: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16958. */
  16959. endSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16962. */
  16963. spriteCellWidth: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16966. */
  16967. spriteCellHeight: number;
  16968. /**
  16969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16970. */
  16971. spriteRandomStartCell: boolean;
  16972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16973. translationPivot: Vector2;
  16974. /** @hidden */
  16975. protected _isAnimationSheetEnabled: boolean;
  16976. /**
  16977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16978. */
  16979. beginAnimationOnStart: boolean;
  16980. /**
  16981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16982. */
  16983. beginAnimationFrom: number;
  16984. /**
  16985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationTo: number;
  16988. /**
  16989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationLoop: boolean;
  16992. /**
  16993. * Gets or sets a world offset applied to all particles
  16994. */
  16995. worldOffset: Vector3;
  16996. /**
  16997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16998. */
  16999. isAnimationSheetEnabled: boolean;
  17000. /**
  17001. * Get hosting scene
  17002. * @returns the scene
  17003. */
  17004. getScene(): Scene;
  17005. /**
  17006. * You can use gravity if you want to give an orientation to your particles.
  17007. */
  17008. gravity: Vector3;
  17009. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17010. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17011. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17012. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17013. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17014. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17015. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17016. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17017. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17018. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17019. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17020. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17021. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17022. /**
  17023. * Defines the delay in milliseconds before starting the system (0 by default)
  17024. */
  17025. startDelay: number;
  17026. /**
  17027. * Gets the current list of drag gradients.
  17028. * You must use addDragGradient and removeDragGradient to udpate this list
  17029. * @returns the list of drag gradients
  17030. */
  17031. getDragGradients(): Nullable<Array<FactorGradient>>;
  17032. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17033. limitVelocityDamping: number;
  17034. /**
  17035. * Gets the current list of limit velocity gradients.
  17036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17037. * @returns the list of limit velocity gradients
  17038. */
  17039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17040. /**
  17041. * Gets the current list of color gradients.
  17042. * You must use addColorGradient and removeColorGradient to udpate this list
  17043. * @returns the list of color gradients
  17044. */
  17045. getColorGradients(): Nullable<Array<ColorGradient>>;
  17046. /**
  17047. * Gets the current list of size gradients.
  17048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17049. * @returns the list of size gradients
  17050. */
  17051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17052. /**
  17053. * Gets the current list of color remap gradients.
  17054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17055. * @returns the list of color remap gradients
  17056. */
  17057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Gets the current list of alpha remap gradients.
  17060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17061. * @returns the list of alpha remap gradients
  17062. */
  17063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Gets the current list of life time gradients.
  17066. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17067. * @returns the list of life time gradients
  17068. */
  17069. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of angular speed gradients.
  17072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17073. * @returns the list of angular speed gradients
  17074. */
  17075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17076. /**
  17077. * Gets the current list of velocity gradients.
  17078. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17079. * @returns the list of velocity gradients
  17080. */
  17081. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of start size gradients.
  17084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17085. * @returns the list of start size gradients
  17086. */
  17087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of emit rate gradients.
  17090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17091. * @returns the list of emit rate gradients
  17092. */
  17093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17097. */
  17098. direction1: Vector3;
  17099. /**
  17100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17102. */
  17103. direction2: Vector3;
  17104. /**
  17105. * 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.
  17106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17107. */
  17108. minEmitBox: Vector3;
  17109. /**
  17110. * 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.
  17111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17112. */
  17113. maxEmitBox: Vector3;
  17114. /**
  17115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17116. */
  17117. color1: Color4;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color2: Color4;
  17122. /**
  17123. * Color the particle will have at the end of its lifetime
  17124. */
  17125. colorDead: Color4;
  17126. /**
  17127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17128. */
  17129. textureMask: Color4;
  17130. /**
  17131. * The particle emitter type defines the emitter used by the particle system.
  17132. * It can be for example box, sphere, or cone...
  17133. */
  17134. particleEmitterType: IParticleEmitterType;
  17135. /** @hidden */
  17136. _isSubEmitter: boolean;
  17137. /**
  17138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17140. */
  17141. billboardMode: number;
  17142. protected _isBillboardBased: boolean;
  17143. /**
  17144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17145. */
  17146. isBillboardBased: boolean;
  17147. /**
  17148. * The scene the particle system belongs to.
  17149. */
  17150. protected _scene: Scene;
  17151. /**
  17152. * Local cache of defines for image processing.
  17153. */
  17154. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17155. /**
  17156. * Default configuration related to image processing available in the standard Material.
  17157. */
  17158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17159. /**
  17160. * Gets the image processing configuration used either in this material.
  17161. */
  17162. /**
  17163. * Sets the Default image processing configuration used either in the this material.
  17164. *
  17165. * If sets to null, the scene one is in use.
  17166. */
  17167. imageProcessingConfiguration: ImageProcessingConfiguration;
  17168. /**
  17169. * Attaches a new image processing configuration to the Standard Material.
  17170. * @param configuration
  17171. */
  17172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17173. /** @hidden */
  17174. protected _reset(): void;
  17175. /** @hidden */
  17176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17177. /**
  17178. * Instantiates a particle system.
  17179. * 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.
  17180. * @param name The name of the particle system
  17181. */
  17182. constructor(name: string);
  17183. /**
  17184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17187. * @returns the emitter
  17188. */
  17189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17190. /**
  17191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17192. * @param radius The radius of the hemisphere to emit from
  17193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17194. * @returns the emitter
  17195. */
  17196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17197. /**
  17198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17199. * @param radius The radius of the sphere to emit from
  17200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17201. * @returns the emitter
  17202. */
  17203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17204. /**
  17205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17206. * @param radius The radius of the sphere to emit from
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17209. * @returns the emitter
  17210. */
  17211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17212. /**
  17213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17214. * @param radius The radius of the emission cylinder
  17215. * @param height The height of the emission cylinder
  17216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17218. * @returns the emitter
  17219. */
  17220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17221. /**
  17222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17223. * @param radius The radius of the cylinder to emit from
  17224. * @param height The height of the emission cylinder
  17225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17228. * @returns the emitter
  17229. */
  17230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17231. /**
  17232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17233. * @param radius The radius of the cone to emit from
  17234. * @param angle The base angle of the cone
  17235. * @returns the emitter
  17236. */
  17237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17238. /**
  17239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17244. * @returns the emitter
  17245. */
  17246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17247. }
  17248. }
  17249. declare module "babylonjs/Particles/subEmitter" {
  17250. import { Scene } from "babylonjs/scene";
  17251. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17252. /**
  17253. * Type of sub emitter
  17254. */
  17255. export enum SubEmitterType {
  17256. /**
  17257. * Attached to the particle over it's lifetime
  17258. */
  17259. ATTACHED = 0,
  17260. /**
  17261. * Created when the particle dies
  17262. */
  17263. END = 1
  17264. }
  17265. /**
  17266. * Sub emitter class used to emit particles from an existing particle
  17267. */
  17268. export class SubEmitter {
  17269. /**
  17270. * the particle system to be used by the sub emitter
  17271. */
  17272. particleSystem: ParticleSystem;
  17273. /**
  17274. * Type of the submitter (Default: END)
  17275. */
  17276. type: SubEmitterType;
  17277. /**
  17278. * 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)
  17279. * Note: This only is supported when using an emitter of type Mesh
  17280. */
  17281. inheritDirection: boolean;
  17282. /**
  17283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17284. */
  17285. inheritedVelocityAmount: number;
  17286. /**
  17287. * Creates a sub emitter
  17288. * @param particleSystem the particle system to be used by the sub emitter
  17289. */
  17290. constructor(
  17291. /**
  17292. * the particle system to be used by the sub emitter
  17293. */
  17294. particleSystem: ParticleSystem);
  17295. /**
  17296. * Clones the sub emitter
  17297. * @returns the cloned sub emitter
  17298. */
  17299. clone(): SubEmitter;
  17300. /**
  17301. * Serialize current object to a JSON object
  17302. * @returns the serialized object
  17303. */
  17304. serialize(): any;
  17305. /** @hidden */
  17306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17307. /**
  17308. * Creates a new SubEmitter from a serialized JSON version
  17309. * @param serializationObject defines the JSON object to read from
  17310. * @param scene defines the hosting scene
  17311. * @param rootUrl defines the rootUrl for data loading
  17312. * @returns a new SubEmitter
  17313. */
  17314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17315. /** Release associated resources */
  17316. dispose(): void;
  17317. }
  17318. }
  17319. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17320. /** @hidden */
  17321. export var clipPlaneFragmentDeclaration: {
  17322. name: string;
  17323. shader: string;
  17324. };
  17325. }
  17326. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17327. /** @hidden */
  17328. export var imageProcessingDeclaration: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17334. /** @hidden */
  17335. export var imageProcessingFunctions: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17341. /** @hidden */
  17342. export var clipPlaneFragment: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Shaders/particles.fragment" {
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17349. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17351. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17353. /** @hidden */
  17354. export var particlesPixelShader: {
  17355. name: string;
  17356. shader: string;
  17357. };
  17358. }
  17359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17360. /** @hidden */
  17361. export var clipPlaneVertexDeclaration: {
  17362. name: string;
  17363. shader: string;
  17364. };
  17365. }
  17366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17367. /** @hidden */
  17368. export var clipPlaneVertex: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/particles.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17376. /** @hidden */
  17377. export var particlesVertexShader: {
  17378. name: string;
  17379. shader: string;
  17380. };
  17381. }
  17382. declare module "babylonjs/Particles/particleSystem" {
  17383. import { Nullable } from "babylonjs/types";
  17384. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17385. import { Observable } from "babylonjs/Misc/observable";
  17386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17387. import { Effect } from "babylonjs/Materials/effect";
  17388. import { Scene, IDisposable } from "babylonjs/scene";
  17389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17390. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17391. import { Particle } from "babylonjs/Particles/particle";
  17392. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17394. import "babylonjs/Shaders/particles.fragment";
  17395. import "babylonjs/Shaders/particles.vertex";
  17396. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17397. /**
  17398. * This represents a particle system in Babylon.
  17399. * 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.
  17400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17401. * @example https://doc.babylonjs.com/babylon101/particles
  17402. */
  17403. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17404. /**
  17405. * Billboard mode will only apply to Y axis
  17406. */
  17407. static readonly BILLBOARDMODE_Y: number;
  17408. /**
  17409. * Billboard mode will apply to all axes
  17410. */
  17411. static readonly BILLBOARDMODE_ALL: number;
  17412. /**
  17413. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17414. */
  17415. static readonly BILLBOARDMODE_STRETCHED: number;
  17416. /**
  17417. * This function can be defined to provide custom update for active particles.
  17418. * This function will be called instead of regular update (age, position, color, etc.).
  17419. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17420. */
  17421. updateFunction: (particles: Particle[]) => void;
  17422. private _emitterWorldMatrix;
  17423. /**
  17424. * This function can be defined to specify initial direction for every new particle.
  17425. * It by default use the emitterType defined function
  17426. */
  17427. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17428. /**
  17429. * This function can be defined to specify initial position for every new particle.
  17430. * It by default use the emitterType defined function
  17431. */
  17432. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17433. /**
  17434. * @hidden
  17435. */
  17436. _inheritedVelocityOffset: Vector3;
  17437. /**
  17438. * An event triggered when the system is disposed
  17439. */
  17440. onDisposeObservable: Observable<ParticleSystem>;
  17441. private _onDisposeObserver;
  17442. /**
  17443. * Sets a callback that will be triggered when the system is disposed
  17444. */
  17445. onDispose: () => void;
  17446. private _particles;
  17447. private _epsilon;
  17448. private _capacity;
  17449. private _stockParticles;
  17450. private _newPartsExcess;
  17451. private _vertexData;
  17452. private _vertexBuffer;
  17453. private _vertexBuffers;
  17454. private _spriteBuffer;
  17455. private _indexBuffer;
  17456. private _effect;
  17457. private _customEffect;
  17458. private _cachedDefines;
  17459. private _scaledColorStep;
  17460. private _colorDiff;
  17461. private _scaledDirection;
  17462. private _scaledGravity;
  17463. private _currentRenderId;
  17464. private _alive;
  17465. private _useInstancing;
  17466. private _started;
  17467. private _stopped;
  17468. private _actualFrame;
  17469. private _scaledUpdateSpeed;
  17470. private _vertexBufferSize;
  17471. /** @hidden */
  17472. _currentEmitRateGradient: Nullable<FactorGradient>;
  17473. /** @hidden */
  17474. _currentEmitRate1: number;
  17475. /** @hidden */
  17476. _currentEmitRate2: number;
  17477. /** @hidden */
  17478. _currentStartSizeGradient: Nullable<FactorGradient>;
  17479. /** @hidden */
  17480. _currentStartSize1: number;
  17481. /** @hidden */
  17482. _currentStartSize2: number;
  17483. private readonly _rawTextureWidth;
  17484. private _rampGradientsTexture;
  17485. private _useRampGradients;
  17486. /** Gets or sets a boolean indicating that ramp gradients must be used
  17487. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17488. */
  17489. useRampGradients: boolean;
  17490. /**
  17491. * 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.
  17492. * 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: [])
  17493. */
  17494. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17495. private _subEmitters;
  17496. /**
  17497. * @hidden
  17498. * If the particle systems emitter should be disposed when the particle system is disposed
  17499. */
  17500. _disposeEmitterOnDispose: boolean;
  17501. /**
  17502. * The current active Sub-systems, this property is used by the root particle system only.
  17503. */
  17504. activeSubSystems: Array<ParticleSystem>;
  17505. private _rootParticleSystem;
  17506. /**
  17507. * Gets the current list of active particles
  17508. */
  17509. readonly particles: Particle[];
  17510. /**
  17511. * Returns the string "ParticleSystem"
  17512. * @returns a string containing the class name
  17513. */
  17514. getClassName(): string;
  17515. /**
  17516. * Instantiates a particle system.
  17517. * 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.
  17518. * @param name The name of the particle system
  17519. * @param capacity The max number of particles alive at the same time
  17520. * @param scene The scene the particle system belongs to
  17521. * @param customEffect a custom effect used to change the way particles are rendered by default
  17522. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17523. * @param epsilon Offset used to render the particles
  17524. */
  17525. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17526. private _addFactorGradient;
  17527. private _removeFactorGradient;
  17528. /**
  17529. * Adds a new life time gradient
  17530. * @param gradient defines the gradient to use (between 0 and 1)
  17531. * @param factor defines the life time factor to affect to the specified gradient
  17532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17533. * @returns the current particle system
  17534. */
  17535. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17536. /**
  17537. * Remove a specific life time gradient
  17538. * @param gradient defines the gradient to remove
  17539. * @returns the current particle system
  17540. */
  17541. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17542. /**
  17543. * Adds a new size gradient
  17544. * @param gradient defines the gradient to use (between 0 and 1)
  17545. * @param factor defines the size factor to affect to the specified gradient
  17546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17547. * @returns the current particle system
  17548. */
  17549. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17550. /**
  17551. * Remove a specific size gradient
  17552. * @param gradient defines the gradient to remove
  17553. * @returns the current particle system
  17554. */
  17555. removeSizeGradient(gradient: number): IParticleSystem;
  17556. /**
  17557. * Adds a new color remap gradient
  17558. * @param gradient defines the gradient to use (between 0 and 1)
  17559. * @param min defines the color remap minimal range
  17560. * @param max defines the color remap maximal range
  17561. * @returns the current particle system
  17562. */
  17563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17564. /**
  17565. * Remove a specific color remap gradient
  17566. * @param gradient defines the gradient to remove
  17567. * @returns the current particle system
  17568. */
  17569. removeColorRemapGradient(gradient: number): IParticleSystem;
  17570. /**
  17571. * Adds a new alpha remap gradient
  17572. * @param gradient defines the gradient to use (between 0 and 1)
  17573. * @param min defines the alpha remap minimal range
  17574. * @param max defines the alpha remap maximal range
  17575. * @returns the current particle system
  17576. */
  17577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17578. /**
  17579. * Remove a specific alpha remap gradient
  17580. * @param gradient defines the gradient to remove
  17581. * @returns the current particle system
  17582. */
  17583. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17584. /**
  17585. * Adds a new angular speed gradient
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the angular speed to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific angular speed gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Adds a new velocity gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the velocity to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific velocity gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeVelocityGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new limit velocity gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the limit velocity value to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific limit velocity gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new drag gradient
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param factor defines the drag value to affect to the specified gradient
  17630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17631. * @returns the current particle system
  17632. */
  17633. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific drag gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeDragGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param factor defines the emit rate value to affect to the specified gradient
  17644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17645. * @returns the current particle system
  17646. */
  17647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific emit rate gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeEmitRateGradient(gradient: number): IParticleSystem;
  17654. /**
  17655. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17656. * @param gradient defines the gradient to use (between 0 and 1)
  17657. * @param factor defines the start size value to affect to the specified gradient
  17658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17659. * @returns the current particle system
  17660. */
  17661. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17662. /**
  17663. * Remove a specific start size gradient
  17664. * @param gradient defines the gradient to remove
  17665. * @returns the current particle system
  17666. */
  17667. removeStartSizeGradient(gradient: number): IParticleSystem;
  17668. private _createRampGradientTexture;
  17669. /**
  17670. * Gets the current list of ramp gradients.
  17671. * You must use addRampGradient and removeRampGradient to udpate this list
  17672. * @returns the list of ramp gradients
  17673. */
  17674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17675. /**
  17676. * Adds a new ramp gradient used to remap particle colors
  17677. * @param gradient defines the gradient to use (between 0 and 1)
  17678. * @param color defines the color to affect to the specified gradient
  17679. * @returns the current particle system
  17680. */
  17681. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17682. /**
  17683. * Remove a specific ramp gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns the current particle system
  17686. */
  17687. removeRampGradient(gradient: number): ParticleSystem;
  17688. /**
  17689. * Adds a new color gradient
  17690. * @param gradient defines the gradient to use (between 0 and 1)
  17691. * @param color1 defines the color to affect to the specified gradient
  17692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17693. * @returns this particle system
  17694. */
  17695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17696. /**
  17697. * Remove a specific color gradient
  17698. * @param gradient defines the gradient to remove
  17699. * @returns this particle system
  17700. */
  17701. removeColorGradient(gradient: number): IParticleSystem;
  17702. private _fetchR;
  17703. protected _reset(): void;
  17704. private _resetEffect;
  17705. private _createVertexBuffers;
  17706. private _createIndexBuffer;
  17707. /**
  17708. * Gets the maximum number of particles active at the same time.
  17709. * @returns The max number of active particles.
  17710. */
  17711. getCapacity(): number;
  17712. /**
  17713. * Gets whether there are still active particles in the system.
  17714. * @returns True if it is alive, otherwise false.
  17715. */
  17716. isAlive(): boolean;
  17717. /**
  17718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17719. * @returns True if it has been started, otherwise false.
  17720. */
  17721. isStarted(): boolean;
  17722. private _prepareSubEmitterInternalArray;
  17723. /**
  17724. * Starts the particle system and begins to emit
  17725. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17726. */
  17727. start(delay?: number): void;
  17728. /**
  17729. * Stops the particle system.
  17730. * @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.
  17731. */
  17732. stop(stopSubEmitters?: boolean): void;
  17733. /**
  17734. * Remove all active particles
  17735. */
  17736. reset(): void;
  17737. /**
  17738. * @hidden (for internal use only)
  17739. */
  17740. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17741. /**
  17742. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17743. * Its lifetime will start back at 0.
  17744. */
  17745. recycleParticle: (particle: Particle) => void;
  17746. private _stopSubEmitters;
  17747. private _createParticle;
  17748. private _removeFromRoot;
  17749. private _emitFromParticle;
  17750. private _update;
  17751. /** @hidden */
  17752. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17753. /** @hidden */
  17754. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17755. /** @hidden */
  17756. private _getEffect;
  17757. /**
  17758. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17759. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17760. */
  17761. animate(preWarmOnly?: boolean): void;
  17762. private _appendParticleVertices;
  17763. /**
  17764. * Rebuilds the particle system.
  17765. */
  17766. rebuild(): void;
  17767. /**
  17768. * Is this system ready to be used/rendered
  17769. * @return true if the system is ready
  17770. */
  17771. isReady(): boolean;
  17772. private _render;
  17773. /**
  17774. * Renders the particle system in its current state.
  17775. * @returns the current number of particles
  17776. */
  17777. render(): number;
  17778. /**
  17779. * Disposes the particle system and free the associated resources
  17780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17781. */
  17782. dispose(disposeTexture?: boolean): void;
  17783. /**
  17784. * Clones the particle system.
  17785. * @param name The name of the cloned object
  17786. * @param newEmitter The new emitter to use
  17787. * @returns the cloned particle system
  17788. */
  17789. clone(name: string, newEmitter: any): ParticleSystem;
  17790. /**
  17791. * Serializes the particle system to a JSON object.
  17792. * @returns the JSON object
  17793. */
  17794. serialize(): any;
  17795. /** @hidden */
  17796. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17797. /** @hidden */
  17798. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17799. /**
  17800. * Parses a JSON object to create a particle system.
  17801. * @param parsedParticleSystem The JSON object to parse
  17802. * @param scene The scene to create the particle system in
  17803. * @param rootUrl The root url to use to load external dependencies like texture
  17804. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17805. * @returns the Parsed particle system
  17806. */
  17807. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17808. }
  17809. }
  17810. declare module "babylonjs/Particles/particle" {
  17811. import { Nullable } from "babylonjs/types";
  17812. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17813. import { Color4 } from "babylonjs/Maths/math.color";
  17814. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17815. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17816. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17817. /**
  17818. * A particle represents one of the element emitted by a particle system.
  17819. * This is mainly define by its coordinates, direction, velocity and age.
  17820. */
  17821. export class Particle {
  17822. /**
  17823. * The particle system the particle belongs to.
  17824. */
  17825. particleSystem: ParticleSystem;
  17826. private static _Count;
  17827. /**
  17828. * Unique ID of the particle
  17829. */
  17830. id: number;
  17831. /**
  17832. * The world position of the particle in the scene.
  17833. */
  17834. position: Vector3;
  17835. /**
  17836. * The world direction of the particle in the scene.
  17837. */
  17838. direction: Vector3;
  17839. /**
  17840. * The color of the particle.
  17841. */
  17842. color: Color4;
  17843. /**
  17844. * The color change of the particle per step.
  17845. */
  17846. colorStep: Color4;
  17847. /**
  17848. * Defines how long will the life of the particle be.
  17849. */
  17850. lifeTime: number;
  17851. /**
  17852. * The current age of the particle.
  17853. */
  17854. age: number;
  17855. /**
  17856. * The current size of the particle.
  17857. */
  17858. size: number;
  17859. /**
  17860. * The current scale of the particle.
  17861. */
  17862. scale: Vector2;
  17863. /**
  17864. * The current angle of the particle.
  17865. */
  17866. angle: number;
  17867. /**
  17868. * Defines how fast is the angle changing.
  17869. */
  17870. angularSpeed: number;
  17871. /**
  17872. * Defines the cell index used by the particle to be rendered from a sprite.
  17873. */
  17874. cellIndex: number;
  17875. /**
  17876. * The information required to support color remapping
  17877. */
  17878. remapData: Vector4;
  17879. /** @hidden */
  17880. _randomCellOffset?: number;
  17881. /** @hidden */
  17882. _initialDirection: Nullable<Vector3>;
  17883. /** @hidden */
  17884. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17885. /** @hidden */
  17886. _initialStartSpriteCellID: number;
  17887. /** @hidden */
  17888. _initialEndSpriteCellID: number;
  17889. /** @hidden */
  17890. _currentColorGradient: Nullable<ColorGradient>;
  17891. /** @hidden */
  17892. _currentColor1: Color4;
  17893. /** @hidden */
  17894. _currentColor2: Color4;
  17895. /** @hidden */
  17896. _currentSizeGradient: Nullable<FactorGradient>;
  17897. /** @hidden */
  17898. _currentSize1: number;
  17899. /** @hidden */
  17900. _currentSize2: number;
  17901. /** @hidden */
  17902. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17903. /** @hidden */
  17904. _currentAngularSpeed1: number;
  17905. /** @hidden */
  17906. _currentAngularSpeed2: number;
  17907. /** @hidden */
  17908. _currentVelocityGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentVelocity1: number;
  17911. /** @hidden */
  17912. _currentVelocity2: number;
  17913. /** @hidden */
  17914. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentLimitVelocity1: number;
  17917. /** @hidden */
  17918. _currentLimitVelocity2: number;
  17919. /** @hidden */
  17920. _currentDragGradient: Nullable<FactorGradient>;
  17921. /** @hidden */
  17922. _currentDrag1: number;
  17923. /** @hidden */
  17924. _currentDrag2: number;
  17925. /** @hidden */
  17926. _randomNoiseCoordinates1: Vector3;
  17927. /** @hidden */
  17928. _randomNoiseCoordinates2: Vector3;
  17929. /**
  17930. * Creates a new instance Particle
  17931. * @param particleSystem the particle system the particle belongs to
  17932. */
  17933. constructor(
  17934. /**
  17935. * The particle system the particle belongs to.
  17936. */
  17937. particleSystem: ParticleSystem);
  17938. private updateCellInfoFromSystem;
  17939. /**
  17940. * Defines how the sprite cell index is updated for the particle
  17941. */
  17942. updateCellIndex(): void;
  17943. /** @hidden */
  17944. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17945. /** @hidden */
  17946. _inheritParticleInfoToSubEmitters(): void;
  17947. /** @hidden */
  17948. _reset(): void;
  17949. /**
  17950. * Copy the properties of particle to another one.
  17951. * @param other the particle to copy the information to.
  17952. */
  17953. copyTo(other: Particle): void;
  17954. }
  17955. }
  17956. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17957. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17958. import { Effect } from "babylonjs/Materials/effect";
  17959. import { Particle } from "babylonjs/Particles/particle";
  17960. /**
  17961. * Particle emitter represents a volume emitting particles.
  17962. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17963. */
  17964. export interface IParticleEmitterType {
  17965. /**
  17966. * Called by the particle System when the direction is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param directionToUpdate is the direction vector to update with the result
  17969. * @param particle is the particle we are computed the direction for
  17970. */
  17971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Called by the particle System when the position is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param positionToUpdate is the position vector to update with the result
  17976. * @param particle is the particle we are computed the position for
  17977. */
  17978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Clones the current emitter and returns a copy of it
  17981. * @returns the new emitter
  17982. */
  17983. clone(): IParticleEmitterType;
  17984. /**
  17985. * Called by the GPUParticleSystem to setup the update shader
  17986. * @param effect defines the update shader
  17987. */
  17988. applyToShader(effect: Effect): void;
  17989. /**
  17990. * Returns a string to use to update the GPU particles update shader
  17991. * @returns the effect defines string
  17992. */
  17993. getEffectDefines(): string;
  17994. /**
  17995. * Returns a string representing the class name
  17996. * @returns a string containing the class name
  17997. */
  17998. getClassName(): string;
  17999. /**
  18000. * Serializes the particle system to a JSON object.
  18001. * @returns the JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Parse properties from a JSON object
  18006. * @param serializationObject defines the JSON object
  18007. */
  18008. parse(serializationObject: any): void;
  18009. }
  18010. }
  18011. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18012. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18013. import { Effect } from "babylonjs/Materials/effect";
  18014. import { Particle } from "babylonjs/Particles/particle";
  18015. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a box.
  18018. * It emits the particles randomly between 2 given directions.
  18019. */
  18020. export class BoxParticleEmitter implements IParticleEmitterType {
  18021. /**
  18022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * 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.
  18031. */
  18032. minEmitBox: Vector3;
  18033. /**
  18034. * 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.
  18035. */
  18036. maxEmitBox: Vector3;
  18037. /**
  18038. * Creates a new instance BoxParticleEmitter
  18039. */
  18040. constructor();
  18041. /**
  18042. * Called by the particle System when the direction is computed for the created particle.
  18043. * @param worldMatrix is the world matrix of the particle system
  18044. * @param directionToUpdate is the direction vector to update with the result
  18045. * @param particle is the particle we are computed the direction for
  18046. */
  18047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18048. /**
  18049. * Called by the particle System when the position is computed for the created particle.
  18050. * @param worldMatrix is the world matrix of the particle system
  18051. * @param positionToUpdate is the position vector to update with the result
  18052. * @param particle is the particle we are computed the position for
  18053. */
  18054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18055. /**
  18056. * Clones the current emitter and returns a copy of it
  18057. * @returns the new emitter
  18058. */
  18059. clone(): BoxParticleEmitter;
  18060. /**
  18061. * Called by the GPUParticleSystem to setup the update shader
  18062. * @param effect defines the update shader
  18063. */
  18064. applyToShader(effect: Effect): void;
  18065. /**
  18066. * Returns a string to use to update the GPU particles update shader
  18067. * @returns a string containng the defines string
  18068. */
  18069. getEffectDefines(): string;
  18070. /**
  18071. * Returns the string "BoxParticleEmitter"
  18072. * @returns a string containing the class name
  18073. */
  18074. getClassName(): string;
  18075. /**
  18076. * Serializes the particle system to a JSON object.
  18077. * @returns the JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Parse properties from a JSON object
  18082. * @param serializationObject defines the JSON object
  18083. */
  18084. parse(serializationObject: any): void;
  18085. }
  18086. }
  18087. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18088. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18089. import { Effect } from "babylonjs/Materials/effect";
  18090. import { Particle } from "babylonjs/Particles/particle";
  18091. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18092. /**
  18093. * Particle emitter emitting particles from the inside of a cone.
  18094. * It emits the particles alongside the cone volume from the base to the particle.
  18095. * The emission direction might be randomized.
  18096. */
  18097. export class ConeParticleEmitter implements IParticleEmitterType {
  18098. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18099. directionRandomizer: number;
  18100. private _radius;
  18101. private _angle;
  18102. private _height;
  18103. /**
  18104. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18105. */
  18106. radiusRange: number;
  18107. /**
  18108. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. heightRange: number;
  18111. /**
  18112. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18113. */
  18114. emitFromSpawnPointOnly: boolean;
  18115. /**
  18116. * Gets or sets the radius of the emission cone
  18117. */
  18118. radius: number;
  18119. /**
  18120. * Gets or sets the angle of the emission cone
  18121. */
  18122. angle: number;
  18123. private _buildHeight;
  18124. /**
  18125. * Creates a new instance ConeParticleEmitter
  18126. * @param radius the radius of the emission cone (1 by default)
  18127. * @param angle the cone base angle (PI by default)
  18128. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18129. */
  18130. constructor(radius?: number, angle?: number,
  18131. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18132. directionRandomizer?: number);
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): ConeParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "ConeParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cylinder.
  18186. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18187. */
  18188. export class CylinderParticleEmitter implements IParticleEmitterType {
  18189. /**
  18190. * The radius of the emission cylinder.
  18191. */
  18192. radius: number;
  18193. /**
  18194. * The height of the emission cylinder.
  18195. */
  18196. height: number;
  18197. /**
  18198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18199. */
  18200. radiusRange: number;
  18201. /**
  18202. * How much to randomize the particle direction [0-1].
  18203. */
  18204. directionRandomizer: number;
  18205. /**
  18206. * Creates a new instance CylinderParticleEmitter
  18207. * @param radius the radius of the emission cylinder (1 by default)
  18208. * @param height the height of the emission cylinder (1 by default)
  18209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18211. */
  18212. constructor(
  18213. /**
  18214. * The radius of the emission cylinder.
  18215. */
  18216. radius?: number,
  18217. /**
  18218. * The height of the emission cylinder.
  18219. */
  18220. height?: number,
  18221. /**
  18222. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18223. */
  18224. radiusRange?: number,
  18225. /**
  18226. * How much to randomize the particle direction [0-1].
  18227. */
  18228. directionRandomizer?: number);
  18229. /**
  18230. * Called by the particle System when the direction is computed for the created particle.
  18231. * @param worldMatrix is the world matrix of the particle system
  18232. * @param directionToUpdate is the direction vector to update with the result
  18233. * @param particle is the particle we are computed the direction for
  18234. */
  18235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18236. /**
  18237. * Called by the particle System when the position is computed for the created particle.
  18238. * @param worldMatrix is the world matrix of the particle system
  18239. * @param positionToUpdate is the position vector to update with the result
  18240. * @param particle is the particle we are computed the position for
  18241. */
  18242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18243. /**
  18244. * Clones the current emitter and returns a copy of it
  18245. * @returns the new emitter
  18246. */
  18247. clone(): CylinderParticleEmitter;
  18248. /**
  18249. * Called by the GPUParticleSystem to setup the update shader
  18250. * @param effect defines the update shader
  18251. */
  18252. applyToShader(effect: Effect): void;
  18253. /**
  18254. * Returns a string to use to update the GPU particles update shader
  18255. * @returns a string containng the defines string
  18256. */
  18257. getEffectDefines(): string;
  18258. /**
  18259. * Returns the string "CylinderParticleEmitter"
  18260. * @returns a string containing the class name
  18261. */
  18262. getClassName(): string;
  18263. /**
  18264. * Serializes the particle system to a JSON object.
  18265. * @returns the JSON object
  18266. */
  18267. serialize(): any;
  18268. /**
  18269. * Parse properties from a JSON object
  18270. * @param serializationObject defines the JSON object
  18271. */
  18272. parse(serializationObject: any): void;
  18273. }
  18274. /**
  18275. * Particle emitter emitting particles from the inside of a cylinder.
  18276. * It emits the particles randomly between two vectors.
  18277. */
  18278. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18279. /**
  18280. * The min limit of the emission direction.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * The max limit of the emission direction.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance CylinderDirectedParticleEmitter
  18289. * @param radius the radius of the emission cylinder (1 by default)
  18290. * @param height the height of the emission cylinder (1 by default)
  18291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18292. * @param direction1 the min limit of the emission direction (up vector by default)
  18293. * @param direction2 the max limit of the emission direction (up vector by default)
  18294. */
  18295. constructor(radius?: number, height?: number, radiusRange?: number,
  18296. /**
  18297. * The min limit of the emission direction.
  18298. */
  18299. direction1?: Vector3,
  18300. /**
  18301. * The max limit of the emission direction.
  18302. */
  18303. direction2?: Vector3);
  18304. /**
  18305. * Called by the particle System when the direction is computed for the created particle.
  18306. * @param worldMatrix is the world matrix of the particle system
  18307. * @param directionToUpdate is the direction vector to update with the result
  18308. * @param particle is the particle we are computed the direction for
  18309. */
  18310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18311. /**
  18312. * Clones the current emitter and returns a copy of it
  18313. * @returns the new emitter
  18314. */
  18315. clone(): CylinderDirectedParticleEmitter;
  18316. /**
  18317. * Called by the GPUParticleSystem to setup the update shader
  18318. * @param effect defines the update shader
  18319. */
  18320. applyToShader(effect: Effect): void;
  18321. /**
  18322. * Returns a string to use to update the GPU particles update shader
  18323. * @returns a string containng the defines string
  18324. */
  18325. getEffectDefines(): string;
  18326. /**
  18327. * Returns the string "CylinderDirectedParticleEmitter"
  18328. * @returns a string containing the class name
  18329. */
  18330. getClassName(): string;
  18331. /**
  18332. * Serializes the particle system to a JSON object.
  18333. * @returns the JSON object
  18334. */
  18335. serialize(): any;
  18336. /**
  18337. * Parse properties from a JSON object
  18338. * @param serializationObject defines the JSON object
  18339. */
  18340. parse(serializationObject: any): void;
  18341. }
  18342. }
  18343. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18344. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18345. import { Effect } from "babylonjs/Materials/effect";
  18346. import { Particle } from "babylonjs/Particles/particle";
  18347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18348. /**
  18349. * Particle emitter emitting particles from the inside of a hemisphere.
  18350. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18351. */
  18352. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18353. /**
  18354. * The radius of the emission hemisphere.
  18355. */
  18356. radius: number;
  18357. /**
  18358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18359. */
  18360. radiusRange: number;
  18361. /**
  18362. * How much to randomize the particle direction [0-1].
  18363. */
  18364. directionRandomizer: number;
  18365. /**
  18366. * Creates a new instance HemisphericParticleEmitter
  18367. * @param radius the radius of the emission hemisphere (1 by default)
  18368. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18370. */
  18371. constructor(
  18372. /**
  18373. * The radius of the emission hemisphere.
  18374. */
  18375. radius?: number,
  18376. /**
  18377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18378. */
  18379. radiusRange?: number,
  18380. /**
  18381. * How much to randomize the particle direction [0-1].
  18382. */
  18383. directionRandomizer?: number);
  18384. /**
  18385. * Called by the particle System when the direction is computed for the created particle.
  18386. * @param worldMatrix is the world matrix of the particle system
  18387. * @param directionToUpdate is the direction vector to update with the result
  18388. * @param particle is the particle we are computed the direction for
  18389. */
  18390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18391. /**
  18392. * Called by the particle System when the position is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param positionToUpdate is the position vector to update with the result
  18395. * @param particle is the particle we are computed the position for
  18396. */
  18397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): HemisphericParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "HemisphericParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18435. /**
  18436. * Particle emitter emitting particles from a point.
  18437. * It emits the particles randomly between 2 given directions.
  18438. */
  18439. export class PointParticleEmitter implements IParticleEmitterType {
  18440. /**
  18441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18442. */
  18443. direction1: Vector3;
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction2: Vector3;
  18448. /**
  18449. * Creates a new instance PointParticleEmitter
  18450. */
  18451. constructor();
  18452. /**
  18453. * Called by the particle System when the direction is computed for the created particle.
  18454. * @param worldMatrix is the world matrix of the particle system
  18455. * @param directionToUpdate is the direction vector to update with the result
  18456. * @param particle is the particle we are computed the direction for
  18457. */
  18458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18459. /**
  18460. * Called by the particle System when the position is computed for the created particle.
  18461. * @param worldMatrix is the world matrix of the particle system
  18462. * @param positionToUpdate is the position vector to update with the result
  18463. * @param particle is the particle we are computed the position for
  18464. */
  18465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18466. /**
  18467. * Clones the current emitter and returns a copy of it
  18468. * @returns the new emitter
  18469. */
  18470. clone(): PointParticleEmitter;
  18471. /**
  18472. * Called by the GPUParticleSystem to setup the update shader
  18473. * @param effect defines the update shader
  18474. */
  18475. applyToShader(effect: Effect): void;
  18476. /**
  18477. * Returns a string to use to update the GPU particles update shader
  18478. * @returns a string containng the defines string
  18479. */
  18480. getEffectDefines(): string;
  18481. /**
  18482. * Returns the string "PointParticleEmitter"
  18483. * @returns a string containing the class name
  18484. */
  18485. getClassName(): string;
  18486. /**
  18487. * Serializes the particle system to a JSON object.
  18488. * @returns the JSON object
  18489. */
  18490. serialize(): any;
  18491. /**
  18492. * Parse properties from a JSON object
  18493. * @param serializationObject defines the JSON object
  18494. */
  18495. parse(serializationObject: any): void;
  18496. }
  18497. }
  18498. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18499. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18500. import { Effect } from "babylonjs/Materials/effect";
  18501. import { Particle } from "babylonjs/Particles/particle";
  18502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18503. /**
  18504. * Particle emitter emitting particles from the inside of a sphere.
  18505. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18506. */
  18507. export class SphereParticleEmitter implements IParticleEmitterType {
  18508. /**
  18509. * The radius of the emission sphere.
  18510. */
  18511. radius: number;
  18512. /**
  18513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18514. */
  18515. radiusRange: number;
  18516. /**
  18517. * How much to randomize the particle direction [0-1].
  18518. */
  18519. directionRandomizer: number;
  18520. /**
  18521. * Creates a new instance SphereParticleEmitter
  18522. * @param radius the radius of the emission sphere (1 by default)
  18523. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18525. */
  18526. constructor(
  18527. /**
  18528. * The radius of the emission sphere.
  18529. */
  18530. radius?: number,
  18531. /**
  18532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18533. */
  18534. radiusRange?: number,
  18535. /**
  18536. * How much to randomize the particle direction [0-1].
  18537. */
  18538. directionRandomizer?: number);
  18539. /**
  18540. * Called by the particle System when the direction is computed for the created particle.
  18541. * @param worldMatrix is the world matrix of the particle system
  18542. * @param directionToUpdate is the direction vector to update with the result
  18543. * @param particle is the particle we are computed the direction for
  18544. */
  18545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18546. /**
  18547. * Called by the particle System when the position is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param positionToUpdate is the position vector to update with the result
  18550. * @param particle is the particle we are computed the position for
  18551. */
  18552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. /**
  18585. * Particle emitter emitting particles from the inside of a sphere.
  18586. * It emits the particles randomly between two vectors.
  18587. */
  18588. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18589. /**
  18590. * The min limit of the emission direction.
  18591. */
  18592. direction1: Vector3;
  18593. /**
  18594. * The max limit of the emission direction.
  18595. */
  18596. direction2: Vector3;
  18597. /**
  18598. * Creates a new instance SphereDirectedParticleEmitter
  18599. * @param radius the radius of the emission sphere (1 by default)
  18600. * @param direction1 the min limit of the emission direction (up vector by default)
  18601. * @param direction2 the max limit of the emission direction (up vector by default)
  18602. */
  18603. constructor(radius?: number,
  18604. /**
  18605. * The min limit of the emission direction.
  18606. */
  18607. direction1?: Vector3,
  18608. /**
  18609. * The max limit of the emission direction.
  18610. */
  18611. direction2?: Vector3);
  18612. /**
  18613. * Called by the particle System when the direction is computed for the created particle.
  18614. * @param worldMatrix is the world matrix of the particle system
  18615. * @param directionToUpdate is the direction vector to update with the result
  18616. * @param particle is the particle we are computed the direction for
  18617. */
  18618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18619. /**
  18620. * Clones the current emitter and returns a copy of it
  18621. * @returns the new emitter
  18622. */
  18623. clone(): SphereDirectedParticleEmitter;
  18624. /**
  18625. * Called by the GPUParticleSystem to setup the update shader
  18626. * @param effect defines the update shader
  18627. */
  18628. applyToShader(effect: Effect): void;
  18629. /**
  18630. * Returns a string to use to update the GPU particles update shader
  18631. * @returns a string containng the defines string
  18632. */
  18633. getEffectDefines(): string;
  18634. /**
  18635. * Returns the string "SphereDirectedParticleEmitter"
  18636. * @returns a string containing the class name
  18637. */
  18638. getClassName(): string;
  18639. /**
  18640. * Serializes the particle system to a JSON object.
  18641. * @returns the JSON object
  18642. */
  18643. serialize(): any;
  18644. /**
  18645. * Parse properties from a JSON object
  18646. * @param serializationObject defines the JSON object
  18647. */
  18648. parse(serializationObject: any): void;
  18649. }
  18650. }
  18651. declare module "babylonjs/Particles/EmitterTypes/index" {
  18652. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18653. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18654. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18655. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18656. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18657. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18659. }
  18660. declare module "babylonjs/Particles/IParticleSystem" {
  18661. import { Nullable } from "babylonjs/types";
  18662. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18663. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18666. import { Texture } from "babylonjs/Materials/Textures/texture";
  18667. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18668. import { Scene } from "babylonjs/scene";
  18669. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18670. import { Animation } from "babylonjs/Animations/animation";
  18671. /**
  18672. * Interface representing a particle system in Babylon.js.
  18673. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18674. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18675. */
  18676. export interface IParticleSystem {
  18677. /**
  18678. * List of animations used by the particle system.
  18679. */
  18680. animations: Animation[];
  18681. /**
  18682. * The id of the Particle system.
  18683. */
  18684. id: string;
  18685. /**
  18686. * The name of the Particle system.
  18687. */
  18688. name: string;
  18689. /**
  18690. * The emitter represents the Mesh or position we are attaching the particle system to.
  18691. */
  18692. emitter: Nullable<AbstractMesh | Vector3>;
  18693. /**
  18694. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18695. */
  18696. isBillboardBased: boolean;
  18697. /**
  18698. * The rendering group used by the Particle system to chose when to render.
  18699. */
  18700. renderingGroupId: number;
  18701. /**
  18702. * The layer mask we are rendering the particles through.
  18703. */
  18704. layerMask: number;
  18705. /**
  18706. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18707. */
  18708. updateSpeed: number;
  18709. /**
  18710. * The amount of time the particle system is running (depends of the overall update speed).
  18711. */
  18712. targetStopDuration: number;
  18713. /**
  18714. * The texture used to render each particle. (this can be a spritesheet)
  18715. */
  18716. particleTexture: Nullable<Texture>;
  18717. /**
  18718. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18719. */
  18720. blendMode: number;
  18721. /**
  18722. * Minimum life time of emitting particles.
  18723. */
  18724. minLifeTime: number;
  18725. /**
  18726. * Maximum life time of emitting particles.
  18727. */
  18728. maxLifeTime: number;
  18729. /**
  18730. * Minimum Size of emitting particles.
  18731. */
  18732. minSize: number;
  18733. /**
  18734. * Maximum Size of emitting particles.
  18735. */
  18736. maxSize: number;
  18737. /**
  18738. * Minimum scale of emitting particles on X axis.
  18739. */
  18740. minScaleX: number;
  18741. /**
  18742. * Maximum scale of emitting particles on X axis.
  18743. */
  18744. maxScaleX: number;
  18745. /**
  18746. * Minimum scale of emitting particles on Y axis.
  18747. */
  18748. minScaleY: number;
  18749. /**
  18750. * Maximum scale of emitting particles on Y axis.
  18751. */
  18752. maxScaleY: number;
  18753. /**
  18754. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18755. */
  18756. color1: Color4;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color2: Color4;
  18761. /**
  18762. * Color the particle will have at the end of its lifetime.
  18763. */
  18764. colorDead: Color4;
  18765. /**
  18766. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * You can use gravity if you want to give an orientation to your particles.
  18771. */
  18772. gravity: Vector3;
  18773. /**
  18774. * Minimum power of emitting particles.
  18775. */
  18776. minEmitPower: number;
  18777. /**
  18778. * Maximum power of emitting particles.
  18779. */
  18780. maxEmitPower: number;
  18781. /**
  18782. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18783. */
  18784. minAngularSpeed: number;
  18785. /**
  18786. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. maxAngularSpeed: number;
  18789. /**
  18790. * Gets or sets the minimal initial rotation in radians.
  18791. */
  18792. minInitialRotation: number;
  18793. /**
  18794. * Gets or sets the maximal initial rotation in radians.
  18795. */
  18796. maxInitialRotation: number;
  18797. /**
  18798. * The particle emitter type defines the emitter used by the particle system.
  18799. * It can be for example box, sphere, or cone...
  18800. */
  18801. particleEmitterType: Nullable<IParticleEmitterType>;
  18802. /**
  18803. * Defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. startDelay: number;
  18806. /**
  18807. * 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
  18808. */
  18809. preWarmCycles: number;
  18810. /**
  18811. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18812. */
  18813. preWarmStepOffset: number;
  18814. /**
  18815. * 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)
  18816. */
  18817. spriteCellChangeSpeed: number;
  18818. /**
  18819. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18820. */
  18821. startSpriteCellID: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18824. */
  18825. endSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18828. */
  18829. spriteCellWidth: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18832. */
  18833. spriteCellHeight: number;
  18834. /**
  18835. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18836. */
  18837. spriteRandomStartCell: boolean;
  18838. /**
  18839. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18840. */
  18841. isAnimationSheetEnabled: boolean;
  18842. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18843. translationPivot: Vector2;
  18844. /**
  18845. * Gets or sets a texture used to add random noise to particle positions
  18846. */
  18847. noiseTexture: Nullable<BaseTexture>;
  18848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18849. noiseStrength: Vector3;
  18850. /**
  18851. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18852. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18853. */
  18854. billboardMode: number;
  18855. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18856. limitVelocityDamping: number;
  18857. /**
  18858. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18859. */
  18860. beginAnimationOnStart: boolean;
  18861. /**
  18862. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18863. */
  18864. beginAnimationFrom: number;
  18865. /**
  18866. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationTo: number;
  18869. /**
  18870. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationLoop: boolean;
  18873. /**
  18874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18875. */
  18876. disposeOnStop: boolean;
  18877. /**
  18878. * Gets the maximum number of particles active at the same time.
  18879. * @returns The max number of active particles.
  18880. */
  18881. getCapacity(): number;
  18882. /**
  18883. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18884. * @returns True if it has been started, otherwise false.
  18885. */
  18886. isStarted(): boolean;
  18887. /**
  18888. * Animates the particle system for this frame.
  18889. */
  18890. animate(): void;
  18891. /**
  18892. * Renders the particle system in its current state.
  18893. * @returns the current number of particles
  18894. */
  18895. render(): number;
  18896. /**
  18897. * Dispose the particle system and frees its associated resources.
  18898. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18899. */
  18900. dispose(disposeTexture?: boolean): void;
  18901. /**
  18902. * Clones the particle system.
  18903. * @param name The name of the cloned object
  18904. * @param newEmitter The new emitter to use
  18905. * @returns the cloned particle system
  18906. */
  18907. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18908. /**
  18909. * Serializes the particle system to a JSON object.
  18910. * @returns the JSON object
  18911. */
  18912. serialize(): any;
  18913. /**
  18914. * Rebuild the particle system
  18915. */
  18916. rebuild(): void;
  18917. /**
  18918. * Starts the particle system and begins to emit
  18919. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18920. */
  18921. start(delay?: number): void;
  18922. /**
  18923. * Stops the particle system.
  18924. */
  18925. stop(): void;
  18926. /**
  18927. * Remove all active particles
  18928. */
  18929. reset(): void;
  18930. /**
  18931. * Is this system ready to be used/rendered
  18932. * @return true if the system is ready
  18933. */
  18934. isReady(): boolean;
  18935. /**
  18936. * Adds a new color gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param color1 defines the color to affect to the specified gradient
  18939. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18940. * @returns the current particle system
  18941. */
  18942. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18943. /**
  18944. * Remove a specific color gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeColorGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Adds a new size gradient
  18951. * @param gradient defines the gradient to use (between 0 and 1)
  18952. * @param factor defines the size factor to affect to the specified gradient
  18953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18954. * @returns the current particle system
  18955. */
  18956. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18957. /**
  18958. * Remove a specific size gradient
  18959. * @param gradient defines the gradient to remove
  18960. * @returns the current particle system
  18961. */
  18962. removeSizeGradient(gradient: number): IParticleSystem;
  18963. /**
  18964. * Gets the current list of color gradients.
  18965. * You must use addColorGradient and removeColorGradient to udpate this list
  18966. * @returns the list of color gradients
  18967. */
  18968. getColorGradients(): Nullable<Array<ColorGradient>>;
  18969. /**
  18970. * Gets the current list of size gradients.
  18971. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18972. * @returns the list of size gradients
  18973. */
  18974. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of angular speed gradients.
  18977. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18978. * @returns the list of angular speed gradients
  18979. */
  18980. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Adds a new angular speed gradient
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param factor defines the angular speed to affect to the specified gradient
  18985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18986. * @returns the current particle system
  18987. */
  18988. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18989. /**
  18990. * Remove a specific angular speed gradient
  18991. * @param gradient defines the gradient to remove
  18992. * @returns the current particle system
  18993. */
  18994. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18995. /**
  18996. * Gets the current list of velocity gradients.
  18997. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18998. * @returns the list of velocity gradients
  18999. */
  19000. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19001. /**
  19002. * Adds a new velocity gradient
  19003. * @param gradient defines the gradient to use (between 0 and 1)
  19004. * @param factor defines the velocity to affect to the specified gradient
  19005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19006. * @returns the current particle system
  19007. */
  19008. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19009. /**
  19010. * Remove a specific velocity gradient
  19011. * @param gradient defines the gradient to remove
  19012. * @returns the current particle system
  19013. */
  19014. removeVelocityGradient(gradient: number): IParticleSystem;
  19015. /**
  19016. * Gets the current list of limit velocity gradients.
  19017. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19018. * @returns the list of limit velocity gradients
  19019. */
  19020. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19021. /**
  19022. * Adds a new limit velocity gradient
  19023. * @param gradient defines the gradient to use (between 0 and 1)
  19024. * @param factor defines the limit velocity to affect to the specified gradient
  19025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19026. * @returns the current particle system
  19027. */
  19028. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19029. /**
  19030. * Remove a specific limit velocity gradient
  19031. * @param gradient defines the gradient to remove
  19032. * @returns the current particle system
  19033. */
  19034. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19035. /**
  19036. * Adds a new drag gradient
  19037. * @param gradient defines the gradient to use (between 0 and 1)
  19038. * @param factor defines the drag to affect to the specified gradient
  19039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19040. * @returns the current particle system
  19041. */
  19042. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19043. /**
  19044. * Remove a specific drag gradient
  19045. * @param gradient defines the gradient to remove
  19046. * @returns the current particle system
  19047. */
  19048. removeDragGradient(gradient: number): IParticleSystem;
  19049. /**
  19050. * Gets the current list of drag gradients.
  19051. * You must use addDragGradient and removeDragGradient to udpate this list
  19052. * @returns the list of drag gradients
  19053. */
  19054. getDragGradients(): Nullable<Array<FactorGradient>>;
  19055. /**
  19056. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param factor defines the emit rate to affect to the specified gradient
  19059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19060. * @returns the current particle system
  19061. */
  19062. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19063. /**
  19064. * Remove a specific emit rate gradient
  19065. * @param gradient defines the gradient to remove
  19066. * @returns the current particle system
  19067. */
  19068. removeEmitRateGradient(gradient: number): IParticleSystem;
  19069. /**
  19070. * Gets the current list of emit rate gradients.
  19071. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19072. * @returns the list of emit rate gradients
  19073. */
  19074. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19075. /**
  19076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19077. * @param gradient defines the gradient to use (between 0 and 1)
  19078. * @param factor defines the start size to affect to the specified gradient
  19079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19080. * @returns the current particle system
  19081. */
  19082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19083. /**
  19084. * Remove a specific start size gradient
  19085. * @param gradient defines the gradient to remove
  19086. * @returns the current particle system
  19087. */
  19088. removeStartSizeGradient(gradient: number): IParticleSystem;
  19089. /**
  19090. * Gets the current list of start size gradients.
  19091. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19092. * @returns the list of start size gradients
  19093. */
  19094. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19095. /**
  19096. * Adds a new life time gradient
  19097. * @param gradient defines the gradient to use (between 0 and 1)
  19098. * @param factor defines the life time factor to affect to the specified gradient
  19099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19100. * @returns the current particle system
  19101. */
  19102. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19103. /**
  19104. * Remove a specific life time gradient
  19105. * @param gradient defines the gradient to remove
  19106. * @returns the current particle system
  19107. */
  19108. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19109. /**
  19110. * Gets the current list of life time gradients.
  19111. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19112. * @returns the list of life time gradients
  19113. */
  19114. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19115. /**
  19116. * Gets the current list of color gradients.
  19117. * You must use addColorGradient and removeColorGradient to udpate this list
  19118. * @returns the list of color gradients
  19119. */
  19120. getColorGradients(): Nullable<Array<ColorGradient>>;
  19121. /**
  19122. * Adds a new ramp gradient used to remap particle colors
  19123. * @param gradient defines the gradient to use (between 0 and 1)
  19124. * @param color defines the color to affect to the specified gradient
  19125. * @returns the current particle system
  19126. */
  19127. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19128. /**
  19129. * Gets the current list of ramp gradients.
  19130. * You must use addRampGradient and removeRampGradient to udpate this list
  19131. * @returns the list of ramp gradients
  19132. */
  19133. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19134. /** Gets or sets a boolean indicating that ramp gradients must be used
  19135. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19136. */
  19137. useRampGradients: boolean;
  19138. /**
  19139. * Adds a new color remap gradient
  19140. * @param gradient defines the gradient to use (between 0 and 1)
  19141. * @param min defines the color remap minimal range
  19142. * @param max defines the color remap maximal range
  19143. * @returns the current particle system
  19144. */
  19145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of color remap gradients.
  19148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19149. * @returns the list of color remap gradients
  19150. */
  19151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new alpha remap gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param min defines the alpha remap minimal range
  19156. * @param max defines the alpha remap maximal range
  19157. * @returns the current particle system
  19158. */
  19159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19160. /**
  19161. * Gets the current list of alpha remap gradients.
  19162. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19163. * @returns the list of alpha remap gradients
  19164. */
  19165. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19166. /**
  19167. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19170. * @returns the emitter
  19171. */
  19172. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19173. /**
  19174. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19175. * @param radius The radius of the hemisphere to emit from
  19176. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19177. * @returns the emitter
  19178. */
  19179. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19180. /**
  19181. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19182. * @param radius The radius of the sphere to emit from
  19183. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19184. * @returns the emitter
  19185. */
  19186. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19187. /**
  19188. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19189. * @param radius The radius of the sphere to emit from
  19190. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19191. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19192. * @returns the emitter
  19193. */
  19194. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19195. /**
  19196. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19197. * @param radius The radius of the emission cylinder
  19198. * @param height The height of the emission cylinder
  19199. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19200. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19201. * @returns the emitter
  19202. */
  19203. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19204. /**
  19205. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19206. * @param radius The radius of the cylinder to emit from
  19207. * @param height The height of the emission cylinder
  19208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19211. * @returns the emitter
  19212. */
  19213. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19214. /**
  19215. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19216. * @param radius The radius of the cone to emit from
  19217. * @param angle The base angle of the cone
  19218. * @returns the emitter
  19219. */
  19220. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19221. /**
  19222. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19225. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19226. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19227. * @returns the emitter
  19228. */
  19229. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19230. /**
  19231. * Get hosting scene
  19232. * @returns the scene
  19233. */
  19234. getScene(): Scene;
  19235. }
  19236. }
  19237. declare module "babylonjs/Meshes/instancedMesh" {
  19238. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19240. import { Camera } from "babylonjs/Cameras/camera";
  19241. import { Node } from "babylonjs/node";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { Material } from "babylonjs/Materials/material";
  19245. import { Skeleton } from "babylonjs/Bones/skeleton";
  19246. import { Light } from "babylonjs/Lights/light";
  19247. /**
  19248. * Creates an instance based on a source mesh.
  19249. */
  19250. export class InstancedMesh extends AbstractMesh {
  19251. private _sourceMesh;
  19252. private _currentLOD;
  19253. /** @hidden */
  19254. _indexInSourceMeshInstanceArray: number;
  19255. constructor(name: string, source: Mesh);
  19256. /**
  19257. * Returns the string "InstancedMesh".
  19258. */
  19259. getClassName(): string;
  19260. /** Gets the list of lights affecting that mesh */
  19261. readonly lightSources: Light[];
  19262. _resyncLightSources(): void;
  19263. _resyncLighSource(light: Light): void;
  19264. _removeLightSource(light: Light, dispose: boolean): void;
  19265. /**
  19266. * If the source mesh receives shadows
  19267. */
  19268. readonly receiveShadows: boolean;
  19269. /**
  19270. * The material of the source mesh
  19271. */
  19272. readonly material: Nullable<Material>;
  19273. /**
  19274. * Visibility of the source mesh
  19275. */
  19276. readonly visibility: number;
  19277. /**
  19278. * Skeleton of the source mesh
  19279. */
  19280. readonly skeleton: Nullable<Skeleton>;
  19281. /**
  19282. * Rendering ground id of the source mesh
  19283. */
  19284. renderingGroupId: number;
  19285. /**
  19286. * Returns the total number of vertices (integer).
  19287. */
  19288. getTotalVertices(): number;
  19289. /**
  19290. * Returns a positive integer : the total number of indices in this mesh geometry.
  19291. * @returns the numner of indices or zero if the mesh has no geometry.
  19292. */
  19293. getTotalIndices(): number;
  19294. /**
  19295. * The source mesh of the instance
  19296. */
  19297. readonly sourceMesh: Mesh;
  19298. /**
  19299. * Is this node ready to be used/rendered
  19300. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19301. * @return {boolean} is it ready
  19302. */
  19303. isReady(completeCheck?: boolean): boolean;
  19304. /**
  19305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19306. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19307. * @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.
  19308. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19309. */
  19310. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19311. /**
  19312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19314. * The `data` are either a numeric array either a Float32Array.
  19315. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19316. * 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).
  19317. * Note that a new underlying VertexBuffer object is created each call.
  19318. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19319. *
  19320. * Possible `kind` values :
  19321. * - VertexBuffer.PositionKind
  19322. * - VertexBuffer.UVKind
  19323. * - VertexBuffer.UV2Kind
  19324. * - VertexBuffer.UV3Kind
  19325. * - VertexBuffer.UV4Kind
  19326. * - VertexBuffer.UV5Kind
  19327. * - VertexBuffer.UV6Kind
  19328. * - VertexBuffer.ColorKind
  19329. * - VertexBuffer.MatricesIndicesKind
  19330. * - VertexBuffer.MatricesIndicesExtraKind
  19331. * - VertexBuffer.MatricesWeightsKind
  19332. * - VertexBuffer.MatricesWeightsExtraKind
  19333. *
  19334. * Returns the Mesh.
  19335. */
  19336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19337. /**
  19338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19339. * If the mesh has no geometry, it is simply returned as it is.
  19340. * The `data` are either a numeric array either a Float32Array.
  19341. * No new underlying VertexBuffer object is created.
  19342. * 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.
  19343. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19344. *
  19345. * Possible `kind` values :
  19346. * - VertexBuffer.PositionKind
  19347. * - VertexBuffer.UVKind
  19348. * - VertexBuffer.UV2Kind
  19349. * - VertexBuffer.UV3Kind
  19350. * - VertexBuffer.UV4Kind
  19351. * - VertexBuffer.UV5Kind
  19352. * - VertexBuffer.UV6Kind
  19353. * - VertexBuffer.ColorKind
  19354. * - VertexBuffer.MatricesIndicesKind
  19355. * - VertexBuffer.MatricesIndicesExtraKind
  19356. * - VertexBuffer.MatricesWeightsKind
  19357. * - VertexBuffer.MatricesWeightsExtraKind
  19358. *
  19359. * Returns the Mesh.
  19360. */
  19361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19362. /**
  19363. * Sets the mesh indices.
  19364. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19366. * This method creates a new index buffer each call.
  19367. * Returns the Mesh.
  19368. */
  19369. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19370. /**
  19371. * Boolean : True if the mesh owns the requested kind of data.
  19372. */
  19373. isVerticesDataPresent(kind: string): boolean;
  19374. /**
  19375. * Returns an array of indices (IndicesArray).
  19376. */
  19377. getIndices(): Nullable<IndicesArray>;
  19378. readonly _positions: Nullable<Vector3[]>;
  19379. /**
  19380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19381. * This means the mesh underlying bounding box and sphere are recomputed.
  19382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19383. * @returns the current mesh
  19384. */
  19385. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19386. /** @hidden */
  19387. _preActivate(): InstancedMesh;
  19388. /** @hidden */
  19389. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19390. /** @hidden */
  19391. _postActivate(): void;
  19392. getWorldMatrix(): Matrix;
  19393. readonly isAnInstance: boolean;
  19394. /**
  19395. * Returns the current associated LOD AbstractMesh.
  19396. */
  19397. getLOD(camera: Camera): AbstractMesh;
  19398. /** @hidden */
  19399. _syncSubMeshes(): InstancedMesh;
  19400. /** @hidden */
  19401. _generatePointsArray(): boolean;
  19402. /**
  19403. * Creates a new InstancedMesh from the current mesh.
  19404. * - name (string) : the cloned mesh name
  19405. * - newParent (optional Node) : the optional Node to parent the clone to.
  19406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19407. *
  19408. * Returns the clone.
  19409. */
  19410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19411. /**
  19412. * Disposes the InstancedMesh.
  19413. * Returns nothing.
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. }
  19417. }
  19418. declare module "babylonjs/Materials/shaderMaterial" {
  19419. import { Scene } from "babylonjs/scene";
  19420. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19422. import { Mesh } from "babylonjs/Meshes/mesh";
  19423. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19425. import { Texture } from "babylonjs/Materials/Textures/texture";
  19426. import { Material } from "babylonjs/Materials/material";
  19427. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19428. /**
  19429. * Defines the options associated with the creation of a shader material.
  19430. */
  19431. export interface IShaderMaterialOptions {
  19432. /**
  19433. * Does the material work in alpha blend mode
  19434. */
  19435. needAlphaBlending: boolean;
  19436. /**
  19437. * Does the material work in alpha test mode
  19438. */
  19439. needAlphaTesting: boolean;
  19440. /**
  19441. * The list of attribute names used in the shader
  19442. */
  19443. attributes: string[];
  19444. /**
  19445. * The list of unifrom names used in the shader
  19446. */
  19447. uniforms: string[];
  19448. /**
  19449. * The list of UBO names used in the shader
  19450. */
  19451. uniformBuffers: string[];
  19452. /**
  19453. * The list of sampler names used in the shader
  19454. */
  19455. samplers: string[];
  19456. /**
  19457. * The list of defines used in the shader
  19458. */
  19459. defines: string[];
  19460. }
  19461. /**
  19462. * 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.
  19463. *
  19464. * This returned material effects how the mesh will look based on the code in the shaders.
  19465. *
  19466. * @see http://doc.babylonjs.com/how_to/shader_material
  19467. */
  19468. export class ShaderMaterial extends Material {
  19469. private _shaderPath;
  19470. private _options;
  19471. private _textures;
  19472. private _textureArrays;
  19473. private _floats;
  19474. private _ints;
  19475. private _floatsArrays;
  19476. private _colors3;
  19477. private _colors3Arrays;
  19478. private _colors4;
  19479. private _colors4Arrays;
  19480. private _vectors2;
  19481. private _vectors3;
  19482. private _vectors4;
  19483. private _matrices;
  19484. private _matrices3x3;
  19485. private _matrices2x2;
  19486. private _vectors2Arrays;
  19487. private _vectors3Arrays;
  19488. private _vectors4Arrays;
  19489. private _cachedWorldViewMatrix;
  19490. private _cachedWorldViewProjectionMatrix;
  19491. private _renderId;
  19492. /**
  19493. * Instantiate a new shader material.
  19494. * 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.
  19495. * This returned material effects how the mesh will look based on the code in the shaders.
  19496. * @see http://doc.babylonjs.com/how_to/shader_material
  19497. * @param name Define the name of the material in the scene
  19498. * @param scene Define the scene the material belongs to
  19499. * @param shaderPath Defines the route to the shader code in one of three ways:
  19500. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19501. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19502. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19503. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19504. * @param options Define the options used to create the shader
  19505. */
  19506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19507. /**
  19508. * Gets the options used to compile the shader.
  19509. * They can be modified to trigger a new compilation
  19510. */
  19511. readonly options: IShaderMaterialOptions;
  19512. /**
  19513. * Gets the current class name of the material e.g. "ShaderMaterial"
  19514. * Mainly use in serialization.
  19515. * @returns the class name
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * Specifies if the material will require alpha blending
  19520. * @returns a boolean specifying if alpha blending is needed
  19521. */
  19522. needAlphaBlending(): boolean;
  19523. /**
  19524. * Specifies if this material should be rendered in alpha test mode
  19525. * @returns a boolean specifying if an alpha test is needed.
  19526. */
  19527. needAlphaTesting(): boolean;
  19528. private _checkUniform;
  19529. /**
  19530. * Set a texture in the shader.
  19531. * @param name Define the name of the uniform samplers as defined in the shader
  19532. * @param texture Define the texture to bind to this sampler
  19533. * @return the material itself allowing "fluent" like uniform updates
  19534. */
  19535. setTexture(name: string, texture: Texture): ShaderMaterial;
  19536. /**
  19537. * Set a texture array in the shader.
  19538. * @param name Define the name of the uniform sampler array as defined in the shader
  19539. * @param textures Define the list of textures to bind to this sampler
  19540. * @return the material itself allowing "fluent" like uniform updates
  19541. */
  19542. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19543. /**
  19544. * Set a float in the shader.
  19545. * @param name Define the name of the uniform as defined in the shader
  19546. * @param value Define the value to give to the uniform
  19547. * @return the material itself allowing "fluent" like uniform updates
  19548. */
  19549. setFloat(name: string, value: number): ShaderMaterial;
  19550. /**
  19551. * Set a int in the shader.
  19552. * @param name Define the name of the uniform as defined in the shader
  19553. * @param value Define the value to give to the uniform
  19554. * @return the material itself allowing "fluent" like uniform updates
  19555. */
  19556. setInt(name: string, value: number): ShaderMaterial;
  19557. /**
  19558. * Set an array of floats in the shader.
  19559. * @param name Define the name of the uniform as defined in the shader
  19560. * @param value Define the value to give to the uniform
  19561. * @return the material itself allowing "fluent" like uniform updates
  19562. */
  19563. setFloats(name: string, value: number[]): ShaderMaterial;
  19564. /**
  19565. * Set a vec3 in the shader from a Color3.
  19566. * @param name Define the name of the uniform as defined in the shader
  19567. * @param value Define the value to give to the uniform
  19568. * @return the material itself allowing "fluent" like uniform updates
  19569. */
  19570. setColor3(name: string, value: Color3): ShaderMaterial;
  19571. /**
  19572. * Set a vec3 array in the shader from a Color3 array.
  19573. * @param name Define the name of the uniform as defined in the shader
  19574. * @param value Define the value to give to the uniform
  19575. * @return the material itself allowing "fluent" like uniform updates
  19576. */
  19577. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19578. /**
  19579. * Set a vec4 in the shader from a Color4.
  19580. * @param name Define the name of the uniform as defined in the shader
  19581. * @param value Define the value to give to the uniform
  19582. * @return the material itself allowing "fluent" like uniform updates
  19583. */
  19584. setColor4(name: string, value: Color4): ShaderMaterial;
  19585. /**
  19586. * Set a vec4 array in the shader from a Color4 array.
  19587. * @param name Define the name of the uniform as defined in the shader
  19588. * @param value Define the value to give to the uniform
  19589. * @return the material itself allowing "fluent" like uniform updates
  19590. */
  19591. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19592. /**
  19593. * Set a vec2 in the shader from a Vector2.
  19594. * @param name Define the name of the uniform as defined in the shader
  19595. * @param value Define the value to give to the uniform
  19596. * @return the material itself allowing "fluent" like uniform updates
  19597. */
  19598. setVector2(name: string, value: Vector2): ShaderMaterial;
  19599. /**
  19600. * Set a vec3 in the shader from a Vector3.
  19601. * @param name Define the name of the uniform as defined in the shader
  19602. * @param value Define the value to give to the uniform
  19603. * @return the material itself allowing "fluent" like uniform updates
  19604. */
  19605. setVector3(name: string, value: Vector3): ShaderMaterial;
  19606. /**
  19607. * Set a vec4 in the shader from a Vector4.
  19608. * @param name Define the name of the uniform as defined in the shader
  19609. * @param value Define the value to give to the uniform
  19610. * @return the material itself allowing "fluent" like uniform updates
  19611. */
  19612. setVector4(name: string, value: Vector4): ShaderMaterial;
  19613. /**
  19614. * Set a mat4 in the shader from a Matrix.
  19615. * @param name Define the name of the uniform as defined in the shader
  19616. * @param value Define the value to give to the uniform
  19617. * @return the material itself allowing "fluent" like uniform updates
  19618. */
  19619. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19620. /**
  19621. * Set a mat3 in the shader from a Float32Array.
  19622. * @param name Define the name of the uniform as defined in the shader
  19623. * @param value Define the value to give to the uniform
  19624. * @return the material itself allowing "fluent" like uniform updates
  19625. */
  19626. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19627. /**
  19628. * Set a mat2 in the shader from a Float32Array.
  19629. * @param name Define the name of the uniform as defined in the shader
  19630. * @param value Define the value to give to the uniform
  19631. * @return the material itself allowing "fluent" like uniform updates
  19632. */
  19633. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19634. /**
  19635. * Set a vec2 array in the shader from a number array.
  19636. * @param name Define the name of the uniform as defined in the shader
  19637. * @param value Define the value to give to the uniform
  19638. * @return the material itself allowing "fluent" like uniform updates
  19639. */
  19640. setArray2(name: string, value: number[]): ShaderMaterial;
  19641. /**
  19642. * Set a vec3 array in the shader from a number array.
  19643. * @param name Define the name of the uniform as defined in the shader
  19644. * @param value Define the value to give to the uniform
  19645. * @return the material itself allowing "fluent" like uniform updates
  19646. */
  19647. setArray3(name: string, value: number[]): ShaderMaterial;
  19648. /**
  19649. * Set a vec4 array in the shader from a number array.
  19650. * @param name Define the name of the uniform as defined in the shader
  19651. * @param value Define the value to give to the uniform
  19652. * @return the material itself allowing "fluent" like uniform updates
  19653. */
  19654. setArray4(name: string, value: number[]): ShaderMaterial;
  19655. private _checkCache;
  19656. /**
  19657. * Specifies that the submesh is ready to be used
  19658. * @param mesh defines the mesh to check
  19659. * @param subMesh defines which submesh to check
  19660. * @param useInstances specifies that instances should be used
  19661. * @returns a boolean indicating that the submesh is ready or not
  19662. */
  19663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19664. /**
  19665. * Checks if the material is ready to render the requested mesh
  19666. * @param mesh Define the mesh to render
  19667. * @param useInstances Define whether or not the material is used with instances
  19668. * @returns true if ready, otherwise false
  19669. */
  19670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19671. /**
  19672. * Binds the world matrix to the material
  19673. * @param world defines the world transformation matrix
  19674. */
  19675. bindOnlyWorldMatrix(world: Matrix): void;
  19676. /**
  19677. * Binds the material to the mesh
  19678. * @param world defines the world transformation matrix
  19679. * @param mesh defines the mesh to bind the material to
  19680. */
  19681. bind(world: Matrix, mesh?: Mesh): void;
  19682. /**
  19683. * Gets the active textures from the material
  19684. * @returns an array of textures
  19685. */
  19686. getActiveTextures(): BaseTexture[];
  19687. /**
  19688. * Specifies if the material uses a texture
  19689. * @param texture defines the texture to check against the material
  19690. * @returns a boolean specifying if the material uses the texture
  19691. */
  19692. hasTexture(texture: BaseTexture): boolean;
  19693. /**
  19694. * Makes a duplicate of the material, and gives it a new name
  19695. * @param name defines the new name for the duplicated material
  19696. * @returns the cloned material
  19697. */
  19698. clone(name: string): ShaderMaterial;
  19699. /**
  19700. * Disposes the material
  19701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19704. */
  19705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19706. /**
  19707. * Serializes this material in a JSON representation
  19708. * @returns the serialized material object
  19709. */
  19710. serialize(): any;
  19711. /**
  19712. * Creates a shader material from parsed shader material data
  19713. * @param source defines the JSON represnetation of the material
  19714. * @param scene defines the hosting scene
  19715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19716. * @returns a new material
  19717. */
  19718. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19719. }
  19720. }
  19721. declare module "babylonjs/Shaders/color.fragment" {
  19722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19723. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19724. /** @hidden */
  19725. export var colorPixelShader: {
  19726. name: string;
  19727. shader: string;
  19728. };
  19729. }
  19730. declare module "babylonjs/Shaders/color.vertex" {
  19731. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19734. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19735. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19737. /** @hidden */
  19738. export var colorVertexShader: {
  19739. name: string;
  19740. shader: string;
  19741. };
  19742. }
  19743. declare module "babylonjs/Meshes/linesMesh" {
  19744. import { Nullable } from "babylonjs/types";
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Color3 } from "babylonjs/Maths/math.color";
  19747. import { Node } from "babylonjs/node";
  19748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19749. import { Mesh } from "babylonjs/Meshes/mesh";
  19750. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19751. import { Effect } from "babylonjs/Materials/effect";
  19752. import { Material } from "babylonjs/Materials/material";
  19753. import "babylonjs/Shaders/color.fragment";
  19754. import "babylonjs/Shaders/color.vertex";
  19755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19756. /**
  19757. * Line mesh
  19758. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19759. */
  19760. export class LinesMesh extends Mesh {
  19761. /**
  19762. * If vertex color should be applied to the mesh
  19763. */
  19764. readonly useVertexColor?: boolean | undefined;
  19765. /**
  19766. * If vertex alpha should be applied to the mesh
  19767. */
  19768. readonly useVertexAlpha?: boolean | undefined;
  19769. /**
  19770. * Color of the line (Default: White)
  19771. */
  19772. color: Color3;
  19773. /**
  19774. * Alpha of the line (Default: 1)
  19775. */
  19776. alpha: number;
  19777. /**
  19778. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19779. * This margin is expressed in world space coordinates, so its value may vary.
  19780. * Default value is 0.1
  19781. */
  19782. intersectionThreshold: number;
  19783. private _colorShader;
  19784. private color4;
  19785. /**
  19786. * Creates a new LinesMesh
  19787. * @param name defines the name
  19788. * @param scene defines the hosting scene
  19789. * @param parent defines the parent mesh if any
  19790. * @param source defines the optional source LinesMesh used to clone data from
  19791. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19792. * When false, achieved by calling a clone(), also passing False.
  19793. * This will make creation of children, recursive.
  19794. * @param useVertexColor defines if this LinesMesh supports vertex color
  19795. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19796. */
  19797. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19798. /**
  19799. * If vertex color should be applied to the mesh
  19800. */
  19801. useVertexColor?: boolean | undefined,
  19802. /**
  19803. * If vertex alpha should be applied to the mesh
  19804. */
  19805. useVertexAlpha?: boolean | undefined);
  19806. private _addClipPlaneDefine;
  19807. private _removeClipPlaneDefine;
  19808. isReady(): boolean;
  19809. /**
  19810. * Returns the string "LineMesh"
  19811. */
  19812. getClassName(): string;
  19813. /**
  19814. * @hidden
  19815. */
  19816. /**
  19817. * @hidden
  19818. */
  19819. material: Material;
  19820. /**
  19821. * @hidden
  19822. */
  19823. readonly checkCollisions: boolean;
  19824. /** @hidden */
  19825. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19826. /** @hidden */
  19827. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19828. /**
  19829. * Disposes of the line mesh
  19830. * @param doNotRecurse If children should be disposed
  19831. */
  19832. dispose(doNotRecurse?: boolean): void;
  19833. /**
  19834. * Returns a new LineMesh object cloned from the current one.
  19835. */
  19836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19837. /**
  19838. * Creates a new InstancedLinesMesh object from the mesh model.
  19839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19840. * @param name defines the name of the new instance
  19841. * @returns a new InstancedLinesMesh
  19842. */
  19843. createInstance(name: string): InstancedLinesMesh;
  19844. }
  19845. /**
  19846. * Creates an instance based on a source LinesMesh
  19847. */
  19848. export class InstancedLinesMesh extends InstancedMesh {
  19849. /**
  19850. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19851. * This margin is expressed in world space coordinates, so its value may vary.
  19852. * Initilized with the intersectionThreshold value of the source LinesMesh
  19853. */
  19854. intersectionThreshold: number;
  19855. constructor(name: string, source: LinesMesh);
  19856. /**
  19857. * Returns the string "InstancedLinesMesh".
  19858. */
  19859. getClassName(): string;
  19860. }
  19861. }
  19862. declare module "babylonjs/Shaders/line.fragment" {
  19863. /** @hidden */
  19864. export var linePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module "babylonjs/Shaders/line.vertex" {
  19870. /** @hidden */
  19871. export var lineVertexShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module "babylonjs/Rendering/edgesRenderer" {
  19877. import { Nullable } from "babylonjs/types";
  19878. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Vector3 } from "babylonjs/Maths/math.vector";
  19881. import { IDisposable } from "babylonjs/scene";
  19882. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19883. import "babylonjs/Shaders/line.fragment";
  19884. import "babylonjs/Shaders/line.vertex";
  19885. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19886. module "babylonjs/Meshes/abstractMesh" {
  19887. interface AbstractMesh {
  19888. /**
  19889. * Gets the edgesRenderer associated with the mesh
  19890. */
  19891. edgesRenderer: Nullable<EdgesRenderer>;
  19892. }
  19893. }
  19894. module "babylonjs/Meshes/linesMesh" {
  19895. interface LinesMesh {
  19896. /**
  19897. * Enables the edge rendering mode on the mesh.
  19898. * This mode makes the mesh edges visible
  19899. * @param epsilon defines the maximal distance between two angles to detect a face
  19900. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19901. * @returns the currentAbstractMesh
  19902. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19903. */
  19904. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19905. }
  19906. }
  19907. module "babylonjs/Meshes/linesMesh" {
  19908. interface InstancedLinesMesh {
  19909. /**
  19910. * Enables the edge rendering mode on the mesh.
  19911. * This mode makes the mesh edges visible
  19912. * @param epsilon defines the maximal distance between two angles to detect a face
  19913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19914. * @returns the current InstancedLinesMesh
  19915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19916. */
  19917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19918. }
  19919. }
  19920. /**
  19921. * Defines the minimum contract an Edges renderer should follow.
  19922. */
  19923. export interface IEdgesRenderer extends IDisposable {
  19924. /**
  19925. * Gets or sets a boolean indicating if the edgesRenderer is active
  19926. */
  19927. isEnabled: boolean;
  19928. /**
  19929. * Renders the edges of the attached mesh,
  19930. */
  19931. render(): void;
  19932. /**
  19933. * Checks wether or not the edges renderer is ready to render.
  19934. * @return true if ready, otherwise false.
  19935. */
  19936. isReady(): boolean;
  19937. }
  19938. /**
  19939. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19940. */
  19941. export class EdgesRenderer implements IEdgesRenderer {
  19942. /**
  19943. * Define the size of the edges with an orthographic camera
  19944. */
  19945. edgesWidthScalerForOrthographic: number;
  19946. /**
  19947. * Define the size of the edges with a perspective camera
  19948. */
  19949. edgesWidthScalerForPerspective: number;
  19950. protected _source: AbstractMesh;
  19951. protected _linesPositions: number[];
  19952. protected _linesNormals: number[];
  19953. protected _linesIndices: number[];
  19954. protected _epsilon: number;
  19955. protected _indicesCount: number;
  19956. protected _lineShader: ShaderMaterial;
  19957. protected _ib: DataBuffer;
  19958. protected _buffers: {
  19959. [key: string]: Nullable<VertexBuffer>;
  19960. };
  19961. protected _checkVerticesInsteadOfIndices: boolean;
  19962. private _meshRebuildObserver;
  19963. private _meshDisposeObserver;
  19964. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19965. isEnabled: boolean;
  19966. /**
  19967. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19968. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19969. * @param source Mesh used to create edges
  19970. * @param epsilon sum of angles in adjacency to check for edge
  19971. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19972. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19973. */
  19974. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19975. protected _prepareRessources(): void;
  19976. /** @hidden */
  19977. _rebuild(): void;
  19978. /**
  19979. * Releases the required resources for the edges renderer
  19980. */
  19981. dispose(): void;
  19982. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19983. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19984. /**
  19985. * Checks if the pair of p0 and p1 is en edge
  19986. * @param faceIndex
  19987. * @param edge
  19988. * @param faceNormals
  19989. * @param p0
  19990. * @param p1
  19991. * @private
  19992. */
  19993. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19994. /**
  19995. * push line into the position, normal and index buffer
  19996. * @protected
  19997. */
  19998. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19999. /**
  20000. * Generates lines edges from adjacencjes
  20001. * @private
  20002. */
  20003. _generateEdgesLines(): void;
  20004. /**
  20005. * Checks wether or not the edges renderer is ready to render.
  20006. * @return true if ready, otherwise false.
  20007. */
  20008. isReady(): boolean;
  20009. /**
  20010. * Renders the edges of the attached mesh,
  20011. */
  20012. render(): void;
  20013. }
  20014. /**
  20015. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20016. */
  20017. export class LineEdgesRenderer extends EdgesRenderer {
  20018. /**
  20019. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20020. * @param source LineMesh used to generate edges
  20021. * @param epsilon not important (specified angle for edge detection)
  20022. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20023. */
  20024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20025. /**
  20026. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20027. */
  20028. _generateEdgesLines(): void;
  20029. }
  20030. }
  20031. declare module "babylonjs/Rendering/renderingGroup" {
  20032. import { SmartArray } from "babylonjs/Misc/smartArray";
  20033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20035. import { Nullable } from "babylonjs/types";
  20036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20037. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20038. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20039. import { Material } from "babylonjs/Materials/material";
  20040. import { Scene } from "babylonjs/scene";
  20041. /**
  20042. * This represents the object necessary to create a rendering group.
  20043. * This is exclusively used and created by the rendering manager.
  20044. * To modify the behavior, you use the available helpers in your scene or meshes.
  20045. * @hidden
  20046. */
  20047. export class RenderingGroup {
  20048. index: number;
  20049. private static _zeroVector;
  20050. private _scene;
  20051. private _opaqueSubMeshes;
  20052. private _transparentSubMeshes;
  20053. private _alphaTestSubMeshes;
  20054. private _depthOnlySubMeshes;
  20055. private _particleSystems;
  20056. private _spriteManagers;
  20057. private _opaqueSortCompareFn;
  20058. private _alphaTestSortCompareFn;
  20059. private _transparentSortCompareFn;
  20060. private _renderOpaque;
  20061. private _renderAlphaTest;
  20062. private _renderTransparent;
  20063. /** @hidden */
  20064. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20065. onBeforeTransparentRendering: () => void;
  20066. /**
  20067. * Set the opaque sort comparison function.
  20068. * If null the sub meshes will be render in the order they were created
  20069. */
  20070. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20071. /**
  20072. * Set the alpha test sort comparison function.
  20073. * If null the sub meshes will be render in the order they were created
  20074. */
  20075. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20076. /**
  20077. * Set the transparent sort comparison function.
  20078. * If null the sub meshes will be render in the order they were created
  20079. */
  20080. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20081. /**
  20082. * Creates a new rendering group.
  20083. * @param index The rendering group index
  20084. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20085. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20086. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20087. */
  20088. 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>);
  20089. /**
  20090. * Render all the sub meshes contained in the group.
  20091. * @param customRenderFunction Used to override the default render behaviour of the group.
  20092. * @returns true if rendered some submeshes.
  20093. */
  20094. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20095. /**
  20096. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20097. * @param subMeshes The submeshes to render
  20098. */
  20099. private renderOpaqueSorted;
  20100. /**
  20101. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20102. * @param subMeshes The submeshes to render
  20103. */
  20104. private renderAlphaTestSorted;
  20105. /**
  20106. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20107. * @param subMeshes The submeshes to render
  20108. */
  20109. private renderTransparentSorted;
  20110. /**
  20111. * Renders the submeshes in a specified order.
  20112. * @param subMeshes The submeshes to sort before render
  20113. * @param sortCompareFn The comparison function use to sort
  20114. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20115. * @param transparent Specifies to activate blending if true
  20116. */
  20117. private static renderSorted;
  20118. /**
  20119. * Renders the submeshes in the order they were dispatched (no sort applied).
  20120. * @param subMeshes The submeshes to render
  20121. */
  20122. private static renderUnsorted;
  20123. /**
  20124. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20125. * are rendered back to front if in the same alpha index.
  20126. *
  20127. * @param a The first submesh
  20128. * @param b The second submesh
  20129. * @returns The result of the comparison
  20130. */
  20131. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20132. /**
  20133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20134. * are rendered back to front.
  20135. *
  20136. * @param a The first submesh
  20137. * @param b The second submesh
  20138. * @returns The result of the comparison
  20139. */
  20140. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20141. /**
  20142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20143. * are rendered front to back (prevent overdraw).
  20144. *
  20145. * @param a The first submesh
  20146. * @param b The second submesh
  20147. * @returns The result of the comparison
  20148. */
  20149. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20150. /**
  20151. * Resets the different lists of submeshes to prepare a new frame.
  20152. */
  20153. prepare(): void;
  20154. dispose(): void;
  20155. /**
  20156. * Inserts the submesh in its correct queue depending on its material.
  20157. * @param subMesh The submesh to dispatch
  20158. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20159. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20160. */
  20161. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20162. dispatchSprites(spriteManager: ISpriteManager): void;
  20163. dispatchParticles(particleSystem: IParticleSystem): void;
  20164. private _renderParticles;
  20165. private _renderSprites;
  20166. }
  20167. }
  20168. declare module "babylonjs/Rendering/renderingManager" {
  20169. import { Nullable } from "babylonjs/types";
  20170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20172. import { SmartArray } from "babylonjs/Misc/smartArray";
  20173. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20175. import { Material } from "babylonjs/Materials/material";
  20176. import { Scene } from "babylonjs/scene";
  20177. import { Camera } from "babylonjs/Cameras/camera";
  20178. /**
  20179. * Interface describing the different options available in the rendering manager
  20180. * regarding Auto Clear between groups.
  20181. */
  20182. export interface IRenderingManagerAutoClearSetup {
  20183. /**
  20184. * Defines whether or not autoclear is enable.
  20185. */
  20186. autoClear: boolean;
  20187. /**
  20188. * Defines whether or not to autoclear the depth buffer.
  20189. */
  20190. depth: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the stencil buffer.
  20193. */
  20194. stencil: boolean;
  20195. }
  20196. /**
  20197. * This class is used by the onRenderingGroupObservable
  20198. */
  20199. export class RenderingGroupInfo {
  20200. /**
  20201. * The Scene that being rendered
  20202. */
  20203. scene: Scene;
  20204. /**
  20205. * The camera currently used for the rendering pass
  20206. */
  20207. camera: Nullable<Camera>;
  20208. /**
  20209. * The ID of the renderingGroup being processed
  20210. */
  20211. renderingGroupId: number;
  20212. }
  20213. /**
  20214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20215. * It is enable to manage the different groups as well as the different necessary sort functions.
  20216. * This should not be used directly aside of the few static configurations
  20217. */
  20218. export class RenderingManager {
  20219. /**
  20220. * The max id used for rendering groups (not included)
  20221. */
  20222. static MAX_RENDERINGGROUPS: number;
  20223. /**
  20224. * The min id used for rendering groups (included)
  20225. */
  20226. static MIN_RENDERINGGROUPS: number;
  20227. /**
  20228. * Used to globally prevent autoclearing scenes.
  20229. */
  20230. static AUTOCLEAR: boolean;
  20231. /**
  20232. * @hidden
  20233. */
  20234. _useSceneAutoClearSetup: boolean;
  20235. private _scene;
  20236. private _renderingGroups;
  20237. private _depthStencilBufferAlreadyCleaned;
  20238. private _autoClearDepthStencil;
  20239. private _customOpaqueSortCompareFn;
  20240. private _customAlphaTestSortCompareFn;
  20241. private _customTransparentSortCompareFn;
  20242. private _renderingGroupInfo;
  20243. /**
  20244. * Instantiates a new rendering group for a particular scene
  20245. * @param scene Defines the scene the groups belongs to
  20246. */
  20247. constructor(scene: Scene);
  20248. private _clearDepthStencilBuffer;
  20249. /**
  20250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20251. * @hidden
  20252. */
  20253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20254. /**
  20255. * Resets the different information of the group to prepare a new frame
  20256. * @hidden
  20257. */
  20258. reset(): void;
  20259. /**
  20260. * Dispose and release the group and its associated resources.
  20261. * @hidden
  20262. */
  20263. dispose(): void;
  20264. /**
  20265. * Clear the info related to rendering groups preventing retention points during dispose.
  20266. */
  20267. freeRenderingGroups(): void;
  20268. private _prepareRenderingGroup;
  20269. /**
  20270. * Add a sprite manager to the rendering manager in order to render it this frame.
  20271. * @param spriteManager Define the sprite manager to render
  20272. */
  20273. dispatchSprites(spriteManager: ISpriteManager): void;
  20274. /**
  20275. * Add a particle system to the rendering manager in order to render it this frame.
  20276. * @param particleSystem Define the particle system to render
  20277. */
  20278. dispatchParticles(particleSystem: IParticleSystem): void;
  20279. /**
  20280. * Add a submesh to the manager in order to render it this frame
  20281. * @param subMesh The submesh to dispatch
  20282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20284. */
  20285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20286. /**
  20287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20288. * This allowed control for front to back rendering or reversly depending of the special needs.
  20289. *
  20290. * @param renderingGroupId The rendering group id corresponding to its index
  20291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20294. */
  20295. 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;
  20296. /**
  20297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20298. *
  20299. * @param renderingGroupId The rendering group id corresponding to its index
  20300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20303. */
  20304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20305. /**
  20306. * Gets the current auto clear configuration for one rendering group of the rendering
  20307. * manager.
  20308. * @param index the rendering group index to get the information for
  20309. * @returns The auto clear setup for the requested rendering group
  20310. */
  20311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20312. }
  20313. }
  20314. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20315. import { Observable } from "babylonjs/Misc/observable";
  20316. import { SmartArray } from "babylonjs/Misc/smartArray";
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Camera } from "babylonjs/Cameras/camera";
  20319. import { Scene } from "babylonjs/scene";
  20320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20321. import { Color4 } from "babylonjs/Maths/math.color";
  20322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20326. import { Texture } from "babylonjs/Materials/Textures/texture";
  20327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20328. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20329. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20330. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20331. import { Engine } from "babylonjs/Engines/engine";
  20332. /**
  20333. * This Helps creating a texture that will be created from a camera in your scene.
  20334. * It is basically a dynamic texture that could be used to create special effects for instance.
  20335. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20336. */
  20337. export class RenderTargetTexture extends Texture {
  20338. isCube: boolean;
  20339. /**
  20340. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20341. */
  20342. static readonly REFRESHRATE_RENDER_ONCE: number;
  20343. /**
  20344. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20347. /**
  20348. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20349. * the central point of your effect and can save a lot of performances.
  20350. */
  20351. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20352. /**
  20353. * Use this predicate to dynamically define the list of mesh you want to render.
  20354. * If set, the renderList property will be overwritten.
  20355. */
  20356. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20357. private _renderList;
  20358. /**
  20359. * Use this list to define the list of mesh you want to render.
  20360. */
  20361. renderList: Nullable<Array<AbstractMesh>>;
  20362. private _hookArray;
  20363. /**
  20364. * Define if particles should be rendered in your texture.
  20365. */
  20366. renderParticles: boolean;
  20367. /**
  20368. * Define if sprites should be rendered in your texture.
  20369. */
  20370. renderSprites: boolean;
  20371. /**
  20372. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20373. */
  20374. coordinatesMode: number;
  20375. /**
  20376. * Define the camera used to render the texture.
  20377. */
  20378. activeCamera: Nullable<Camera>;
  20379. /**
  20380. * Override the render function of the texture with your own one.
  20381. */
  20382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20383. /**
  20384. * Define if camera post processes should be use while rendering the texture.
  20385. */
  20386. useCameraPostProcesses: boolean;
  20387. /**
  20388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20389. */
  20390. ignoreCameraViewport: boolean;
  20391. private _postProcessManager;
  20392. private _postProcesses;
  20393. private _resizeObserver;
  20394. /**
  20395. * An event triggered when the texture is unbind.
  20396. */
  20397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20402. private _onAfterUnbindObserver;
  20403. /**
  20404. * Set a after unbind callback in the texture.
  20405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20406. */
  20407. onAfterUnbind: () => void;
  20408. /**
  20409. * An event triggered before rendering the texture
  20410. */
  20411. onBeforeRenderObservable: Observable<number>;
  20412. private _onBeforeRenderObserver;
  20413. /**
  20414. * Set a before render callback in the texture.
  20415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20416. */
  20417. onBeforeRender: (faceIndex: number) => void;
  20418. /**
  20419. * An event triggered after rendering the texture
  20420. */
  20421. onAfterRenderObservable: Observable<number>;
  20422. private _onAfterRenderObserver;
  20423. /**
  20424. * Set a after render callback in the texture.
  20425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20426. */
  20427. onAfterRender: (faceIndex: number) => void;
  20428. /**
  20429. * An event triggered after the texture clear
  20430. */
  20431. onClearObservable: Observable<Engine>;
  20432. private _onClearObserver;
  20433. /**
  20434. * Set a clear callback in the texture.
  20435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20436. */
  20437. onClear: (Engine: Engine) => void;
  20438. /**
  20439. * An event triggered when the texture is resized.
  20440. */
  20441. onResizeObservable: Observable<RenderTargetTexture>;
  20442. /**
  20443. * Define the clear color of the Render Target if it should be different from the scene.
  20444. */
  20445. clearColor: Color4;
  20446. protected _size: number | {
  20447. width: number;
  20448. height: number;
  20449. };
  20450. protected _initialSizeParameter: number | {
  20451. width: number;
  20452. height: number;
  20453. } | {
  20454. ratio: number;
  20455. };
  20456. protected _sizeRatio: Nullable<number>;
  20457. /** @hidden */
  20458. _generateMipMaps: boolean;
  20459. protected _renderingManager: RenderingManager;
  20460. /** @hidden */
  20461. _waitingRenderList: string[];
  20462. protected _doNotChangeAspectRatio: boolean;
  20463. protected _currentRefreshId: number;
  20464. protected _refreshRate: number;
  20465. protected _textureMatrix: Matrix;
  20466. protected _samples: number;
  20467. protected _renderTargetOptions: RenderTargetCreationOptions;
  20468. /**
  20469. * Gets render target creation options that were used.
  20470. */
  20471. readonly renderTargetOptions: RenderTargetCreationOptions;
  20472. protected _engine: Engine;
  20473. protected _onRatioRescale(): void;
  20474. /**
  20475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20476. * It must define where the camera used to render the texture is set
  20477. */
  20478. boundingBoxPosition: Vector3;
  20479. private _boundingBoxSize;
  20480. /**
  20481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20482. * When defined, the cubemap will switch to local mode
  20483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20484. * @example https://www.babylonjs-playground.com/#RNASML
  20485. */
  20486. boundingBoxSize: Vector3;
  20487. /**
  20488. * In case the RTT has been created with a depth texture, get the associated
  20489. * depth texture.
  20490. * Otherwise, return null.
  20491. */
  20492. depthStencilTexture: Nullable<InternalTexture>;
  20493. /**
  20494. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20495. * or used a shadow, depth texture...
  20496. * @param name The friendly name of the texture
  20497. * @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)
  20498. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20499. * @param generateMipMaps True if mip maps need to be generated after render.
  20500. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20501. * @param type The type of the buffer in the RTT (int, half float, float...)
  20502. * @param isCube True if a cube texture needs to be created
  20503. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20504. * @param generateDepthBuffer True to generate a depth buffer
  20505. * @param generateStencilBuffer True to generate a stencil buffer
  20506. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20507. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20508. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20509. */
  20510. constructor(name: string, size: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20516. /**
  20517. * Creates a depth stencil texture.
  20518. * This is only available in WebGL 2 or with the depth texture extension available.
  20519. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20520. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20521. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20522. */
  20523. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20524. private _processSizeParameter;
  20525. /**
  20526. * Define the number of samples to use in case of MSAA.
  20527. * It defaults to one meaning no MSAA has been enabled.
  20528. */
  20529. samples: number;
  20530. /**
  20531. * Resets the refresh counter of the texture and start bak from scratch.
  20532. * Could be useful to regenerate the texture if it is setup to render only once.
  20533. */
  20534. resetRefreshCounter(): void;
  20535. /**
  20536. * Define the refresh rate of the texture or the rendering frequency.
  20537. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20538. */
  20539. refreshRate: number;
  20540. /**
  20541. * Adds a post process to the render target rendering passes.
  20542. * @param postProcess define the post process to add
  20543. */
  20544. addPostProcess(postProcess: PostProcess): void;
  20545. /**
  20546. * Clear all the post processes attached to the render target
  20547. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20548. */
  20549. clearPostProcesses(dispose?: boolean): void;
  20550. /**
  20551. * Remove one of the post process from the list of attached post processes to the texture
  20552. * @param postProcess define the post process to remove from the list
  20553. */
  20554. removePostProcess(postProcess: PostProcess): void;
  20555. /** @hidden */
  20556. _shouldRender(): boolean;
  20557. /**
  20558. * Gets the actual render size of the texture.
  20559. * @returns the width of the render size
  20560. */
  20561. getRenderSize(): number;
  20562. /**
  20563. * Gets the actual render width of the texture.
  20564. * @returns the width of the render size
  20565. */
  20566. getRenderWidth(): number;
  20567. /**
  20568. * Gets the actual render height of the texture.
  20569. * @returns the height of the render size
  20570. */
  20571. getRenderHeight(): number;
  20572. /**
  20573. * Get if the texture can be rescaled or not.
  20574. */
  20575. readonly canRescale: boolean;
  20576. /**
  20577. * Resize the texture using a ratio.
  20578. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20579. */
  20580. scale(ratio: number): void;
  20581. /**
  20582. * Get the texture reflection matrix used to rotate/transform the reflection.
  20583. * @returns the reflection matrix
  20584. */
  20585. getReflectionTextureMatrix(): Matrix;
  20586. /**
  20587. * Resize the texture to a new desired size.
  20588. * Be carrefull as it will recreate all the data in the new texture.
  20589. * @param size Define the new size. It can be:
  20590. * - a number for squared texture,
  20591. * - an object containing { width: number, height: number }
  20592. * - or an object containing a ratio { ratio: number }
  20593. */
  20594. resize(size: number | {
  20595. width: number;
  20596. height: number;
  20597. } | {
  20598. ratio: number;
  20599. }): void;
  20600. /**
  20601. * Renders all the objects from the render list into the texture.
  20602. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20603. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20604. */
  20605. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20606. private _bestReflectionRenderTargetDimension;
  20607. /**
  20608. * @hidden
  20609. * @param faceIndex face index to bind to if this is a cubetexture
  20610. */
  20611. _bindFrameBuffer(faceIndex?: number): void;
  20612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20613. private renderToTarget;
  20614. /**
  20615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20616. * This allowed control for front to back rendering or reversly depending of the special needs.
  20617. *
  20618. * @param renderingGroupId The rendering group id corresponding to its index
  20619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20622. */
  20623. 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;
  20624. /**
  20625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20626. *
  20627. * @param renderingGroupId The rendering group id corresponding to its index
  20628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20629. */
  20630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20631. /**
  20632. * Clones the texture.
  20633. * @returns the cloned texture
  20634. */
  20635. clone(): RenderTargetTexture;
  20636. /**
  20637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20638. * @returns The JSON representation of the texture
  20639. */
  20640. serialize(): any;
  20641. /**
  20642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20643. */
  20644. disposeFramebufferObjects(): void;
  20645. /**
  20646. * Dispose the texture and release its associated resources.
  20647. */
  20648. dispose(): void;
  20649. /** @hidden */
  20650. _rebuild(): void;
  20651. /**
  20652. * Clear the info related to rendering groups preventing retention point in material dispose.
  20653. */
  20654. freeRenderingGroups(): void;
  20655. /**
  20656. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20657. * @returns the view count
  20658. */
  20659. getViewCount(): number;
  20660. }
  20661. }
  20662. declare module "babylonjs/Materials/material" {
  20663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20664. import { SmartArray } from "babylonjs/Misc/smartArray";
  20665. import { Observable } from "babylonjs/Misc/observable";
  20666. import { Nullable } from "babylonjs/types";
  20667. import { Scene } from "babylonjs/scene";
  20668. import { Matrix } from "babylonjs/Maths/math.vector";
  20669. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20676. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20677. import { Mesh } from "babylonjs/Meshes/mesh";
  20678. import { Animation } from "babylonjs/Animations/animation";
  20679. /**
  20680. * Base class for the main features of a material in Babylon.js
  20681. */
  20682. export class Material implements IAnimatable {
  20683. /**
  20684. * Returns the triangle fill mode
  20685. */
  20686. static readonly TriangleFillMode: number;
  20687. /**
  20688. * Returns the wireframe mode
  20689. */
  20690. static readonly WireFrameFillMode: number;
  20691. /**
  20692. * Returns the point fill mode
  20693. */
  20694. static readonly PointFillMode: number;
  20695. /**
  20696. * Returns the point list draw mode
  20697. */
  20698. static readonly PointListDrawMode: number;
  20699. /**
  20700. * Returns the line list draw mode
  20701. */
  20702. static readonly LineListDrawMode: number;
  20703. /**
  20704. * Returns the line loop draw mode
  20705. */
  20706. static readonly LineLoopDrawMode: number;
  20707. /**
  20708. * Returns the line strip draw mode
  20709. */
  20710. static readonly LineStripDrawMode: number;
  20711. /**
  20712. * Returns the triangle strip draw mode
  20713. */
  20714. static readonly TriangleStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle fan draw mode
  20717. */
  20718. static readonly TriangleFanDrawMode: number;
  20719. /**
  20720. * Stores the clock-wise side orientation
  20721. */
  20722. static readonly ClockWiseSideOrientation: number;
  20723. /**
  20724. * Stores the counter clock-wise side orientation
  20725. */
  20726. static readonly CounterClockWiseSideOrientation: number;
  20727. /**
  20728. * The dirty texture flag value
  20729. */
  20730. static readonly TextureDirtyFlag: number;
  20731. /**
  20732. * The dirty light flag value
  20733. */
  20734. static readonly LightDirtyFlag: number;
  20735. /**
  20736. * The dirty fresnel flag value
  20737. */
  20738. static readonly FresnelDirtyFlag: number;
  20739. /**
  20740. * The dirty attribute flag value
  20741. */
  20742. static readonly AttributesDirtyFlag: number;
  20743. /**
  20744. * The dirty misc flag value
  20745. */
  20746. static readonly MiscDirtyFlag: number;
  20747. /**
  20748. * The all dirty flag value
  20749. */
  20750. static readonly AllDirtyFlag: number;
  20751. /**
  20752. * The ID of the material
  20753. */
  20754. id: string;
  20755. /**
  20756. * Gets or sets the unique id of the material
  20757. */
  20758. uniqueId: number;
  20759. /**
  20760. * The name of the material
  20761. */
  20762. name: string;
  20763. /**
  20764. * Gets or sets user defined metadata
  20765. */
  20766. metadata: any;
  20767. /**
  20768. * For internal use only. Please do not use.
  20769. */
  20770. reservedDataStore: any;
  20771. /**
  20772. * Specifies if the ready state should be checked on each call
  20773. */
  20774. checkReadyOnEveryCall: boolean;
  20775. /**
  20776. * Specifies if the ready state should be checked once
  20777. */
  20778. checkReadyOnlyOnce: boolean;
  20779. /**
  20780. * The state of the material
  20781. */
  20782. state: string;
  20783. /**
  20784. * The alpha value of the material
  20785. */
  20786. protected _alpha: number;
  20787. /**
  20788. * List of inspectable custom properties (used by the Inspector)
  20789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20790. */
  20791. inspectableCustomProperties: IInspectable[];
  20792. /**
  20793. * Sets the alpha value of the material
  20794. */
  20795. /**
  20796. * Gets the alpha value of the material
  20797. */
  20798. alpha: number;
  20799. /**
  20800. * Specifies if back face culling is enabled
  20801. */
  20802. protected _backFaceCulling: boolean;
  20803. /**
  20804. * Sets the back-face culling state
  20805. */
  20806. /**
  20807. * Gets the back-face culling state
  20808. */
  20809. backFaceCulling: boolean;
  20810. /**
  20811. * Stores the value for side orientation
  20812. */
  20813. sideOrientation: number;
  20814. /**
  20815. * Callback triggered when the material is compiled
  20816. */
  20817. onCompiled: Nullable<(effect: Effect) => void>;
  20818. /**
  20819. * Callback triggered when an error occurs
  20820. */
  20821. onError: Nullable<(effect: Effect, errors: string) => void>;
  20822. /**
  20823. * Callback triggered to get the render target textures
  20824. */
  20825. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20826. /**
  20827. * Gets a boolean indicating that current material needs to register RTT
  20828. */
  20829. readonly hasRenderTargetTextures: boolean;
  20830. /**
  20831. * Specifies if the material should be serialized
  20832. */
  20833. doNotSerialize: boolean;
  20834. /**
  20835. * @hidden
  20836. */
  20837. _storeEffectOnSubMeshes: boolean;
  20838. /**
  20839. * Stores the animations for the material
  20840. */
  20841. animations: Nullable<Array<Animation>>;
  20842. /**
  20843. * An event triggered when the material is disposed
  20844. */
  20845. onDisposeObservable: Observable<Material>;
  20846. /**
  20847. * An observer which watches for dispose events
  20848. */
  20849. private _onDisposeObserver;
  20850. private _onUnBindObservable;
  20851. /**
  20852. * Called during a dispose event
  20853. */
  20854. onDispose: () => void;
  20855. private _onBindObservable;
  20856. /**
  20857. * An event triggered when the material is bound
  20858. */
  20859. readonly onBindObservable: Observable<AbstractMesh>;
  20860. /**
  20861. * An observer which watches for bind events
  20862. */
  20863. private _onBindObserver;
  20864. /**
  20865. * Called during a bind event
  20866. */
  20867. onBind: (Mesh: AbstractMesh) => void;
  20868. /**
  20869. * An event triggered when the material is unbound
  20870. */
  20871. readonly onUnBindObservable: Observable<Material>;
  20872. /**
  20873. * Stores the value of the alpha mode
  20874. */
  20875. private _alphaMode;
  20876. /**
  20877. * Sets the value of the alpha mode.
  20878. *
  20879. * | Value | Type | Description |
  20880. * | --- | --- | --- |
  20881. * | 0 | ALPHA_DISABLE | |
  20882. * | 1 | ALPHA_ADD | |
  20883. * | 2 | ALPHA_COMBINE | |
  20884. * | 3 | ALPHA_SUBTRACT | |
  20885. * | 4 | ALPHA_MULTIPLY | |
  20886. * | 5 | ALPHA_MAXIMIZED | |
  20887. * | 6 | ALPHA_ONEONE | |
  20888. * | 7 | ALPHA_PREMULTIPLIED | |
  20889. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20890. * | 9 | ALPHA_INTERPOLATE | |
  20891. * | 10 | ALPHA_SCREENMODE | |
  20892. *
  20893. */
  20894. /**
  20895. * Gets the value of the alpha mode
  20896. */
  20897. alphaMode: number;
  20898. /**
  20899. * Stores the state of the need depth pre-pass value
  20900. */
  20901. private _needDepthPrePass;
  20902. /**
  20903. * Sets the need depth pre-pass value
  20904. */
  20905. /**
  20906. * Gets the depth pre-pass value
  20907. */
  20908. needDepthPrePass: boolean;
  20909. /**
  20910. * Specifies if depth writing should be disabled
  20911. */
  20912. disableDepthWrite: boolean;
  20913. /**
  20914. * Specifies if depth writing should be forced
  20915. */
  20916. forceDepthWrite: boolean;
  20917. /**
  20918. * Specifies if there should be a separate pass for culling
  20919. */
  20920. separateCullingPass: boolean;
  20921. /**
  20922. * Stores the state specifing if fog should be enabled
  20923. */
  20924. private _fogEnabled;
  20925. /**
  20926. * Sets the state for enabling fog
  20927. */
  20928. /**
  20929. * Gets the value of the fog enabled state
  20930. */
  20931. fogEnabled: boolean;
  20932. /**
  20933. * Stores the size of points
  20934. */
  20935. pointSize: number;
  20936. /**
  20937. * Stores the z offset value
  20938. */
  20939. zOffset: number;
  20940. /**
  20941. * Gets a value specifying if wireframe mode is enabled
  20942. */
  20943. /**
  20944. * Sets the state of wireframe mode
  20945. */
  20946. wireframe: boolean;
  20947. /**
  20948. * Gets the value specifying if point clouds are enabled
  20949. */
  20950. /**
  20951. * Sets the state of point cloud mode
  20952. */
  20953. pointsCloud: boolean;
  20954. /**
  20955. * Gets the material fill mode
  20956. */
  20957. /**
  20958. * Sets the material fill mode
  20959. */
  20960. fillMode: number;
  20961. /**
  20962. * @hidden
  20963. * Stores the effects for the material
  20964. */
  20965. _effect: Nullable<Effect>;
  20966. /**
  20967. * @hidden
  20968. * Specifies if the material was previously ready
  20969. */
  20970. _wasPreviouslyReady: boolean;
  20971. /**
  20972. * Specifies if uniform buffers should be used
  20973. */
  20974. private _useUBO;
  20975. /**
  20976. * Stores a reference to the scene
  20977. */
  20978. private _scene;
  20979. /**
  20980. * Stores the fill mode state
  20981. */
  20982. private _fillMode;
  20983. /**
  20984. * Specifies if the depth write state should be cached
  20985. */
  20986. private _cachedDepthWriteState;
  20987. /**
  20988. * Stores the uniform buffer
  20989. */
  20990. protected _uniformBuffer: UniformBuffer;
  20991. /** @hidden */
  20992. _indexInSceneMaterialArray: number;
  20993. /** @hidden */
  20994. meshMap: Nullable<{
  20995. [id: string]: AbstractMesh | undefined;
  20996. }>;
  20997. /**
  20998. * Creates a material instance
  20999. * @param name defines the name of the material
  21000. * @param scene defines the scene to reference
  21001. * @param doNotAdd specifies if the material should be added to the scene
  21002. */
  21003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21004. /**
  21005. * Returns a string representation of the current material
  21006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21007. * @returns a string with material information
  21008. */
  21009. toString(fullDetails?: boolean): string;
  21010. /**
  21011. * Gets the class name of the material
  21012. * @returns a string with the class name of the material
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Specifies if updates for the material been locked
  21017. */
  21018. readonly isFrozen: boolean;
  21019. /**
  21020. * Locks updates for the material
  21021. */
  21022. freeze(): void;
  21023. /**
  21024. * Unlocks updates for the material
  21025. */
  21026. unfreeze(): void;
  21027. /**
  21028. * Specifies if the material is ready to be used
  21029. * @param mesh defines the mesh to check
  21030. * @param useInstances specifies if instances should be used
  21031. * @returns a boolean indicating if the material is ready to be used
  21032. */
  21033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21034. /**
  21035. * Specifies that the submesh is ready to be used
  21036. * @param mesh defines the mesh to check
  21037. * @param subMesh defines which submesh to check
  21038. * @param useInstances specifies that instances should be used
  21039. * @returns a boolean indicating that the submesh is ready or not
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Returns the material effect
  21044. * @returns the effect associated with the material
  21045. */
  21046. getEffect(): Nullable<Effect>;
  21047. /**
  21048. * Returns the current scene
  21049. * @returns a Scene
  21050. */
  21051. getScene(): Scene;
  21052. /**
  21053. * Specifies if the material will require alpha blending
  21054. * @returns a boolean specifying if alpha blending is needed
  21055. */
  21056. needAlphaBlending(): boolean;
  21057. /**
  21058. * Specifies if the mesh will require alpha blending
  21059. * @param mesh defines the mesh to check
  21060. * @returns a boolean specifying if alpha blending is needed for the mesh
  21061. */
  21062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21063. /**
  21064. * Specifies if this material should be rendered in alpha test mode
  21065. * @returns a boolean specifying if an alpha test is needed.
  21066. */
  21067. needAlphaTesting(): boolean;
  21068. /**
  21069. * Gets the texture used for the alpha test
  21070. * @returns the texture to use for alpha testing
  21071. */
  21072. getAlphaTestTexture(): Nullable<BaseTexture>;
  21073. /**
  21074. * Marks the material to indicate that it needs to be re-calculated
  21075. */
  21076. markDirty(): void;
  21077. /** @hidden */
  21078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21079. /**
  21080. * Binds the material to the mesh
  21081. * @param world defines the world transformation matrix
  21082. * @param mesh defines the mesh to bind the material to
  21083. */
  21084. bind(world: Matrix, mesh?: Mesh): void;
  21085. /**
  21086. * Binds the submesh to the material
  21087. * @param world defines the world transformation matrix
  21088. * @param mesh defines the mesh containing the submesh
  21089. * @param subMesh defines the submesh to bind the material to
  21090. */
  21091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21092. /**
  21093. * Binds the world matrix to the material
  21094. * @param world defines the world transformation matrix
  21095. */
  21096. bindOnlyWorldMatrix(world: Matrix): void;
  21097. /**
  21098. * Binds the scene's uniform buffer to the effect.
  21099. * @param effect defines the effect to bind to the scene uniform buffer
  21100. * @param sceneUbo defines the uniform buffer storing scene data
  21101. */
  21102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21103. /**
  21104. * Binds the view matrix to the effect
  21105. * @param effect defines the effect to bind the view matrix to
  21106. */
  21107. bindView(effect: Effect): void;
  21108. /**
  21109. * Binds the view projection matrix to the effect
  21110. * @param effect defines the effect to bind the view projection matrix to
  21111. */
  21112. bindViewProjection(effect: Effect): void;
  21113. /**
  21114. * Specifies if material alpha testing should be turned on for the mesh
  21115. * @param mesh defines the mesh to check
  21116. */
  21117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21118. /**
  21119. * Processes to execute after binding the material to a mesh
  21120. * @param mesh defines the rendered mesh
  21121. */
  21122. protected _afterBind(mesh?: Mesh): void;
  21123. /**
  21124. * Unbinds the material from the mesh
  21125. */
  21126. unbind(): void;
  21127. /**
  21128. * Gets the active textures from the material
  21129. * @returns an array of textures
  21130. */
  21131. getActiveTextures(): BaseTexture[];
  21132. /**
  21133. * Specifies if the material uses a texture
  21134. * @param texture defines the texture to check against the material
  21135. * @returns a boolean specifying if the material uses the texture
  21136. */
  21137. hasTexture(texture: BaseTexture): boolean;
  21138. /**
  21139. * Makes a duplicate of the material, and gives it a new name
  21140. * @param name defines the new name for the duplicated material
  21141. * @returns the cloned material
  21142. */
  21143. clone(name: string): Nullable<Material>;
  21144. /**
  21145. * Gets the meshes bound to the material
  21146. * @returns an array of meshes bound to the material
  21147. */
  21148. getBindedMeshes(): AbstractMesh[];
  21149. /**
  21150. * Force shader compilation
  21151. * @param mesh defines the mesh associated with this material
  21152. * @param onCompiled defines a function to execute once the material is compiled
  21153. * @param options defines the options to configure the compilation
  21154. * @param onError defines a function to execute if the material fails compiling
  21155. */
  21156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21157. clipPlane: boolean;
  21158. }>, onError?: (reason: string) => void): void;
  21159. /**
  21160. * Force shader compilation
  21161. * @param mesh defines the mesh that will use this material
  21162. * @param options defines additional options for compiling the shaders
  21163. * @returns a promise that resolves when the compilation completes
  21164. */
  21165. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21166. clipPlane: boolean;
  21167. }>): Promise<void>;
  21168. private static readonly _AllDirtyCallBack;
  21169. private static readonly _ImageProcessingDirtyCallBack;
  21170. private static readonly _TextureDirtyCallBack;
  21171. private static readonly _FresnelDirtyCallBack;
  21172. private static readonly _MiscDirtyCallBack;
  21173. private static readonly _LightsDirtyCallBack;
  21174. private static readonly _AttributeDirtyCallBack;
  21175. private static _FresnelAndMiscDirtyCallBack;
  21176. private static _TextureAndMiscDirtyCallBack;
  21177. private static readonly _DirtyCallbackArray;
  21178. private static readonly _RunDirtyCallBacks;
  21179. /**
  21180. * Marks a define in the material to indicate that it needs to be re-computed
  21181. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21182. */
  21183. markAsDirty(flag: number): void;
  21184. /**
  21185. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21186. * @param func defines a function which checks material defines against the submeshes
  21187. */
  21188. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21189. /**
  21190. * Indicates that we need to re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsAllDirty(): void;
  21193. /**
  21194. * Indicates that image processing needs to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21197. /**
  21198. * Indicates that textures need to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsTexturesDirty(): void;
  21201. /**
  21202. * Indicates that fresnel needs to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsFresnelDirty(): void;
  21205. /**
  21206. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21209. /**
  21210. * Indicates that lights need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsLightsDirty(): void;
  21213. /**
  21214. * Indicates that attributes need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsAttributesDirty(): void;
  21217. /**
  21218. * Indicates that misc needs to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsMiscDirty(): void;
  21221. /**
  21222. * Indicates that textures and misc need to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21225. /**
  21226. * Disposes the material
  21227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21229. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21230. */
  21231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21232. /** @hidden */
  21233. private releaseVertexArrayObject;
  21234. /**
  21235. * Serializes this material
  21236. * @returns the serialized material object
  21237. */
  21238. serialize(): any;
  21239. /**
  21240. * Creates a material from parsed material data
  21241. * @param parsedMaterial defines parsed material data
  21242. * @param scene defines the hosting scene
  21243. * @param rootUrl defines the root URL to use to load textures
  21244. * @returns a new material
  21245. */
  21246. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21247. }
  21248. }
  21249. declare module "babylonjs/Materials/multiMaterial" {
  21250. import { Nullable } from "babylonjs/types";
  21251. import { Scene } from "babylonjs/scene";
  21252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21253. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21255. import { Material } from "babylonjs/Materials/material";
  21256. /**
  21257. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21258. * separate meshes. This can be use to improve performances.
  21259. * @see http://doc.babylonjs.com/how_to/multi_materials
  21260. */
  21261. export class MultiMaterial extends Material {
  21262. private _subMaterials;
  21263. /**
  21264. * Gets or Sets the list of Materials used within the multi material.
  21265. * They need to be ordered according to the submeshes order in the associated mesh
  21266. */
  21267. subMaterials: Nullable<Material>[];
  21268. /**
  21269. * Function used to align with Node.getChildren()
  21270. * @returns the list of Materials used within the multi material
  21271. */
  21272. getChildren(): Nullable<Material>[];
  21273. /**
  21274. * Instantiates a new Multi Material
  21275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21276. * separate meshes. This can be use to improve performances.
  21277. * @see http://doc.babylonjs.com/how_to/multi_materials
  21278. * @param name Define the name in the scene
  21279. * @param scene Define the scene the material belongs to
  21280. */
  21281. constructor(name: string, scene: Scene);
  21282. private _hookArray;
  21283. /**
  21284. * Get one of the submaterial by its index in the submaterials array
  21285. * @param index The index to look the sub material at
  21286. * @returns The Material if the index has been defined
  21287. */
  21288. getSubMaterial(index: number): Nullable<Material>;
  21289. /**
  21290. * Get the list of active textures for the whole sub materials list.
  21291. * @returns All the textures that will be used during the rendering
  21292. */
  21293. getActiveTextures(): BaseTexture[];
  21294. /**
  21295. * Gets the current class name of the material e.g. "MultiMaterial"
  21296. * Mainly use in serialization.
  21297. * @returns the class name
  21298. */
  21299. getClassName(): string;
  21300. /**
  21301. * Checks if the material is ready to render the requested sub mesh
  21302. * @param mesh Define the mesh the submesh belongs to
  21303. * @param subMesh Define the sub mesh to look readyness for
  21304. * @param useInstances Define whether or not the material is used with instances
  21305. * @returns true if ready, otherwise false
  21306. */
  21307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21308. /**
  21309. * Clones the current material and its related sub materials
  21310. * @param name Define the name of the newly cloned material
  21311. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21312. * @returns the cloned material
  21313. */
  21314. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21315. /**
  21316. * Serializes the materials into a JSON representation.
  21317. * @returns the JSON representation
  21318. */
  21319. serialize(): any;
  21320. /**
  21321. * Dispose the material and release its associated resources
  21322. * @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)
  21323. * @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)
  21324. * @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)
  21325. */
  21326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21327. /**
  21328. * Creates a MultiMaterial from parsed MultiMaterial data.
  21329. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21330. * @param scene defines the hosting scene
  21331. * @returns a new MultiMaterial
  21332. */
  21333. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21334. }
  21335. }
  21336. declare module "babylonjs/Meshes/subMesh" {
  21337. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21338. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21339. import { Engine } from "babylonjs/Engines/engine";
  21340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21341. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21342. import { Effect } from "babylonjs/Materials/effect";
  21343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21344. import { Plane } from "babylonjs/Maths/math.plane";
  21345. import { Collider } from "babylonjs/Collisions/collider";
  21346. import { Material } from "babylonjs/Materials/material";
  21347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { Mesh } from "babylonjs/Meshes/mesh";
  21350. import { Ray } from "babylonjs/Culling/ray";
  21351. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21352. /**
  21353. * Base class for submeshes
  21354. */
  21355. export class BaseSubMesh {
  21356. /** @hidden */
  21357. _materialDefines: Nullable<MaterialDefines>;
  21358. /** @hidden */
  21359. _materialEffect: Nullable<Effect>;
  21360. /**
  21361. * Gets associated effect
  21362. */
  21363. readonly effect: Nullable<Effect>;
  21364. /**
  21365. * Sets associated effect (effect used to render this submesh)
  21366. * @param effect defines the effect to associate with
  21367. * @param defines defines the set of defines used to compile this effect
  21368. */
  21369. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21370. }
  21371. /**
  21372. * Defines a subdivision inside a mesh
  21373. */
  21374. export class SubMesh extends BaseSubMesh implements ICullable {
  21375. /** the material index to use */
  21376. materialIndex: number;
  21377. /** vertex index start */
  21378. verticesStart: number;
  21379. /** vertices count */
  21380. verticesCount: number;
  21381. /** index start */
  21382. indexStart: number;
  21383. /** indices count */
  21384. indexCount: number;
  21385. /** @hidden */
  21386. _linesIndexCount: number;
  21387. private _mesh;
  21388. private _renderingMesh;
  21389. private _boundingInfo;
  21390. private _linesIndexBuffer;
  21391. /** @hidden */
  21392. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21393. /** @hidden */
  21394. _trianglePlanes: Plane[];
  21395. /** @hidden */
  21396. _lastColliderTransformMatrix: Nullable<Matrix>;
  21397. /** @hidden */
  21398. _renderId: number;
  21399. /** @hidden */
  21400. _alphaIndex: number;
  21401. /** @hidden */
  21402. _distanceToCamera: number;
  21403. /** @hidden */
  21404. _id: number;
  21405. private _currentMaterial;
  21406. /**
  21407. * Add a new submesh to a mesh
  21408. * @param materialIndex defines the material index to use
  21409. * @param verticesStart defines vertex index start
  21410. * @param verticesCount defines vertices count
  21411. * @param indexStart defines index start
  21412. * @param indexCount defines indices count
  21413. * @param mesh defines the parent mesh
  21414. * @param renderingMesh defines an optional rendering mesh
  21415. * @param createBoundingBox defines if bounding box should be created for this submesh
  21416. * @returns the new submesh
  21417. */
  21418. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21419. /**
  21420. * Creates a new submesh
  21421. * @param materialIndex defines the material index to use
  21422. * @param verticesStart defines vertex index start
  21423. * @param verticesCount defines vertices count
  21424. * @param indexStart defines index start
  21425. * @param indexCount defines indices count
  21426. * @param mesh defines the parent mesh
  21427. * @param renderingMesh defines an optional rendering mesh
  21428. * @param createBoundingBox defines if bounding box should be created for this submesh
  21429. */
  21430. constructor(
  21431. /** the material index to use */
  21432. materialIndex: number,
  21433. /** vertex index start */
  21434. verticesStart: number,
  21435. /** vertices count */
  21436. verticesCount: number,
  21437. /** index start */
  21438. indexStart: number,
  21439. /** indices count */
  21440. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21441. /**
  21442. * Returns true if this submesh covers the entire parent mesh
  21443. * @ignorenaming
  21444. */
  21445. readonly IsGlobal: boolean;
  21446. /**
  21447. * Returns the submesh BoudingInfo object
  21448. * @returns current bounding info (or mesh's one if the submesh is global)
  21449. */
  21450. getBoundingInfo(): BoundingInfo;
  21451. /**
  21452. * Sets the submesh BoundingInfo
  21453. * @param boundingInfo defines the new bounding info to use
  21454. * @returns the SubMesh
  21455. */
  21456. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21457. /**
  21458. * Returns the mesh of the current submesh
  21459. * @return the parent mesh
  21460. */
  21461. getMesh(): AbstractMesh;
  21462. /**
  21463. * Returns the rendering mesh of the submesh
  21464. * @returns the rendering mesh (could be different from parent mesh)
  21465. */
  21466. getRenderingMesh(): Mesh;
  21467. /**
  21468. * Returns the submesh material
  21469. * @returns null or the current material
  21470. */
  21471. getMaterial(): Nullable<Material>;
  21472. /**
  21473. * Sets a new updated BoundingInfo object to the submesh
  21474. * @param data defines an optional position array to use to determine the bounding info
  21475. * @returns the SubMesh
  21476. */
  21477. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21478. /** @hidden */
  21479. _checkCollision(collider: Collider): boolean;
  21480. /**
  21481. * Updates the submesh BoundingInfo
  21482. * @param world defines the world matrix to use to update the bounding info
  21483. * @returns the submesh
  21484. */
  21485. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21486. /**
  21487. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21488. * @param frustumPlanes defines the frustum planes
  21489. * @returns true if the submesh is intersecting with the frustum
  21490. */
  21491. isInFrustum(frustumPlanes: Plane[]): boolean;
  21492. /**
  21493. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21494. * @param frustumPlanes defines the frustum planes
  21495. * @returns true if the submesh is inside the frustum
  21496. */
  21497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21498. /**
  21499. * Renders the submesh
  21500. * @param enableAlphaMode defines if alpha needs to be used
  21501. * @returns the submesh
  21502. */
  21503. render(enableAlphaMode: boolean): SubMesh;
  21504. /**
  21505. * @hidden
  21506. */
  21507. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21508. /**
  21509. * Checks if the submesh intersects with a ray
  21510. * @param ray defines the ray to test
  21511. * @returns true is the passed ray intersects the submesh bounding box
  21512. */
  21513. canIntersects(ray: Ray): boolean;
  21514. /**
  21515. * Intersects current submesh with a ray
  21516. * @param ray defines the ray to test
  21517. * @param positions defines mesh's positions array
  21518. * @param indices defines mesh's indices array
  21519. * @param fastCheck defines if only bounding info should be used
  21520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21521. * @returns intersection info or null if no intersection
  21522. */
  21523. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21524. /** @hidden */
  21525. private _intersectLines;
  21526. /** @hidden */
  21527. private _intersectUnIndexedLines;
  21528. /** @hidden */
  21529. private _intersectTriangles;
  21530. /** @hidden */
  21531. private _intersectUnIndexedTriangles;
  21532. /** @hidden */
  21533. _rebuild(): void;
  21534. /**
  21535. * Creates a new submesh from the passed mesh
  21536. * @param newMesh defines the new hosting mesh
  21537. * @param newRenderingMesh defines an optional rendering mesh
  21538. * @returns the new submesh
  21539. */
  21540. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21541. /**
  21542. * Release associated resources
  21543. */
  21544. dispose(): void;
  21545. /**
  21546. * Gets the class name
  21547. * @returns the string "SubMesh".
  21548. */
  21549. getClassName(): string;
  21550. /**
  21551. * Creates a new submesh from indices data
  21552. * @param materialIndex the index of the main mesh material
  21553. * @param startIndex the index where to start the copy in the mesh indices array
  21554. * @param indexCount the number of indices to copy then from the startIndex
  21555. * @param mesh the main mesh to create the submesh from
  21556. * @param renderingMesh the optional rendering mesh
  21557. * @returns a new submesh
  21558. */
  21559. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21560. }
  21561. }
  21562. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21563. /**
  21564. * Class used to represent data loading progression
  21565. */
  21566. export class SceneLoaderFlags {
  21567. private static _ForceFullSceneLoadingForIncremental;
  21568. private static _ShowLoadingScreen;
  21569. private static _CleanBoneMatrixWeights;
  21570. private static _loggingLevel;
  21571. /**
  21572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21573. */
  21574. static ForceFullSceneLoadingForIncremental: boolean;
  21575. /**
  21576. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21577. */
  21578. static ShowLoadingScreen: boolean;
  21579. /**
  21580. * Defines the current logging level (while loading the scene)
  21581. * @ignorenaming
  21582. */
  21583. static loggingLevel: number;
  21584. /**
  21585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21586. */
  21587. static CleanBoneMatrixWeights: boolean;
  21588. }
  21589. }
  21590. declare module "babylonjs/Meshes/geometry" {
  21591. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21594. import { Engine } from "babylonjs/Engines/engine";
  21595. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21596. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21599. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21600. import { Mesh } from "babylonjs/Meshes/mesh";
  21601. /**
  21602. * Class used to store geometry data (vertex buffers + index buffer)
  21603. */
  21604. export class Geometry implements IGetSetVerticesData {
  21605. /**
  21606. * Gets or sets the ID of the geometry
  21607. */
  21608. id: string;
  21609. /**
  21610. * Gets or sets the unique ID of the geometry
  21611. */
  21612. uniqueId: number;
  21613. /**
  21614. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21615. */
  21616. delayLoadState: number;
  21617. /**
  21618. * Gets the file containing the data to load when running in delay load state
  21619. */
  21620. delayLoadingFile: Nullable<string>;
  21621. /**
  21622. * Callback called when the geometry is updated
  21623. */
  21624. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21625. private _scene;
  21626. private _engine;
  21627. private _meshes;
  21628. private _totalVertices;
  21629. /** @hidden */
  21630. _indices: IndicesArray;
  21631. /** @hidden */
  21632. _vertexBuffers: {
  21633. [key: string]: VertexBuffer;
  21634. };
  21635. private _isDisposed;
  21636. private _extend;
  21637. private _boundingBias;
  21638. /** @hidden */
  21639. _delayInfo: Array<string>;
  21640. private _indexBuffer;
  21641. private _indexBufferIsUpdatable;
  21642. /** @hidden */
  21643. _boundingInfo: Nullable<BoundingInfo>;
  21644. /** @hidden */
  21645. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21646. /** @hidden */
  21647. _softwareSkinningFrameId: number;
  21648. private _vertexArrayObjects;
  21649. private _updatable;
  21650. /** @hidden */
  21651. _positions: Nullable<Vector3[]>;
  21652. /**
  21653. * 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
  21654. */
  21655. /**
  21656. * 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
  21657. */
  21658. boundingBias: Vector2;
  21659. /**
  21660. * Static function used to attach a new empty geometry to a mesh
  21661. * @param mesh defines the mesh to attach the geometry to
  21662. * @returns the new Geometry
  21663. */
  21664. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21665. /**
  21666. * Creates a new geometry
  21667. * @param id defines the unique ID
  21668. * @param scene defines the hosting scene
  21669. * @param vertexData defines the VertexData used to get geometry data
  21670. * @param updatable defines if geometry must be updatable (false by default)
  21671. * @param mesh defines the mesh that will be associated with the geometry
  21672. */
  21673. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21674. /**
  21675. * Gets the current extend of the geometry
  21676. */
  21677. readonly extend: {
  21678. minimum: Vector3;
  21679. maximum: Vector3;
  21680. };
  21681. /**
  21682. * Gets the hosting scene
  21683. * @returns the hosting Scene
  21684. */
  21685. getScene(): Scene;
  21686. /**
  21687. * Gets the hosting engine
  21688. * @returns the hosting Engine
  21689. */
  21690. getEngine(): Engine;
  21691. /**
  21692. * Defines if the geometry is ready to use
  21693. * @returns true if the geometry is ready to be used
  21694. */
  21695. isReady(): boolean;
  21696. /**
  21697. * Gets a value indicating that the geometry should not be serialized
  21698. */
  21699. readonly doNotSerialize: boolean;
  21700. /** @hidden */
  21701. _rebuild(): void;
  21702. /**
  21703. * Affects all geometry data in one call
  21704. * @param vertexData defines the geometry data
  21705. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21706. */
  21707. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21708. /**
  21709. * Set specific vertex data
  21710. * @param kind defines the data kind (Position, normal, etc...)
  21711. * @param data defines the vertex data to use
  21712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21714. */
  21715. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21716. /**
  21717. * Removes a specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. */
  21720. removeVerticesData(kind: string): void;
  21721. /**
  21722. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21723. * @param buffer defines the vertex buffer to use
  21724. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21725. */
  21726. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21727. /**
  21728. * Update a specific vertex buffer
  21729. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21730. * It will do nothing if the buffer is not updatable
  21731. * @param kind defines the data kind (Position, normal, etc...)
  21732. * @param data defines the data to use
  21733. * @param offset defines the offset in the target buffer where to store the data
  21734. * @param useBytes set to true if the offset is in bytes
  21735. */
  21736. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21737. /**
  21738. * Update a specific vertex buffer
  21739. * This function will create a new buffer if the current one is not updatable
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @param data defines the data to use
  21742. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21743. */
  21744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21745. private _updateBoundingInfo;
  21746. /** @hidden */
  21747. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21748. /**
  21749. * Gets total number of vertices
  21750. * @returns the total number of vertices
  21751. */
  21752. getTotalVertices(): number;
  21753. /**
  21754. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21755. * @param kind defines the data kind (Position, normal, etc...)
  21756. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21758. * @returns a float array containing vertex data
  21759. */
  21760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21761. /**
  21762. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @returns true if the vertex buffer with the specified kind is updatable
  21765. */
  21766. isVertexBufferUpdatable(kind: string): boolean;
  21767. /**
  21768. * Gets a specific vertex buffer
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @returns a VertexBuffer
  21771. */
  21772. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21773. /**
  21774. * Returns all vertex buffers
  21775. * @return an object holding all vertex buffers indexed by kind
  21776. */
  21777. getVertexBuffers(): Nullable<{
  21778. [key: string]: VertexBuffer;
  21779. }>;
  21780. /**
  21781. * Gets a boolean indicating if specific vertex buffer is present
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @returns true if data is present
  21784. */
  21785. isVerticesDataPresent(kind: string): boolean;
  21786. /**
  21787. * Gets a list of all attached data kinds (Position, normal, etc...)
  21788. * @returns a list of string containing all kinds
  21789. */
  21790. getVerticesDataKinds(): string[];
  21791. /**
  21792. * Update index buffer
  21793. * @param indices defines the indices to store in the index buffer
  21794. * @param offset defines the offset in the target buffer where to store the data
  21795. * @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)
  21796. */
  21797. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21798. /**
  21799. * Creates a new index buffer
  21800. * @param indices defines the indices to store in the index buffer
  21801. * @param totalVertices defines the total number of vertices (could be null)
  21802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21803. */
  21804. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21805. /**
  21806. * Return the total number of indices
  21807. * @returns the total number of indices
  21808. */
  21809. getTotalIndices(): number;
  21810. /**
  21811. * Gets the index buffer array
  21812. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21814. * @returns the index buffer array
  21815. */
  21816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21817. /**
  21818. * Gets the index buffer
  21819. * @return the index buffer
  21820. */
  21821. getIndexBuffer(): Nullable<DataBuffer>;
  21822. /** @hidden */
  21823. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21824. /**
  21825. * Release the associated resources for a specific mesh
  21826. * @param mesh defines the source mesh
  21827. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21828. */
  21829. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21830. /**
  21831. * Apply current geometry to a given mesh
  21832. * @param mesh defines the mesh to apply geometry to
  21833. */
  21834. applyToMesh(mesh: Mesh): void;
  21835. private _updateExtend;
  21836. private _applyToMesh;
  21837. private notifyUpdate;
  21838. /**
  21839. * Load the geometry if it was flagged as delay loaded
  21840. * @param scene defines the hosting scene
  21841. * @param onLoaded defines a callback called when the geometry is loaded
  21842. */
  21843. load(scene: Scene, onLoaded?: () => void): void;
  21844. private _queueLoad;
  21845. /**
  21846. * Invert the geometry to move from a right handed system to a left handed one.
  21847. */
  21848. toLeftHanded(): void;
  21849. /** @hidden */
  21850. _resetPointsArrayCache(): void;
  21851. /** @hidden */
  21852. _generatePointsArray(): boolean;
  21853. /**
  21854. * Gets a value indicating if the geometry is disposed
  21855. * @returns true if the geometry was disposed
  21856. */
  21857. isDisposed(): boolean;
  21858. private _disposeVertexArrayObjects;
  21859. /**
  21860. * Free all associated resources
  21861. */
  21862. dispose(): void;
  21863. /**
  21864. * Clone the current geometry into a new geometry
  21865. * @param id defines the unique ID of the new geometry
  21866. * @returns a new geometry object
  21867. */
  21868. copy(id: string): Geometry;
  21869. /**
  21870. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21871. * @return a JSON representation of the current geometry data (without the vertices data)
  21872. */
  21873. serialize(): any;
  21874. private toNumberArray;
  21875. /**
  21876. * Serialize all vertices data into a JSON oject
  21877. * @returns a JSON representation of the current geometry data
  21878. */
  21879. serializeVerticeData(): any;
  21880. /**
  21881. * Extracts a clone of a mesh geometry
  21882. * @param mesh defines the source mesh
  21883. * @param id defines the unique ID of the new geometry object
  21884. * @returns the new geometry object
  21885. */
  21886. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21887. /**
  21888. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21889. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21890. * Be aware Math.random() could cause collisions, but:
  21891. * "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"
  21892. * @returns a string containing a new GUID
  21893. */
  21894. static RandomId(): string;
  21895. /** @hidden */
  21896. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21897. private static _CleanMatricesWeights;
  21898. /**
  21899. * Create a new geometry from persisted data (Using .babylon file format)
  21900. * @param parsedVertexData defines the persisted data
  21901. * @param scene defines the hosting scene
  21902. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21903. * @returns the new geometry object
  21904. */
  21905. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21906. }
  21907. }
  21908. declare module "babylonjs/Meshes/mesh.vertexData" {
  21909. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21910. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21912. import { Geometry } from "babylonjs/Meshes/geometry";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Define an interface for all classes that will get and set the data on vertices
  21916. */
  21917. export interface IGetSetVerticesData {
  21918. /**
  21919. * Gets a boolean indicating if specific vertex data is present
  21920. * @param kind defines the vertex data kind to use
  21921. * @returns true is data kind is present
  21922. */
  21923. isVerticesDataPresent(kind: string): boolean;
  21924. /**
  21925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21926. * @param kind defines the data kind (Position, normal, etc...)
  21927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21929. * @returns a float array containing vertex data
  21930. */
  21931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21932. /**
  21933. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21934. * @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.
  21935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21936. * @returns the indices array or an empty array if the mesh has no geometry
  21937. */
  21938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21939. /**
  21940. * Set specific vertex data
  21941. * @param kind defines the data kind (Position, normal, etc...)
  21942. * @param data defines the vertex data to use
  21943. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21944. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21945. */
  21946. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21947. /**
  21948. * Update a specific associated vertex buffer
  21949. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21950. * - VertexBuffer.PositionKind
  21951. * - VertexBuffer.UVKind
  21952. * - VertexBuffer.UV2Kind
  21953. * - VertexBuffer.UV3Kind
  21954. * - VertexBuffer.UV4Kind
  21955. * - VertexBuffer.UV5Kind
  21956. * - VertexBuffer.UV6Kind
  21957. * - VertexBuffer.ColorKind
  21958. * - VertexBuffer.MatricesIndicesKind
  21959. * - VertexBuffer.MatricesIndicesExtraKind
  21960. * - VertexBuffer.MatricesWeightsKind
  21961. * - VertexBuffer.MatricesWeightsExtraKind
  21962. * @param data defines the data source
  21963. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21964. * @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)
  21965. */
  21966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21967. /**
  21968. * Creates a new index buffer
  21969. * @param indices defines the indices to store in the index buffer
  21970. * @param totalVertices defines the total number of vertices (could be null)
  21971. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21972. */
  21973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21974. }
  21975. /**
  21976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21977. */
  21978. export class VertexData {
  21979. /**
  21980. * Mesh side orientation : usually the external or front surface
  21981. */
  21982. static readonly FRONTSIDE: number;
  21983. /**
  21984. * Mesh side orientation : usually the internal or back surface
  21985. */
  21986. static readonly BACKSIDE: number;
  21987. /**
  21988. * Mesh side orientation : both internal and external or front and back surfaces
  21989. */
  21990. static readonly DOUBLESIDE: number;
  21991. /**
  21992. * Mesh side orientation : by default, `FRONTSIDE`
  21993. */
  21994. static readonly DEFAULTSIDE: number;
  21995. /**
  21996. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21997. */
  21998. positions: Nullable<FloatArray>;
  21999. /**
  22000. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22001. */
  22002. normals: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. tangents: Nullable<FloatArray>;
  22007. /**
  22008. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22009. */
  22010. uvs: Nullable<FloatArray>;
  22011. /**
  22012. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs2: Nullable<FloatArray>;
  22015. /**
  22016. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs3: Nullable<FloatArray>;
  22019. /**
  22020. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs4: Nullable<FloatArray>;
  22023. /**
  22024. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs5: Nullable<FloatArray>;
  22027. /**
  22028. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs6: Nullable<FloatArray>;
  22031. /**
  22032. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22033. */
  22034. colors: Nullable<FloatArray>;
  22035. /**
  22036. * 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).
  22037. */
  22038. matricesIndices: Nullable<FloatArray>;
  22039. /**
  22040. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22041. */
  22042. matricesWeights: Nullable<FloatArray>;
  22043. /**
  22044. * An array extending the number of possible indices
  22045. */
  22046. matricesIndicesExtra: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible weights when the number of indices is extended
  22049. */
  22050. matricesWeightsExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22053. */
  22054. indices: Nullable<IndicesArray>;
  22055. /**
  22056. * Uses the passed data array to set the set the values for the specified kind of data
  22057. * @param data a linear array of floating numbers
  22058. * @param kind the type of data that is being set, eg positions, colors etc
  22059. */
  22060. set(data: FloatArray, kind: string): void;
  22061. /**
  22062. * Associates the vertexData to the passed Mesh.
  22063. * Sets it as updatable or not (default `false`)
  22064. * @param mesh the mesh the vertexData is applied to
  22065. * @param updatable when used and having the value true allows new data to update the vertexData
  22066. * @returns the VertexData
  22067. */
  22068. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22069. /**
  22070. * Associates the vertexData to the passed Geometry.
  22071. * Sets it as updatable or not (default `false`)
  22072. * @param geometry the geometry the vertexData is applied to
  22073. * @param updatable when used and having the value true allows new data to update the vertexData
  22074. * @returns VertexData
  22075. */
  22076. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22077. /**
  22078. * Updates the associated mesh
  22079. * @param mesh the mesh to be updated
  22080. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22081. * @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
  22082. * @returns VertexData
  22083. */
  22084. updateMesh(mesh: Mesh): VertexData;
  22085. /**
  22086. * Updates the associated geometry
  22087. * @param geometry the geometry to be updated
  22088. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22089. * @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
  22090. * @returns VertexData.
  22091. */
  22092. updateGeometry(geometry: Geometry): VertexData;
  22093. private _applyTo;
  22094. private _update;
  22095. /**
  22096. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22097. * @param matrix the transforming matrix
  22098. * @returns the VertexData
  22099. */
  22100. transform(matrix: Matrix): VertexData;
  22101. /**
  22102. * Merges the passed VertexData into the current one
  22103. * @param other the VertexData to be merged into the current one
  22104. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22105. * @returns the modified VertexData
  22106. */
  22107. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22108. private _mergeElement;
  22109. private _validate;
  22110. /**
  22111. * Serializes the VertexData
  22112. * @returns a serialized object
  22113. */
  22114. serialize(): any;
  22115. /**
  22116. * Extracts the vertexData from a mesh
  22117. * @param mesh the mesh from which to extract the VertexData
  22118. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22120. * @returns the object VertexData associated to the passed mesh
  22121. */
  22122. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22123. /**
  22124. * Extracts the vertexData from the geometry
  22125. * @param geometry the geometry from which to extract the VertexData
  22126. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22127. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22128. * @returns the object VertexData associated to the passed mesh
  22129. */
  22130. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22131. private static _ExtractFrom;
  22132. /**
  22133. * Creates the VertexData for a Ribbon
  22134. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22135. * * pathArray array of paths, each of which an array of successive Vector3
  22136. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22137. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22138. * * 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
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * 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)
  22141. * * 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)
  22142. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22143. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22144. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22145. * @returns the VertexData of the ribbon
  22146. */
  22147. static CreateRibbon(options: {
  22148. pathArray: Vector3[][];
  22149. closeArray?: boolean;
  22150. closePath?: boolean;
  22151. offset?: number;
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. invertUV?: boolean;
  22156. uvs?: Vector2[];
  22157. colors?: Color4[];
  22158. }): VertexData;
  22159. /**
  22160. * Creates the VertexData for a box
  22161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22162. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22163. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22164. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22165. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22166. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22167. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22169. * * 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)
  22170. * * 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)
  22171. * @returns the VertexData of the box
  22172. */
  22173. static CreateBox(options: {
  22174. size?: number;
  22175. width?: number;
  22176. height?: number;
  22177. depth?: number;
  22178. faceUV?: Vector4[];
  22179. faceColors?: Color4[];
  22180. sideOrientation?: number;
  22181. frontUVs?: Vector4;
  22182. backUVs?: Vector4;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a tiled box
  22186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * @returns the VertexData of the box
  22192. */
  22193. static CreateTiledBox(options: {
  22194. pattern?: number;
  22195. width?: number;
  22196. height?: number;
  22197. depth?: number;
  22198. tileSize?: number;
  22199. tileWidth?: number;
  22200. tileHeight?: number;
  22201. alignHorizontal?: number;
  22202. alignVertical?: number;
  22203. faceUV?: Vector4[];
  22204. faceColors?: Color4[];
  22205. sideOrientation?: number;
  22206. }): VertexData;
  22207. /**
  22208. * Creates the VertexData for a tiled plane
  22209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22210. * * pattern a limited pattern arrangement depending on the number
  22211. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22212. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22213. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * 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)
  22216. * * 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)
  22217. * @returns the VertexData of the tiled plane
  22218. */
  22219. static CreateTiledPlane(options: {
  22220. pattern?: number;
  22221. tileSize?: number;
  22222. tileWidth?: number;
  22223. tileHeight?: number;
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. alignHorizontal?: number;
  22228. alignVertical?: number;
  22229. sideOrientation?: number;
  22230. frontUVs?: Vector4;
  22231. backUVs?: Vector4;
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22236. * * segments sets the number of horizontal strips optional, default 32
  22237. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22238. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22239. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22240. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22241. * * 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
  22242. * * 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
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * 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)
  22245. * * 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)
  22246. * @returns the VertexData of the ellipsoid
  22247. */
  22248. static CreateSphere(options: {
  22249. segments?: number;
  22250. diameter?: number;
  22251. diameterX?: number;
  22252. diameterY?: number;
  22253. diameterZ?: number;
  22254. arc?: number;
  22255. slice?: number;
  22256. sideOrientation?: number;
  22257. frontUVs?: Vector4;
  22258. backUVs?: Vector4;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a cylinder, cone or prism
  22262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22263. * * height sets the height (y direction) of the cylinder, optional, default 2
  22264. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22265. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22266. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22267. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22268. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22269. * * 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
  22270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22272. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22273. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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)
  22276. * * 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)
  22277. * @returns the VertexData of the cylinder, cone or prism
  22278. */
  22279. static CreateCylinder(options: {
  22280. height?: number;
  22281. diameterTop?: number;
  22282. diameterBottom?: number;
  22283. diameter?: number;
  22284. tessellation?: number;
  22285. subdivisions?: number;
  22286. arc?: number;
  22287. faceColors?: Color4[];
  22288. faceUV?: Vector4[];
  22289. hasRings?: boolean;
  22290. enclose?: boolean;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }): VertexData;
  22295. /**
  22296. * Creates the VertexData for a torus
  22297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22298. * * diameter the diameter of the torus, optional default 1
  22299. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22300. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22302. * * 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)
  22303. * * 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)
  22304. * @returns the VertexData of the torus
  22305. */
  22306. static CreateTorus(options: {
  22307. diameter?: number;
  22308. thickness?: number;
  22309. tessellation?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData of the LineSystem
  22316. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22317. * - lines an array of lines, each line being an array of successive Vector3
  22318. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22319. * @returns the VertexData of the LineSystem
  22320. */
  22321. static CreateLineSystem(options: {
  22322. lines: Vector3[][];
  22323. colors?: Nullable<Color4[][]>;
  22324. }): VertexData;
  22325. /**
  22326. * Create the VertexData for a DashedLines
  22327. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22328. * - points an array successive Vector3
  22329. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22330. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22331. * - dashNb the intended total number of dashes, optional, default 200
  22332. * @returns the VertexData for the DashedLines
  22333. */
  22334. static CreateDashedLines(options: {
  22335. points: Vector3[];
  22336. dashSize?: number;
  22337. gapSize?: number;
  22338. dashNb?: number;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a Ground
  22342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22343. * - width the width (x direction) of the ground, optional, default 1
  22344. * - height the height (z direction) of the ground, optional, default 1
  22345. * - subdivisions the number of subdivisions per side, optional, default 1
  22346. * @returns the VertexData of the Ground
  22347. */
  22348. static CreateGround(options: {
  22349. width?: number;
  22350. height?: number;
  22351. subdivisions?: number;
  22352. subdivisionsX?: number;
  22353. subdivisionsY?: number;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22357. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22358. * * xmin the ground minimum X coordinate, optional, default -1
  22359. * * zmin the ground minimum Z coordinate, optional, default -1
  22360. * * xmax the ground maximum X coordinate, optional, default 1
  22361. * * zmax the ground maximum Z coordinate, optional, default 1
  22362. * * 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}
  22363. * * 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}
  22364. * @returns the VertexData of the TiledGround
  22365. */
  22366. static CreateTiledGround(options: {
  22367. xmin: number;
  22368. zmin: number;
  22369. xmax: number;
  22370. zmax: number;
  22371. subdivisions?: {
  22372. w: number;
  22373. h: number;
  22374. };
  22375. precision?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData of the Ground designed from a heightmap
  22382. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22383. * * width the width (x direction) of the ground
  22384. * * height the height (z direction) of the ground
  22385. * * subdivisions the number of subdivisions per side
  22386. * * minHeight the minimum altitude on the ground, optional, default 0
  22387. * * maxHeight the maximum altitude on the ground, optional default 1
  22388. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22389. * * buffer the array holding the image color data
  22390. * * bufferWidth the width of image
  22391. * * bufferHeight the height of image
  22392. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22393. * @returns the VertexData of the Ground designed from a heightmap
  22394. */
  22395. static CreateGroundFromHeightMap(options: {
  22396. width: number;
  22397. height: number;
  22398. subdivisions: number;
  22399. minHeight: number;
  22400. maxHeight: number;
  22401. colorFilter: Color3;
  22402. buffer: Uint8Array;
  22403. bufferWidth: number;
  22404. bufferHeight: number;
  22405. alphaFilter: number;
  22406. }): VertexData;
  22407. /**
  22408. * Creates the VertexData for a Plane
  22409. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22410. * * size sets the width and height of the plane to the value of size, optional default 1
  22411. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22412. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * 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)
  22415. * * 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)
  22416. * @returns the VertexData of the box
  22417. */
  22418. static CreatePlane(options: {
  22419. size?: number;
  22420. width?: number;
  22421. height?: number;
  22422. sideOrientation?: number;
  22423. frontUVs?: Vector4;
  22424. backUVs?: Vector4;
  22425. }): VertexData;
  22426. /**
  22427. * Creates the VertexData of the Disc or regular Polygon
  22428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22429. * * radius the radius of the disc, optional default 0.5
  22430. * * tessellation the number of polygon sides, optional, default 64
  22431. * * 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
  22432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22433. * * 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)
  22434. * * 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)
  22435. * @returns the VertexData of the box
  22436. */
  22437. static CreateDisc(options: {
  22438. radius?: number;
  22439. tessellation?: number;
  22440. arc?: number;
  22441. sideOrientation?: number;
  22442. frontUVs?: Vector4;
  22443. backUVs?: Vector4;
  22444. }): VertexData;
  22445. /**
  22446. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22447. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22448. * @param polygon a mesh built from polygonTriangulation.build()
  22449. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22451. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22452. * @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)
  22453. * @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)
  22454. * @returns the VertexData of the Polygon
  22455. */
  22456. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22457. /**
  22458. * Creates the VertexData of the IcoSphere
  22459. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22460. * * radius the radius of the IcoSphere, optional default 1
  22461. * * radiusX allows stretching in the x direction, optional, default radius
  22462. * * radiusY allows stretching in the y direction, optional, default radius
  22463. * * radiusZ allows stretching in the z direction, optional, default radius
  22464. * * flat when true creates a flat shaded mesh, optional, default true
  22465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the IcoSphere
  22470. */
  22471. static CreateIcoSphere(options: {
  22472. radius?: number;
  22473. radiusX?: number;
  22474. radiusY?: number;
  22475. radiusZ?: number;
  22476. flat?: boolean;
  22477. subdivisions?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a Polyhedron
  22484. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22485. * * type provided types are:
  22486. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22487. * * 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)
  22488. * * size the size of the IcoSphere, optional default 1
  22489. * * sizeX allows stretching in the x direction, optional, default size
  22490. * * sizeY allows stretching in the y direction, optional, default size
  22491. * * sizeZ allows stretching in the z direction, optional, default size
  22492. * * 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
  22493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22494. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22495. * * flat when true creates a flat shaded mesh, optional, default true
  22496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22498. * * 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)
  22499. * * 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)
  22500. * @returns the VertexData of the Polyhedron
  22501. */
  22502. static CreatePolyhedron(options: {
  22503. type?: number;
  22504. size?: number;
  22505. sizeX?: number;
  22506. sizeY?: number;
  22507. sizeZ?: number;
  22508. custom?: any;
  22509. faceUV?: Vector4[];
  22510. faceColors?: Color4[];
  22511. flat?: boolean;
  22512. sideOrientation?: number;
  22513. frontUVs?: Vector4;
  22514. backUVs?: Vector4;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a TorusKnot
  22518. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22519. * * radius the radius of the torus knot, optional, default 2
  22520. * * tube the thickness of the tube, optional, default 0.5
  22521. * * radialSegments the number of sides on each tube segments, optional, default 32
  22522. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22523. * * p the number of windings around the z axis, optional, default 2
  22524. * * q the number of windings around the x axis, optional, default 3
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * * 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)
  22527. * * 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)
  22528. * @returns the VertexData of the Torus Knot
  22529. */
  22530. static CreateTorusKnot(options: {
  22531. radius?: number;
  22532. tube?: number;
  22533. radialSegments?: number;
  22534. tubularSegments?: number;
  22535. p?: number;
  22536. q?: number;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }): VertexData;
  22541. /**
  22542. * Compute normals for given positions and indices
  22543. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22544. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22545. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22546. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22547. * * facetNormals : optional array of facet normals (vector3)
  22548. * * facetPositions : optional array of facet positions (vector3)
  22549. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22550. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22551. * * bInfo : optional bounding info, required for facetPartitioning computation
  22552. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22553. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22554. * * useRightHandedSystem: optional boolean to for right handed system computation
  22555. * * depthSort : optional boolean to enable the facet depth sort computation
  22556. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22557. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22558. */
  22559. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22560. facetNormals?: any;
  22561. facetPositions?: any;
  22562. facetPartitioning?: any;
  22563. ratio?: number;
  22564. bInfo?: any;
  22565. bbSize?: Vector3;
  22566. subDiv?: any;
  22567. useRightHandedSystem?: boolean;
  22568. depthSort?: boolean;
  22569. distanceTo?: Vector3;
  22570. depthSortedFacets?: any;
  22571. }): void;
  22572. /** @hidden */
  22573. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22574. /**
  22575. * Applies VertexData created from the imported parameters to the geometry
  22576. * @param parsedVertexData the parsed data from an imported file
  22577. * @param geometry the geometry to apply the VertexData to
  22578. */
  22579. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22580. }
  22581. }
  22582. declare module "babylonjs/Morph/morphTarget" {
  22583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22584. import { Observable } from "babylonjs/Misc/observable";
  22585. import { Nullable, FloatArray } from "babylonjs/types";
  22586. import { Scene } from "babylonjs/scene";
  22587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22588. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22589. /**
  22590. * Defines a target to use with MorphTargetManager
  22591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22592. */
  22593. export class MorphTarget implements IAnimatable {
  22594. /** defines the name of the target */
  22595. name: string;
  22596. /**
  22597. * Gets or sets the list of animations
  22598. */
  22599. animations: import("babylonjs/Animations/animation").Animation[];
  22600. private _scene;
  22601. private _positions;
  22602. private _normals;
  22603. private _tangents;
  22604. private _uvs;
  22605. private _influence;
  22606. /**
  22607. * Observable raised when the influence changes
  22608. */
  22609. onInfluenceChanged: Observable<boolean>;
  22610. /** @hidden */
  22611. _onDataLayoutChanged: Observable<void>;
  22612. /**
  22613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22614. */
  22615. influence: number;
  22616. /**
  22617. * Gets or sets the id of the morph Target
  22618. */
  22619. id: string;
  22620. private _animationPropertiesOverride;
  22621. /**
  22622. * Gets or sets the animation properties override
  22623. */
  22624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22625. /**
  22626. * Creates a new MorphTarget
  22627. * @param name defines the name of the target
  22628. * @param influence defines the influence to use
  22629. * @param scene defines the scene the morphtarget belongs to
  22630. */
  22631. constructor(
  22632. /** defines the name of the target */
  22633. name: string, influence?: number, scene?: Nullable<Scene>);
  22634. /**
  22635. * Gets a boolean defining if the target contains position data
  22636. */
  22637. readonly hasPositions: boolean;
  22638. /**
  22639. * Gets a boolean defining if the target contains normal data
  22640. */
  22641. readonly hasNormals: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains tangent data
  22644. */
  22645. readonly hasTangents: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains texture coordinates data
  22648. */
  22649. readonly hasUVs: boolean;
  22650. /**
  22651. * Affects position data to this target
  22652. * @param data defines the position data to use
  22653. */
  22654. setPositions(data: Nullable<FloatArray>): void;
  22655. /**
  22656. * Gets the position data stored in this target
  22657. * @returns a FloatArray containing the position data (or null if not present)
  22658. */
  22659. getPositions(): Nullable<FloatArray>;
  22660. /**
  22661. * Affects normal data to this target
  22662. * @param data defines the normal data to use
  22663. */
  22664. setNormals(data: Nullable<FloatArray>): void;
  22665. /**
  22666. * Gets the normal data stored in this target
  22667. * @returns a FloatArray containing the normal data (or null if not present)
  22668. */
  22669. getNormals(): Nullable<FloatArray>;
  22670. /**
  22671. * Affects tangent data to this target
  22672. * @param data defines the tangent data to use
  22673. */
  22674. setTangents(data: Nullable<FloatArray>): void;
  22675. /**
  22676. * Gets the tangent data stored in this target
  22677. * @returns a FloatArray containing the tangent data (or null if not present)
  22678. */
  22679. getTangents(): Nullable<FloatArray>;
  22680. /**
  22681. * Affects texture coordinates data to this target
  22682. * @param data defines the texture coordinates data to use
  22683. */
  22684. setUVs(data: Nullable<FloatArray>): void;
  22685. /**
  22686. * Gets the texture coordinates data stored in this target
  22687. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22688. */
  22689. getUVs(): Nullable<FloatArray>;
  22690. /**
  22691. * Serializes the current target into a Serialization object
  22692. * @returns the serialized object
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * Returns the string "MorphTarget"
  22697. * @returns "MorphTarget"
  22698. */
  22699. getClassName(): string;
  22700. /**
  22701. * Creates a new target from serialized data
  22702. * @param serializationObject defines the serialized data to use
  22703. * @returns a new MorphTarget
  22704. */
  22705. static Parse(serializationObject: any): MorphTarget;
  22706. /**
  22707. * Creates a MorphTarget from mesh data
  22708. * @param mesh defines the source mesh
  22709. * @param name defines the name to use for the new target
  22710. * @param influence defines the influence to attach to the target
  22711. * @returns a new MorphTarget
  22712. */
  22713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22714. }
  22715. }
  22716. declare module "babylonjs/Morph/morphTargetManager" {
  22717. import { Nullable } from "babylonjs/types";
  22718. import { Scene } from "babylonjs/scene";
  22719. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22720. /**
  22721. * This class is used to deform meshes using morphing between different targets
  22722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22723. */
  22724. export class MorphTargetManager {
  22725. private _targets;
  22726. private _targetInfluenceChangedObservers;
  22727. private _targetDataLayoutChangedObservers;
  22728. private _activeTargets;
  22729. private _scene;
  22730. private _influences;
  22731. private _supportsNormals;
  22732. private _supportsTangents;
  22733. private _supportsUVs;
  22734. private _vertexCount;
  22735. private _uniqueId;
  22736. private _tempInfluences;
  22737. /**
  22738. * Gets or sets a boolean indicating if normals must be morphed
  22739. */
  22740. enableNormalMorphing: boolean;
  22741. /**
  22742. * Gets or sets a boolean indicating if tangents must be morphed
  22743. */
  22744. enableTangentMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if UV must be morphed
  22747. */
  22748. enableUVMorphing: boolean;
  22749. /**
  22750. * Creates a new MorphTargetManager
  22751. * @param scene defines the current scene
  22752. */
  22753. constructor(scene?: Nullable<Scene>);
  22754. /**
  22755. * Gets the unique ID of this manager
  22756. */
  22757. readonly uniqueId: number;
  22758. /**
  22759. * Gets the number of vertices handled by this manager
  22760. */
  22761. readonly vertexCount: number;
  22762. /**
  22763. * Gets a boolean indicating if this manager supports morphing of normals
  22764. */
  22765. readonly supportsNormals: boolean;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of tangents
  22768. */
  22769. readonly supportsTangents: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22772. */
  22773. readonly supportsUVs: boolean;
  22774. /**
  22775. * Gets the number of targets stored in this manager
  22776. */
  22777. readonly numTargets: number;
  22778. /**
  22779. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22780. */
  22781. readonly numInfluencers: number;
  22782. /**
  22783. * Gets the list of influences (one per target)
  22784. */
  22785. readonly influences: Float32Array;
  22786. /**
  22787. * Gets the active target at specified index. An active target is a target with an influence > 0
  22788. * @param index defines the index to check
  22789. * @returns the requested target
  22790. */
  22791. getActiveTarget(index: number): MorphTarget;
  22792. /**
  22793. * Gets the target at specified index
  22794. * @param index defines the index to check
  22795. * @returns the requested target
  22796. */
  22797. getTarget(index: number): MorphTarget;
  22798. /**
  22799. * Add a new target to this manager
  22800. * @param target defines the target to add
  22801. */
  22802. addTarget(target: MorphTarget): void;
  22803. /**
  22804. * Removes a target from the manager
  22805. * @param target defines the target to remove
  22806. */
  22807. removeTarget(target: MorphTarget): void;
  22808. /**
  22809. * Serializes the current manager into a Serialization object
  22810. * @returns the serialized object
  22811. */
  22812. serialize(): any;
  22813. private _syncActiveTargets;
  22814. /**
  22815. * Syncrhonize the targets with all the meshes using this morph target manager
  22816. */
  22817. synchronize(): void;
  22818. /**
  22819. * Creates a new MorphTargetManager from serialized data
  22820. * @param serializationObject defines the serialized data
  22821. * @param scene defines the hosting scene
  22822. * @returns the new MorphTargetManager
  22823. */
  22824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22825. }
  22826. }
  22827. declare module "babylonjs/Meshes/meshLODLevel" {
  22828. import { Mesh } from "babylonjs/Meshes/mesh";
  22829. import { Nullable } from "babylonjs/types";
  22830. /**
  22831. * Class used to represent a specific level of detail of a mesh
  22832. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22833. */
  22834. export class MeshLODLevel {
  22835. /** Defines the distance where this level should start being displayed */
  22836. distance: number;
  22837. /** Defines the mesh to use to render this level */
  22838. mesh: Nullable<Mesh>;
  22839. /**
  22840. * Creates a new LOD level
  22841. * @param distance defines the distance where this level should star being displayed
  22842. * @param mesh defines the mesh to use to render this level
  22843. */
  22844. constructor(
  22845. /** Defines the distance where this level should start being displayed */
  22846. distance: number,
  22847. /** Defines the mesh to use to render this level */
  22848. mesh: Nullable<Mesh>);
  22849. }
  22850. }
  22851. declare module "babylonjs/Meshes/groundMesh" {
  22852. import { Scene } from "babylonjs/scene";
  22853. import { Vector3 } from "babylonjs/Maths/math.vector";
  22854. import { Mesh } from "babylonjs/Meshes/mesh";
  22855. /**
  22856. * Mesh representing the gorund
  22857. */
  22858. export class GroundMesh extends Mesh {
  22859. /** If octree should be generated */
  22860. generateOctree: boolean;
  22861. private _heightQuads;
  22862. /** @hidden */
  22863. _subdivisionsX: number;
  22864. /** @hidden */
  22865. _subdivisionsY: number;
  22866. /** @hidden */
  22867. _width: number;
  22868. /** @hidden */
  22869. _height: number;
  22870. /** @hidden */
  22871. _minX: number;
  22872. /** @hidden */
  22873. _maxX: number;
  22874. /** @hidden */
  22875. _minZ: number;
  22876. /** @hidden */
  22877. _maxZ: number;
  22878. constructor(name: string, scene: Scene);
  22879. /**
  22880. * "GroundMesh"
  22881. * @returns "GroundMesh"
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * The minimum of x and y subdivisions
  22886. */
  22887. readonly subdivisions: number;
  22888. /**
  22889. * X subdivisions
  22890. */
  22891. readonly subdivisionsX: number;
  22892. /**
  22893. * Y subdivisions
  22894. */
  22895. readonly subdivisionsY: number;
  22896. /**
  22897. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22898. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22899. * @param chunksCount the number of subdivisions for x and y
  22900. * @param octreeBlocksSize (Default: 32)
  22901. */
  22902. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22903. /**
  22904. * Returns a height (y) value in the Worl system :
  22905. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22906. * @param x x coordinate
  22907. * @param z z coordinate
  22908. * @returns the ground y position if (x, z) are outside the ground surface.
  22909. */
  22910. getHeightAtCoordinates(x: number, z: number): number;
  22911. /**
  22912. * Returns a normalized vector (Vector3) orthogonal to the ground
  22913. * at the ground coordinates (x, z) expressed in the World system.
  22914. * @param x x coordinate
  22915. * @param z z coordinate
  22916. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22917. */
  22918. getNormalAtCoordinates(x: number, z: number): Vector3;
  22919. /**
  22920. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22921. * at the ground coordinates (x, z) expressed in the World system.
  22922. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22923. * @param x x coordinate
  22924. * @param z z coordinate
  22925. * @param ref vector to store the result
  22926. * @returns the GroundMesh.
  22927. */
  22928. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22929. /**
  22930. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22931. * if the ground has been updated.
  22932. * This can be used in the render loop.
  22933. * @returns the GroundMesh.
  22934. */
  22935. updateCoordinateHeights(): GroundMesh;
  22936. private _getFacetAt;
  22937. private _initHeightQuads;
  22938. private _computeHeightQuads;
  22939. /**
  22940. * Serializes this ground mesh
  22941. * @param serializationObject object to write serialization to
  22942. */
  22943. serialize(serializationObject: any): void;
  22944. /**
  22945. * Parses a serialized ground mesh
  22946. * @param parsedMesh the serialized mesh
  22947. * @param scene the scene to create the ground mesh in
  22948. * @returns the created ground mesh
  22949. */
  22950. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22951. }
  22952. }
  22953. declare module "babylonjs/Physics/physicsJoint" {
  22954. import { Vector3 } from "babylonjs/Maths/math.vector";
  22955. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22956. /**
  22957. * Interface for Physics-Joint data
  22958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22959. */
  22960. export interface PhysicsJointData {
  22961. /**
  22962. * The main pivot of the joint
  22963. */
  22964. mainPivot?: Vector3;
  22965. /**
  22966. * The connected pivot of the joint
  22967. */
  22968. connectedPivot?: Vector3;
  22969. /**
  22970. * The main axis of the joint
  22971. */
  22972. mainAxis?: Vector3;
  22973. /**
  22974. * The connected axis of the joint
  22975. */
  22976. connectedAxis?: Vector3;
  22977. /**
  22978. * The collision of the joint
  22979. */
  22980. collision?: boolean;
  22981. /**
  22982. * Native Oimo/Cannon/Energy data
  22983. */
  22984. nativeParams?: any;
  22985. }
  22986. /**
  22987. * This is a holder class for the physics joint created by the physics plugin
  22988. * It holds a set of functions to control the underlying joint
  22989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22990. */
  22991. export class PhysicsJoint {
  22992. /**
  22993. * The type of the physics joint
  22994. */
  22995. type: number;
  22996. /**
  22997. * The data for the physics joint
  22998. */
  22999. jointData: PhysicsJointData;
  23000. private _physicsJoint;
  23001. protected _physicsPlugin: IPhysicsEnginePlugin;
  23002. /**
  23003. * Initializes the physics joint
  23004. * @param type The type of the physics joint
  23005. * @param jointData The data for the physics joint
  23006. */
  23007. constructor(
  23008. /**
  23009. * The type of the physics joint
  23010. */
  23011. type: number,
  23012. /**
  23013. * The data for the physics joint
  23014. */
  23015. jointData: PhysicsJointData);
  23016. /**
  23017. * Gets the physics joint
  23018. */
  23019. /**
  23020. * Sets the physics joint
  23021. */
  23022. physicsJoint: any;
  23023. /**
  23024. * Sets the physics plugin
  23025. */
  23026. physicsPlugin: IPhysicsEnginePlugin;
  23027. /**
  23028. * Execute a function that is physics-plugin specific.
  23029. * @param {Function} func the function that will be executed.
  23030. * It accepts two parameters: the physics world and the physics joint
  23031. */
  23032. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23033. /**
  23034. * Distance-Joint type
  23035. */
  23036. static DistanceJoint: number;
  23037. /**
  23038. * Hinge-Joint type
  23039. */
  23040. static HingeJoint: number;
  23041. /**
  23042. * Ball-and-Socket joint type
  23043. */
  23044. static BallAndSocketJoint: number;
  23045. /**
  23046. * Wheel-Joint type
  23047. */
  23048. static WheelJoint: number;
  23049. /**
  23050. * Slider-Joint type
  23051. */
  23052. static SliderJoint: number;
  23053. /**
  23054. * Prismatic-Joint type
  23055. */
  23056. static PrismaticJoint: number;
  23057. /**
  23058. * Universal-Joint type
  23059. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23060. */
  23061. static UniversalJoint: number;
  23062. /**
  23063. * Hinge-Joint 2 type
  23064. */
  23065. static Hinge2Joint: number;
  23066. /**
  23067. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23068. */
  23069. static PointToPointJoint: number;
  23070. /**
  23071. * Spring-Joint type
  23072. */
  23073. static SpringJoint: number;
  23074. /**
  23075. * Lock-Joint type
  23076. */
  23077. static LockJoint: number;
  23078. }
  23079. /**
  23080. * A class representing a physics distance joint
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class DistanceJoint extends PhysicsJoint {
  23084. /**
  23085. *
  23086. * @param jointData The data for the Distance-Joint
  23087. */
  23088. constructor(jointData: DistanceJointData);
  23089. /**
  23090. * Update the predefined distance.
  23091. * @param maxDistance The maximum preferred distance
  23092. * @param minDistance The minimum preferred distance
  23093. */
  23094. updateDistance(maxDistance: number, minDistance?: number): void;
  23095. }
  23096. /**
  23097. * Represents a Motor-Enabled Joint
  23098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23099. */
  23100. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23101. /**
  23102. * Initializes the Motor-Enabled Joint
  23103. * @param type The type of the joint
  23104. * @param jointData The physica joint data for the joint
  23105. */
  23106. constructor(type: number, jointData: PhysicsJointData);
  23107. /**
  23108. * Set the motor values.
  23109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23110. * @param force the force to apply
  23111. * @param maxForce max force for this motor.
  23112. */
  23113. setMotor(force?: number, maxForce?: number): void;
  23114. /**
  23115. * Set the motor's limits.
  23116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23117. * @param upperLimit The upper limit of the motor
  23118. * @param lowerLimit The lower limit of the motor
  23119. */
  23120. setLimit(upperLimit: number, lowerLimit?: number): void;
  23121. }
  23122. /**
  23123. * This class represents a single physics Hinge-Joint
  23124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23125. */
  23126. export class HingeJoint extends MotorEnabledJoint {
  23127. /**
  23128. * Initializes the Hinge-Joint
  23129. * @param jointData The joint data for the Hinge-Joint
  23130. */
  23131. constructor(jointData: PhysicsJointData);
  23132. /**
  23133. * Set the motor values.
  23134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23135. * @param {number} force the force to apply
  23136. * @param {number} maxForce max force for this motor.
  23137. */
  23138. setMotor(force?: number, maxForce?: number): void;
  23139. /**
  23140. * Set the motor's limits.
  23141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23142. * @param upperLimit The upper limit of the motor
  23143. * @param lowerLimit The lower limit of the motor
  23144. */
  23145. setLimit(upperLimit: number, lowerLimit?: number): void;
  23146. }
  23147. /**
  23148. * This class represents a dual hinge physics joint (same as wheel joint)
  23149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23150. */
  23151. export class Hinge2Joint extends MotorEnabledJoint {
  23152. /**
  23153. * Initializes the Hinge2-Joint
  23154. * @param jointData The joint data for the Hinge2-Joint
  23155. */
  23156. constructor(jointData: PhysicsJointData);
  23157. /**
  23158. * Set the motor values.
  23159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23160. * @param {number} targetSpeed the speed the motor is to reach
  23161. * @param {number} maxForce max force for this motor.
  23162. * @param {motorIndex} the motor's index, 0 or 1.
  23163. */
  23164. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23165. /**
  23166. * Set the motor limits.
  23167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23168. * @param {number} upperLimit the upper limit
  23169. * @param {number} lowerLimit lower limit
  23170. * @param {motorIndex} the motor's index, 0 or 1.
  23171. */
  23172. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23173. }
  23174. /**
  23175. * Interface for a motor enabled joint
  23176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23177. */
  23178. export interface IMotorEnabledJoint {
  23179. /**
  23180. * Physics joint
  23181. */
  23182. physicsJoint: any;
  23183. /**
  23184. * Sets the motor of the motor-enabled joint
  23185. * @param force The force of the motor
  23186. * @param maxForce The maximum force of the motor
  23187. * @param motorIndex The index of the motor
  23188. */
  23189. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23190. /**
  23191. * Sets the limit of the motor
  23192. * @param upperLimit The upper limit of the motor
  23193. * @param lowerLimit The lower limit of the motor
  23194. * @param motorIndex The index of the motor
  23195. */
  23196. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23197. }
  23198. /**
  23199. * Joint data for a Distance-Joint
  23200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23201. */
  23202. export interface DistanceJointData extends PhysicsJointData {
  23203. /**
  23204. * Max distance the 2 joint objects can be apart
  23205. */
  23206. maxDistance: number;
  23207. }
  23208. /**
  23209. * Joint data from a spring joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface SpringJointData extends PhysicsJointData {
  23213. /**
  23214. * Length of the spring
  23215. */
  23216. length: number;
  23217. /**
  23218. * Stiffness of the spring
  23219. */
  23220. stiffness: number;
  23221. /**
  23222. * Damping of the spring
  23223. */
  23224. damping: number;
  23225. /** this callback will be called when applying the force to the impostors. */
  23226. forceApplicationCallback: () => void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Physics/physicsRaycastResult" {
  23230. import { Vector3 } from "babylonjs/Maths/math.vector";
  23231. /**
  23232. * Holds the data for the raycast result
  23233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23234. */
  23235. export class PhysicsRaycastResult {
  23236. private _hasHit;
  23237. private _hitDistance;
  23238. private _hitNormalWorld;
  23239. private _hitPointWorld;
  23240. private _rayFromWorld;
  23241. private _rayToWorld;
  23242. /**
  23243. * Gets if there was a hit
  23244. */
  23245. readonly hasHit: boolean;
  23246. /**
  23247. * Gets the distance from the hit
  23248. */
  23249. readonly hitDistance: number;
  23250. /**
  23251. * Gets the hit normal/direction in the world
  23252. */
  23253. readonly hitNormalWorld: Vector3;
  23254. /**
  23255. * Gets the hit point in the world
  23256. */
  23257. readonly hitPointWorld: Vector3;
  23258. /**
  23259. * Gets the ray "start point" of the ray in the world
  23260. */
  23261. readonly rayFromWorld: Vector3;
  23262. /**
  23263. * Gets the ray "end point" of the ray in the world
  23264. */
  23265. readonly rayToWorld: Vector3;
  23266. /**
  23267. * Sets the hit data (normal & point in world space)
  23268. * @param hitNormalWorld defines the normal in world space
  23269. * @param hitPointWorld defines the point in world space
  23270. */
  23271. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23272. /**
  23273. * Sets the distance from the start point to the hit point
  23274. * @param distance
  23275. */
  23276. setHitDistance(distance: number): void;
  23277. /**
  23278. * Calculates the distance manually
  23279. */
  23280. calculateHitDistance(): void;
  23281. /**
  23282. * Resets all the values to default
  23283. * @param from The from point on world space
  23284. * @param to The to point on world space
  23285. */
  23286. reset(from?: Vector3, to?: Vector3): void;
  23287. }
  23288. /**
  23289. * Interface for the size containing width and height
  23290. */
  23291. interface IXYZ {
  23292. /**
  23293. * X
  23294. */
  23295. x: number;
  23296. /**
  23297. * Y
  23298. */
  23299. y: number;
  23300. /**
  23301. * Z
  23302. */
  23303. z: number;
  23304. }
  23305. }
  23306. declare module "babylonjs/Physics/IPhysicsEngine" {
  23307. import { Nullable } from "babylonjs/types";
  23308. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23310. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23311. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23312. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23313. /**
  23314. * Interface used to describe a physics joint
  23315. */
  23316. export interface PhysicsImpostorJoint {
  23317. /** Defines the main impostor to which the joint is linked */
  23318. mainImpostor: PhysicsImpostor;
  23319. /** Defines the impostor that is connected to the main impostor using this joint */
  23320. connectedImpostor: PhysicsImpostor;
  23321. /** Defines the joint itself */
  23322. joint: PhysicsJoint;
  23323. }
  23324. /** @hidden */
  23325. export interface IPhysicsEnginePlugin {
  23326. world: any;
  23327. name: string;
  23328. setGravity(gravity: Vector3): void;
  23329. setTimeStep(timeStep: number): void;
  23330. getTimeStep(): number;
  23331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23335. removePhysicsBody(impostor: PhysicsImpostor): void;
  23336. generateJoint(joint: PhysicsImpostorJoint): void;
  23337. removeJoint(joint: PhysicsImpostorJoint): void;
  23338. isSupported(): boolean;
  23339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23346. getBodyMass(impostor: PhysicsImpostor): number;
  23347. getBodyFriction(impostor: PhysicsImpostor): number;
  23348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23349. getBodyRestitution(impostor: PhysicsImpostor): number;
  23350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23351. getBodyPressure?(impostor: PhysicsImpostor): number;
  23352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23361. sleepBody(impostor: PhysicsImpostor): void;
  23362. wakeUpBody(impostor: PhysicsImpostor): void;
  23363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23367. getRadius(impostor: PhysicsImpostor): number;
  23368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23370. dispose(): void;
  23371. }
  23372. /**
  23373. * Interface used to define a physics engine
  23374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23375. */
  23376. export interface IPhysicsEngine {
  23377. /**
  23378. * Gets the gravity vector used by the simulation
  23379. */
  23380. gravity: Vector3;
  23381. /**
  23382. * Sets the gravity vector used by the simulation
  23383. * @param gravity defines the gravity vector to use
  23384. */
  23385. setGravity(gravity: Vector3): void;
  23386. /**
  23387. * Set the time step of the physics engine.
  23388. * Default is 1/60.
  23389. * To slow it down, enter 1/600 for example.
  23390. * To speed it up, 1/30
  23391. * @param newTimeStep the new timestep to apply to this world.
  23392. */
  23393. setTimeStep(newTimeStep: number): void;
  23394. /**
  23395. * Get the time step of the physics engine.
  23396. * @returns the current time step
  23397. */
  23398. getTimeStep(): number;
  23399. /**
  23400. * Release all resources
  23401. */
  23402. dispose(): void;
  23403. /**
  23404. * Gets the name of the current physics plugin
  23405. * @returns the name of the plugin
  23406. */
  23407. getPhysicsPluginName(): string;
  23408. /**
  23409. * Adding a new impostor for the impostor tracking.
  23410. * This will be done by the impostor itself.
  23411. * @param impostor the impostor to add
  23412. */
  23413. addImpostor(impostor: PhysicsImpostor): void;
  23414. /**
  23415. * Remove an impostor from the engine.
  23416. * This impostor and its mesh will not longer be updated by the physics engine.
  23417. * @param impostor the impostor to remove
  23418. */
  23419. removeImpostor(impostor: PhysicsImpostor): void;
  23420. /**
  23421. * Add a joint to the physics engine
  23422. * @param mainImpostor defines the main impostor to which the joint is added.
  23423. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23424. * @param joint defines the joint that will connect both impostors.
  23425. */
  23426. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23427. /**
  23428. * Removes a joint from the simulation
  23429. * @param mainImpostor defines the impostor used with the joint
  23430. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23431. * @param joint defines the joint to remove
  23432. */
  23433. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23434. /**
  23435. * Gets the current plugin used to run the simulation
  23436. * @returns current plugin
  23437. */
  23438. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23439. /**
  23440. * Gets the list of physic impostors
  23441. * @returns an array of PhysicsImpostor
  23442. */
  23443. getImpostors(): Array<PhysicsImpostor>;
  23444. /**
  23445. * Gets the impostor for a physics enabled object
  23446. * @param object defines the object impersonated by the impostor
  23447. * @returns the PhysicsImpostor or null if not found
  23448. */
  23449. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23450. /**
  23451. * Gets the impostor for a physics body object
  23452. * @param body defines physics body used by the impostor
  23453. * @returns the PhysicsImpostor or null if not found
  23454. */
  23455. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23456. /**
  23457. * Does a raycast in the physics world
  23458. * @param from when should the ray start?
  23459. * @param to when should the ray end?
  23460. * @returns PhysicsRaycastResult
  23461. */
  23462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23463. /**
  23464. * Called by the scene. No need to call it.
  23465. * @param delta defines the timespam between frames
  23466. */
  23467. _step(delta: number): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Physics/physicsImpostor" {
  23471. import { Nullable, IndicesArray } from "babylonjs/types";
  23472. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23475. import { Scene } from "babylonjs/scene";
  23476. import { Bone } from "babylonjs/Bones/bone";
  23477. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23478. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23479. import { Space } from "babylonjs/Maths/math.axis";
  23480. /**
  23481. * The interface for the physics imposter parameters
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface PhysicsImpostorParameters {
  23485. /**
  23486. * The mass of the physics imposter
  23487. */
  23488. mass: number;
  23489. /**
  23490. * The friction of the physics imposter
  23491. */
  23492. friction?: number;
  23493. /**
  23494. * The coefficient of restitution of the physics imposter
  23495. */
  23496. restitution?: number;
  23497. /**
  23498. * The native options of the physics imposter
  23499. */
  23500. nativeOptions?: any;
  23501. /**
  23502. * Specifies if the parent should be ignored
  23503. */
  23504. ignoreParent?: boolean;
  23505. /**
  23506. * Specifies if bi-directional transformations should be disabled
  23507. */
  23508. disableBidirectionalTransformation?: boolean;
  23509. /**
  23510. * The pressure inside the physics imposter, soft object only
  23511. */
  23512. pressure?: number;
  23513. /**
  23514. * The stiffness the physics imposter, soft object only
  23515. */
  23516. stiffness?: number;
  23517. /**
  23518. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23519. */
  23520. velocityIterations?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23523. */
  23524. positionIterations?: number;
  23525. /**
  23526. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23527. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23528. * Add to fix multiple points
  23529. */
  23530. fixedPoints?: number;
  23531. /**
  23532. * The collision margin around a soft object
  23533. */
  23534. margin?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. damping?: number;
  23539. /**
  23540. * The path for a rope based on an extrusion
  23541. */
  23542. path?: any;
  23543. /**
  23544. * The shape of an extrusion used for a rope based on an extrusion
  23545. */
  23546. shape?: any;
  23547. }
  23548. /**
  23549. * Interface for a physics-enabled object
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IPhysicsEnabledObject {
  23553. /**
  23554. * The position of the physics-enabled object
  23555. */
  23556. position: Vector3;
  23557. /**
  23558. * The rotation of the physics-enabled object
  23559. */
  23560. rotationQuaternion: Nullable<Quaternion>;
  23561. /**
  23562. * The scale of the physics-enabled object
  23563. */
  23564. scaling: Vector3;
  23565. /**
  23566. * The rotation of the physics-enabled object
  23567. */
  23568. rotation?: Vector3;
  23569. /**
  23570. * The parent of the physics-enabled object
  23571. */
  23572. parent?: any;
  23573. /**
  23574. * The bounding info of the physics-enabled object
  23575. * @returns The bounding info of the physics-enabled object
  23576. */
  23577. getBoundingInfo(): BoundingInfo;
  23578. /**
  23579. * Computes the world matrix
  23580. * @param force Specifies if the world matrix should be computed by force
  23581. * @returns A world matrix
  23582. */
  23583. computeWorldMatrix(force: boolean): Matrix;
  23584. /**
  23585. * Gets the world matrix
  23586. * @returns A world matrix
  23587. */
  23588. getWorldMatrix?(): Matrix;
  23589. /**
  23590. * Gets the child meshes
  23591. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23592. * @returns An array of abstract meshes
  23593. */
  23594. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23595. /**
  23596. * Gets the vertex data
  23597. * @param kind The type of vertex data
  23598. * @returns A nullable array of numbers, or a float32 array
  23599. */
  23600. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23601. /**
  23602. * Gets the indices from the mesh
  23603. * @returns A nullable array of index arrays
  23604. */
  23605. getIndices?(): Nullable<IndicesArray>;
  23606. /**
  23607. * Gets the scene from the mesh
  23608. * @returns the indices array or null
  23609. */
  23610. getScene?(): Scene;
  23611. /**
  23612. * Gets the absolute position from the mesh
  23613. * @returns the absolute position
  23614. */
  23615. getAbsolutePosition(): Vector3;
  23616. /**
  23617. * Gets the absolute pivot point from the mesh
  23618. * @returns the absolute pivot point
  23619. */
  23620. getAbsolutePivotPoint(): Vector3;
  23621. /**
  23622. * Rotates the mesh
  23623. * @param axis The axis of rotation
  23624. * @param amount The amount of rotation
  23625. * @param space The space of the rotation
  23626. * @returns The rotation transform node
  23627. */
  23628. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23629. /**
  23630. * Translates the mesh
  23631. * @param axis The axis of translation
  23632. * @param distance The distance of translation
  23633. * @param space The space of the translation
  23634. * @returns The transform node
  23635. */
  23636. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23637. /**
  23638. * Sets the absolute position of the mesh
  23639. * @param absolutePosition The absolute position of the mesh
  23640. * @returns The transform node
  23641. */
  23642. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23643. /**
  23644. * Gets the class name of the mesh
  23645. * @returns The class name
  23646. */
  23647. getClassName(): string;
  23648. }
  23649. /**
  23650. * Represents a physics imposter
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export class PhysicsImpostor {
  23654. /**
  23655. * The physics-enabled object used as the physics imposter
  23656. */
  23657. object: IPhysicsEnabledObject;
  23658. /**
  23659. * The type of the physics imposter
  23660. */
  23661. type: number;
  23662. private _options;
  23663. private _scene?;
  23664. /**
  23665. * The default object size of the imposter
  23666. */
  23667. static DEFAULT_OBJECT_SIZE: Vector3;
  23668. /**
  23669. * The identity quaternion of the imposter
  23670. */
  23671. static IDENTITY_QUATERNION: Quaternion;
  23672. /** @hidden */
  23673. _pluginData: any;
  23674. private _physicsEngine;
  23675. private _physicsBody;
  23676. private _bodyUpdateRequired;
  23677. private _onBeforePhysicsStepCallbacks;
  23678. private _onAfterPhysicsStepCallbacks;
  23679. /** @hidden */
  23680. _onPhysicsCollideCallbacks: Array<{
  23681. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23682. otherImpostors: Array<PhysicsImpostor>;
  23683. }>;
  23684. private _deltaPosition;
  23685. private _deltaRotation;
  23686. private _deltaRotationConjugated;
  23687. /** @hidden */
  23688. _isFromLine: boolean;
  23689. private _parent;
  23690. private _isDisposed;
  23691. private static _tmpVecs;
  23692. private static _tmpQuat;
  23693. /**
  23694. * Specifies if the physics imposter is disposed
  23695. */
  23696. readonly isDisposed: boolean;
  23697. /**
  23698. * Gets the mass of the physics imposter
  23699. */
  23700. mass: number;
  23701. /**
  23702. * Gets the coefficient of friction
  23703. */
  23704. /**
  23705. * Sets the coefficient of friction
  23706. */
  23707. friction: number;
  23708. /**
  23709. * Gets the coefficient of restitution
  23710. */
  23711. /**
  23712. * Sets the coefficient of restitution
  23713. */
  23714. restitution: number;
  23715. /**
  23716. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23717. */
  23718. /**
  23719. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23720. */
  23721. pressure: number;
  23722. /**
  23723. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. /**
  23726. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23727. */
  23728. stiffness: number;
  23729. /**
  23730. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. /**
  23733. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23734. */
  23735. velocityIterations: number;
  23736. /**
  23737. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. /**
  23740. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23741. */
  23742. positionIterations: number;
  23743. /**
  23744. * The unique id of the physics imposter
  23745. * set by the physics engine when adding this impostor to the array
  23746. */
  23747. uniqueId: number;
  23748. /**
  23749. * @hidden
  23750. */
  23751. soft: boolean;
  23752. /**
  23753. * @hidden
  23754. */
  23755. segments: number;
  23756. private _joints;
  23757. /**
  23758. * Initializes the physics imposter
  23759. * @param object The physics-enabled object used as the physics imposter
  23760. * @param type The type of the physics imposter
  23761. * @param _options The options for the physics imposter
  23762. * @param _scene The Babylon scene
  23763. */
  23764. constructor(
  23765. /**
  23766. * The physics-enabled object used as the physics imposter
  23767. */
  23768. object: IPhysicsEnabledObject,
  23769. /**
  23770. * The type of the physics imposter
  23771. */
  23772. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23773. /**
  23774. * This function will completly initialize this impostor.
  23775. * It will create a new body - but only if this mesh has no parent.
  23776. * If it has, this impostor will not be used other than to define the impostor
  23777. * of the child mesh.
  23778. * @hidden
  23779. */
  23780. _init(): void;
  23781. private _getPhysicsParent;
  23782. /**
  23783. * Should a new body be generated.
  23784. * @returns boolean specifying if body initialization is required
  23785. */
  23786. isBodyInitRequired(): boolean;
  23787. /**
  23788. * Sets the updated scaling
  23789. * @param updated Specifies if the scaling is updated
  23790. */
  23791. setScalingUpdated(): void;
  23792. /**
  23793. * Force a regeneration of this or the parent's impostor's body.
  23794. * Use under cautious - This will remove all joints already implemented.
  23795. */
  23796. forceUpdate(): void;
  23797. /**
  23798. * Gets the body that holds this impostor. Either its own, or its parent.
  23799. */
  23800. /**
  23801. * Set the physics body. Used mainly by the physics engine/plugin
  23802. */
  23803. physicsBody: any;
  23804. /**
  23805. * Get the parent of the physics imposter
  23806. * @returns Physics imposter or null
  23807. */
  23808. /**
  23809. * Sets the parent of the physics imposter
  23810. */
  23811. parent: Nullable<PhysicsImpostor>;
  23812. /**
  23813. * Resets the update flags
  23814. */
  23815. resetUpdateFlags(): void;
  23816. /**
  23817. * Gets the object extend size
  23818. * @returns the object extend size
  23819. */
  23820. getObjectExtendSize(): Vector3;
  23821. /**
  23822. * Gets the object center
  23823. * @returns The object center
  23824. */
  23825. getObjectCenter(): Vector3;
  23826. /**
  23827. * Get a specific parametes from the options parameter
  23828. * @param paramName The object parameter name
  23829. * @returns The object parameter
  23830. */
  23831. getParam(paramName: string): any;
  23832. /**
  23833. * Sets a specific parameter in the options given to the physics plugin
  23834. * @param paramName The parameter name
  23835. * @param value The value of the parameter
  23836. */
  23837. setParam(paramName: string, value: number): void;
  23838. /**
  23839. * Specifically change the body's mass option. Won't recreate the physics body object
  23840. * @param mass The mass of the physics imposter
  23841. */
  23842. setMass(mass: number): void;
  23843. /**
  23844. * Gets the linear velocity
  23845. * @returns linear velocity or null
  23846. */
  23847. getLinearVelocity(): Nullable<Vector3>;
  23848. /**
  23849. * Sets the linear velocity
  23850. * @param velocity linear velocity or null
  23851. */
  23852. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23853. /**
  23854. * Gets the angular velocity
  23855. * @returns angular velocity or null
  23856. */
  23857. getAngularVelocity(): Nullable<Vector3>;
  23858. /**
  23859. * Sets the angular velocity
  23860. * @param velocity The velocity or null
  23861. */
  23862. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23863. /**
  23864. * Execute a function with the physics plugin native code
  23865. * Provide a function the will have two variables - the world object and the physics body object
  23866. * @param func The function to execute with the physics plugin native code
  23867. */
  23868. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23869. /**
  23870. * Register a function that will be executed before the physics world is stepping forward
  23871. * @param func The function to execute before the physics world is stepped forward
  23872. */
  23873. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23874. /**
  23875. * Unregister a function that will be executed before the physics world is stepping forward
  23876. * @param func The function to execute before the physics world is stepped forward
  23877. */
  23878. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23879. /**
  23880. * Register a function that will be executed after the physics step
  23881. * @param func The function to execute after physics step
  23882. */
  23883. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23884. /**
  23885. * Unregisters a function that will be executed after the physics step
  23886. * @param func The function to execute after physics step
  23887. */
  23888. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23889. /**
  23890. * register a function that will be executed when this impostor collides against a different body
  23891. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23892. * @param func Callback that is executed on collision
  23893. */
  23894. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23895. /**
  23896. * Unregisters the physics imposter on contact
  23897. * @param collideAgainst The physics object to collide against
  23898. * @param func Callback to execute on collision
  23899. */
  23900. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23901. private _tmpQuat;
  23902. private _tmpQuat2;
  23903. /**
  23904. * Get the parent rotation
  23905. * @returns The parent rotation
  23906. */
  23907. getParentsRotation(): Quaternion;
  23908. /**
  23909. * this function is executed by the physics engine.
  23910. */
  23911. beforeStep: () => void;
  23912. /**
  23913. * this function is executed by the physics engine
  23914. */
  23915. afterStep: () => void;
  23916. /**
  23917. * Legacy collision detection event support
  23918. */
  23919. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23920. /**
  23921. * event and body object due to cannon's event-based architecture.
  23922. */
  23923. onCollide: (e: {
  23924. body: any;
  23925. }) => void;
  23926. /**
  23927. * Apply a force
  23928. * @param force The force to apply
  23929. * @param contactPoint The contact point for the force
  23930. * @returns The physics imposter
  23931. */
  23932. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23933. /**
  23934. * Apply an impulse
  23935. * @param force The impulse force
  23936. * @param contactPoint The contact point for the impulse force
  23937. * @returns The physics imposter
  23938. */
  23939. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23940. /**
  23941. * A help function to create a joint
  23942. * @param otherImpostor A physics imposter used to create a joint
  23943. * @param jointType The type of joint
  23944. * @param jointData The data for the joint
  23945. * @returns The physics imposter
  23946. */
  23947. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23948. /**
  23949. * Add a joint to this impostor with a different impostor
  23950. * @param otherImpostor A physics imposter used to add a joint
  23951. * @param joint The joint to add
  23952. * @returns The physics imposter
  23953. */
  23954. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23955. /**
  23956. * Add an anchor to a cloth impostor
  23957. * @param otherImpostor rigid impostor to anchor to
  23958. * @param width ratio across width from 0 to 1
  23959. * @param height ratio up height from 0 to 1
  23960. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23961. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23962. * @returns impostor the soft imposter
  23963. */
  23964. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23965. /**
  23966. * Add a hook to a rope impostor
  23967. * @param otherImpostor rigid impostor to anchor to
  23968. * @param length ratio across rope from 0 to 1
  23969. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23971. * @returns impostor the rope imposter
  23972. */
  23973. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23974. /**
  23975. * Will keep this body still, in a sleep mode.
  23976. * @returns the physics imposter
  23977. */
  23978. sleep(): PhysicsImpostor;
  23979. /**
  23980. * Wake the body up.
  23981. * @returns The physics imposter
  23982. */
  23983. wakeUp(): PhysicsImpostor;
  23984. /**
  23985. * Clones the physics imposter
  23986. * @param newObject The physics imposter clones to this physics-enabled object
  23987. * @returns A nullable physics imposter
  23988. */
  23989. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23990. /**
  23991. * Disposes the physics imposter
  23992. */
  23993. dispose(): void;
  23994. /**
  23995. * Sets the delta position
  23996. * @param position The delta position amount
  23997. */
  23998. setDeltaPosition(position: Vector3): void;
  23999. /**
  24000. * Sets the delta rotation
  24001. * @param rotation The delta rotation amount
  24002. */
  24003. setDeltaRotation(rotation: Quaternion): void;
  24004. /**
  24005. * Gets the box size of the physics imposter and stores the result in the input parameter
  24006. * @param result Stores the box size
  24007. * @returns The physics imposter
  24008. */
  24009. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24010. /**
  24011. * Gets the radius of the physics imposter
  24012. * @returns Radius of the physics imposter
  24013. */
  24014. getRadius(): number;
  24015. /**
  24016. * Sync a bone with this impostor
  24017. * @param bone The bone to sync to the impostor.
  24018. * @param boneMesh The mesh that the bone is influencing.
  24019. * @param jointPivot The pivot of the joint / bone in local space.
  24020. * @param distToJoint Optional distance from the impostor to the joint.
  24021. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24022. */
  24023. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24024. /**
  24025. * Sync impostor to a bone
  24026. * @param bone The bone that the impostor will be synced to.
  24027. * @param boneMesh The mesh that the bone is influencing.
  24028. * @param jointPivot The pivot of the joint / bone in local space.
  24029. * @param distToJoint Optional distance from the impostor to the joint.
  24030. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24031. * @param boneAxis Optional vector3 axis the bone is aligned with
  24032. */
  24033. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24034. /**
  24035. * No-Imposter type
  24036. */
  24037. static NoImpostor: number;
  24038. /**
  24039. * Sphere-Imposter type
  24040. */
  24041. static SphereImpostor: number;
  24042. /**
  24043. * Box-Imposter type
  24044. */
  24045. static BoxImpostor: number;
  24046. /**
  24047. * Plane-Imposter type
  24048. */
  24049. static PlaneImpostor: number;
  24050. /**
  24051. * Mesh-imposter type
  24052. */
  24053. static MeshImpostor: number;
  24054. /**
  24055. * Capsule-Impostor type (Ammo.js plugin only)
  24056. */
  24057. static CapsuleImpostor: number;
  24058. /**
  24059. * Cylinder-Imposter type
  24060. */
  24061. static CylinderImpostor: number;
  24062. /**
  24063. * Particle-Imposter type
  24064. */
  24065. static ParticleImpostor: number;
  24066. /**
  24067. * Heightmap-Imposter type
  24068. */
  24069. static HeightmapImpostor: number;
  24070. /**
  24071. * ConvexHull-Impostor type (Ammo.js plugin only)
  24072. */
  24073. static ConvexHullImpostor: number;
  24074. /**
  24075. * Rope-Imposter type
  24076. */
  24077. static RopeImpostor: number;
  24078. /**
  24079. * Cloth-Imposter type
  24080. */
  24081. static ClothImpostor: number;
  24082. /**
  24083. * Softbody-Imposter type
  24084. */
  24085. static SoftbodyImpostor: number;
  24086. }
  24087. }
  24088. declare module "babylonjs/Meshes/mesh" {
  24089. import { Observable } from "babylonjs/Misc/observable";
  24090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24091. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24092. import { Camera } from "babylonjs/Cameras/camera";
  24093. import { Scene } from "babylonjs/scene";
  24094. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24095. import { Color4 } from "babylonjs/Maths/math.color";
  24096. import { Engine } from "babylonjs/Engines/engine";
  24097. import { Node } from "babylonjs/node";
  24098. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24099. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24100. import { Buffer } from "babylonjs/Meshes/buffer";
  24101. import { Geometry } from "babylonjs/Meshes/geometry";
  24102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24104. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24105. import { Effect } from "babylonjs/Materials/effect";
  24106. import { Material } from "babylonjs/Materials/material";
  24107. import { Skeleton } from "babylonjs/Bones/skeleton";
  24108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24109. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24110. import { Path3D } from "babylonjs/Maths/math.path";
  24111. import { Plane } from "babylonjs/Maths/math.plane";
  24112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24113. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24114. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24115. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24116. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24117. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24118. /**
  24119. * @hidden
  24120. **/
  24121. export class _CreationDataStorage {
  24122. closePath?: boolean;
  24123. closeArray?: boolean;
  24124. idx: number[];
  24125. dashSize: number;
  24126. gapSize: number;
  24127. path3D: Path3D;
  24128. pathArray: Vector3[][];
  24129. arc: number;
  24130. radius: number;
  24131. cap: number;
  24132. tessellation: number;
  24133. }
  24134. /**
  24135. * @hidden
  24136. **/
  24137. class _InstanceDataStorage {
  24138. visibleInstances: any;
  24139. batchCache: _InstancesBatch;
  24140. instancesBufferSize: number;
  24141. instancesBuffer: Nullable<Buffer>;
  24142. instancesData: Float32Array;
  24143. overridenInstanceCount: number;
  24144. isFrozen: boolean;
  24145. previousBatch: Nullable<_InstancesBatch>;
  24146. hardwareInstancedRendering: boolean;
  24147. sideOrientation: number;
  24148. }
  24149. /**
  24150. * @hidden
  24151. **/
  24152. export class _InstancesBatch {
  24153. mustReturn: boolean;
  24154. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24155. renderSelf: boolean[];
  24156. hardwareInstancedRendering: boolean[];
  24157. }
  24158. /**
  24159. * Class used to represent renderable models
  24160. */
  24161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24162. /**
  24163. * Mesh side orientation : usually the external or front surface
  24164. */
  24165. static readonly FRONTSIDE: number;
  24166. /**
  24167. * Mesh side orientation : usually the internal or back surface
  24168. */
  24169. static readonly BACKSIDE: number;
  24170. /**
  24171. * Mesh side orientation : both internal and external or front and back surfaces
  24172. */
  24173. static readonly DOUBLESIDE: number;
  24174. /**
  24175. * Mesh side orientation : by default, `FRONTSIDE`
  24176. */
  24177. static readonly DEFAULTSIDE: number;
  24178. /**
  24179. * Mesh cap setting : no cap
  24180. */
  24181. static readonly NO_CAP: number;
  24182. /**
  24183. * Mesh cap setting : one cap at the beginning of the mesh
  24184. */
  24185. static readonly CAP_START: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the end of the mesh
  24188. */
  24189. static readonly CAP_END: number;
  24190. /**
  24191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24192. */
  24193. static readonly CAP_ALL: number;
  24194. /**
  24195. * Mesh pattern setting : no flip or rotate
  24196. */
  24197. static readonly NO_FLIP: number;
  24198. /**
  24199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24200. */
  24201. static readonly FLIP_TILE: number;
  24202. /**
  24203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24204. */
  24205. static readonly ROTATE_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24208. */
  24209. static readonly FLIP_ROW: number;
  24210. /**
  24211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24212. */
  24213. static readonly ROTATE_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24216. */
  24217. static readonly FLIP_N_ROTATE_TILE: number;
  24218. /**
  24219. * Mesh pattern setting : rotate pattern and rotate
  24220. */
  24221. static readonly FLIP_N_ROTATE_ROW: number;
  24222. /**
  24223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24224. */
  24225. static readonly CENTER: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles on left
  24228. */
  24229. static readonly LEFT: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on right
  24232. */
  24233. static readonly RIGHT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on top
  24236. */
  24237. static readonly TOP: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on bottom
  24240. */
  24241. static readonly BOTTOM: number;
  24242. /**
  24243. * Gets the default side orientation.
  24244. * @param orientation the orientation to value to attempt to get
  24245. * @returns the default orientation
  24246. * @hidden
  24247. */
  24248. static _GetDefaultSideOrientation(orientation?: number): number;
  24249. private _internalMeshDataInfo;
  24250. /**
  24251. * An event triggered before rendering the mesh
  24252. */
  24253. readonly onBeforeRenderObservable: Observable<Mesh>;
  24254. /**
  24255. * An event triggered before binding the mesh
  24256. */
  24257. readonly onBeforeBindObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered after rendering the mesh
  24260. */
  24261. readonly onAfterRenderObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered before drawing the mesh
  24264. */
  24265. readonly onBeforeDrawObservable: Observable<Mesh>;
  24266. private _onBeforeDrawObserver;
  24267. /**
  24268. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24269. */
  24270. onBeforeDraw: () => void;
  24271. readonly hasInstances: boolean;
  24272. /**
  24273. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24274. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24275. */
  24276. delayLoadState: number;
  24277. /**
  24278. * Gets the list of instances created from this mesh
  24279. * it is not supposed to be modified manually.
  24280. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24282. */
  24283. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24284. /**
  24285. * Gets the file containing delay loading data for this mesh
  24286. */
  24287. delayLoadingFile: string;
  24288. /** @hidden */
  24289. _binaryInfo: any;
  24290. /**
  24291. * User defined function used to change how LOD level selection is done
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24293. */
  24294. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24295. /**
  24296. * Gets or sets the morph target manager
  24297. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24298. */
  24299. morphTargetManager: Nullable<MorphTargetManager>;
  24300. /** @hidden */
  24301. _creationDataStorage: Nullable<_CreationDataStorage>;
  24302. /** @hidden */
  24303. _geometry: Nullable<Geometry>;
  24304. /** @hidden */
  24305. _delayInfo: Array<string>;
  24306. /** @hidden */
  24307. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24308. /** @hidden */
  24309. _instanceDataStorage: _InstanceDataStorage;
  24310. private _effectiveMaterial;
  24311. /** @hidden */
  24312. _shouldGenerateFlatShading: boolean;
  24313. /** @hidden */
  24314. _originalBuilderSideOrientation: number;
  24315. /**
  24316. * Use this property to change the original side orientation defined at construction time
  24317. */
  24318. overrideMaterialSideOrientation: Nullable<number>;
  24319. /**
  24320. * Gets the source mesh (the one used to clone this one from)
  24321. */
  24322. readonly source: Nullable<Mesh>;
  24323. /**
  24324. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24325. */
  24326. isUnIndexed: boolean;
  24327. /**
  24328. * @constructor
  24329. * @param name The value used by scene.getMeshByName() to do a lookup.
  24330. * @param scene The scene to add this mesh to.
  24331. * @param parent The parent of this mesh, if it has one
  24332. * @param source An optional Mesh from which geometry is shared, cloned.
  24333. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24334. * When false, achieved by calling a clone(), also passing False.
  24335. * This will make creation of children, recursive.
  24336. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24337. */
  24338. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24339. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24340. /**
  24341. * Gets the class name
  24342. * @returns the string "Mesh".
  24343. */
  24344. getClassName(): string;
  24345. /** @hidden */
  24346. readonly _isMesh: boolean;
  24347. /**
  24348. * Returns a description of this mesh
  24349. * @param fullDetails define if full details about this mesh must be used
  24350. * @returns a descriptive string representing this mesh
  24351. */
  24352. toString(fullDetails?: boolean): string;
  24353. /** @hidden */
  24354. _unBindEffect(): void;
  24355. /**
  24356. * Gets a boolean indicating if this mesh has LOD
  24357. */
  24358. readonly hasLODLevels: boolean;
  24359. /**
  24360. * Gets the list of MeshLODLevel associated with the current mesh
  24361. * @returns an array of MeshLODLevel
  24362. */
  24363. getLODLevels(): MeshLODLevel[];
  24364. private _sortLODLevels;
  24365. /**
  24366. * Add a mesh as LOD level triggered at the given distance.
  24367. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24368. * @param distance The distance from the center of the object to show this level
  24369. * @param mesh The mesh to be added as LOD level (can be null)
  24370. * @return This mesh (for chaining)
  24371. */
  24372. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24373. /**
  24374. * Returns the LOD level mesh at the passed distance or null if not found.
  24375. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24376. * @param distance The distance from the center of the object to show this level
  24377. * @returns a Mesh or `null`
  24378. */
  24379. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24380. /**
  24381. * Remove a mesh from the LOD array
  24382. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24383. * @param mesh defines the mesh to be removed
  24384. * @return This mesh (for chaining)
  24385. */
  24386. removeLODLevel(mesh: Mesh): Mesh;
  24387. /**
  24388. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24390. * @param camera defines the camera to use to compute distance
  24391. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24392. * @return This mesh (for chaining)
  24393. */
  24394. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24395. /**
  24396. * Gets the mesh internal Geometry object
  24397. */
  24398. readonly geometry: Nullable<Geometry>;
  24399. /**
  24400. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24401. * @returns the total number of vertices
  24402. */
  24403. getTotalVertices(): number;
  24404. /**
  24405. * Returns the content of an associated vertex buffer
  24406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24407. * - VertexBuffer.PositionKind
  24408. * - VertexBuffer.UVKind
  24409. * - VertexBuffer.UV2Kind
  24410. * - VertexBuffer.UV3Kind
  24411. * - VertexBuffer.UV4Kind
  24412. * - VertexBuffer.UV5Kind
  24413. * - VertexBuffer.UV6Kind
  24414. * - VertexBuffer.ColorKind
  24415. * - VertexBuffer.MatricesIndicesKind
  24416. * - VertexBuffer.MatricesIndicesExtraKind
  24417. * - VertexBuffer.MatricesWeightsKind
  24418. * - VertexBuffer.MatricesWeightsExtraKind
  24419. * @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
  24420. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24421. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24422. */
  24423. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24424. /**
  24425. * Returns the mesh VertexBuffer object from the requested `kind`
  24426. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24427. * - VertexBuffer.PositionKind
  24428. * - VertexBuffer.NormalKind
  24429. * - VertexBuffer.UVKind
  24430. * - VertexBuffer.UV2Kind
  24431. * - VertexBuffer.UV3Kind
  24432. * - VertexBuffer.UV4Kind
  24433. * - VertexBuffer.UV5Kind
  24434. * - VertexBuffer.UV6Kind
  24435. * - VertexBuffer.ColorKind
  24436. * - VertexBuffer.MatricesIndicesKind
  24437. * - VertexBuffer.MatricesIndicesExtraKind
  24438. * - VertexBuffer.MatricesWeightsKind
  24439. * - VertexBuffer.MatricesWeightsExtraKind
  24440. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24441. */
  24442. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24443. /**
  24444. * Tests if a specific vertex buffer is associated with this mesh
  24445. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24446. * - VertexBuffer.PositionKind
  24447. * - VertexBuffer.NormalKind
  24448. * - VertexBuffer.UVKind
  24449. * - VertexBuffer.UV2Kind
  24450. * - VertexBuffer.UV3Kind
  24451. * - VertexBuffer.UV4Kind
  24452. * - VertexBuffer.UV5Kind
  24453. * - VertexBuffer.UV6Kind
  24454. * - VertexBuffer.ColorKind
  24455. * - VertexBuffer.MatricesIndicesKind
  24456. * - VertexBuffer.MatricesIndicesExtraKind
  24457. * - VertexBuffer.MatricesWeightsKind
  24458. * - VertexBuffer.MatricesWeightsExtraKind
  24459. * @returns a boolean
  24460. */
  24461. isVerticesDataPresent(kind: string): boolean;
  24462. /**
  24463. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24464. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24465. * - VertexBuffer.PositionKind
  24466. * - VertexBuffer.UVKind
  24467. * - VertexBuffer.UV2Kind
  24468. * - VertexBuffer.UV3Kind
  24469. * - VertexBuffer.UV4Kind
  24470. * - VertexBuffer.UV5Kind
  24471. * - VertexBuffer.UV6Kind
  24472. * - VertexBuffer.ColorKind
  24473. * - VertexBuffer.MatricesIndicesKind
  24474. * - VertexBuffer.MatricesIndicesExtraKind
  24475. * - VertexBuffer.MatricesWeightsKind
  24476. * - VertexBuffer.MatricesWeightsExtraKind
  24477. * @returns a boolean
  24478. */
  24479. isVertexBufferUpdatable(kind: string): boolean;
  24480. /**
  24481. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24483. * - VertexBuffer.PositionKind
  24484. * - VertexBuffer.NormalKind
  24485. * - VertexBuffer.UVKind
  24486. * - VertexBuffer.UV2Kind
  24487. * - VertexBuffer.UV3Kind
  24488. * - VertexBuffer.UV4Kind
  24489. * - VertexBuffer.UV5Kind
  24490. * - VertexBuffer.UV6Kind
  24491. * - VertexBuffer.ColorKind
  24492. * - VertexBuffer.MatricesIndicesKind
  24493. * - VertexBuffer.MatricesIndicesExtraKind
  24494. * - VertexBuffer.MatricesWeightsKind
  24495. * - VertexBuffer.MatricesWeightsExtraKind
  24496. * @returns an array of strings
  24497. */
  24498. getVerticesDataKinds(): string[];
  24499. /**
  24500. * Returns a positive integer : the total number of indices in this mesh geometry.
  24501. * @returns the numner of indices or zero if the mesh has no geometry.
  24502. */
  24503. getTotalIndices(): number;
  24504. /**
  24505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24506. * @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.
  24507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24508. * @returns the indices array or an empty array if the mesh has no geometry
  24509. */
  24510. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24511. readonly isBlocked: boolean;
  24512. /**
  24513. * Determine if the current mesh is ready to be rendered
  24514. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24515. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24516. * @returns true if all associated assets are ready (material, textures, shaders)
  24517. */
  24518. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24519. /**
  24520. * 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.
  24521. */
  24522. readonly areNormalsFrozen: boolean;
  24523. /**
  24524. * 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.
  24525. * @returns the current mesh
  24526. */
  24527. freezeNormals(): Mesh;
  24528. /**
  24529. * 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
  24530. * @returns the current mesh
  24531. */
  24532. unfreezeNormals(): Mesh;
  24533. /**
  24534. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24535. */
  24536. overridenInstanceCount: number;
  24537. /** @hidden */
  24538. _preActivate(): Mesh;
  24539. /** @hidden */
  24540. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24541. /** @hidden */
  24542. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24543. /**
  24544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24545. * This means the mesh underlying bounding box and sphere are recomputed.
  24546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24547. * @returns the current mesh
  24548. */
  24549. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24550. /** @hidden */
  24551. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24552. /**
  24553. * This function will subdivide the mesh into multiple submeshes
  24554. * @param count defines the expected number of submeshes
  24555. */
  24556. subdivide(count: number): void;
  24557. /**
  24558. * Copy a FloatArray into a specific associated vertex buffer
  24559. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24560. * - VertexBuffer.PositionKind
  24561. * - VertexBuffer.UVKind
  24562. * - VertexBuffer.UV2Kind
  24563. * - VertexBuffer.UV3Kind
  24564. * - VertexBuffer.UV4Kind
  24565. * - VertexBuffer.UV5Kind
  24566. * - VertexBuffer.UV6Kind
  24567. * - VertexBuffer.ColorKind
  24568. * - VertexBuffer.MatricesIndicesKind
  24569. * - VertexBuffer.MatricesIndicesExtraKind
  24570. * - VertexBuffer.MatricesWeightsKind
  24571. * - VertexBuffer.MatricesWeightsExtraKind
  24572. * @param data defines the data source
  24573. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24574. * @param stride defines the data stride size (can be null)
  24575. * @returns the current mesh
  24576. */
  24577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24578. /**
  24579. * Flags an associated vertex buffer as updatable
  24580. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24581. * - VertexBuffer.PositionKind
  24582. * - VertexBuffer.UVKind
  24583. * - VertexBuffer.UV2Kind
  24584. * - VertexBuffer.UV3Kind
  24585. * - VertexBuffer.UV4Kind
  24586. * - VertexBuffer.UV5Kind
  24587. * - VertexBuffer.UV6Kind
  24588. * - VertexBuffer.ColorKind
  24589. * - VertexBuffer.MatricesIndicesKind
  24590. * - VertexBuffer.MatricesIndicesExtraKind
  24591. * - VertexBuffer.MatricesWeightsKind
  24592. * - VertexBuffer.MatricesWeightsExtraKind
  24593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24594. */
  24595. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24596. /**
  24597. * Sets the mesh global Vertex Buffer
  24598. * @param buffer defines the buffer to use
  24599. * @returns the current mesh
  24600. */
  24601. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24602. /**
  24603. * Update a specific associated vertex buffer
  24604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24605. * - VertexBuffer.PositionKind
  24606. * - VertexBuffer.UVKind
  24607. * - VertexBuffer.UV2Kind
  24608. * - VertexBuffer.UV3Kind
  24609. * - VertexBuffer.UV4Kind
  24610. * - VertexBuffer.UV5Kind
  24611. * - VertexBuffer.UV6Kind
  24612. * - VertexBuffer.ColorKind
  24613. * - VertexBuffer.MatricesIndicesKind
  24614. * - VertexBuffer.MatricesIndicesExtraKind
  24615. * - VertexBuffer.MatricesWeightsKind
  24616. * - VertexBuffer.MatricesWeightsExtraKind
  24617. * @param data defines the data source
  24618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24619. * @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)
  24620. * @returns the current mesh
  24621. */
  24622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24623. /**
  24624. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24625. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24626. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24627. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24628. * @returns the current mesh
  24629. */
  24630. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24631. /**
  24632. * Creates a un-shared specific occurence of the geometry for the mesh.
  24633. * @returns the current mesh
  24634. */
  24635. makeGeometryUnique(): Mesh;
  24636. /**
  24637. * Set the index buffer of this mesh
  24638. * @param indices defines the source data
  24639. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24640. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24641. * @returns the current mesh
  24642. */
  24643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24644. /**
  24645. * Update the current index buffer
  24646. * @param indices defines the source data
  24647. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24648. * @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)
  24649. * @returns the current mesh
  24650. */
  24651. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24652. /**
  24653. * Invert the geometry to move from a right handed system to a left handed one.
  24654. * @returns the current mesh
  24655. */
  24656. toLeftHanded(): Mesh;
  24657. /** @hidden */
  24658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24659. /** @hidden */
  24660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24661. /**
  24662. * Registers for this mesh a javascript function called just before the rendering process
  24663. * @param func defines the function to call before rendering this mesh
  24664. * @returns the current mesh
  24665. */
  24666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24667. /**
  24668. * Disposes a previously registered javascript function called before the rendering
  24669. * @param func defines the function to remove
  24670. * @returns the current mesh
  24671. */
  24672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24673. /**
  24674. * Registers for this mesh a javascript function called just after the rendering is complete
  24675. * @param func defines the function to call after rendering this mesh
  24676. * @returns the current mesh
  24677. */
  24678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24679. /**
  24680. * Disposes a previously registered javascript function called after the rendering.
  24681. * @param func defines the function to remove
  24682. * @returns the current mesh
  24683. */
  24684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24685. /** @hidden */
  24686. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24687. /** @hidden */
  24688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24689. /** @hidden */
  24690. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24691. /** @hidden */
  24692. _rebuild(): void;
  24693. /** @hidden */
  24694. _freeze(): void;
  24695. /** @hidden */
  24696. _unFreeze(): void;
  24697. /**
  24698. * 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
  24699. * @param subMesh defines the subMesh to render
  24700. * @param enableAlphaMode defines if alpha mode can be changed
  24701. * @returns the current mesh
  24702. */
  24703. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24704. private _onBeforeDraw;
  24705. /**
  24706. * Renormalize the mesh and patch it up if there are no weights
  24707. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24708. * However in the case of zero weights then we set just a single influence to 1.
  24709. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24710. */
  24711. cleanMatrixWeights(): void;
  24712. private normalizeSkinFourWeights;
  24713. private normalizeSkinWeightsAndExtra;
  24714. /**
  24715. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24716. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24717. * the user know there was an issue with importing the mesh
  24718. * @returns a validation object with skinned, valid and report string
  24719. */
  24720. validateSkinning(): {
  24721. skinned: boolean;
  24722. valid: boolean;
  24723. report: string;
  24724. };
  24725. /** @hidden */
  24726. _checkDelayState(): Mesh;
  24727. private _queueLoad;
  24728. /**
  24729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24730. * A mesh is in the frustum if its bounding box intersects the frustum
  24731. * @param frustumPlanes defines the frustum to test
  24732. * @returns true if the mesh is in the frustum planes
  24733. */
  24734. isInFrustum(frustumPlanes: Plane[]): boolean;
  24735. /**
  24736. * Sets the mesh material by the material or multiMaterial `id` property
  24737. * @param id is a string identifying the material or the multiMaterial
  24738. * @returns the current mesh
  24739. */
  24740. setMaterialByID(id: string): Mesh;
  24741. /**
  24742. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24743. * @returns an array of IAnimatable
  24744. */
  24745. getAnimatables(): IAnimatable[];
  24746. /**
  24747. * Modifies the mesh geometry according to the passed transformation matrix.
  24748. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24749. * The mesh normals are modified using the same transformation.
  24750. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24751. * @param transform defines the transform matrix to use
  24752. * @see http://doc.babylonjs.com/resources/baking_transformations
  24753. * @returns the current mesh
  24754. */
  24755. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24756. /**
  24757. * Modifies the mesh geometry according to its own current World Matrix.
  24758. * The mesh World Matrix is then reset.
  24759. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24760. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24761. * @see http://doc.babylonjs.com/resources/baking_transformations
  24762. * @returns the current mesh
  24763. */
  24764. bakeCurrentTransformIntoVertices(): Mesh;
  24765. /** @hidden */
  24766. readonly _positions: Nullable<Vector3[]>;
  24767. /** @hidden */
  24768. _resetPointsArrayCache(): Mesh;
  24769. /** @hidden */
  24770. _generatePointsArray(): boolean;
  24771. /**
  24772. * Returns a new Mesh object generated from the current mesh properties.
  24773. * This method must not get confused with createInstance()
  24774. * @param name is a string, the name given to the new mesh
  24775. * @param newParent can be any Node object (default `null`)
  24776. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24777. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24778. * @returns a new mesh
  24779. */
  24780. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24781. /**
  24782. * Releases resources associated with this mesh.
  24783. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24784. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24785. */
  24786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24787. /**
  24788. * Modifies the mesh geometry according to a displacement map.
  24789. * 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.
  24790. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24791. * @param url is a string, the URL from the image file is to be downloaded.
  24792. * @param minHeight is the lower limit of the displacement.
  24793. * @param maxHeight is the upper limit of the displacement.
  24794. * @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.
  24795. * @param uvOffset is an optional vector2 used to offset UV.
  24796. * @param uvScale is an optional vector2 used to scale UV.
  24797. * @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.
  24798. * @returns the Mesh.
  24799. */
  24800. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24801. /**
  24802. * Modifies the mesh geometry according to a displacementMap buffer.
  24803. * 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.
  24804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24805. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24806. * @param heightMapWidth is the width of the buffer image.
  24807. * @param heightMapHeight is the height of the buffer image.
  24808. * @param minHeight is the lower limit of the displacement.
  24809. * @param maxHeight is the upper limit of the displacement.
  24810. * @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.
  24811. * @param uvOffset is an optional vector2 used to offset UV.
  24812. * @param uvScale is an optional vector2 used to scale UV.
  24813. * @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.
  24814. * @returns the Mesh.
  24815. */
  24816. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24817. /**
  24818. * Modify the mesh to get a flat shading rendering.
  24819. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24820. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24821. * @returns current mesh
  24822. */
  24823. convertToFlatShadedMesh(): Mesh;
  24824. /**
  24825. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24826. * In other words, more vertices, no more indices and a single bigger VBO.
  24827. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24828. * @returns current mesh
  24829. */
  24830. convertToUnIndexedMesh(): Mesh;
  24831. /**
  24832. * Inverses facet orientations.
  24833. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24834. * @param flipNormals will also inverts the normals
  24835. * @returns current mesh
  24836. */
  24837. flipFaces(flipNormals?: boolean): Mesh;
  24838. /**
  24839. * Increase the number of facets and hence vertices in a mesh
  24840. * Vertex normals are interpolated from existing vertex normals
  24841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24842. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24843. */
  24844. increaseVertices(numberPerEdge: number): void;
  24845. /**
  24846. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24847. * This will undo any application of covertToFlatShadedMesh
  24848. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24849. */
  24850. forceSharedVertices(): void;
  24851. /** @hidden */
  24852. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24853. /** @hidden */
  24854. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24855. /**
  24856. * Creates a new InstancedMesh object from the mesh model.
  24857. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24858. * @param name defines the name of the new instance
  24859. * @returns a new InstancedMesh
  24860. */
  24861. createInstance(name: string): InstancedMesh;
  24862. /**
  24863. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24864. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24865. * @returns the current mesh
  24866. */
  24867. synchronizeInstances(): Mesh;
  24868. /**
  24869. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24870. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24871. * This should be used together with the simplification to avoid disappearing triangles.
  24872. * @param successCallback an optional success callback to be called after the optimization finished.
  24873. * @returns the current mesh
  24874. */
  24875. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24876. /**
  24877. * Serialize current mesh
  24878. * @param serializationObject defines the object which will receive the serialization data
  24879. */
  24880. serialize(serializationObject: any): void;
  24881. /** @hidden */
  24882. _syncGeometryWithMorphTargetManager(): void;
  24883. /** @hidden */
  24884. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24885. /**
  24886. * Returns a new Mesh object parsed from the source provided.
  24887. * @param parsedMesh is the source
  24888. * @param scene defines the hosting scene
  24889. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24890. * @returns a new Mesh
  24891. */
  24892. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24893. /**
  24894. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24895. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24896. * @param name defines the name of the mesh to create
  24897. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24898. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24899. * @param closePath creates a seam between the first and the last points of each path of the path array
  24900. * @param offset is taken in account only if the `pathArray` is containing a single path
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @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)
  24905. * @returns a new Mesh
  24906. */
  24907. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24908. /**
  24909. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24910. * @param name defines the name of the mesh to create
  24911. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24912. * @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
  24913. * @param scene defines the hosting scene
  24914. * @param updatable defines if the mesh must be flagged as updatable
  24915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24916. * @returns a new Mesh
  24917. */
  24918. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24919. /**
  24920. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24921. * @param name defines the name of the mesh to create
  24922. * @param size sets the size (float) of each box side (default 1)
  24923. * @param scene defines the hosting scene
  24924. * @param updatable defines if the mesh must be flagged as updatable
  24925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24926. * @returns a new Mesh
  24927. */
  24928. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24929. /**
  24930. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24931. * @param name defines the name of the mesh to create
  24932. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24933. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24934. * @param scene defines the hosting scene
  24935. * @param updatable defines if the mesh must be flagged as updatable
  24936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24940. /**
  24941. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24942. * @param name defines the name of the mesh to create
  24943. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24944. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24945. * @param scene defines the hosting scene
  24946. * @returns a new Mesh
  24947. */
  24948. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24949. /**
  24950. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24951. * @param name defines the name of the mesh to create
  24952. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24953. * @param diameterTop set the top cap diameter (floats, default 1)
  24954. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24955. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24956. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24957. * @param scene defines the hosting scene
  24958. * @param updatable defines if the mesh must be flagged as updatable
  24959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24960. * @returns a new Mesh
  24961. */
  24962. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24963. /**
  24964. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24965. * @param name defines the name of the mesh to create
  24966. * @param diameter sets the diameter size (float) of the torus (default 1)
  24967. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24968. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24969. * @param scene defines the hosting scene
  24970. * @param updatable defines if the mesh must be flagged as updatable
  24971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24972. * @returns a new Mesh
  24973. */
  24974. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24975. /**
  24976. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24977. * @param name defines the name of the mesh to create
  24978. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24979. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24980. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24981. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24982. * @param p the number of windings on X axis (positive integers, default 2)
  24983. * @param q the number of windings on Y axis (positive integers, default 3)
  24984. * @param scene defines the hosting scene
  24985. * @param updatable defines if the mesh must be flagged as updatable
  24986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24987. * @returns a new Mesh
  24988. */
  24989. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24990. /**
  24991. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24992. * @param name defines the name of the mesh to create
  24993. * @param points is an array successive Vector3
  24994. * @param scene defines the hosting scene
  24995. * @param updatable defines if the mesh must be flagged as updatable
  24996. * @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).
  24997. * @returns a new Mesh
  24998. */
  24999. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25000. /**
  25001. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25002. * @param name defines the name of the mesh to create
  25003. * @param points is an array successive Vector3
  25004. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25005. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25006. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @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)
  25010. * @returns a new Mesh
  25011. */
  25012. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25013. /**
  25014. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25016. * 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.
  25017. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25018. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25019. * Remember you can only change the shape positions, not their number when updating a polygon.
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25021. * @param name defines the name of the mesh to create
  25022. * @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
  25023. * @param scene defines the hosting scene
  25024. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @param earcutInjection can be used to inject your own earcut reference
  25028. * @returns a new Mesh
  25029. */
  25030. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25031. /**
  25032. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25033. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25034. * @param name defines the name of the mesh to create
  25035. * @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
  25036. * @param depth defines the height of extrusion
  25037. * @param scene defines the hosting scene
  25038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @param earcutInjection can be used to inject your own earcut reference
  25042. * @returns a new Mesh
  25043. */
  25044. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25045. /**
  25046. * Creates an extruded shape mesh.
  25047. * 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
  25048. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25049. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25050. * @param name defines the name of the mesh to create
  25051. * @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
  25052. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25053. * @param scale is the value to scale the shape
  25054. * @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
  25055. * @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
  25056. * @param scene defines the hosting scene
  25057. * @param updatable defines if the mesh must be flagged as updatable
  25058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25059. * @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)
  25060. * @returns a new Mesh
  25061. */
  25062. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25063. /**
  25064. * Creates an custom extruded shape mesh.
  25065. * The custom extrusion is a parametric shape.
  25066. * It has no predefined shape. Its final shape will depend on the input parameters.
  25067. * Please consider using the same method from the MeshBuilder class instead
  25068. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25069. * @param name defines the name of the mesh to create
  25070. * @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
  25071. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25072. * @param scaleFunction is a custom Javascript function called on each path point
  25073. * @param rotationFunction is a custom Javascript function called on each path point
  25074. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25075. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25076. * @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
  25077. * @param scene defines the hosting scene
  25078. * @param updatable defines if the mesh must be flagged as updatable
  25079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25080. * @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)
  25081. * @returns a new Mesh
  25082. */
  25083. 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;
  25084. /**
  25085. * Creates lathe mesh.
  25086. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25087. * Please consider using the same method from the MeshBuilder class instead
  25088. * @param name defines the name of the mesh to create
  25089. * @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
  25090. * @param radius is the radius value of the lathe
  25091. * @param tessellation is the side number of the lathe.
  25092. * @param scene defines the hosting scene
  25093. * @param updatable defines if the mesh must be flagged as updatable
  25094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25095. * @returns a new Mesh
  25096. */
  25097. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25098. /**
  25099. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25100. * @param name defines the name of the mesh to create
  25101. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25105. * @returns a new Mesh
  25106. */
  25107. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25108. /**
  25109. * Creates a ground mesh.
  25110. * Please consider using the same method from the MeshBuilder class instead
  25111. * @param name defines the name of the mesh to create
  25112. * @param width set the width of the ground
  25113. * @param height set the height of the ground
  25114. * @param subdivisions sets the number of subdivisions per side
  25115. * @param scene defines the hosting scene
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @returns a new Mesh
  25118. */
  25119. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25120. /**
  25121. * Creates a tiled ground mesh.
  25122. * Please consider using the same method from the MeshBuilder class instead
  25123. * @param name defines the name of the mesh to create
  25124. * @param xmin set the ground minimum X coordinate
  25125. * @param zmin set the ground minimum Y coordinate
  25126. * @param xmax set the ground maximum X coordinate
  25127. * @param zmax set the ground maximum Z coordinate
  25128. * @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
  25129. * @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
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @returns a new Mesh
  25133. */
  25134. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25135. w: number;
  25136. h: number;
  25137. }, precision: {
  25138. w: number;
  25139. h: number;
  25140. }, scene: Scene, updatable?: boolean): Mesh;
  25141. /**
  25142. * Creates a ground mesh from a height map.
  25143. * Please consider using the same method from the MeshBuilder class instead
  25144. * @see http://doc.babylonjs.com/babylon101/height_map
  25145. * @param name defines the name of the mesh to create
  25146. * @param url sets the URL of the height map image resource
  25147. * @param width set the ground width size
  25148. * @param height set the ground height size
  25149. * @param subdivisions sets the number of subdivision per side
  25150. * @param minHeight is the minimum altitude on the ground
  25151. * @param maxHeight is the maximum altitude on the ground
  25152. * @param scene defines the hosting scene
  25153. * @param updatable defines if the mesh must be flagged as updatable
  25154. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25155. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25156. * @returns a new Mesh
  25157. */
  25158. 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;
  25159. /**
  25160. * Creates a tube mesh.
  25161. * The tube is a parametric shape.
  25162. * It has no predefined shape. Its final shape will depend on the input parameters.
  25163. * Please consider using the same method from the MeshBuilder class instead
  25164. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25165. * @param name defines the name of the mesh to create
  25166. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25167. * @param radius sets the tube radius size
  25168. * @param tessellation is the number of sides on the tubular surface
  25169. * @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
  25170. * @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
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @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)
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25178. (i: number, distance: number): number;
  25179. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25180. /**
  25181. * Creates a polyhedron mesh.
  25182. * Please consider using the same method from the MeshBuilder class instead.
  25183. * * 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
  25184. * * The parameter `size` (positive float, default 1) sets the polygon size
  25185. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25186. * * 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`
  25187. * * 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
  25188. * * 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)`)
  25189. * * 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
  25190. * * 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
  25191. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25192. * * If you create a double-sided mesh, you can choose what parts of 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
  25193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25194. * @param name defines the name of the mesh to create
  25195. * @param options defines the options used to create the mesh
  25196. * @param scene defines the hosting scene
  25197. * @returns a new Mesh
  25198. */
  25199. static CreatePolyhedron(name: string, options: {
  25200. type?: number;
  25201. size?: number;
  25202. sizeX?: number;
  25203. sizeY?: number;
  25204. sizeZ?: number;
  25205. custom?: any;
  25206. faceUV?: Vector4[];
  25207. faceColors?: Color4[];
  25208. updatable?: boolean;
  25209. sideOrientation?: number;
  25210. }, scene: Scene): Mesh;
  25211. /**
  25212. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25213. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25214. * * 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`)
  25215. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25216. * * 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
  25217. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25218. * * If you create a double-sided mesh, you can choose what parts of 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
  25219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25220. * @param name defines the name of the mesh
  25221. * @param options defines the options used to create the mesh
  25222. * @param scene defines the hosting scene
  25223. * @returns a new Mesh
  25224. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25225. */
  25226. static CreateIcoSphere(name: string, options: {
  25227. radius?: number;
  25228. flat?: boolean;
  25229. subdivisions?: number;
  25230. sideOrientation?: number;
  25231. updatable?: boolean;
  25232. }, scene: Scene): Mesh;
  25233. /**
  25234. * Creates a decal mesh.
  25235. * Please consider using the same method from the MeshBuilder class instead.
  25236. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25237. * @param name defines the name of the mesh
  25238. * @param sourceMesh defines the mesh receiving the decal
  25239. * @param position sets the position of the decal in world coordinates
  25240. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25241. * @param size sets the decal scaling
  25242. * @param angle sets the angle to rotate the decal
  25243. * @returns a new Mesh
  25244. */
  25245. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25246. /**
  25247. * Prepare internal position array for software CPU skinning
  25248. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25249. */
  25250. setPositionsForCPUSkinning(): Float32Array;
  25251. /**
  25252. * Prepare internal normal array for software CPU skinning
  25253. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25254. */
  25255. setNormalsForCPUSkinning(): Float32Array;
  25256. /**
  25257. * Updates the vertex buffer by applying transformation from the bones
  25258. * @param skeleton defines the skeleton to apply to current mesh
  25259. * @returns the current mesh
  25260. */
  25261. applySkeleton(skeleton: Skeleton): Mesh;
  25262. /**
  25263. * 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
  25264. * @param meshes defines the list of meshes to scan
  25265. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25266. */
  25267. static MinMax(meshes: AbstractMesh[]): {
  25268. min: Vector3;
  25269. max: Vector3;
  25270. };
  25271. /**
  25272. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25273. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25274. * @returns a vector3
  25275. */
  25276. static Center(meshesOrMinMaxVector: {
  25277. min: Vector3;
  25278. max: Vector3;
  25279. } | AbstractMesh[]): Vector3;
  25280. /**
  25281. * Merge the array of meshes into a single mesh for performance reasons.
  25282. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25283. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25284. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25285. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25286. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25287. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25288. * @returns a new mesh
  25289. */
  25290. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25291. /** @hidden */
  25292. addInstance(instance: InstancedMesh): void;
  25293. /** @hidden */
  25294. removeInstance(instance: InstancedMesh): void;
  25295. }
  25296. }
  25297. declare module "babylonjs/Cameras/camera" {
  25298. import { SmartArray } from "babylonjs/Misc/smartArray";
  25299. import { Observable } from "babylonjs/Misc/observable";
  25300. import { Nullable } from "babylonjs/types";
  25301. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25302. import { Scene } from "babylonjs/scene";
  25303. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25304. import { Node } from "babylonjs/node";
  25305. import { Mesh } from "babylonjs/Meshes/mesh";
  25306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25307. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25308. import { Viewport } from "babylonjs/Maths/math.viewport";
  25309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25311. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25312. import { Ray } from "babylonjs/Culling/ray";
  25313. /**
  25314. * This is the base class of all the camera used in the application.
  25315. * @see http://doc.babylonjs.com/features/cameras
  25316. */
  25317. export class Camera extends Node {
  25318. /** @hidden */
  25319. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25320. /**
  25321. * This is the default projection mode used by the cameras.
  25322. * It helps recreating a feeling of perspective and better appreciate depth.
  25323. * This is the best way to simulate real life cameras.
  25324. */
  25325. static readonly PERSPECTIVE_CAMERA: number;
  25326. /**
  25327. * This helps creating camera with an orthographic mode.
  25328. * 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.
  25329. */
  25330. static readonly ORTHOGRAPHIC_CAMERA: number;
  25331. /**
  25332. * This is the default FOV mode for perspective cameras.
  25333. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25334. */
  25335. static readonly FOVMODE_VERTICAL_FIXED: number;
  25336. /**
  25337. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25338. */
  25339. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25340. /**
  25341. * This specifies ther is no need for a camera rig.
  25342. * Basically only one eye is rendered corresponding to the camera.
  25343. */
  25344. static readonly RIG_MODE_NONE: number;
  25345. /**
  25346. * Simulates a camera Rig with one blue eye and one red eye.
  25347. * This can be use with 3d blue and red glasses.
  25348. */
  25349. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25350. /**
  25351. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25352. */
  25353. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25354. /**
  25355. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25356. */
  25357. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25358. /**
  25359. * Defines that both eyes of the camera will be rendered over under each other.
  25360. */
  25361. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25362. /**
  25363. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25364. */
  25365. static readonly RIG_MODE_VR: number;
  25366. /**
  25367. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25368. */
  25369. static readonly RIG_MODE_WEBVR: number;
  25370. /**
  25371. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25372. */
  25373. static readonly RIG_MODE_CUSTOM: number;
  25374. /**
  25375. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25376. */
  25377. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25378. /**
  25379. * Define the input manager associated with the camera.
  25380. */
  25381. inputs: CameraInputsManager<Camera>;
  25382. /** @hidden */
  25383. _position: Vector3;
  25384. /**
  25385. * Define the current local position of the camera in the scene
  25386. */
  25387. position: Vector3;
  25388. /**
  25389. * The vector the camera should consider as up.
  25390. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25391. */
  25392. upVector: Vector3;
  25393. /**
  25394. * Define the current limit on the left side for an orthographic camera
  25395. * In scene unit
  25396. */
  25397. orthoLeft: Nullable<number>;
  25398. /**
  25399. * Define the current limit on the right side for an orthographic camera
  25400. * In scene unit
  25401. */
  25402. orthoRight: Nullable<number>;
  25403. /**
  25404. * Define the current limit on the bottom side for an orthographic camera
  25405. * In scene unit
  25406. */
  25407. orthoBottom: Nullable<number>;
  25408. /**
  25409. * Define the current limit on the top side for an orthographic camera
  25410. * In scene unit
  25411. */
  25412. orthoTop: Nullable<number>;
  25413. /**
  25414. * Field Of View is set in Radians. (default is 0.8)
  25415. */
  25416. fov: number;
  25417. /**
  25418. * Define the minimum distance the camera can see from.
  25419. * This is important to note that the depth buffer are not infinite and the closer it starts
  25420. * the more your scene might encounter depth fighting issue.
  25421. */
  25422. minZ: number;
  25423. /**
  25424. * Define the maximum distance the camera can see to.
  25425. * This is important to note that the depth buffer are not infinite and the further it end
  25426. * the more your scene might encounter depth fighting issue.
  25427. */
  25428. maxZ: number;
  25429. /**
  25430. * Define the default inertia of the camera.
  25431. * This helps giving a smooth feeling to the camera movement.
  25432. */
  25433. inertia: number;
  25434. /**
  25435. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25436. */
  25437. mode: number;
  25438. /**
  25439. * Define wether the camera is intermediate.
  25440. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25441. */
  25442. isIntermediate: boolean;
  25443. /**
  25444. * Define the viewport of the camera.
  25445. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25446. */
  25447. viewport: Viewport;
  25448. /**
  25449. * Restricts the camera to viewing objects with the same layerMask.
  25450. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25451. */
  25452. layerMask: number;
  25453. /**
  25454. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25455. */
  25456. fovMode: number;
  25457. /**
  25458. * Rig mode of the camera.
  25459. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25460. * This is normally controlled byt the camera themselves as internal use.
  25461. */
  25462. cameraRigMode: number;
  25463. /**
  25464. * Defines the distance between both "eyes" in case of a RIG
  25465. */
  25466. interaxialDistance: number;
  25467. /**
  25468. * Defines if stereoscopic rendering is done side by side or over under.
  25469. */
  25470. isStereoscopicSideBySide: boolean;
  25471. /**
  25472. * 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
  25473. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25474. * else in the scene. (Eg. security camera)
  25475. *
  25476. * 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)
  25477. */
  25478. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25479. /**
  25480. * When set, the camera will render to this render target instead of the default canvas
  25481. *
  25482. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25483. */
  25484. outputRenderTarget: Nullable<RenderTargetTexture>;
  25485. /**
  25486. * Observable triggered when the camera view matrix has changed.
  25487. */
  25488. onViewMatrixChangedObservable: Observable<Camera>;
  25489. /**
  25490. * Observable triggered when the camera Projection matrix has changed.
  25491. */
  25492. onProjectionMatrixChangedObservable: Observable<Camera>;
  25493. /**
  25494. * Observable triggered when the inputs have been processed.
  25495. */
  25496. onAfterCheckInputsObservable: Observable<Camera>;
  25497. /**
  25498. * Observable triggered when reset has been called and applied to the camera.
  25499. */
  25500. onRestoreStateObservable: Observable<Camera>;
  25501. /** @hidden */
  25502. _cameraRigParams: any;
  25503. /** @hidden */
  25504. _rigCameras: Camera[];
  25505. /** @hidden */
  25506. _rigPostProcess: Nullable<PostProcess>;
  25507. protected _webvrViewMatrix: Matrix;
  25508. /** @hidden */
  25509. _skipRendering: boolean;
  25510. /** @hidden */
  25511. _projectionMatrix: Matrix;
  25512. /** @hidden */
  25513. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25514. /** @hidden */
  25515. _activeMeshes: SmartArray<AbstractMesh>;
  25516. protected _globalPosition: Vector3;
  25517. /** @hidden */
  25518. _computedViewMatrix: Matrix;
  25519. private _doNotComputeProjectionMatrix;
  25520. private _transformMatrix;
  25521. private _frustumPlanes;
  25522. private _refreshFrustumPlanes;
  25523. private _storedFov;
  25524. private _stateStored;
  25525. /**
  25526. * Instantiates a new camera object.
  25527. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25528. * @see http://doc.babylonjs.com/features/cameras
  25529. * @param name Defines the name of the camera in the scene
  25530. * @param position Defines the position of the camera
  25531. * @param scene Defines the scene the camera belongs too
  25532. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25533. */
  25534. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25535. /**
  25536. * Store current camera state (fov, position, etc..)
  25537. * @returns the camera
  25538. */
  25539. storeState(): Camera;
  25540. /**
  25541. * Restores the camera state values if it has been stored. You must call storeState() first
  25542. */
  25543. protected _restoreStateValues(): boolean;
  25544. /**
  25545. * Restored camera state. You must call storeState() first.
  25546. * @returns true if restored and false otherwise
  25547. */
  25548. restoreState(): boolean;
  25549. /**
  25550. * Gets the class name of the camera.
  25551. * @returns the class name
  25552. */
  25553. getClassName(): string;
  25554. /** @hidden */
  25555. readonly _isCamera: boolean;
  25556. /**
  25557. * Gets a string representation of the camera useful for debug purpose.
  25558. * @param fullDetails Defines that a more verboe level of logging is required
  25559. * @returns the string representation
  25560. */
  25561. toString(fullDetails?: boolean): string;
  25562. /**
  25563. * Gets the current world space position of the camera.
  25564. */
  25565. readonly globalPosition: Vector3;
  25566. /**
  25567. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25568. * @returns the active meshe list
  25569. */
  25570. getActiveMeshes(): SmartArray<AbstractMesh>;
  25571. /**
  25572. * Check wether a mesh is part of the current active mesh list of the camera
  25573. * @param mesh Defines the mesh to check
  25574. * @returns true if active, false otherwise
  25575. */
  25576. isActiveMesh(mesh: Mesh): boolean;
  25577. /**
  25578. * Is this camera ready to be used/rendered
  25579. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25580. * @return true if the camera is ready
  25581. */
  25582. isReady(completeCheck?: boolean): boolean;
  25583. /** @hidden */
  25584. _initCache(): void;
  25585. /** @hidden */
  25586. _updateCache(ignoreParentClass?: boolean): void;
  25587. /** @hidden */
  25588. _isSynchronized(): boolean;
  25589. /** @hidden */
  25590. _isSynchronizedViewMatrix(): boolean;
  25591. /** @hidden */
  25592. _isSynchronizedProjectionMatrix(): boolean;
  25593. /**
  25594. * Attach the input controls to a specific dom element to get the input from.
  25595. * @param element Defines the element the controls should be listened from
  25596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25597. */
  25598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25599. /**
  25600. * Detach the current controls from the specified dom element.
  25601. * @param element Defines the element to stop listening the inputs from
  25602. */
  25603. detachControl(element: HTMLElement): void;
  25604. /**
  25605. * Update the camera state according to the different inputs gathered during the frame.
  25606. */
  25607. update(): void;
  25608. /** @hidden */
  25609. _checkInputs(): void;
  25610. /** @hidden */
  25611. readonly rigCameras: Camera[];
  25612. /**
  25613. * Gets the post process used by the rig cameras
  25614. */
  25615. readonly rigPostProcess: Nullable<PostProcess>;
  25616. /**
  25617. * Internal, gets the first post proces.
  25618. * @returns the first post process to be run on this camera.
  25619. */
  25620. _getFirstPostProcess(): Nullable<PostProcess>;
  25621. private _cascadePostProcessesToRigCams;
  25622. /**
  25623. * Attach a post process to the camera.
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25625. * @param postProcess The post process to attach to the camera
  25626. * @param insertAt The position of the post process in case several of them are in use in the scene
  25627. * @returns the position the post process has been inserted at
  25628. */
  25629. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25630. /**
  25631. * Detach a post process to the camera.
  25632. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25633. * @param postProcess The post process to detach from the camera
  25634. */
  25635. detachPostProcess(postProcess: PostProcess): void;
  25636. /**
  25637. * Gets the current world matrix of the camera
  25638. */
  25639. getWorldMatrix(): Matrix;
  25640. /** @hidden */
  25641. _getViewMatrix(): Matrix;
  25642. /**
  25643. * Gets the current view matrix of the camera.
  25644. * @param force forces the camera to recompute the matrix without looking at the cached state
  25645. * @returns the view matrix
  25646. */
  25647. getViewMatrix(force?: boolean): Matrix;
  25648. /**
  25649. * Freeze the projection matrix.
  25650. * It will prevent the cache check of the camera projection compute and can speed up perf
  25651. * if no parameter of the camera are meant to change
  25652. * @param projection Defines manually a projection if necessary
  25653. */
  25654. freezeProjectionMatrix(projection?: Matrix): void;
  25655. /**
  25656. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25657. */
  25658. unfreezeProjectionMatrix(): void;
  25659. /**
  25660. * Gets the current projection matrix of the camera.
  25661. * @param force forces the camera to recompute the matrix without looking at the cached state
  25662. * @returns the projection matrix
  25663. */
  25664. getProjectionMatrix(force?: boolean): Matrix;
  25665. /**
  25666. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25667. * @returns a Matrix
  25668. */
  25669. getTransformationMatrix(): Matrix;
  25670. private _updateFrustumPlanes;
  25671. /**
  25672. * Checks if a cullable object (mesh...) is in the camera frustum
  25673. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25674. * @param target The object to check
  25675. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25676. * @returns true if the object is in frustum otherwise false
  25677. */
  25678. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25679. /**
  25680. * Checks if a cullable object (mesh...) is in the camera frustum
  25681. * Unlike isInFrustum this cheks the full bounding box
  25682. * @param target The object to check
  25683. * @returns true if the object is in frustum otherwise false
  25684. */
  25685. isCompletelyInFrustum(target: ICullable): boolean;
  25686. /**
  25687. * Gets a ray in the forward direction from the camera.
  25688. * @param length Defines the length of the ray to create
  25689. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25690. * @param origin Defines the start point of the ray which defaults to the camera position
  25691. * @returns the forward ray
  25692. */
  25693. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25694. /**
  25695. * Releases resources associated with this node.
  25696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25698. */
  25699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25700. /** @hidden */
  25701. _isLeftCamera: boolean;
  25702. /**
  25703. * Gets the left camera of a rig setup in case of Rigged Camera
  25704. */
  25705. readonly isLeftCamera: boolean;
  25706. /** @hidden */
  25707. _isRightCamera: boolean;
  25708. /**
  25709. * Gets the right camera of a rig setup in case of Rigged Camera
  25710. */
  25711. readonly isRightCamera: boolean;
  25712. /**
  25713. * Gets the left camera of a rig setup in case of Rigged Camera
  25714. */
  25715. readonly leftCamera: Nullable<FreeCamera>;
  25716. /**
  25717. * Gets the right camera of a rig setup in case of Rigged Camera
  25718. */
  25719. readonly rightCamera: Nullable<FreeCamera>;
  25720. /**
  25721. * Gets the left camera target of a rig setup in case of Rigged Camera
  25722. * @returns the target position
  25723. */
  25724. getLeftTarget(): Nullable<Vector3>;
  25725. /**
  25726. * Gets the right camera target of a rig setup in case of Rigged Camera
  25727. * @returns the target position
  25728. */
  25729. getRightTarget(): Nullable<Vector3>;
  25730. /**
  25731. * @hidden
  25732. */
  25733. setCameraRigMode(mode: number, rigParams: any): void;
  25734. /** @hidden */
  25735. static _setStereoscopicRigMode(camera: Camera): void;
  25736. /** @hidden */
  25737. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25738. /** @hidden */
  25739. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25740. /** @hidden */
  25741. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25742. /** @hidden */
  25743. _getVRProjectionMatrix(): Matrix;
  25744. protected _updateCameraRotationMatrix(): void;
  25745. protected _updateWebVRCameraRotationMatrix(): void;
  25746. /**
  25747. * This function MUST be overwritten by the different WebVR cameras available.
  25748. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25749. * @hidden
  25750. */
  25751. _getWebVRProjectionMatrix(): Matrix;
  25752. /**
  25753. * This function MUST be overwritten by the different WebVR cameras available.
  25754. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25755. * @hidden
  25756. */
  25757. _getWebVRViewMatrix(): Matrix;
  25758. /** @hidden */
  25759. setCameraRigParameter(name: string, value: any): void;
  25760. /**
  25761. * needs to be overridden by children so sub has required properties to be copied
  25762. * @hidden
  25763. */
  25764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25765. /**
  25766. * May need to be overridden by children
  25767. * @hidden
  25768. */
  25769. _updateRigCameras(): void;
  25770. /** @hidden */
  25771. _setupInputs(): void;
  25772. /**
  25773. * Serialiaze the camera setup to a json represention
  25774. * @returns the JSON representation
  25775. */
  25776. serialize(): any;
  25777. /**
  25778. * Clones the current camera.
  25779. * @param name The cloned camera name
  25780. * @returns the cloned camera
  25781. */
  25782. clone(name: string): Camera;
  25783. /**
  25784. * Gets the direction of the camera relative to a given local axis.
  25785. * @param localAxis Defines the reference axis to provide a relative direction.
  25786. * @return the direction
  25787. */
  25788. getDirection(localAxis: Vector3): Vector3;
  25789. /**
  25790. * Returns the current camera absolute rotation
  25791. */
  25792. readonly absoluteRotation: Quaternion;
  25793. /**
  25794. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25795. * @param localAxis Defines the reference axis to provide a relative direction.
  25796. * @param result Defines the vector to store the result in
  25797. */
  25798. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25799. /**
  25800. * Gets a camera constructor for a given camera type
  25801. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25802. * @param name The name of the camera the result will be able to instantiate
  25803. * @param scene The scene the result will construct the camera in
  25804. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25805. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25806. * @returns a factory method to construc the camera
  25807. */
  25808. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25809. /**
  25810. * Compute the world matrix of the camera.
  25811. * @returns the camera workd matrix
  25812. */
  25813. computeWorldMatrix(): Matrix;
  25814. /**
  25815. * Parse a JSON and creates the camera from the parsed information
  25816. * @param parsedCamera The JSON to parse
  25817. * @param scene The scene to instantiate the camera in
  25818. * @returns the newly constructed camera
  25819. */
  25820. static Parse(parsedCamera: any, scene: Scene): Camera;
  25821. }
  25822. }
  25823. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25824. import { Nullable } from "babylonjs/types";
  25825. import { Scene } from "babylonjs/scene";
  25826. import { Vector4 } from "babylonjs/Maths/math.vector";
  25827. import { Mesh } from "babylonjs/Meshes/mesh";
  25828. /**
  25829. * Class containing static functions to help procedurally build meshes
  25830. */
  25831. export class DiscBuilder {
  25832. /**
  25833. * Creates a plane polygonal mesh. By default, this is a disc
  25834. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25835. * * 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
  25836. * * 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
  25837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25840. * @param name defines the name of the mesh
  25841. * @param options defines the options used to create the mesh
  25842. * @param scene defines the hosting scene
  25843. * @returns the plane polygonal mesh
  25844. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25845. */
  25846. static CreateDisc(name: string, options: {
  25847. radius?: number;
  25848. tessellation?: number;
  25849. arc?: number;
  25850. updatable?: boolean;
  25851. sideOrientation?: number;
  25852. frontUVs?: Vector4;
  25853. backUVs?: Vector4;
  25854. }, scene?: Nullable<Scene>): Mesh;
  25855. }
  25856. }
  25857. declare module "babylonjs/Particles/solidParticleSystem" {
  25858. import { Vector3 } from "babylonjs/Maths/math.vector";
  25859. import { Mesh } from "babylonjs/Meshes/mesh";
  25860. import { Scene, IDisposable } from "babylonjs/scene";
  25861. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25862. /**
  25863. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25864. *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.
  25865. * The SPS is also a particle system. It provides some methods to manage the particles.
  25866. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25867. *
  25868. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25869. */
  25870. export class SolidParticleSystem implements IDisposable {
  25871. /**
  25872. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25873. * Example : var p = SPS.particles[i];
  25874. */
  25875. particles: SolidParticle[];
  25876. /**
  25877. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25878. */
  25879. nbParticles: number;
  25880. /**
  25881. * If the particles must ever face the camera (default false). Useful for planar particles.
  25882. */
  25883. billboard: boolean;
  25884. /**
  25885. * Recompute normals when adding a shape
  25886. */
  25887. recomputeNormals: boolean;
  25888. /**
  25889. * This a counter ofr your own usage. It's not set by any SPS functions.
  25890. */
  25891. counter: number;
  25892. /**
  25893. * The SPS name. This name is also given to the underlying mesh.
  25894. */
  25895. name: string;
  25896. /**
  25897. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25898. */
  25899. mesh: Mesh;
  25900. /**
  25901. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25902. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25903. */
  25904. vars: any;
  25905. /**
  25906. * This array is populated when the SPS is set as 'pickable'.
  25907. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25908. * Each element of this array is an object `{idx: int, faceId: int}`.
  25909. * `idx` is the picked particle index in the `SPS.particles` array
  25910. * `faceId` is the picked face index counted within this particle.
  25911. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25912. */
  25913. pickedParticles: {
  25914. idx: number;
  25915. faceId: number;
  25916. }[];
  25917. /**
  25918. * This array is populated when `enableDepthSort` is set to true.
  25919. * Each element of this array is an instance of the class DepthSortedParticle.
  25920. */
  25921. depthSortedParticles: DepthSortedParticle[];
  25922. /**
  25923. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25924. * @hidden
  25925. */
  25926. _bSphereOnly: boolean;
  25927. /**
  25928. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25929. * @hidden
  25930. */
  25931. _bSphereRadiusFactor: number;
  25932. private _scene;
  25933. private _positions;
  25934. private _indices;
  25935. private _normals;
  25936. private _colors;
  25937. private _uvs;
  25938. private _indices32;
  25939. private _positions32;
  25940. private _normals32;
  25941. private _fixedNormal32;
  25942. private _colors32;
  25943. private _uvs32;
  25944. private _index;
  25945. private _updatable;
  25946. private _pickable;
  25947. private _isVisibilityBoxLocked;
  25948. private _alwaysVisible;
  25949. private _depthSort;
  25950. private _expandable;
  25951. private _shapeCounter;
  25952. private _copy;
  25953. private _color;
  25954. private _computeParticleColor;
  25955. private _computeParticleTexture;
  25956. private _computeParticleRotation;
  25957. private _computeParticleVertex;
  25958. private _computeBoundingBox;
  25959. private _depthSortParticles;
  25960. private _camera;
  25961. private _mustUnrotateFixedNormals;
  25962. private _particlesIntersect;
  25963. private _needs32Bits;
  25964. /**
  25965. * Creates a SPS (Solid Particle System) object.
  25966. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25967. * @param scene (Scene) is the scene in which the SPS is added.
  25968. * @param options defines the options of the sps e.g.
  25969. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25970. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25971. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25972. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25973. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25974. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25975. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25976. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25977. */
  25978. constructor(name: string, scene: Scene, options?: {
  25979. updatable?: boolean;
  25980. isPickable?: boolean;
  25981. enableDepthSort?: boolean;
  25982. particleIntersection?: boolean;
  25983. boundingSphereOnly?: boolean;
  25984. bSphereRadiusFactor?: number;
  25985. expandable?: boolean;
  25986. });
  25987. /**
  25988. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25989. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25990. * @returns the created mesh
  25991. */
  25992. buildMesh(): Mesh;
  25993. /**
  25994. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25995. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25996. * Thus the particles generated from `digest()` have their property `position` set yet.
  25997. * @param mesh ( Mesh ) is the mesh to be digested
  25998. * @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
  25999. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26000. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26001. * @returns the current SPS
  26002. */
  26003. digest(mesh: Mesh, options?: {
  26004. facetNb?: number;
  26005. number?: number;
  26006. delta?: number;
  26007. }): SolidParticleSystem;
  26008. private _unrotateFixedNormals;
  26009. private _resetCopy;
  26010. private _meshBuilder;
  26011. private _posToShape;
  26012. private _uvsToShapeUV;
  26013. private _addParticle;
  26014. /**
  26015. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26016. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26017. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26018. * @param nb (positive integer) the number of particles to be created from this model
  26019. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26020. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26021. * @returns the number of shapes in the system
  26022. */
  26023. addShape(mesh: Mesh, nb: number, options?: {
  26024. positionFunction?: any;
  26025. vertexFunction?: any;
  26026. }): number;
  26027. private _rebuildParticle;
  26028. /**
  26029. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26030. * @returns the SPS.
  26031. */
  26032. rebuildMesh(): SolidParticleSystem;
  26033. /**
  26034. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26035. * This method calls `updateParticle()` for each particle of the SPS.
  26036. * For an animated SPS, it is usually called within the render loop.
  26037. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26038. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26039. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26040. * @returns the SPS.
  26041. */
  26042. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26043. /**
  26044. * Disposes the SPS.
  26045. */
  26046. dispose(): void;
  26047. /**
  26048. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26049. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26050. * @returns the SPS.
  26051. */
  26052. refreshVisibleSize(): SolidParticleSystem;
  26053. /**
  26054. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26055. * @param size the size (float) of the visibility box
  26056. * note : this doesn't lock the SPS mesh bounding box.
  26057. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26058. */
  26059. setVisibilityBox(size: number): void;
  26060. /**
  26061. * Gets whether the SPS as always visible or not
  26062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26063. */
  26064. /**
  26065. * Sets the SPS as always visible or not
  26066. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26067. */
  26068. isAlwaysVisible: boolean;
  26069. /**
  26070. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26072. */
  26073. /**
  26074. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26075. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26076. */
  26077. isVisibilityBoxLocked: boolean;
  26078. /**
  26079. * Tells to `setParticles()` to compute the particle rotations or not.
  26080. * Default value : true. The SPS is faster when it's set to false.
  26081. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26082. */
  26083. /**
  26084. * Gets if `setParticles()` computes the particle rotations or not.
  26085. * Default value : true. The SPS is faster when it's set to false.
  26086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26087. */
  26088. computeParticleRotation: boolean;
  26089. /**
  26090. * Tells to `setParticles()` to compute the particle colors or not.
  26091. * Default value : true. The SPS is faster when it's set to false.
  26092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26093. */
  26094. /**
  26095. * Gets if `setParticles()` computes the particle colors or not.
  26096. * Default value : true. The SPS is faster when it's set to false.
  26097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26098. */
  26099. computeParticleColor: boolean;
  26100. /**
  26101. * Gets if `setParticles()` computes the particle textures or not.
  26102. * Default value : true. The SPS is faster when it's set to false.
  26103. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26104. */
  26105. computeParticleTexture: boolean;
  26106. /**
  26107. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26108. * Default value : false. The SPS is faster when it's set to false.
  26109. * Note : the particle custom vertex positions aren't stored values.
  26110. */
  26111. /**
  26112. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26113. * Default value : false. The SPS is faster when it's set to false.
  26114. * Note : the particle custom vertex positions aren't stored values.
  26115. */
  26116. computeParticleVertex: boolean;
  26117. /**
  26118. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26119. */
  26120. /**
  26121. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26122. */
  26123. computeBoundingBox: boolean;
  26124. /**
  26125. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26126. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26127. * Default : `true`
  26128. */
  26129. /**
  26130. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26132. * Default : `true`
  26133. */
  26134. depthSortParticles: boolean;
  26135. /**
  26136. * Gets if the SPS is created as expandable at construction time.
  26137. * Default : `false`
  26138. */
  26139. readonly expandable: boolean;
  26140. /**
  26141. * This function does nothing. It may be overwritten to set all the particle first values.
  26142. * The SPS doesn't call this function, you may have to call it by your own.
  26143. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26144. */
  26145. initParticles(): void;
  26146. /**
  26147. * This function does nothing. It may be overwritten to recycle a particle.
  26148. * The SPS doesn't call this function, you may have to call it by your own.
  26149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26150. * @param particle The particle to recycle
  26151. * @returns the recycled particle
  26152. */
  26153. recycleParticle(particle: SolidParticle): SolidParticle;
  26154. /**
  26155. * Updates a particle : this function should be overwritten by the user.
  26156. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26157. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26158. * @example : just set a particle position or velocity and recycle conditions
  26159. * @param particle The particle to update
  26160. * @returns the updated particle
  26161. */
  26162. updateParticle(particle: SolidParticle): SolidParticle;
  26163. /**
  26164. * Updates a vertex of a particle : it can be overwritten by the user.
  26165. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26166. * @param particle the current particle
  26167. * @param vertex the current index of the current particle
  26168. * @param pt the index of the current vertex in the particle shape
  26169. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26170. * @example : just set a vertex particle position
  26171. * @returns the updated vertex
  26172. */
  26173. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26174. /**
  26175. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26176. * This does nothing and may be overwritten by the user.
  26177. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26178. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26179. * @param update the boolean update value actually passed to setParticles()
  26180. */
  26181. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26182. /**
  26183. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26184. * This will be passed three parameters.
  26185. * This does nothing and may be overwritten by the user.
  26186. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26187. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26188. * @param update the boolean update value actually passed to setParticles()
  26189. */
  26190. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26191. }
  26192. }
  26193. declare module "babylonjs/Particles/solidParticle" {
  26194. import { Nullable } from "babylonjs/types";
  26195. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26196. import { Color4 } from "babylonjs/Maths/math.color";
  26197. import { Mesh } from "babylonjs/Meshes/mesh";
  26198. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26199. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26200. import { Plane } from "babylonjs/Maths/math.plane";
  26201. /**
  26202. * Represents one particle of a solid particle system.
  26203. */
  26204. export class SolidParticle {
  26205. /**
  26206. * particle global index
  26207. */
  26208. idx: number;
  26209. /**
  26210. * The color of the particle
  26211. */
  26212. color: Nullable<Color4>;
  26213. /**
  26214. * The world space position of the particle.
  26215. */
  26216. position: Vector3;
  26217. /**
  26218. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26219. */
  26220. rotation: Vector3;
  26221. /**
  26222. * The world space rotation quaternion of the particle.
  26223. */
  26224. rotationQuaternion: Nullable<Quaternion>;
  26225. /**
  26226. * The scaling of the particle.
  26227. */
  26228. scaling: Vector3;
  26229. /**
  26230. * The uvs of the particle.
  26231. */
  26232. uvs: Vector4;
  26233. /**
  26234. * The current speed of the particle.
  26235. */
  26236. velocity: Vector3;
  26237. /**
  26238. * The pivot point in the particle local space.
  26239. */
  26240. pivot: Vector3;
  26241. /**
  26242. * Must the particle be translated from its pivot point in its local space ?
  26243. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26244. * Default : false
  26245. */
  26246. translateFromPivot: boolean;
  26247. /**
  26248. * Is the particle active or not ?
  26249. */
  26250. alive: boolean;
  26251. /**
  26252. * Is the particle visible or not ?
  26253. */
  26254. isVisible: boolean;
  26255. /**
  26256. * Index of this particle in the global "positions" array (Internal use)
  26257. * @hidden
  26258. */
  26259. _pos: number;
  26260. /**
  26261. * @hidden Index of this particle in the global "indices" array (Internal use)
  26262. */
  26263. _ind: number;
  26264. /**
  26265. * @hidden ModelShape of this particle (Internal use)
  26266. */
  26267. _model: ModelShape;
  26268. /**
  26269. * ModelShape id of this particle
  26270. */
  26271. shapeId: number;
  26272. /**
  26273. * Index of the particle in its shape id
  26274. */
  26275. idxInShape: number;
  26276. /**
  26277. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26278. */
  26279. _modelBoundingInfo: BoundingInfo;
  26280. /**
  26281. * @hidden Particle BoundingInfo object (Internal use)
  26282. */
  26283. _boundingInfo: BoundingInfo;
  26284. /**
  26285. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26286. */
  26287. _sps: SolidParticleSystem;
  26288. /**
  26289. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26290. */
  26291. _stillInvisible: boolean;
  26292. /**
  26293. * @hidden Last computed particle rotation matrix
  26294. */
  26295. _rotationMatrix: number[];
  26296. /**
  26297. * Parent particle Id, if any.
  26298. * Default null.
  26299. */
  26300. parentId: Nullable<number>;
  26301. /**
  26302. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26303. * The possible values are :
  26304. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26305. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26306. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26308. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26309. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26310. * */
  26311. cullingStrategy: number;
  26312. /**
  26313. * @hidden Internal global position in the SPS.
  26314. */
  26315. _globalPosition: Vector3;
  26316. /**
  26317. * Creates a Solid Particle object.
  26318. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26319. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26320. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26321. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26322. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26323. * @param shapeId (integer) is the model shape identifier in the SPS.
  26324. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26325. * @param sps defines the sps it is associated to
  26326. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26327. */
  26328. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26329. /**
  26330. * Legacy support, changed scale to scaling
  26331. */
  26332. /**
  26333. * Legacy support, changed scale to scaling
  26334. */
  26335. scale: Vector3;
  26336. /**
  26337. * Legacy support, changed quaternion to rotationQuaternion
  26338. */
  26339. /**
  26340. * Legacy support, changed quaternion to rotationQuaternion
  26341. */
  26342. quaternion: Nullable<Quaternion>;
  26343. /**
  26344. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26345. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26346. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26347. * @returns true if it intersects
  26348. */
  26349. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26350. /**
  26351. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26352. * A particle is in the frustum if its bounding box intersects the frustum
  26353. * @param frustumPlanes defines the frustum to test
  26354. * @returns true if the particle is in the frustum planes
  26355. */
  26356. isInFrustum(frustumPlanes: Plane[]): boolean;
  26357. /**
  26358. * get the rotation matrix of the particle
  26359. * @hidden
  26360. */
  26361. getRotationMatrix(m: Matrix): void;
  26362. }
  26363. /**
  26364. * Represents the shape of the model used by one particle of a solid particle system.
  26365. * SPS internal tool, don't use it manually.
  26366. */
  26367. export class ModelShape {
  26368. /**
  26369. * The shape id
  26370. * @hidden
  26371. */
  26372. shapeID: number;
  26373. /**
  26374. * flat array of model positions (internal use)
  26375. * @hidden
  26376. */
  26377. _shape: Vector3[];
  26378. /**
  26379. * flat array of model UVs (internal use)
  26380. * @hidden
  26381. */
  26382. _shapeUV: number[];
  26383. /**
  26384. * length of the shape in the model indices array (internal use)
  26385. * @hidden
  26386. */
  26387. _indicesLength: number;
  26388. /**
  26389. * Custom position function (internal use)
  26390. * @hidden
  26391. */
  26392. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26393. /**
  26394. * Custom vertex function (internal use)
  26395. * @hidden
  26396. */
  26397. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26398. /**
  26399. * 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.
  26400. * SPS internal tool, don't use it manually.
  26401. * @hidden
  26402. */
  26403. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26404. }
  26405. /**
  26406. * Represents a Depth Sorted Particle in the solid particle system.
  26407. */
  26408. export class DepthSortedParticle {
  26409. /**
  26410. * Index of the particle in the "indices" array
  26411. */
  26412. ind: number;
  26413. /**
  26414. * Length of the particle shape in the "indices" array
  26415. */
  26416. indicesLength: number;
  26417. /**
  26418. * Squared distance from the particle to the camera
  26419. */
  26420. sqDistance: number;
  26421. }
  26422. }
  26423. declare module "babylonjs/Collisions/meshCollisionData" {
  26424. import { Collider } from "babylonjs/Collisions/collider";
  26425. import { Vector3 } from "babylonjs/Maths/math.vector";
  26426. import { Nullable } from "babylonjs/types";
  26427. import { Observer } from "babylonjs/Misc/observable";
  26428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26429. /**
  26430. * @hidden
  26431. */
  26432. export class _MeshCollisionData {
  26433. _checkCollisions: boolean;
  26434. _collisionMask: number;
  26435. _collisionGroup: number;
  26436. _collider: Nullable<Collider>;
  26437. _oldPositionForCollisions: Vector3;
  26438. _diffPositionForCollisions: Vector3;
  26439. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26440. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26441. }
  26442. }
  26443. declare module "babylonjs/Meshes/abstractMesh" {
  26444. import { Observable } from "babylonjs/Misc/observable";
  26445. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26446. import { Camera } from "babylonjs/Cameras/camera";
  26447. import { Scene, IDisposable } from "babylonjs/scene";
  26448. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26449. import { Node } from "babylonjs/node";
  26450. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26451. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26452. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26453. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26454. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26455. import { Material } from "babylonjs/Materials/material";
  26456. import { Light } from "babylonjs/Lights/light";
  26457. import { Skeleton } from "babylonjs/Bones/skeleton";
  26458. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26459. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26460. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26461. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26462. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26463. import { Plane } from "babylonjs/Maths/math.plane";
  26464. import { Ray } from "babylonjs/Culling/ray";
  26465. import { Collider } from "babylonjs/Collisions/collider";
  26466. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26467. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26468. /** @hidden */
  26469. class _FacetDataStorage {
  26470. facetPositions: Vector3[];
  26471. facetNormals: Vector3[];
  26472. facetPartitioning: number[][];
  26473. facetNb: number;
  26474. partitioningSubdivisions: number;
  26475. partitioningBBoxRatio: number;
  26476. facetDataEnabled: boolean;
  26477. facetParameters: any;
  26478. bbSize: Vector3;
  26479. subDiv: {
  26480. max: number;
  26481. X: number;
  26482. Y: number;
  26483. Z: number;
  26484. };
  26485. facetDepthSort: boolean;
  26486. facetDepthSortEnabled: boolean;
  26487. depthSortedIndices: IndicesArray;
  26488. depthSortedFacets: {
  26489. ind: number;
  26490. sqDistance: number;
  26491. }[];
  26492. facetDepthSortFunction: (f1: {
  26493. ind: number;
  26494. sqDistance: number;
  26495. }, f2: {
  26496. ind: number;
  26497. sqDistance: number;
  26498. }) => number;
  26499. facetDepthSortFrom: Vector3;
  26500. facetDepthSortOrigin: Vector3;
  26501. invertedMatrix: Matrix;
  26502. }
  26503. /**
  26504. * @hidden
  26505. **/
  26506. class _InternalAbstractMeshDataInfo {
  26507. _hasVertexAlpha: boolean;
  26508. _useVertexColors: boolean;
  26509. _numBoneInfluencers: number;
  26510. _applyFog: boolean;
  26511. _receiveShadows: boolean;
  26512. _facetData: _FacetDataStorage;
  26513. _visibility: number;
  26514. _skeleton: Nullable<Skeleton>;
  26515. _layerMask: number;
  26516. _computeBonesUsingShaders: boolean;
  26517. _isActive: boolean;
  26518. _onlyForInstances: boolean;
  26519. _isActiveIntermediate: boolean;
  26520. _onlyForInstancesIntermediate: boolean;
  26521. }
  26522. /**
  26523. * Class used to store all common mesh properties
  26524. */
  26525. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26526. /** No occlusion */
  26527. static OCCLUSION_TYPE_NONE: number;
  26528. /** Occlusion set to optimisitic */
  26529. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26530. /** Occlusion set to strict */
  26531. static OCCLUSION_TYPE_STRICT: number;
  26532. /** Use an accurante occlusion algorithm */
  26533. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26534. /** Use a conservative occlusion algorithm */
  26535. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26536. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26537. * Test order :
  26538. * Is the bounding sphere outside the frustum ?
  26539. * If not, are the bounding box vertices outside the frustum ?
  26540. * It not, then the cullable object is in the frustum.
  26541. */
  26542. static readonly CULLINGSTRATEGY_STANDARD: number;
  26543. /** Culling strategy : Bounding Sphere Only.
  26544. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26545. * It's also less accurate than the standard because some not visible objects can still be selected.
  26546. * Test : is the bounding sphere outside the frustum ?
  26547. * If not, then the cullable object is in the frustum.
  26548. */
  26549. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26550. /** Culling strategy : Optimistic Inclusion.
  26551. * This in an inclusion test first, then the standard exclusion test.
  26552. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26553. * 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.
  26554. * Anyway, it's as accurate as the standard strategy.
  26555. * Test :
  26556. * Is the cullable object bounding sphere center in the frustum ?
  26557. * If not, apply the default culling strategy.
  26558. */
  26559. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26560. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26561. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26562. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26563. * 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.
  26564. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26565. * Test :
  26566. * Is the cullable object bounding sphere center in the frustum ?
  26567. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26568. */
  26569. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26570. /**
  26571. * No billboard
  26572. */
  26573. static readonly BILLBOARDMODE_NONE: number;
  26574. /** Billboard on X axis */
  26575. static readonly BILLBOARDMODE_X: number;
  26576. /** Billboard on Y axis */
  26577. static readonly BILLBOARDMODE_Y: number;
  26578. /** Billboard on Z axis */
  26579. static readonly BILLBOARDMODE_Z: number;
  26580. /** Billboard on all axes */
  26581. static readonly BILLBOARDMODE_ALL: number;
  26582. /** Billboard on using position instead of orientation */
  26583. static readonly BILLBOARDMODE_USE_POSITION: number;
  26584. /** @hidden */
  26585. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26586. /**
  26587. * The culling strategy to use to check whether the mesh must be rendered or not.
  26588. * This value can be changed at any time and will be used on the next render mesh selection.
  26589. * The possible values are :
  26590. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26591. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26592. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26593. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26594. * Please read each static variable documentation to get details about the culling process.
  26595. * */
  26596. cullingStrategy: number;
  26597. /**
  26598. * Gets the number of facets in the mesh
  26599. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26600. */
  26601. readonly facetNb: number;
  26602. /**
  26603. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26605. */
  26606. partitioningSubdivisions: number;
  26607. /**
  26608. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26609. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26611. */
  26612. partitioningBBoxRatio: number;
  26613. /**
  26614. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26615. * Works only for updatable meshes.
  26616. * Doesn't work with multi-materials
  26617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26618. */
  26619. mustDepthSortFacets: boolean;
  26620. /**
  26621. * The location (Vector3) where the facet depth sort must be computed from.
  26622. * By default, the active camera position.
  26623. * Used only when facet depth sort is enabled
  26624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26625. */
  26626. facetDepthSortFrom: Vector3;
  26627. /**
  26628. * gets a boolean indicating if facetData is enabled
  26629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26630. */
  26631. readonly isFacetDataEnabled: boolean;
  26632. /** @hidden */
  26633. _updateNonUniformScalingState(value: boolean): boolean;
  26634. /**
  26635. * An event triggered when this mesh collides with another one
  26636. */
  26637. onCollideObservable: Observable<AbstractMesh>;
  26638. /** Set a function to call when this mesh collides with another one */
  26639. onCollide: () => void;
  26640. /**
  26641. * An event triggered when the collision's position changes
  26642. */
  26643. onCollisionPositionChangeObservable: Observable<Vector3>;
  26644. /** Set a function to call when the collision's position changes */
  26645. onCollisionPositionChange: () => void;
  26646. /**
  26647. * An event triggered when material is changed
  26648. */
  26649. onMaterialChangedObservable: Observable<AbstractMesh>;
  26650. /**
  26651. * Gets or sets the orientation for POV movement & rotation
  26652. */
  26653. definedFacingForward: boolean;
  26654. /** @hidden */
  26655. _occlusionQuery: Nullable<WebGLQuery>;
  26656. /** @hidden */
  26657. _renderingGroup: Nullable<RenderingGroup>;
  26658. /**
  26659. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26660. */
  26661. /**
  26662. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26663. */
  26664. visibility: number;
  26665. /** Gets or sets the alpha index used to sort transparent meshes
  26666. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26667. */
  26668. alphaIndex: number;
  26669. /**
  26670. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26671. */
  26672. isVisible: boolean;
  26673. /**
  26674. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26675. */
  26676. isPickable: boolean;
  26677. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26678. showSubMeshesBoundingBox: boolean;
  26679. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26680. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26681. */
  26682. isBlocker: boolean;
  26683. /**
  26684. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26685. */
  26686. enablePointerMoveEvents: boolean;
  26687. /**
  26688. * Specifies the rendering group id for this mesh (0 by default)
  26689. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26690. */
  26691. renderingGroupId: number;
  26692. private _material;
  26693. /** Gets or sets current material */
  26694. material: Nullable<Material>;
  26695. /**
  26696. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26697. * @see http://doc.babylonjs.com/babylon101/shadows
  26698. */
  26699. receiveShadows: boolean;
  26700. /** Defines color to use when rendering outline */
  26701. outlineColor: Color3;
  26702. /** Define width to use when rendering outline */
  26703. outlineWidth: number;
  26704. /** Defines color to use when rendering overlay */
  26705. overlayColor: Color3;
  26706. /** Defines alpha to use when rendering overlay */
  26707. overlayAlpha: number;
  26708. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26709. hasVertexAlpha: boolean;
  26710. /** 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) */
  26711. useVertexColors: boolean;
  26712. /**
  26713. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26714. */
  26715. computeBonesUsingShaders: boolean;
  26716. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26717. numBoneInfluencers: number;
  26718. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26719. applyFog: boolean;
  26720. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26721. useOctreeForRenderingSelection: boolean;
  26722. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26723. useOctreeForPicking: boolean;
  26724. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26725. useOctreeForCollisions: boolean;
  26726. /**
  26727. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26728. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26729. */
  26730. layerMask: number;
  26731. /**
  26732. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26733. */
  26734. alwaysSelectAsActiveMesh: boolean;
  26735. /**
  26736. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26737. */
  26738. doNotSyncBoundingInfo: boolean;
  26739. /**
  26740. * Gets or sets the current action manager
  26741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26742. */
  26743. actionManager: Nullable<AbstractActionManager>;
  26744. private _meshCollisionData;
  26745. /**
  26746. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26747. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26748. */
  26749. ellipsoid: Vector3;
  26750. /**
  26751. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26753. */
  26754. ellipsoidOffset: Vector3;
  26755. /**
  26756. * Gets or sets a collision mask used to mask collisions (default is -1).
  26757. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26758. */
  26759. collisionMask: number;
  26760. /**
  26761. * Gets or sets the current collision group mask (-1 by default).
  26762. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26763. */
  26764. collisionGroup: number;
  26765. /**
  26766. * Defines edge width used when edgesRenderer is enabled
  26767. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26768. */
  26769. edgesWidth: number;
  26770. /**
  26771. * Defines edge color used when edgesRenderer is enabled
  26772. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26773. */
  26774. edgesColor: Color4;
  26775. /** @hidden */
  26776. _edgesRenderer: Nullable<IEdgesRenderer>;
  26777. /** @hidden */
  26778. _masterMesh: Nullable<AbstractMesh>;
  26779. /** @hidden */
  26780. _boundingInfo: Nullable<BoundingInfo>;
  26781. /** @hidden */
  26782. _renderId: number;
  26783. /**
  26784. * Gets or sets the list of subMeshes
  26785. * @see http://doc.babylonjs.com/how_to/multi_materials
  26786. */
  26787. subMeshes: SubMesh[];
  26788. /** @hidden */
  26789. _intersectionsInProgress: AbstractMesh[];
  26790. /** @hidden */
  26791. _unIndexed: boolean;
  26792. /** @hidden */
  26793. _lightSources: Light[];
  26794. /** Gets the list of lights affecting that mesh */
  26795. readonly lightSources: Light[];
  26796. /** @hidden */
  26797. readonly _positions: Nullable<Vector3[]>;
  26798. /** @hidden */
  26799. _waitingData: {
  26800. lods: Nullable<any>;
  26801. actions: Nullable<any>;
  26802. freezeWorldMatrix: Nullable<boolean>;
  26803. };
  26804. /** @hidden */
  26805. _bonesTransformMatrices: Nullable<Float32Array>;
  26806. /** @hidden */
  26807. _transformMatrixTexture: Nullable<RawTexture>;
  26808. /**
  26809. * Gets or sets a skeleton to apply skining transformations
  26810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26811. */
  26812. skeleton: Nullable<Skeleton>;
  26813. /**
  26814. * An event triggered when the mesh is rebuilt.
  26815. */
  26816. onRebuildObservable: Observable<AbstractMesh>;
  26817. /**
  26818. * Creates a new AbstractMesh
  26819. * @param name defines the name of the mesh
  26820. * @param scene defines the hosting scene
  26821. */
  26822. constructor(name: string, scene?: Nullable<Scene>);
  26823. /**
  26824. * Returns the string "AbstractMesh"
  26825. * @returns "AbstractMesh"
  26826. */
  26827. getClassName(): string;
  26828. /**
  26829. * Gets a string representation of the current mesh
  26830. * @param fullDetails defines a boolean indicating if full details must be included
  26831. * @returns a string representation of the current mesh
  26832. */
  26833. toString(fullDetails?: boolean): string;
  26834. /**
  26835. * @hidden
  26836. */
  26837. protected _getEffectiveParent(): Nullable<Node>;
  26838. /** @hidden */
  26839. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26840. /** @hidden */
  26841. _rebuild(): void;
  26842. /** @hidden */
  26843. _resyncLightSources(): void;
  26844. /** @hidden */
  26845. _resyncLighSource(light: Light): void;
  26846. /** @hidden */
  26847. _unBindEffect(): void;
  26848. /** @hidden */
  26849. _removeLightSource(light: Light, dispose: boolean): void;
  26850. private _markSubMeshesAsDirty;
  26851. /** @hidden */
  26852. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26853. /** @hidden */
  26854. _markSubMeshesAsAttributesDirty(): void;
  26855. /** @hidden */
  26856. _markSubMeshesAsMiscDirty(): void;
  26857. /**
  26858. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26859. */
  26860. scaling: Vector3;
  26861. /**
  26862. * Returns true if the mesh is blocked. Implemented by child classes
  26863. */
  26864. readonly isBlocked: boolean;
  26865. /**
  26866. * Returns the mesh itself by default. Implemented by child classes
  26867. * @param camera defines the camera to use to pick the right LOD level
  26868. * @returns the currentAbstractMesh
  26869. */
  26870. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26871. /**
  26872. * Returns 0 by default. Implemented by child classes
  26873. * @returns an integer
  26874. */
  26875. getTotalVertices(): number;
  26876. /**
  26877. * Returns a positive integer : the total number of indices in this mesh geometry.
  26878. * @returns the numner of indices or zero if the mesh has no geometry.
  26879. */
  26880. getTotalIndices(): number;
  26881. /**
  26882. * Returns null by default. Implemented by child classes
  26883. * @returns null
  26884. */
  26885. getIndices(): Nullable<IndicesArray>;
  26886. /**
  26887. * Returns the array of the requested vertex data kind. Implemented by child classes
  26888. * @param kind defines the vertex data kind to use
  26889. * @returns null
  26890. */
  26891. getVerticesData(kind: string): Nullable<FloatArray>;
  26892. /**
  26893. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26894. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26895. * Note that a new underlying VertexBuffer object is created each call.
  26896. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26897. * @param kind defines vertex data kind:
  26898. * * VertexBuffer.PositionKind
  26899. * * VertexBuffer.UVKind
  26900. * * VertexBuffer.UV2Kind
  26901. * * VertexBuffer.UV3Kind
  26902. * * VertexBuffer.UV4Kind
  26903. * * VertexBuffer.UV5Kind
  26904. * * VertexBuffer.UV6Kind
  26905. * * VertexBuffer.ColorKind
  26906. * * VertexBuffer.MatricesIndicesKind
  26907. * * VertexBuffer.MatricesIndicesExtraKind
  26908. * * VertexBuffer.MatricesWeightsKind
  26909. * * VertexBuffer.MatricesWeightsExtraKind
  26910. * @param data defines the data source
  26911. * @param updatable defines if the data must be flagged as updatable (or static)
  26912. * @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
  26913. * @returns the current mesh
  26914. */
  26915. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26916. /**
  26917. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26918. * If the mesh has no geometry, it is simply returned as it is.
  26919. * @param kind defines vertex data kind:
  26920. * * VertexBuffer.PositionKind
  26921. * * VertexBuffer.UVKind
  26922. * * VertexBuffer.UV2Kind
  26923. * * VertexBuffer.UV3Kind
  26924. * * VertexBuffer.UV4Kind
  26925. * * VertexBuffer.UV5Kind
  26926. * * VertexBuffer.UV6Kind
  26927. * * VertexBuffer.ColorKind
  26928. * * VertexBuffer.MatricesIndicesKind
  26929. * * VertexBuffer.MatricesIndicesExtraKind
  26930. * * VertexBuffer.MatricesWeightsKind
  26931. * * VertexBuffer.MatricesWeightsExtraKind
  26932. * @param data defines the data source
  26933. * @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
  26934. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26935. * @returns the current mesh
  26936. */
  26937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26938. /**
  26939. * Sets the mesh indices,
  26940. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26941. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26942. * @param totalVertices Defines the total number of vertices
  26943. * @returns the current mesh
  26944. */
  26945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26946. /**
  26947. * Gets a boolean indicating if specific vertex data is present
  26948. * @param kind defines the vertex data kind to use
  26949. * @returns true is data kind is present
  26950. */
  26951. isVerticesDataPresent(kind: string): boolean;
  26952. /**
  26953. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26954. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26955. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26956. * @returns a BoundingInfo
  26957. */
  26958. getBoundingInfo(): BoundingInfo;
  26959. /**
  26960. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26961. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26962. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26963. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26964. * @returns the current mesh
  26965. */
  26966. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26967. /**
  26968. * Overwrite the current bounding info
  26969. * @param boundingInfo defines the new bounding info
  26970. * @returns the current mesh
  26971. */
  26972. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26973. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26974. readonly useBones: boolean;
  26975. /** @hidden */
  26976. _preActivate(): void;
  26977. /** @hidden */
  26978. _preActivateForIntermediateRendering(renderId: number): void;
  26979. /** @hidden */
  26980. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26981. /** @hidden */
  26982. _postActivate(): void;
  26983. /** @hidden */
  26984. _freeze(): void;
  26985. /** @hidden */
  26986. _unFreeze(): void;
  26987. /**
  26988. * Gets the current world matrix
  26989. * @returns a Matrix
  26990. */
  26991. getWorldMatrix(): Matrix;
  26992. /** @hidden */
  26993. _getWorldMatrixDeterminant(): number;
  26994. /**
  26995. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26996. */
  26997. readonly isAnInstance: boolean;
  26998. /**
  26999. * Gets a boolean indicating if this mesh has instances
  27000. */
  27001. readonly hasInstances: boolean;
  27002. /**
  27003. * Perform relative position change from the point of view of behind the front of the mesh.
  27004. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27005. * Supports definition of mesh facing forward or backward
  27006. * @param amountRight defines the distance on the right axis
  27007. * @param amountUp defines the distance on the up axis
  27008. * @param amountForward defines the distance on the forward axis
  27009. * @returns the current mesh
  27010. */
  27011. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27012. /**
  27013. * Calculate relative position change from the point of view of behind the front of the mesh.
  27014. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27015. * Supports definition of mesh facing forward or backward
  27016. * @param amountRight defines the distance on the right axis
  27017. * @param amountUp defines the distance on the up axis
  27018. * @param amountForward defines the distance on the forward axis
  27019. * @returns the new displacement vector
  27020. */
  27021. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27022. /**
  27023. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27024. * Supports definition of mesh facing forward or backward
  27025. * @param flipBack defines the flip
  27026. * @param twirlClockwise defines the twirl
  27027. * @param tiltRight defines the tilt
  27028. * @returns the current mesh
  27029. */
  27030. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27031. /**
  27032. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27033. * Supports definition of mesh facing forward or backward.
  27034. * @param flipBack defines the flip
  27035. * @param twirlClockwise defines the twirl
  27036. * @param tiltRight defines the tilt
  27037. * @returns the new rotation vector
  27038. */
  27039. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27040. /**
  27041. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27042. * This means the mesh underlying bounding box and sphere are recomputed.
  27043. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27044. * @returns the current mesh
  27045. */
  27046. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27047. /** @hidden */
  27048. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27049. /** @hidden */
  27050. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27051. /** @hidden */
  27052. _updateBoundingInfo(): AbstractMesh;
  27053. /** @hidden */
  27054. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27055. /** @hidden */
  27056. protected _afterComputeWorldMatrix(): void;
  27057. /** @hidden */
  27058. readonly _effectiveMesh: AbstractMesh;
  27059. /**
  27060. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27061. * A mesh is in the frustum if its bounding box intersects the frustum
  27062. * @param frustumPlanes defines the frustum to test
  27063. * @returns true if the mesh is in the frustum planes
  27064. */
  27065. isInFrustum(frustumPlanes: Plane[]): boolean;
  27066. /**
  27067. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27068. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27069. * @param frustumPlanes defines the frustum to test
  27070. * @returns true if the mesh is completely in the frustum planes
  27071. */
  27072. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27073. /**
  27074. * True if the mesh intersects another mesh or a SolidParticle object
  27075. * @param mesh defines a target mesh or SolidParticle to test
  27076. * @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)
  27077. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27078. * @returns true if there is an intersection
  27079. */
  27080. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27081. /**
  27082. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27083. * @param point defines the point to test
  27084. * @returns true if there is an intersection
  27085. */
  27086. intersectsPoint(point: Vector3): boolean;
  27087. /**
  27088. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27090. */
  27091. checkCollisions: boolean;
  27092. /**
  27093. * Gets Collider object used to compute collisions (not physics)
  27094. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27095. */
  27096. readonly collider: Nullable<Collider>;
  27097. /**
  27098. * Move the mesh using collision engine
  27099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27100. * @param displacement defines the requested displacement vector
  27101. * @returns the current mesh
  27102. */
  27103. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27104. private _onCollisionPositionChange;
  27105. /** @hidden */
  27106. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27107. /** @hidden */
  27108. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27109. /** @hidden */
  27110. _checkCollision(collider: Collider): AbstractMesh;
  27111. /** @hidden */
  27112. _generatePointsArray(): boolean;
  27113. /**
  27114. * Checks if the passed Ray intersects with the mesh
  27115. * @param ray defines the ray to use
  27116. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27118. * @returns the picking info
  27119. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27120. */
  27121. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27122. /**
  27123. * Clones the current mesh
  27124. * @param name defines the mesh name
  27125. * @param newParent defines the new mesh parent
  27126. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27127. * @returns the new mesh
  27128. */
  27129. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27130. /**
  27131. * Disposes all the submeshes of the current meshnp
  27132. * @returns the current mesh
  27133. */
  27134. releaseSubMeshes(): AbstractMesh;
  27135. /**
  27136. * Releases resources associated with this abstract mesh.
  27137. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27138. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27139. */
  27140. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27141. /**
  27142. * Adds the passed mesh as a child to the current mesh
  27143. * @param mesh defines the child mesh
  27144. * @returns the current mesh
  27145. */
  27146. addChild(mesh: AbstractMesh): AbstractMesh;
  27147. /**
  27148. * Removes the passed mesh from the current mesh children list
  27149. * @param mesh defines the child mesh
  27150. * @returns the current mesh
  27151. */
  27152. removeChild(mesh: AbstractMesh): AbstractMesh;
  27153. /** @hidden */
  27154. private _initFacetData;
  27155. /**
  27156. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27157. * This method can be called within the render loop.
  27158. * 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
  27159. * @returns the current mesh
  27160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27161. */
  27162. updateFacetData(): AbstractMesh;
  27163. /**
  27164. * Returns the facetLocalNormals array.
  27165. * The normals are expressed in the mesh local spac
  27166. * @returns an array of Vector3
  27167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27168. */
  27169. getFacetLocalNormals(): Vector3[];
  27170. /**
  27171. * Returns the facetLocalPositions array.
  27172. * The facet positions are expressed in the mesh local space
  27173. * @returns an array of Vector3
  27174. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27175. */
  27176. getFacetLocalPositions(): Vector3[];
  27177. /**
  27178. * Returns the facetLocalPartioning array
  27179. * @returns an array of array of numbers
  27180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27181. */
  27182. getFacetLocalPartitioning(): number[][];
  27183. /**
  27184. * Returns the i-th facet position in the world system.
  27185. * This method allocates a new Vector3 per call
  27186. * @param i defines the facet index
  27187. * @returns a new Vector3
  27188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27189. */
  27190. getFacetPosition(i: number): Vector3;
  27191. /**
  27192. * Sets the reference Vector3 with the i-th facet position in the world system
  27193. * @param i defines the facet index
  27194. * @param ref defines the target vector
  27195. * @returns the current mesh
  27196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27197. */
  27198. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27199. /**
  27200. * Returns the i-th facet normal in the world system.
  27201. * This method allocates a new Vector3 per call
  27202. * @param i defines the facet index
  27203. * @returns a new Vector3
  27204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27205. */
  27206. getFacetNormal(i: number): Vector3;
  27207. /**
  27208. * Sets the reference Vector3 with the i-th facet normal in the world system
  27209. * @param i defines the facet index
  27210. * @param ref defines the target vector
  27211. * @returns the current mesh
  27212. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27213. */
  27214. getFacetNormalToRef(i: number, ref: Vector3): this;
  27215. /**
  27216. * 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)
  27217. * @param x defines x coordinate
  27218. * @param y defines y coordinate
  27219. * @param z defines z coordinate
  27220. * @returns the array of facet indexes
  27221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27222. */
  27223. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27224. /**
  27225. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27226. * @param projected sets as the (x,y,z) world projection on the facet
  27227. * @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
  27228. * @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
  27229. * @param x defines x coordinate
  27230. * @param y defines y coordinate
  27231. * @param z defines z coordinate
  27232. * @returns the face index if found (or null instead)
  27233. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27234. */
  27235. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27236. /**
  27237. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27238. * @param projected sets as the (x,y,z) local projection on the facet
  27239. * @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
  27240. * @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
  27241. * @param x defines x coordinate
  27242. * @param y defines y coordinate
  27243. * @param z defines z coordinate
  27244. * @returns the face index if found (or null instead)
  27245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27246. */
  27247. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27248. /**
  27249. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27250. * @returns the parameters
  27251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27252. */
  27253. getFacetDataParameters(): any;
  27254. /**
  27255. * Disables the feature FacetData and frees the related memory
  27256. * @returns the current mesh
  27257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27258. */
  27259. disableFacetData(): AbstractMesh;
  27260. /**
  27261. * Updates the AbstractMesh indices array
  27262. * @param indices defines the data source
  27263. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27264. * @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)
  27265. * @returns the current mesh
  27266. */
  27267. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27268. /**
  27269. * Creates new normals data for the mesh
  27270. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27271. * @returns the current mesh
  27272. */
  27273. createNormals(updatable: boolean): AbstractMesh;
  27274. /**
  27275. * Align the mesh with a normal
  27276. * @param normal defines the normal to use
  27277. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27278. * @returns the current mesh
  27279. */
  27280. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27281. /** @hidden */
  27282. _checkOcclusionQuery(): boolean;
  27283. /**
  27284. * Disables the mesh edge rendering mode
  27285. * @returns the currentAbstractMesh
  27286. */
  27287. disableEdgesRendering(): AbstractMesh;
  27288. /**
  27289. * Enables the edge rendering mode on the mesh.
  27290. * This mode makes the mesh edges visible
  27291. * @param epsilon defines the maximal distance between two angles to detect a face
  27292. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27293. * @returns the currentAbstractMesh
  27294. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27295. */
  27296. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27297. }
  27298. }
  27299. declare module "babylonjs/Actions/actionEvent" {
  27300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27301. import { Nullable } from "babylonjs/types";
  27302. import { Sprite } from "babylonjs/Sprites/sprite";
  27303. import { Scene } from "babylonjs/scene";
  27304. import { Vector2 } from "babylonjs/Maths/math.vector";
  27305. /**
  27306. * Interface used to define ActionEvent
  27307. */
  27308. export interface IActionEvent {
  27309. /** The mesh or sprite that triggered the action */
  27310. source: any;
  27311. /** The X mouse cursor position at the time of the event */
  27312. pointerX: number;
  27313. /** The Y mouse cursor position at the time of the event */
  27314. pointerY: number;
  27315. /** The mesh that is currently pointed at (can be null) */
  27316. meshUnderPointer: Nullable<AbstractMesh>;
  27317. /** the original (browser) event that triggered the ActionEvent */
  27318. sourceEvent?: any;
  27319. /** additional data for the event */
  27320. additionalData?: any;
  27321. }
  27322. /**
  27323. * ActionEvent is the event being sent when an action is triggered.
  27324. */
  27325. export class ActionEvent implements IActionEvent {
  27326. /** The mesh or sprite that triggered the action */
  27327. source: any;
  27328. /** The X mouse cursor position at the time of the event */
  27329. pointerX: number;
  27330. /** The Y mouse cursor position at the time of the event */
  27331. pointerY: number;
  27332. /** The mesh that is currently pointed at (can be null) */
  27333. meshUnderPointer: Nullable<AbstractMesh>;
  27334. /** the original (browser) event that triggered the ActionEvent */
  27335. sourceEvent?: any;
  27336. /** additional data for the event */
  27337. additionalData?: any;
  27338. /**
  27339. * Creates a new ActionEvent
  27340. * @param source The mesh or sprite that triggered the action
  27341. * @param pointerX The X mouse cursor position at the time of the event
  27342. * @param pointerY The Y mouse cursor position at the time of the event
  27343. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27344. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27345. * @param additionalData additional data for the event
  27346. */
  27347. constructor(
  27348. /** The mesh or sprite that triggered the action */
  27349. source: any,
  27350. /** The X mouse cursor position at the time of the event */
  27351. pointerX: number,
  27352. /** The Y mouse cursor position at the time of the event */
  27353. pointerY: number,
  27354. /** The mesh that is currently pointed at (can be null) */
  27355. meshUnderPointer: Nullable<AbstractMesh>,
  27356. /** the original (browser) event that triggered the ActionEvent */
  27357. sourceEvent?: any,
  27358. /** additional data for the event */
  27359. additionalData?: any);
  27360. /**
  27361. * Helper function to auto-create an ActionEvent from a source mesh.
  27362. * @param source The source mesh that triggered the event
  27363. * @param evt The original (browser) event
  27364. * @param additionalData additional data for the event
  27365. * @returns the new ActionEvent
  27366. */
  27367. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27368. /**
  27369. * Helper function to auto-create an ActionEvent from a source sprite
  27370. * @param source The source sprite that triggered the event
  27371. * @param scene Scene associated with the sprite
  27372. * @param evt The original (browser) event
  27373. * @param additionalData additional data for the event
  27374. * @returns the new ActionEvent
  27375. */
  27376. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27377. /**
  27378. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27379. * @param scene the scene where the event occurred
  27380. * @param evt The original (browser) event
  27381. * @returns the new ActionEvent
  27382. */
  27383. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27384. /**
  27385. * Helper function to auto-create an ActionEvent from a primitive
  27386. * @param prim defines the target primitive
  27387. * @param pointerPos defines the pointer position
  27388. * @param evt The original (browser) event
  27389. * @param additionalData additional data for the event
  27390. * @returns the new ActionEvent
  27391. */
  27392. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27393. }
  27394. }
  27395. declare module "babylonjs/Actions/abstractActionManager" {
  27396. import { IDisposable } from "babylonjs/scene";
  27397. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27398. import { IAction } from "babylonjs/Actions/action";
  27399. import { Nullable } from "babylonjs/types";
  27400. /**
  27401. * Abstract class used to decouple action Manager from scene and meshes.
  27402. * Do not instantiate.
  27403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27404. */
  27405. export abstract class AbstractActionManager implements IDisposable {
  27406. /** Gets the list of active triggers */
  27407. static Triggers: {
  27408. [key: string]: number;
  27409. };
  27410. /** Gets the cursor to use when hovering items */
  27411. hoverCursor: string;
  27412. /** Gets the list of actions */
  27413. actions: IAction[];
  27414. /**
  27415. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27416. */
  27417. isRecursive: boolean;
  27418. /**
  27419. * Releases all associated resources
  27420. */
  27421. abstract dispose(): void;
  27422. /**
  27423. * Does this action manager has pointer triggers
  27424. */
  27425. abstract readonly hasPointerTriggers: boolean;
  27426. /**
  27427. * Does this action manager has pick triggers
  27428. */
  27429. abstract readonly hasPickTriggers: boolean;
  27430. /**
  27431. * Process a specific trigger
  27432. * @param trigger defines the trigger to process
  27433. * @param evt defines the event details to be processed
  27434. */
  27435. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27436. /**
  27437. * Does this action manager handles actions of any of the given triggers
  27438. * @param triggers defines the triggers to be tested
  27439. * @return a boolean indicating whether one (or more) of the triggers is handled
  27440. */
  27441. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27442. /**
  27443. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27444. * speed.
  27445. * @param triggerA defines the trigger to be tested
  27446. * @param triggerB defines the trigger to be tested
  27447. * @return a boolean indicating whether one (or more) of the triggers is handled
  27448. */
  27449. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27450. /**
  27451. * Does this action manager handles actions of a given trigger
  27452. * @param trigger defines the trigger to be tested
  27453. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27454. * @return whether the trigger is handled
  27455. */
  27456. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27457. /**
  27458. * Serialize this manager to a JSON object
  27459. * @param name defines the property name to store this manager
  27460. * @returns a JSON representation of this manager
  27461. */
  27462. abstract serialize(name: string): any;
  27463. /**
  27464. * Registers an action to this action manager
  27465. * @param action defines the action to be registered
  27466. * @return the action amended (prepared) after registration
  27467. */
  27468. abstract registerAction(action: IAction): Nullable<IAction>;
  27469. /**
  27470. * Unregisters an action to this action manager
  27471. * @param action defines the action to be unregistered
  27472. * @return a boolean indicating whether the action has been unregistered
  27473. */
  27474. abstract unregisterAction(action: IAction): Boolean;
  27475. /**
  27476. * Does exist one action manager with at least one trigger
  27477. **/
  27478. static readonly HasTriggers: boolean;
  27479. /**
  27480. * Does exist one action manager with at least one pick trigger
  27481. **/
  27482. static readonly HasPickTriggers: boolean;
  27483. /**
  27484. * Does exist one action manager that handles actions of a given trigger
  27485. * @param trigger defines the trigger to be tested
  27486. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27487. **/
  27488. static HasSpecificTrigger(trigger: number): boolean;
  27489. }
  27490. }
  27491. declare module "babylonjs/node" {
  27492. import { Scene } from "babylonjs/scene";
  27493. import { Nullable } from "babylonjs/types";
  27494. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27495. import { Engine } from "babylonjs/Engines/engine";
  27496. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27497. import { Observable } from "babylonjs/Misc/observable";
  27498. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27500. import { Animatable } from "babylonjs/Animations/animatable";
  27501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27502. import { Animation } from "babylonjs/Animations/animation";
  27503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27505. /**
  27506. * Defines how a node can be built from a string name.
  27507. */
  27508. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27509. /**
  27510. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27511. */
  27512. export class Node implements IBehaviorAware<Node> {
  27513. /** @hidden */
  27514. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27515. private static _NodeConstructors;
  27516. /**
  27517. * Add a new node constructor
  27518. * @param type defines the type name of the node to construct
  27519. * @param constructorFunc defines the constructor function
  27520. */
  27521. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27522. /**
  27523. * Returns a node constructor based on type name
  27524. * @param type defines the type name
  27525. * @param name defines the new node name
  27526. * @param scene defines the hosting scene
  27527. * @param options defines optional options to transmit to constructors
  27528. * @returns the new constructor or null
  27529. */
  27530. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27531. /**
  27532. * Gets or sets the name of the node
  27533. */
  27534. name: string;
  27535. /**
  27536. * Gets or sets the id of the node
  27537. */
  27538. id: string;
  27539. /**
  27540. * Gets or sets the unique id of the node
  27541. */
  27542. uniqueId: number;
  27543. /**
  27544. * Gets or sets a string used to store user defined state for the node
  27545. */
  27546. state: string;
  27547. /**
  27548. * Gets or sets an object used to store user defined information for the node
  27549. */
  27550. metadata: any;
  27551. /**
  27552. * For internal use only. Please do not use.
  27553. */
  27554. reservedDataStore: any;
  27555. /**
  27556. * List of inspectable custom properties (used by the Inspector)
  27557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27558. */
  27559. inspectableCustomProperties: IInspectable[];
  27560. private _doNotSerialize;
  27561. /**
  27562. * Gets or sets a boolean used to define if the node must be serialized
  27563. */
  27564. doNotSerialize: boolean;
  27565. /** @hidden */
  27566. _isDisposed: boolean;
  27567. /**
  27568. * Gets a list of Animations associated with the node
  27569. */
  27570. animations: import("babylonjs/Animations/animation").Animation[];
  27571. protected _ranges: {
  27572. [name: string]: Nullable<AnimationRange>;
  27573. };
  27574. /**
  27575. * Callback raised when the node is ready to be used
  27576. */
  27577. onReady: Nullable<(node: Node) => void>;
  27578. private _isEnabled;
  27579. private _isParentEnabled;
  27580. private _isReady;
  27581. /** @hidden */
  27582. _currentRenderId: number;
  27583. private _parentUpdateId;
  27584. /** @hidden */
  27585. _childUpdateId: number;
  27586. /** @hidden */
  27587. _waitingParentId: Nullable<string>;
  27588. /** @hidden */
  27589. _scene: Scene;
  27590. /** @hidden */
  27591. _cache: any;
  27592. private _parentNode;
  27593. private _children;
  27594. /** @hidden */
  27595. _worldMatrix: Matrix;
  27596. /** @hidden */
  27597. _worldMatrixDeterminant: number;
  27598. /** @hidden */
  27599. _worldMatrixDeterminantIsDirty: boolean;
  27600. /** @hidden */
  27601. private _sceneRootNodesIndex;
  27602. /**
  27603. * Gets a boolean indicating if the node has been disposed
  27604. * @returns true if the node was disposed
  27605. */
  27606. isDisposed(): boolean;
  27607. /**
  27608. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27609. * @see https://doc.babylonjs.com/how_to/parenting
  27610. */
  27611. parent: Nullable<Node>;
  27612. private addToSceneRootNodes;
  27613. private removeFromSceneRootNodes;
  27614. private _animationPropertiesOverride;
  27615. /**
  27616. * Gets or sets the animation properties override
  27617. */
  27618. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27619. /**
  27620. * Gets a string idenfifying the name of the class
  27621. * @returns "Node" string
  27622. */
  27623. getClassName(): string;
  27624. /** @hidden */
  27625. readonly _isNode: boolean;
  27626. /**
  27627. * An event triggered when the mesh is disposed
  27628. */
  27629. onDisposeObservable: Observable<Node>;
  27630. private _onDisposeObserver;
  27631. /**
  27632. * Sets a callback that will be raised when the node will be disposed
  27633. */
  27634. onDispose: () => void;
  27635. /**
  27636. * Creates a new Node
  27637. * @param name the name and id to be given to this node
  27638. * @param scene the scene this node will be added to
  27639. * @param addToRootNodes the node will be added to scene.rootNodes
  27640. */
  27641. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27642. /**
  27643. * Gets the scene of the node
  27644. * @returns a scene
  27645. */
  27646. getScene(): Scene;
  27647. /**
  27648. * Gets the engine of the node
  27649. * @returns a Engine
  27650. */
  27651. getEngine(): Engine;
  27652. private _behaviors;
  27653. /**
  27654. * Attach a behavior to the node
  27655. * @see http://doc.babylonjs.com/features/behaviour
  27656. * @param behavior defines the behavior to attach
  27657. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27658. * @returns the current Node
  27659. */
  27660. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27661. /**
  27662. * Remove an attached behavior
  27663. * @see http://doc.babylonjs.com/features/behaviour
  27664. * @param behavior defines the behavior to attach
  27665. * @returns the current Node
  27666. */
  27667. removeBehavior(behavior: Behavior<Node>): Node;
  27668. /**
  27669. * Gets the list of attached behaviors
  27670. * @see http://doc.babylonjs.com/features/behaviour
  27671. */
  27672. readonly behaviors: Behavior<Node>[];
  27673. /**
  27674. * Gets an attached behavior by name
  27675. * @param name defines the name of the behavior to look for
  27676. * @see http://doc.babylonjs.com/features/behaviour
  27677. * @returns null if behavior was not found else the requested behavior
  27678. */
  27679. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27680. /**
  27681. * Returns the latest update of the World matrix
  27682. * @returns a Matrix
  27683. */
  27684. getWorldMatrix(): Matrix;
  27685. /** @hidden */
  27686. _getWorldMatrixDeterminant(): number;
  27687. /**
  27688. * Returns directly the latest state of the mesh World matrix.
  27689. * A Matrix is returned.
  27690. */
  27691. readonly worldMatrixFromCache: Matrix;
  27692. /** @hidden */
  27693. _initCache(): void;
  27694. /** @hidden */
  27695. updateCache(force?: boolean): void;
  27696. /** @hidden */
  27697. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27698. /** @hidden */
  27699. _updateCache(ignoreParentClass?: boolean): void;
  27700. /** @hidden */
  27701. _isSynchronized(): boolean;
  27702. /** @hidden */
  27703. _markSyncedWithParent(): void;
  27704. /** @hidden */
  27705. isSynchronizedWithParent(): boolean;
  27706. /** @hidden */
  27707. isSynchronized(): boolean;
  27708. /**
  27709. * Is this node ready to be used/rendered
  27710. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27711. * @return true if the node is ready
  27712. */
  27713. isReady(completeCheck?: boolean): boolean;
  27714. /**
  27715. * Is this node enabled?
  27716. * 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
  27717. * @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
  27718. * @return whether this node (and its parent) is enabled
  27719. */
  27720. isEnabled(checkAncestors?: boolean): boolean;
  27721. /** @hidden */
  27722. protected _syncParentEnabledState(): void;
  27723. /**
  27724. * Set the enabled state of this node
  27725. * @param value defines the new enabled state
  27726. */
  27727. setEnabled(value: boolean): void;
  27728. /**
  27729. * Is this node a descendant of the given node?
  27730. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27731. * @param ancestor defines the parent node to inspect
  27732. * @returns a boolean indicating if this node is a descendant of the given node
  27733. */
  27734. isDescendantOf(ancestor: Node): boolean;
  27735. /** @hidden */
  27736. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27737. /**
  27738. * Will return all nodes that have this node as ascendant
  27739. * @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
  27740. * @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
  27741. * @return all children nodes of all types
  27742. */
  27743. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27744. /**
  27745. * Get all child-meshes of this node
  27746. * @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)
  27747. * @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
  27748. * @returns an array of AbstractMesh
  27749. */
  27750. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27751. /**
  27752. * Get all direct children of this node
  27753. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27754. * @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)
  27755. * @returns an array of Node
  27756. */
  27757. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27758. /** @hidden */
  27759. _setReady(state: boolean): void;
  27760. /**
  27761. * Get an animation by name
  27762. * @param name defines the name of the animation to look for
  27763. * @returns null if not found else the requested animation
  27764. */
  27765. getAnimationByName(name: string): Nullable<Animation>;
  27766. /**
  27767. * Creates an animation range for this node
  27768. * @param name defines the name of the range
  27769. * @param from defines the starting key
  27770. * @param to defines the end key
  27771. */
  27772. createAnimationRange(name: string, from: number, to: number): void;
  27773. /**
  27774. * Delete a specific animation range
  27775. * @param name defines the name of the range to delete
  27776. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27777. */
  27778. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27779. /**
  27780. * Get an animation range by name
  27781. * @param name defines the name of the animation range to look for
  27782. * @returns null if not found else the requested animation range
  27783. */
  27784. getAnimationRange(name: string): Nullable<AnimationRange>;
  27785. /**
  27786. * Gets the list of all animation ranges defined on this node
  27787. * @returns an array
  27788. */
  27789. getAnimationRanges(): Nullable<AnimationRange>[];
  27790. /**
  27791. * Will start the animation sequence
  27792. * @param name defines the range frames for animation sequence
  27793. * @param loop defines if the animation should loop (false by default)
  27794. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27795. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27796. * @returns the object created for this animation. If range does not exist, it will return null
  27797. */
  27798. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27799. /**
  27800. * Serialize animation ranges into a JSON compatible object
  27801. * @returns serialization object
  27802. */
  27803. serializeAnimationRanges(): any;
  27804. /**
  27805. * Computes the world matrix of the node
  27806. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27807. * @returns the world matrix
  27808. */
  27809. computeWorldMatrix(force?: boolean): Matrix;
  27810. /**
  27811. * Releases resources associated with this node.
  27812. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27813. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27814. */
  27815. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27816. /**
  27817. * Parse animation range data from a serialization object and store them into a given node
  27818. * @param node defines where to store the animation ranges
  27819. * @param parsedNode defines the serialization object to read data from
  27820. * @param scene defines the hosting scene
  27821. */
  27822. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27823. /**
  27824. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27825. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27826. * @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
  27827. * @returns the new bounding vectors
  27828. */
  27829. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27830. min: Vector3;
  27831. max: Vector3;
  27832. };
  27833. }
  27834. }
  27835. declare module "babylonjs/Animations/animation" {
  27836. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27837. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27838. import { Color3 } from "babylonjs/Maths/math.color";
  27839. import { Nullable } from "babylonjs/types";
  27840. import { Scene } from "babylonjs/scene";
  27841. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27842. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27843. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27844. import { Node } from "babylonjs/node";
  27845. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27846. import { Size } from "babylonjs/Maths/math.size";
  27847. import { Animatable } from "babylonjs/Animations/animatable";
  27848. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27849. /**
  27850. * @hidden
  27851. */
  27852. export class _IAnimationState {
  27853. key: number;
  27854. repeatCount: number;
  27855. workValue?: any;
  27856. loopMode?: number;
  27857. offsetValue?: any;
  27858. highLimitValue?: any;
  27859. }
  27860. /**
  27861. * Class used to store any kind of animation
  27862. */
  27863. export class Animation {
  27864. /**Name of the animation */
  27865. name: string;
  27866. /**Property to animate */
  27867. targetProperty: string;
  27868. /**The frames per second of the animation */
  27869. framePerSecond: number;
  27870. /**The data type of the animation */
  27871. dataType: number;
  27872. /**The loop mode of the animation */
  27873. loopMode?: number | undefined;
  27874. /**Specifies if blending should be enabled */
  27875. enableBlending?: boolean | undefined;
  27876. /**
  27877. * Use matrix interpolation instead of using direct key value when animating matrices
  27878. */
  27879. static AllowMatricesInterpolation: boolean;
  27880. /**
  27881. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27882. */
  27883. static AllowMatrixDecomposeForInterpolation: boolean;
  27884. /**
  27885. * Stores the key frames of the animation
  27886. */
  27887. private _keys;
  27888. /**
  27889. * Stores the easing function of the animation
  27890. */
  27891. private _easingFunction;
  27892. /**
  27893. * @hidden Internal use only
  27894. */
  27895. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27896. /**
  27897. * The set of event that will be linked to this animation
  27898. */
  27899. private _events;
  27900. /**
  27901. * Stores an array of target property paths
  27902. */
  27903. targetPropertyPath: string[];
  27904. /**
  27905. * Stores the blending speed of the animation
  27906. */
  27907. blendingSpeed: number;
  27908. /**
  27909. * Stores the animation ranges for the animation
  27910. */
  27911. private _ranges;
  27912. /**
  27913. * @hidden Internal use
  27914. */
  27915. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27916. /**
  27917. * Sets up an animation
  27918. * @param property The property to animate
  27919. * @param animationType The animation type to apply
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param easingFunction The easing function used in the animation
  27922. * @returns The created animation
  27923. */
  27924. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27925. /**
  27926. * Create and start an animation on a node
  27927. * @param name defines the name of the global animation that will be run on all nodes
  27928. * @param node defines the root node where the animation will take place
  27929. * @param targetProperty defines property to animate
  27930. * @param framePerSecond defines the number of frame per second yo use
  27931. * @param totalFrame defines the number of frames in total
  27932. * @param from defines the initial value
  27933. * @param to defines the final value
  27934. * @param loopMode defines which loop mode you want to use (off by default)
  27935. * @param easingFunction defines the easing function to use (linear by default)
  27936. * @param onAnimationEnd defines the callback to call when animation end
  27937. * @returns the animatable created for this animation
  27938. */
  27939. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27940. /**
  27941. * Create and start an animation on a node and its descendants
  27942. * @param name defines the name of the global animation that will be run on all nodes
  27943. * @param node defines the root node where the animation will take place
  27944. * @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
  27945. * @param targetProperty defines property to animate
  27946. * @param framePerSecond defines the number of frame per second to use
  27947. * @param totalFrame defines the number of frames in total
  27948. * @param from defines the initial value
  27949. * @param to defines the final value
  27950. * @param loopMode defines which loop mode you want to use (off by default)
  27951. * @param easingFunction defines the easing function to use (linear by default)
  27952. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27953. * @returns the list of animatables created for all nodes
  27954. * @example https://www.babylonjs-playground.com/#MH0VLI
  27955. */
  27956. 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[]>;
  27957. /**
  27958. * Creates a new animation, merges it with the existing animations and starts it
  27959. * @param name Name of the animation
  27960. * @param node Node which contains the scene that begins the animations
  27961. * @param targetProperty Specifies which property to animate
  27962. * @param framePerSecond The frames per second of the animation
  27963. * @param totalFrame The total number of frames
  27964. * @param from The frame at the beginning of the animation
  27965. * @param to The frame at the end of the animation
  27966. * @param loopMode Specifies the loop mode of the animation
  27967. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27968. * @param onAnimationEnd Callback to run once the animation is complete
  27969. * @returns Nullable animation
  27970. */
  27971. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27972. /**
  27973. * Transition property of an host to the target Value
  27974. * @param property The property to transition
  27975. * @param targetValue The target Value of the property
  27976. * @param host The object where the property to animate belongs
  27977. * @param scene Scene used to run the animation
  27978. * @param frameRate Framerate (in frame/s) to use
  27979. * @param transition The transition type we want to use
  27980. * @param duration The duration of the animation, in milliseconds
  27981. * @param onAnimationEnd Callback trigger at the end of the animation
  27982. * @returns Nullable animation
  27983. */
  27984. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27985. /**
  27986. * Return the array of runtime animations currently using this animation
  27987. */
  27988. readonly runtimeAnimations: RuntimeAnimation[];
  27989. /**
  27990. * Specifies if any of the runtime animations are currently running
  27991. */
  27992. readonly hasRunningRuntimeAnimations: boolean;
  27993. /**
  27994. * Initializes the animation
  27995. * @param name Name of the animation
  27996. * @param targetProperty Property to animate
  27997. * @param framePerSecond The frames per second of the animation
  27998. * @param dataType The data type of the animation
  27999. * @param loopMode The loop mode of the animation
  28000. * @param enableBlending Specifies if blending should be enabled
  28001. */
  28002. constructor(
  28003. /**Name of the animation */
  28004. name: string,
  28005. /**Property to animate */
  28006. targetProperty: string,
  28007. /**The frames per second of the animation */
  28008. framePerSecond: number,
  28009. /**The data type of the animation */
  28010. dataType: number,
  28011. /**The loop mode of the animation */
  28012. loopMode?: number | undefined,
  28013. /**Specifies if blending should be enabled */
  28014. enableBlending?: boolean | undefined);
  28015. /**
  28016. * Converts the animation to a string
  28017. * @param fullDetails support for multiple levels of logging within scene loading
  28018. * @returns String form of the animation
  28019. */
  28020. toString(fullDetails?: boolean): string;
  28021. /**
  28022. * Add an event to this animation
  28023. * @param event Event to add
  28024. */
  28025. addEvent(event: AnimationEvent): void;
  28026. /**
  28027. * Remove all events found at the given frame
  28028. * @param frame The frame to remove events from
  28029. */
  28030. removeEvents(frame: number): void;
  28031. /**
  28032. * Retrieves all the events from the animation
  28033. * @returns Events from the animation
  28034. */
  28035. getEvents(): AnimationEvent[];
  28036. /**
  28037. * Creates an animation range
  28038. * @param name Name of the animation range
  28039. * @param from Starting frame of the animation range
  28040. * @param to Ending frame of the animation
  28041. */
  28042. createRange(name: string, from: number, to: number): void;
  28043. /**
  28044. * Deletes an animation range by name
  28045. * @param name Name of the animation range to delete
  28046. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28047. */
  28048. deleteRange(name: string, deleteFrames?: boolean): void;
  28049. /**
  28050. * Gets the animation range by name, or null if not defined
  28051. * @param name Name of the animation range
  28052. * @returns Nullable animation range
  28053. */
  28054. getRange(name: string): Nullable<AnimationRange>;
  28055. /**
  28056. * Gets the key frames from the animation
  28057. * @returns The key frames of the animation
  28058. */
  28059. getKeys(): Array<IAnimationKey>;
  28060. /**
  28061. * Gets the highest frame rate of the animation
  28062. * @returns Highest frame rate of the animation
  28063. */
  28064. getHighestFrame(): number;
  28065. /**
  28066. * Gets the easing function of the animation
  28067. * @returns Easing function of the animation
  28068. */
  28069. getEasingFunction(): IEasingFunction;
  28070. /**
  28071. * Sets the easing function of the animation
  28072. * @param easingFunction A custom mathematical formula for animation
  28073. */
  28074. setEasingFunction(easingFunction: EasingFunction): void;
  28075. /**
  28076. * Interpolates a scalar linearly
  28077. * @param startValue Start value of the animation curve
  28078. * @param endValue End value of the animation curve
  28079. * @param gradient Scalar amount to interpolate
  28080. * @returns Interpolated scalar value
  28081. */
  28082. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28083. /**
  28084. * Interpolates a scalar cubically
  28085. * @param startValue Start value of the animation curve
  28086. * @param outTangent End tangent of the animation
  28087. * @param endValue End value of the animation curve
  28088. * @param inTangent Start tangent of the animation curve
  28089. * @param gradient Scalar amount to interpolate
  28090. * @returns Interpolated scalar value
  28091. */
  28092. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28093. /**
  28094. * Interpolates a quaternion using a spherical linear interpolation
  28095. * @param startValue Start value of the animation curve
  28096. * @param endValue End value of the animation curve
  28097. * @param gradient Scalar amount to interpolate
  28098. * @returns Interpolated quaternion value
  28099. */
  28100. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28101. /**
  28102. * Interpolates a quaternion cubically
  28103. * @param startValue Start value of the animation curve
  28104. * @param outTangent End tangent of the animation curve
  28105. * @param endValue End value of the animation curve
  28106. * @param inTangent Start tangent of the animation curve
  28107. * @param gradient Scalar amount to interpolate
  28108. * @returns Interpolated quaternion value
  28109. */
  28110. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28111. /**
  28112. * Interpolates a Vector3 linearl
  28113. * @param startValue Start value of the animation curve
  28114. * @param endValue End value of the animation curve
  28115. * @param gradient Scalar amount to interpolate
  28116. * @returns Interpolated scalar value
  28117. */
  28118. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28119. /**
  28120. * Interpolates a Vector3 cubically
  28121. * @param startValue Start value of the animation curve
  28122. * @param outTangent End tangent of the animation
  28123. * @param endValue End value of the animation curve
  28124. * @param inTangent Start tangent of the animation curve
  28125. * @param gradient Scalar amount to interpolate
  28126. * @returns InterpolatedVector3 value
  28127. */
  28128. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28129. /**
  28130. * Interpolates a Vector2 linearly
  28131. * @param startValue Start value of the animation curve
  28132. * @param endValue End value of the animation curve
  28133. * @param gradient Scalar amount to interpolate
  28134. * @returns Interpolated Vector2 value
  28135. */
  28136. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28137. /**
  28138. * Interpolates a Vector2 cubically
  28139. * @param startValue Start value of the animation curve
  28140. * @param outTangent End tangent of the animation
  28141. * @param endValue End value of the animation curve
  28142. * @param inTangent Start tangent of the animation curve
  28143. * @param gradient Scalar amount to interpolate
  28144. * @returns Interpolated Vector2 value
  28145. */
  28146. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28147. /**
  28148. * Interpolates a size linearly
  28149. * @param startValue Start value of the animation curve
  28150. * @param endValue End value of the animation curve
  28151. * @param gradient Scalar amount to interpolate
  28152. * @returns Interpolated Size value
  28153. */
  28154. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28155. /**
  28156. * Interpolates a Color3 linearly
  28157. * @param startValue Start value of the animation curve
  28158. * @param endValue End value of the animation curve
  28159. * @param gradient Scalar amount to interpolate
  28160. * @returns Interpolated Color3 value
  28161. */
  28162. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28163. /**
  28164. * @hidden Internal use only
  28165. */
  28166. _getKeyValue(value: any): any;
  28167. /**
  28168. * @hidden Internal use only
  28169. */
  28170. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28171. /**
  28172. * Defines the function to use to interpolate matrices
  28173. * @param startValue defines the start matrix
  28174. * @param endValue defines the end matrix
  28175. * @param gradient defines the gradient between both matrices
  28176. * @param result defines an optional target matrix where to store the interpolation
  28177. * @returns the interpolated matrix
  28178. */
  28179. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28180. /**
  28181. * Makes a copy of the animation
  28182. * @returns Cloned animation
  28183. */
  28184. clone(): Animation;
  28185. /**
  28186. * Sets the key frames of the animation
  28187. * @param values The animation key frames to set
  28188. */
  28189. setKeys(values: Array<IAnimationKey>): void;
  28190. /**
  28191. * Serializes the animation to an object
  28192. * @returns Serialized object
  28193. */
  28194. serialize(): any;
  28195. /**
  28196. * Float animation type
  28197. */
  28198. private static _ANIMATIONTYPE_FLOAT;
  28199. /**
  28200. * Vector3 animation type
  28201. */
  28202. private static _ANIMATIONTYPE_VECTOR3;
  28203. /**
  28204. * Quaternion animation type
  28205. */
  28206. private static _ANIMATIONTYPE_QUATERNION;
  28207. /**
  28208. * Matrix animation type
  28209. */
  28210. private static _ANIMATIONTYPE_MATRIX;
  28211. /**
  28212. * Color3 animation type
  28213. */
  28214. private static _ANIMATIONTYPE_COLOR3;
  28215. /**
  28216. * Vector2 animation type
  28217. */
  28218. private static _ANIMATIONTYPE_VECTOR2;
  28219. /**
  28220. * Size animation type
  28221. */
  28222. private static _ANIMATIONTYPE_SIZE;
  28223. /**
  28224. * Relative Loop Mode
  28225. */
  28226. private static _ANIMATIONLOOPMODE_RELATIVE;
  28227. /**
  28228. * Cycle Loop Mode
  28229. */
  28230. private static _ANIMATIONLOOPMODE_CYCLE;
  28231. /**
  28232. * Constant Loop Mode
  28233. */
  28234. private static _ANIMATIONLOOPMODE_CONSTANT;
  28235. /**
  28236. * Get the float animation type
  28237. */
  28238. static readonly ANIMATIONTYPE_FLOAT: number;
  28239. /**
  28240. * Get the Vector3 animation type
  28241. */
  28242. static readonly ANIMATIONTYPE_VECTOR3: number;
  28243. /**
  28244. * Get the Vector2 animation type
  28245. */
  28246. static readonly ANIMATIONTYPE_VECTOR2: number;
  28247. /**
  28248. * Get the Size animation type
  28249. */
  28250. static readonly ANIMATIONTYPE_SIZE: number;
  28251. /**
  28252. * Get the Quaternion animation type
  28253. */
  28254. static readonly ANIMATIONTYPE_QUATERNION: number;
  28255. /**
  28256. * Get the Matrix animation type
  28257. */
  28258. static readonly ANIMATIONTYPE_MATRIX: number;
  28259. /**
  28260. * Get the Color3 animation type
  28261. */
  28262. static readonly ANIMATIONTYPE_COLOR3: number;
  28263. /**
  28264. * Get the Relative Loop Mode
  28265. */
  28266. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28267. /**
  28268. * Get the Cycle Loop Mode
  28269. */
  28270. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28271. /**
  28272. * Get the Constant Loop Mode
  28273. */
  28274. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28275. /** @hidden */
  28276. static _UniversalLerp(left: any, right: any, amount: number): any;
  28277. /**
  28278. * Parses an animation object and creates an animation
  28279. * @param parsedAnimation Parsed animation object
  28280. * @returns Animation object
  28281. */
  28282. static Parse(parsedAnimation: any): Animation;
  28283. /**
  28284. * Appends the serialized animations from the source animations
  28285. * @param source Source containing the animations
  28286. * @param destination Target to store the animations
  28287. */
  28288. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28289. }
  28290. }
  28291. declare module "babylonjs/Animations/animatable.interface" {
  28292. import { Nullable } from "babylonjs/types";
  28293. import { Animation } from "babylonjs/Animations/animation";
  28294. /**
  28295. * Interface containing an array of animations
  28296. */
  28297. export interface IAnimatable {
  28298. /**
  28299. * Array of animations
  28300. */
  28301. animations: Nullable<Array<Animation>>;
  28302. }
  28303. }
  28304. declare module "babylonjs/Materials/fresnelParameters" {
  28305. import { Color3 } from "babylonjs/Maths/math.color";
  28306. /**
  28307. * This represents all the required information to add a fresnel effect on a material:
  28308. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28309. */
  28310. export class FresnelParameters {
  28311. private _isEnabled;
  28312. /**
  28313. * Define if the fresnel effect is enable or not.
  28314. */
  28315. isEnabled: boolean;
  28316. /**
  28317. * Define the color used on edges (grazing angle)
  28318. */
  28319. leftColor: Color3;
  28320. /**
  28321. * Define the color used on center
  28322. */
  28323. rightColor: Color3;
  28324. /**
  28325. * Define bias applied to computed fresnel term
  28326. */
  28327. bias: number;
  28328. /**
  28329. * Defined the power exponent applied to fresnel term
  28330. */
  28331. power: number;
  28332. /**
  28333. * Clones the current fresnel and its valuues
  28334. * @returns a clone fresnel configuration
  28335. */
  28336. clone(): FresnelParameters;
  28337. /**
  28338. * Serializes the current fresnel parameters to a JSON representation.
  28339. * @return the JSON serialization
  28340. */
  28341. serialize(): any;
  28342. /**
  28343. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28344. * @param parsedFresnelParameters Define the JSON representation
  28345. * @returns the parsed parameters
  28346. */
  28347. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28348. }
  28349. }
  28350. declare module "babylonjs/Misc/decorators" {
  28351. import { Nullable } from "babylonjs/types";
  28352. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28353. import { Scene } from "babylonjs/scene";
  28354. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28355. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28356. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28357. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28358. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28359. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28360. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28361. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. /**
  28368. * Decorator used to define property that can be serialized as reference to a camera
  28369. * @param sourceName defines the name of the property to decorate
  28370. */
  28371. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28372. /**
  28373. * Class used to help serialization objects
  28374. */
  28375. export class SerializationHelper {
  28376. /** @hidden */
  28377. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28378. /** @hidden */
  28379. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28380. /** @hidden */
  28381. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28382. /** @hidden */
  28383. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28384. /**
  28385. * Appends the serialized animations from the source animations
  28386. * @param source Source containing the animations
  28387. * @param destination Target to store the animations
  28388. */
  28389. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28390. /**
  28391. * Static function used to serialized a specific entity
  28392. * @param entity defines the entity to serialize
  28393. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28394. * @returns a JSON compatible object representing the serialization of the entity
  28395. */
  28396. static Serialize<T>(entity: T, serializationObject?: any): any;
  28397. /**
  28398. * Creates a new entity from a serialization data object
  28399. * @param creationFunction defines a function used to instanciated the new entity
  28400. * @param source defines the source serialization data
  28401. * @param scene defines the hosting scene
  28402. * @param rootUrl defines the root url for resources
  28403. * @returns a new entity
  28404. */
  28405. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28406. /**
  28407. * Clones an object
  28408. * @param creationFunction defines the function used to instanciate the new object
  28409. * @param source defines the source object
  28410. * @returns the cloned object
  28411. */
  28412. static Clone<T>(creationFunction: () => T, source: T): T;
  28413. /**
  28414. * Instanciates a new object based on a source one (some data will be shared between both object)
  28415. * @param creationFunction defines the function used to instanciate the new object
  28416. * @param source defines the source object
  28417. * @returns the new object
  28418. */
  28419. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28420. }
  28421. }
  28422. declare module "babylonjs/Misc/guid" {
  28423. /**
  28424. * Class used to manipulate GUIDs
  28425. */
  28426. export class GUID {
  28427. /**
  28428. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28429. * Be aware Math.random() could cause collisions, but:
  28430. * "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"
  28431. * @returns a pseudo random id
  28432. */
  28433. static RandomId(): string;
  28434. }
  28435. }
  28436. declare module "babylonjs/Materials/Textures/baseTexture" {
  28437. import { Observable } from "babylonjs/Misc/observable";
  28438. import { Nullable } from "babylonjs/types";
  28439. import { Scene } from "babylonjs/scene";
  28440. import { Matrix } from "babylonjs/Maths/math.vector";
  28441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28442. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28443. import { ISize } from "babylonjs/Maths/math.size";
  28444. /**
  28445. * Base class of all the textures in babylon.
  28446. * It groups all the common properties the materials, post process, lights... might need
  28447. * in order to make a correct use of the texture.
  28448. */
  28449. export class BaseTexture implements IAnimatable {
  28450. /**
  28451. * Default anisotropic filtering level for the application.
  28452. * It is set to 4 as a good tradeoff between perf and quality.
  28453. */
  28454. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28455. /**
  28456. * Gets or sets the unique id of the texture
  28457. */
  28458. uniqueId: number;
  28459. /**
  28460. * Define the name of the texture.
  28461. */
  28462. name: string;
  28463. /**
  28464. * Gets or sets an object used to store user defined information.
  28465. */
  28466. metadata: any;
  28467. /**
  28468. * For internal use only. Please do not use.
  28469. */
  28470. reservedDataStore: any;
  28471. private _hasAlpha;
  28472. /**
  28473. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28474. */
  28475. hasAlpha: boolean;
  28476. /**
  28477. * Defines if the alpha value should be determined via the rgb values.
  28478. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28479. */
  28480. getAlphaFromRGB: boolean;
  28481. /**
  28482. * Intensity or strength of the texture.
  28483. * It is commonly used by materials to fine tune the intensity of the texture
  28484. */
  28485. level: number;
  28486. /**
  28487. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28488. * This is part of the texture as textures usually maps to one uv set.
  28489. */
  28490. coordinatesIndex: number;
  28491. private _coordinatesMode;
  28492. /**
  28493. * How a texture is mapped.
  28494. *
  28495. * | Value | Type | Description |
  28496. * | ----- | ----------------------------------- | ----------- |
  28497. * | 0 | EXPLICIT_MODE | |
  28498. * | 1 | SPHERICAL_MODE | |
  28499. * | 2 | PLANAR_MODE | |
  28500. * | 3 | CUBIC_MODE | |
  28501. * | 4 | PROJECTION_MODE | |
  28502. * | 5 | SKYBOX_MODE | |
  28503. * | 6 | INVCUBIC_MODE | |
  28504. * | 7 | EQUIRECTANGULAR_MODE | |
  28505. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28506. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28507. */
  28508. coordinatesMode: number;
  28509. /**
  28510. * | Value | Type | Description |
  28511. * | ----- | ------------------ | ----------- |
  28512. * | 0 | CLAMP_ADDRESSMODE | |
  28513. * | 1 | WRAP_ADDRESSMODE | |
  28514. * | 2 | MIRROR_ADDRESSMODE | |
  28515. */
  28516. wrapU: number;
  28517. /**
  28518. * | Value | Type | Description |
  28519. * | ----- | ------------------ | ----------- |
  28520. * | 0 | CLAMP_ADDRESSMODE | |
  28521. * | 1 | WRAP_ADDRESSMODE | |
  28522. * | 2 | MIRROR_ADDRESSMODE | |
  28523. */
  28524. wrapV: number;
  28525. /**
  28526. * | Value | Type | Description |
  28527. * | ----- | ------------------ | ----------- |
  28528. * | 0 | CLAMP_ADDRESSMODE | |
  28529. * | 1 | WRAP_ADDRESSMODE | |
  28530. * | 2 | MIRROR_ADDRESSMODE | |
  28531. */
  28532. wrapR: number;
  28533. /**
  28534. * With compliant hardware and browser (supporting anisotropic filtering)
  28535. * this defines the level of anisotropic filtering in the texture.
  28536. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28537. */
  28538. anisotropicFilteringLevel: number;
  28539. /**
  28540. * Define if the texture is a cube texture or if false a 2d texture.
  28541. */
  28542. isCube: boolean;
  28543. /**
  28544. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28545. */
  28546. is3D: boolean;
  28547. /**
  28548. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28549. * HDR texture are usually stored in linear space.
  28550. * This only impacts the PBR and Background materials
  28551. */
  28552. gammaSpace: boolean;
  28553. /**
  28554. * Gets or sets whether or not the texture contains RGBD data.
  28555. */
  28556. isRGBD: boolean;
  28557. /**
  28558. * Is Z inverted in the texture (useful in a cube texture).
  28559. */
  28560. invertZ: boolean;
  28561. /**
  28562. * Are mip maps generated for this texture or not.
  28563. */
  28564. readonly noMipmap: boolean;
  28565. /**
  28566. * @hidden
  28567. */
  28568. lodLevelInAlpha: boolean;
  28569. /**
  28570. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28571. */
  28572. lodGenerationOffset: number;
  28573. /**
  28574. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28575. */
  28576. lodGenerationScale: number;
  28577. /**
  28578. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28579. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28580. * average roughness values.
  28581. */
  28582. linearSpecularLOD: boolean;
  28583. /**
  28584. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28585. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28586. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28587. */
  28588. irradianceTexture: Nullable<BaseTexture>;
  28589. /**
  28590. * Define if the texture is a render target.
  28591. */
  28592. isRenderTarget: boolean;
  28593. /**
  28594. * Define the unique id of the texture in the scene.
  28595. */
  28596. readonly uid: string;
  28597. /**
  28598. * Return a string representation of the texture.
  28599. * @returns the texture as a string
  28600. */
  28601. toString(): string;
  28602. /**
  28603. * Get the class name of the texture.
  28604. * @returns "BaseTexture"
  28605. */
  28606. getClassName(): string;
  28607. /**
  28608. * Define the list of animation attached to the texture.
  28609. */
  28610. animations: import("babylonjs/Animations/animation").Animation[];
  28611. /**
  28612. * An event triggered when the texture is disposed.
  28613. */
  28614. onDisposeObservable: Observable<BaseTexture>;
  28615. private _onDisposeObserver;
  28616. /**
  28617. * Callback triggered when the texture has been disposed.
  28618. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28619. */
  28620. onDispose: () => void;
  28621. /**
  28622. * Define the current state of the loading sequence when in delayed load mode.
  28623. */
  28624. delayLoadState: number;
  28625. private _scene;
  28626. /** @hidden */
  28627. _texture: Nullable<InternalTexture>;
  28628. private _uid;
  28629. /**
  28630. * Define if the texture is preventinga material to render or not.
  28631. * If not and the texture is not ready, the engine will use a default black texture instead.
  28632. */
  28633. readonly isBlocking: boolean;
  28634. /**
  28635. * Instantiates a new BaseTexture.
  28636. * Base class of all the textures in babylon.
  28637. * It groups all the common properties the materials, post process, lights... might need
  28638. * in order to make a correct use of the texture.
  28639. * @param scene Define the scene the texture blongs to
  28640. */
  28641. constructor(scene: Nullable<Scene>);
  28642. /**
  28643. * Get the scene the texture belongs to.
  28644. * @returns the scene or null if undefined
  28645. */
  28646. getScene(): Nullable<Scene>;
  28647. /**
  28648. * Get the texture transform matrix used to offset tile the texture for istance.
  28649. * @returns the transformation matrix
  28650. */
  28651. getTextureMatrix(): Matrix;
  28652. /**
  28653. * Get the texture reflection matrix used to rotate/transform the reflection.
  28654. * @returns the reflection matrix
  28655. */
  28656. getReflectionTextureMatrix(): Matrix;
  28657. /**
  28658. * Get the underlying lower level texture from Babylon.
  28659. * @returns the insternal texture
  28660. */
  28661. getInternalTexture(): Nullable<InternalTexture>;
  28662. /**
  28663. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28664. * @returns true if ready or not blocking
  28665. */
  28666. isReadyOrNotBlocking(): boolean;
  28667. /**
  28668. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28669. * @returns true if fully ready
  28670. */
  28671. isReady(): boolean;
  28672. private _cachedSize;
  28673. /**
  28674. * Get the size of the texture.
  28675. * @returns the texture size.
  28676. */
  28677. getSize(): ISize;
  28678. /**
  28679. * Get the base size of the texture.
  28680. * It can be different from the size if the texture has been resized for POT for instance
  28681. * @returns the base size
  28682. */
  28683. getBaseSize(): ISize;
  28684. /**
  28685. * Update the sampling mode of the texture.
  28686. * Default is Trilinear mode.
  28687. *
  28688. * | Value | Type | Description |
  28689. * | ----- | ------------------ | ----------- |
  28690. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28691. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28692. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28693. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28694. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28695. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28696. * | 7 | NEAREST_LINEAR | |
  28697. * | 8 | NEAREST_NEAREST | |
  28698. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28699. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28700. * | 11 | LINEAR_LINEAR | |
  28701. * | 12 | LINEAR_NEAREST | |
  28702. *
  28703. * > _mag_: magnification filter (close to the viewer)
  28704. * > _min_: minification filter (far from the viewer)
  28705. * > _mip_: filter used between mip map levels
  28706. *@param samplingMode Define the new sampling mode of the texture
  28707. */
  28708. updateSamplingMode(samplingMode: number): void;
  28709. /**
  28710. * Scales the texture if is `canRescale()`
  28711. * @param ratio the resize factor we want to use to rescale
  28712. */
  28713. scale(ratio: number): void;
  28714. /**
  28715. * Get if the texture can rescale.
  28716. */
  28717. readonly canRescale: boolean;
  28718. /** @hidden */
  28719. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28720. /** @hidden */
  28721. _rebuild(): void;
  28722. /**
  28723. * Triggers the load sequence in delayed load mode.
  28724. */
  28725. delayLoad(): void;
  28726. /**
  28727. * Clones the texture.
  28728. * @returns the cloned texture
  28729. */
  28730. clone(): Nullable<BaseTexture>;
  28731. /**
  28732. * Get the texture underlying type (INT, FLOAT...)
  28733. */
  28734. readonly textureType: number;
  28735. /**
  28736. * Get the texture underlying format (RGB, RGBA...)
  28737. */
  28738. readonly textureFormat: number;
  28739. /**
  28740. * Indicates that textures need to be re-calculated for all materials
  28741. */
  28742. protected _markAllSubMeshesAsTexturesDirty(): void;
  28743. /**
  28744. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28745. * This will returns an RGBA array buffer containing either in values (0-255) or
  28746. * float values (0-1) depending of the underlying buffer type.
  28747. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28748. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28749. * @param buffer defines a user defined buffer to fill with data (can be null)
  28750. * @returns The Array buffer containing the pixels data.
  28751. */
  28752. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28753. /**
  28754. * Release and destroy the underlying lower level texture aka internalTexture.
  28755. */
  28756. releaseInternalTexture(): void;
  28757. /** @hidden */
  28758. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28759. /** @hidden */
  28760. readonly _lodTextureMid: Nullable<BaseTexture>;
  28761. /** @hidden */
  28762. readonly _lodTextureLow: Nullable<BaseTexture>;
  28763. /**
  28764. * Dispose the texture and release its associated resources.
  28765. */
  28766. dispose(): void;
  28767. /**
  28768. * Serialize the texture into a JSON representation that can be parsed later on.
  28769. * @returns the JSON representation of the texture
  28770. */
  28771. serialize(): any;
  28772. /**
  28773. * Helper function to be called back once a list of texture contains only ready textures.
  28774. * @param textures Define the list of textures to wait for
  28775. * @param callback Define the callback triggered once the entire list will be ready
  28776. */
  28777. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28778. }
  28779. }
  28780. declare module "babylonjs/Materials/effect" {
  28781. import { Observable } from "babylonjs/Misc/observable";
  28782. import { Nullable } from "babylonjs/types";
  28783. import { IDisposable } from "babylonjs/scene";
  28784. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28785. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28786. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28787. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28788. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28789. import { Engine } from "babylonjs/Engines/engine";
  28790. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28791. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28792. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28793. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28794. /**
  28795. * Options to be used when creating an effect.
  28796. */
  28797. export interface IEffectCreationOptions {
  28798. /**
  28799. * Atrributes that will be used in the shader.
  28800. */
  28801. attributes: string[];
  28802. /**
  28803. * Uniform varible names that will be set in the shader.
  28804. */
  28805. uniformsNames: string[];
  28806. /**
  28807. * Uniform buffer varible names that will be set in the shader.
  28808. */
  28809. uniformBuffersNames: string[];
  28810. /**
  28811. * Sampler texture variable names that will be set in the shader.
  28812. */
  28813. samplers: string[];
  28814. /**
  28815. * Define statements that will be set in the shader.
  28816. */
  28817. defines: any;
  28818. /**
  28819. * Possible fallbacks for this effect to improve performance when needed.
  28820. */
  28821. fallbacks: Nullable<IEffectFallbacks>;
  28822. /**
  28823. * Callback that will be called when the shader is compiled.
  28824. */
  28825. onCompiled: Nullable<(effect: Effect) => void>;
  28826. /**
  28827. * Callback that will be called if an error occurs during shader compilation.
  28828. */
  28829. onError: Nullable<(effect: Effect, errors: string) => void>;
  28830. /**
  28831. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28832. */
  28833. indexParameters?: any;
  28834. /**
  28835. * Max number of lights that can be used in the shader.
  28836. */
  28837. maxSimultaneousLights?: number;
  28838. /**
  28839. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28840. */
  28841. transformFeedbackVaryings?: Nullable<string[]>;
  28842. }
  28843. /**
  28844. * Effect containing vertex and fragment shader that can be executed on an object.
  28845. */
  28846. export class Effect implements IDisposable {
  28847. /**
  28848. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28849. */
  28850. static ShadersRepository: string;
  28851. /**
  28852. * Name of the effect.
  28853. */
  28854. name: any;
  28855. /**
  28856. * String container all the define statements that should be set on the shader.
  28857. */
  28858. defines: string;
  28859. /**
  28860. * Callback that will be called when the shader is compiled.
  28861. */
  28862. onCompiled: Nullable<(effect: Effect) => void>;
  28863. /**
  28864. * Callback that will be called if an error occurs during shader compilation.
  28865. */
  28866. onError: Nullable<(effect: Effect, errors: string) => void>;
  28867. /**
  28868. * Callback that will be called when effect is bound.
  28869. */
  28870. onBind: Nullable<(effect: Effect) => void>;
  28871. /**
  28872. * Unique ID of the effect.
  28873. */
  28874. uniqueId: number;
  28875. /**
  28876. * Observable that will be called when the shader is compiled.
  28877. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28878. */
  28879. onCompileObservable: Observable<Effect>;
  28880. /**
  28881. * Observable that will be called if an error occurs during shader compilation.
  28882. */
  28883. onErrorObservable: Observable<Effect>;
  28884. /** @hidden */
  28885. _onBindObservable: Nullable<Observable<Effect>>;
  28886. /**
  28887. * Observable that will be called when effect is bound.
  28888. */
  28889. readonly onBindObservable: Observable<Effect>;
  28890. /** @hidden */
  28891. _bonesComputationForcedToCPU: boolean;
  28892. private static _uniqueIdSeed;
  28893. private _engine;
  28894. private _uniformBuffersNames;
  28895. private _uniformsNames;
  28896. private _samplerList;
  28897. private _samplers;
  28898. private _isReady;
  28899. private _compilationError;
  28900. private _allFallbacksProcessed;
  28901. private _attributesNames;
  28902. private _attributes;
  28903. private _uniforms;
  28904. /**
  28905. * Key for the effect.
  28906. * @hidden
  28907. */
  28908. _key: string;
  28909. private _indexParameters;
  28910. private _fallbacks;
  28911. private _vertexSourceCode;
  28912. private _fragmentSourceCode;
  28913. private _vertexSourceCodeOverride;
  28914. private _fragmentSourceCodeOverride;
  28915. private _transformFeedbackVaryings;
  28916. /**
  28917. * Compiled shader to webGL program.
  28918. * @hidden
  28919. */
  28920. _pipelineContext: Nullable<IPipelineContext>;
  28921. private _valueCache;
  28922. private static _baseCache;
  28923. /**
  28924. * Instantiates an effect.
  28925. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28926. * @param baseName Name of the effect.
  28927. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28928. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28929. * @param samplers List of sampler variables that will be passed to the shader.
  28930. * @param engine Engine to be used to render the effect
  28931. * @param defines Define statements to be added to the shader.
  28932. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28933. * @param onCompiled Callback that will be called when the shader is compiled.
  28934. * @param onError Callback that will be called if an error occurs during shader compilation.
  28935. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28936. */
  28937. 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);
  28938. private _useFinalCode;
  28939. /**
  28940. * Unique key for this effect
  28941. */
  28942. readonly key: string;
  28943. /**
  28944. * If the effect has been compiled and prepared.
  28945. * @returns if the effect is compiled and prepared.
  28946. */
  28947. isReady(): boolean;
  28948. private _isReadyInternal;
  28949. /**
  28950. * The engine the effect was initialized with.
  28951. * @returns the engine.
  28952. */
  28953. getEngine(): Engine;
  28954. /**
  28955. * The pipeline context for this effect
  28956. * @returns the associated pipeline context
  28957. */
  28958. getPipelineContext(): Nullable<IPipelineContext>;
  28959. /**
  28960. * The set of names of attribute variables for the shader.
  28961. * @returns An array of attribute names.
  28962. */
  28963. getAttributesNames(): string[];
  28964. /**
  28965. * Returns the attribute at the given index.
  28966. * @param index The index of the attribute.
  28967. * @returns The location of the attribute.
  28968. */
  28969. getAttributeLocation(index: number): number;
  28970. /**
  28971. * Returns the attribute based on the name of the variable.
  28972. * @param name of the attribute to look up.
  28973. * @returns the attribute location.
  28974. */
  28975. getAttributeLocationByName(name: string): number;
  28976. /**
  28977. * The number of attributes.
  28978. * @returns the numnber of attributes.
  28979. */
  28980. getAttributesCount(): number;
  28981. /**
  28982. * Gets the index of a uniform variable.
  28983. * @param uniformName of the uniform to look up.
  28984. * @returns the index.
  28985. */
  28986. getUniformIndex(uniformName: string): number;
  28987. /**
  28988. * Returns the attribute based on the name of the variable.
  28989. * @param uniformName of the uniform to look up.
  28990. * @returns the location of the uniform.
  28991. */
  28992. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28993. /**
  28994. * Returns an array of sampler variable names
  28995. * @returns The array of sampler variable neames.
  28996. */
  28997. getSamplers(): string[];
  28998. /**
  28999. * The error from the last compilation.
  29000. * @returns the error string.
  29001. */
  29002. getCompilationError(): string;
  29003. /**
  29004. * Gets a boolean indicating that all fallbacks were used during compilation
  29005. * @returns true if all fallbacks were used
  29006. */
  29007. allFallbacksProcessed(): boolean;
  29008. /**
  29009. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29010. * @param func The callback to be used.
  29011. */
  29012. executeWhenCompiled(func: (effect: Effect) => void): void;
  29013. private _checkIsReady;
  29014. private _loadShader;
  29015. /**
  29016. * Recompiles the webGL program
  29017. * @param vertexSourceCode The source code for the vertex shader.
  29018. * @param fragmentSourceCode The source code for the fragment shader.
  29019. * @param onCompiled Callback called when completed.
  29020. * @param onError Callback called on error.
  29021. * @hidden
  29022. */
  29023. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29024. /**
  29025. * Prepares the effect
  29026. * @hidden
  29027. */
  29028. _prepareEffect(): void;
  29029. private _processCompilationErrors;
  29030. /**
  29031. * Checks if the effect is supported. (Must be called after compilation)
  29032. */
  29033. readonly isSupported: boolean;
  29034. /**
  29035. * Binds a texture to the engine to be used as output of the shader.
  29036. * @param channel Name of the output variable.
  29037. * @param texture Texture to bind.
  29038. * @hidden
  29039. */
  29040. _bindTexture(channel: string, texture: InternalTexture): void;
  29041. /**
  29042. * Sets a texture on the engine to be used in the shader.
  29043. * @param channel Name of the sampler variable.
  29044. * @param texture Texture to set.
  29045. */
  29046. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29047. /**
  29048. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29049. * @param channel Name of the sampler variable.
  29050. * @param texture Texture to set.
  29051. */
  29052. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29053. /**
  29054. * Sets an array of textures on the engine to be used in the shader.
  29055. * @param channel Name of the variable.
  29056. * @param textures Textures to set.
  29057. */
  29058. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29059. /**
  29060. * 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)
  29061. * @param channel Name of the sampler variable.
  29062. * @param postProcess Post process to get the input texture from.
  29063. */
  29064. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29065. /**
  29066. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29067. * 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)
  29068. * @param channel Name of the sampler variable.
  29069. * @param postProcess Post process to get the output texture from.
  29070. */
  29071. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29072. /** @hidden */
  29073. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29074. /** @hidden */
  29075. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29076. /** @hidden */
  29077. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29078. /** @hidden */
  29079. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29080. /**
  29081. * Binds a buffer to a uniform.
  29082. * @param buffer Buffer to bind.
  29083. * @param name Name of the uniform variable to bind to.
  29084. */
  29085. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29086. /**
  29087. * Binds block to a uniform.
  29088. * @param blockName Name of the block to bind.
  29089. * @param index Index to bind.
  29090. */
  29091. bindUniformBlock(blockName: string, index: number): void;
  29092. /**
  29093. * Sets an interger value on a uniform variable.
  29094. * @param uniformName Name of the variable.
  29095. * @param value Value to be set.
  29096. * @returns this effect.
  29097. */
  29098. setInt(uniformName: string, value: number): Effect;
  29099. /**
  29100. * Sets an int array on a uniform variable.
  29101. * @param uniformName Name of the variable.
  29102. * @param array array to be set.
  29103. * @returns this effect.
  29104. */
  29105. setIntArray(uniformName: string, array: Int32Array): Effect;
  29106. /**
  29107. * 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)
  29108. * @param uniformName Name of the variable.
  29109. * @param array array to be set.
  29110. * @returns this effect.
  29111. */
  29112. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29113. /**
  29114. * 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)
  29115. * @param uniformName Name of the variable.
  29116. * @param array array to be set.
  29117. * @returns this effect.
  29118. */
  29119. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29120. /**
  29121. * 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)
  29122. * @param uniformName Name of the variable.
  29123. * @param array array to be set.
  29124. * @returns this effect.
  29125. */
  29126. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29127. /**
  29128. * Sets an float array on a uniform variable.
  29129. * @param uniformName Name of the variable.
  29130. * @param array array to be set.
  29131. * @returns this effect.
  29132. */
  29133. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29134. /**
  29135. * 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)
  29136. * @param uniformName Name of the variable.
  29137. * @param array array to be set.
  29138. * @returns this effect.
  29139. */
  29140. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29141. /**
  29142. * 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)
  29143. * @param uniformName Name of the variable.
  29144. * @param array array to be set.
  29145. * @returns this effect.
  29146. */
  29147. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29148. /**
  29149. * 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)
  29150. * @param uniformName Name of the variable.
  29151. * @param array array to be set.
  29152. * @returns this effect.
  29153. */
  29154. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29155. /**
  29156. * Sets an array on a uniform variable.
  29157. * @param uniformName Name of the variable.
  29158. * @param array array to be set.
  29159. * @returns this effect.
  29160. */
  29161. setArray(uniformName: string, array: number[]): Effect;
  29162. /**
  29163. * 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)
  29164. * @param uniformName Name of the variable.
  29165. * @param array array to be set.
  29166. * @returns this effect.
  29167. */
  29168. setArray2(uniformName: string, array: number[]): Effect;
  29169. /**
  29170. * 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)
  29171. * @param uniformName Name of the variable.
  29172. * @param array array to be set.
  29173. * @returns this effect.
  29174. */
  29175. setArray3(uniformName: string, array: number[]): Effect;
  29176. /**
  29177. * 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)
  29178. * @param uniformName Name of the variable.
  29179. * @param array array to be set.
  29180. * @returns this effect.
  29181. */
  29182. setArray4(uniformName: string, array: number[]): Effect;
  29183. /**
  29184. * Sets matrices on a uniform variable.
  29185. * @param uniformName Name of the variable.
  29186. * @param matrices matrices to be set.
  29187. * @returns this effect.
  29188. */
  29189. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29190. /**
  29191. * Sets matrix on a uniform variable.
  29192. * @param uniformName Name of the variable.
  29193. * @param matrix matrix to be set.
  29194. * @returns this effect.
  29195. */
  29196. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29197. /**
  29198. * 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)
  29199. * @param uniformName Name of the variable.
  29200. * @param matrix matrix to be set.
  29201. * @returns this effect.
  29202. */
  29203. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29204. /**
  29205. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29206. * @param uniformName Name of the variable.
  29207. * @param matrix matrix to be set.
  29208. * @returns this effect.
  29209. */
  29210. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29211. /**
  29212. * Sets a float on a uniform variable.
  29213. * @param uniformName Name of the variable.
  29214. * @param value value to be set.
  29215. * @returns this effect.
  29216. */
  29217. setFloat(uniformName: string, value: number): Effect;
  29218. /**
  29219. * Sets a boolean on a uniform variable.
  29220. * @param uniformName Name of the variable.
  29221. * @param bool value to be set.
  29222. * @returns this effect.
  29223. */
  29224. setBool(uniformName: string, bool: boolean): Effect;
  29225. /**
  29226. * Sets a Vector2 on a uniform variable.
  29227. * @param uniformName Name of the variable.
  29228. * @param vector2 vector2 to be set.
  29229. * @returns this effect.
  29230. */
  29231. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29232. /**
  29233. * Sets a float2 on a uniform variable.
  29234. * @param uniformName Name of the variable.
  29235. * @param x First float in float2.
  29236. * @param y Second float in float2.
  29237. * @returns this effect.
  29238. */
  29239. setFloat2(uniformName: string, x: number, y: number): Effect;
  29240. /**
  29241. * Sets a Vector3 on a uniform variable.
  29242. * @param uniformName Name of the variable.
  29243. * @param vector3 Value to be set.
  29244. * @returns this effect.
  29245. */
  29246. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29247. /**
  29248. * Sets a float3 on a uniform variable.
  29249. * @param uniformName Name of the variable.
  29250. * @param x First float in float3.
  29251. * @param y Second float in float3.
  29252. * @param z Third float in float3.
  29253. * @returns this effect.
  29254. */
  29255. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29256. /**
  29257. * Sets a Vector4 on a uniform variable.
  29258. * @param uniformName Name of the variable.
  29259. * @param vector4 Value to be set.
  29260. * @returns this effect.
  29261. */
  29262. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29263. /**
  29264. * Sets a float4 on a uniform variable.
  29265. * @param uniformName Name of the variable.
  29266. * @param x First float in float4.
  29267. * @param y Second float in float4.
  29268. * @param z Third float in float4.
  29269. * @param w Fourth float in float4.
  29270. * @returns this effect.
  29271. */
  29272. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29273. /**
  29274. * Sets a Color3 on a uniform variable.
  29275. * @param uniformName Name of the variable.
  29276. * @param color3 Value to be set.
  29277. * @returns this effect.
  29278. */
  29279. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29280. /**
  29281. * Sets a Color4 on a uniform variable.
  29282. * @param uniformName Name of the variable.
  29283. * @param color3 Value to be set.
  29284. * @param alpha Alpha value to be set.
  29285. * @returns this effect.
  29286. */
  29287. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29288. /**
  29289. * Sets a Color4 on a uniform variable
  29290. * @param uniformName defines the name of the variable
  29291. * @param color4 defines the value to be set
  29292. * @returns this effect.
  29293. */
  29294. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29295. /** Release all associated resources */
  29296. dispose(): void;
  29297. /**
  29298. * This function will add a new shader to the shader store
  29299. * @param name the name of the shader
  29300. * @param pixelShader optional pixel shader content
  29301. * @param vertexShader optional vertex shader content
  29302. */
  29303. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29304. /**
  29305. * Store of each shader (The can be looked up using effect.key)
  29306. */
  29307. static ShadersStore: {
  29308. [key: string]: string;
  29309. };
  29310. /**
  29311. * Store of each included file for a shader (The can be looked up using effect.key)
  29312. */
  29313. static IncludesShadersStore: {
  29314. [key: string]: string;
  29315. };
  29316. /**
  29317. * Resets the cache of effects.
  29318. */
  29319. static ResetCache(): void;
  29320. }
  29321. }
  29322. declare module "babylonjs/Engines/engineCapabilities" {
  29323. import { Nullable } from "babylonjs/types";
  29324. /**
  29325. * Class used to describe the capabilities of the engine relatively to the current browser
  29326. */
  29327. export class EngineCapabilities {
  29328. /** Maximum textures units per fragment shader */
  29329. maxTexturesImageUnits: number;
  29330. /** Maximum texture units per vertex shader */
  29331. maxVertexTextureImageUnits: number;
  29332. /** Maximum textures units in the entire pipeline */
  29333. maxCombinedTexturesImageUnits: number;
  29334. /** Maximum texture size */
  29335. maxTextureSize: number;
  29336. /** Maximum cube texture size */
  29337. maxCubemapTextureSize: number;
  29338. /** Maximum render texture size */
  29339. maxRenderTextureSize: number;
  29340. /** Maximum number of vertex attributes */
  29341. maxVertexAttribs: number;
  29342. /** Maximum number of varyings */
  29343. maxVaryingVectors: number;
  29344. /** Maximum number of uniforms per vertex shader */
  29345. maxVertexUniformVectors: number;
  29346. /** Maximum number of uniforms per fragment shader */
  29347. maxFragmentUniformVectors: number;
  29348. /** Defines if standard derivates (dx/dy) are supported */
  29349. standardDerivatives: boolean;
  29350. /** Defines if s3tc texture compression is supported */
  29351. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29352. /** Defines if pvrtc texture compression is supported */
  29353. pvrtc: any;
  29354. /** Defines if etc1 texture compression is supported */
  29355. etc1: any;
  29356. /** Defines if etc2 texture compression is supported */
  29357. etc2: any;
  29358. /** Defines if astc texture compression is supported */
  29359. astc: any;
  29360. /** Defines if float textures are supported */
  29361. textureFloat: boolean;
  29362. /** Defines if vertex array objects are supported */
  29363. vertexArrayObject: boolean;
  29364. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29365. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29366. /** Gets the maximum level of anisotropy supported */
  29367. maxAnisotropy: number;
  29368. /** Defines if instancing is supported */
  29369. instancedArrays: boolean;
  29370. /** Defines if 32 bits indices are supported */
  29371. uintIndices: boolean;
  29372. /** Defines if high precision shaders are supported */
  29373. highPrecisionShaderSupported: boolean;
  29374. /** Defines if depth reading in the fragment shader is supported */
  29375. fragmentDepthSupported: boolean;
  29376. /** Defines if float texture linear filtering is supported*/
  29377. textureFloatLinearFiltering: boolean;
  29378. /** Defines if rendering to float textures is supported */
  29379. textureFloatRender: boolean;
  29380. /** Defines if half float textures are supported*/
  29381. textureHalfFloat: boolean;
  29382. /** Defines if half float texture linear filtering is supported*/
  29383. textureHalfFloatLinearFiltering: boolean;
  29384. /** Defines if rendering to half float textures is supported */
  29385. textureHalfFloatRender: boolean;
  29386. /** Defines if textureLOD shader command is supported */
  29387. textureLOD: boolean;
  29388. /** Defines if draw buffers extension is supported */
  29389. drawBuffersExtension: boolean;
  29390. /** Defines if depth textures are supported */
  29391. depthTextureExtension: boolean;
  29392. /** Defines if float color buffer are supported */
  29393. colorBufferFloat: boolean;
  29394. /** Gets disjoint timer query extension (null if not supported) */
  29395. timerQuery: EXT_disjoint_timer_query;
  29396. /** Defines if timestamp can be used with timer query */
  29397. canUseTimestampForTimerQuery: boolean;
  29398. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29399. multiview: any;
  29400. /** Function used to let the system compiles shaders in background */
  29401. parallelShaderCompile: {
  29402. COMPLETION_STATUS_KHR: number;
  29403. };
  29404. /** Max number of texture samples for MSAA */
  29405. maxMSAASamples: number;
  29406. /** Defines if the blend min max extension is supported */
  29407. blendMinMax: boolean;
  29408. }
  29409. }
  29410. declare module "babylonjs/States/depthCullingState" {
  29411. import { Nullable } from "babylonjs/types";
  29412. /**
  29413. * @hidden
  29414. **/
  29415. export class DepthCullingState {
  29416. private _isDepthTestDirty;
  29417. private _isDepthMaskDirty;
  29418. private _isDepthFuncDirty;
  29419. private _isCullFaceDirty;
  29420. private _isCullDirty;
  29421. private _isZOffsetDirty;
  29422. private _isFrontFaceDirty;
  29423. private _depthTest;
  29424. private _depthMask;
  29425. private _depthFunc;
  29426. private _cull;
  29427. private _cullFace;
  29428. private _zOffset;
  29429. private _frontFace;
  29430. /**
  29431. * Initializes the state.
  29432. */
  29433. constructor();
  29434. readonly isDirty: boolean;
  29435. zOffset: number;
  29436. cullFace: Nullable<number>;
  29437. cull: Nullable<boolean>;
  29438. depthFunc: Nullable<number>;
  29439. depthMask: boolean;
  29440. depthTest: boolean;
  29441. frontFace: Nullable<number>;
  29442. reset(): void;
  29443. apply(gl: WebGLRenderingContext): void;
  29444. }
  29445. }
  29446. declare module "babylonjs/States/stencilState" {
  29447. /**
  29448. * @hidden
  29449. **/
  29450. export class StencilState {
  29451. /** 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 */
  29452. static readonly ALWAYS: number;
  29453. /** Passed to stencilOperation to specify that stencil value must be kept */
  29454. static readonly KEEP: number;
  29455. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29456. static readonly REPLACE: number;
  29457. private _isStencilTestDirty;
  29458. private _isStencilMaskDirty;
  29459. private _isStencilFuncDirty;
  29460. private _isStencilOpDirty;
  29461. private _stencilTest;
  29462. private _stencilMask;
  29463. private _stencilFunc;
  29464. private _stencilFuncRef;
  29465. private _stencilFuncMask;
  29466. private _stencilOpStencilFail;
  29467. private _stencilOpDepthFail;
  29468. private _stencilOpStencilDepthPass;
  29469. readonly isDirty: boolean;
  29470. stencilFunc: number;
  29471. stencilFuncRef: number;
  29472. stencilFuncMask: number;
  29473. stencilOpStencilFail: number;
  29474. stencilOpDepthFail: number;
  29475. stencilOpStencilDepthPass: number;
  29476. stencilMask: number;
  29477. stencilTest: boolean;
  29478. constructor();
  29479. reset(): void;
  29480. apply(gl: WebGLRenderingContext): void;
  29481. }
  29482. }
  29483. declare module "babylonjs/States/alphaCullingState" {
  29484. /**
  29485. * @hidden
  29486. **/
  29487. export class AlphaState {
  29488. private _isAlphaBlendDirty;
  29489. private _isBlendFunctionParametersDirty;
  29490. private _isBlendEquationParametersDirty;
  29491. private _isBlendConstantsDirty;
  29492. private _alphaBlend;
  29493. private _blendFunctionParameters;
  29494. private _blendEquationParameters;
  29495. private _blendConstants;
  29496. /**
  29497. * Initializes the state.
  29498. */
  29499. constructor();
  29500. readonly isDirty: boolean;
  29501. alphaBlend: boolean;
  29502. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29503. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29504. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29505. reset(): void;
  29506. apply(gl: WebGLRenderingContext): void;
  29507. }
  29508. }
  29509. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29510. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29511. /** @hidden */
  29512. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29513. attributeProcessor(attribute: string): string;
  29514. varyingProcessor(varying: string, isFragment: boolean): string;
  29515. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29516. }
  29517. }
  29518. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29519. /**
  29520. * Interface for attribute information associated with buffer instanciation
  29521. */
  29522. export class InstancingAttributeInfo {
  29523. /**
  29524. * Index/offset of the attribute in the vertex shader
  29525. */
  29526. index: number;
  29527. /**
  29528. * size of the attribute, 1, 2, 3 or 4
  29529. */
  29530. attributeSize: number;
  29531. /**
  29532. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29533. * default is FLOAT
  29534. */
  29535. attribyteType: number;
  29536. /**
  29537. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29538. */
  29539. normalized: boolean;
  29540. /**
  29541. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29542. */
  29543. offset: number;
  29544. /**
  29545. * Name of the GLSL attribute, for debugging purpose only
  29546. */
  29547. attributeName: string;
  29548. }
  29549. }
  29550. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29552. import { Nullable } from "babylonjs/types";
  29553. module "babylonjs/Engines/thinEngine" {
  29554. interface ThinEngine {
  29555. /**
  29556. * Update a video texture
  29557. * @param texture defines the texture to update
  29558. * @param video defines the video element to use
  29559. * @param invertY defines if data must be stored with Y axis inverted
  29560. */
  29561. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29562. }
  29563. }
  29564. }
  29565. declare module "babylonjs/Materials/Textures/videoTexture" {
  29566. import { Observable } from "babylonjs/Misc/observable";
  29567. import { Nullable } from "babylonjs/types";
  29568. import { Scene } from "babylonjs/scene";
  29569. import { Texture } from "babylonjs/Materials/Textures/texture";
  29570. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29571. /**
  29572. * Settings for finer control over video usage
  29573. */
  29574. export interface VideoTextureSettings {
  29575. /**
  29576. * Applies `autoplay` to video, if specified
  29577. */
  29578. autoPlay?: boolean;
  29579. /**
  29580. * Applies `loop` to video, if specified
  29581. */
  29582. loop?: boolean;
  29583. /**
  29584. * Automatically updates internal texture from video at every frame in the render loop
  29585. */
  29586. autoUpdateTexture: boolean;
  29587. /**
  29588. * Image src displayed during the video loading or until the user interacts with the video.
  29589. */
  29590. poster?: string;
  29591. }
  29592. /**
  29593. * If you want to display a video in your scene, this is the special texture for that.
  29594. * This special texture works similar to other textures, with the exception of a few parameters.
  29595. * @see https://doc.babylonjs.com/how_to/video_texture
  29596. */
  29597. export class VideoTexture extends Texture {
  29598. /**
  29599. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29600. */
  29601. readonly autoUpdateTexture: boolean;
  29602. /**
  29603. * The video instance used by the texture internally
  29604. */
  29605. readonly video: HTMLVideoElement;
  29606. private _onUserActionRequestedObservable;
  29607. /**
  29608. * Event triggerd when a dom action is required by the user to play the video.
  29609. * This happens due to recent changes in browser policies preventing video to auto start.
  29610. */
  29611. readonly onUserActionRequestedObservable: Observable<Texture>;
  29612. private _generateMipMaps;
  29613. private _engine;
  29614. private _stillImageCaptured;
  29615. private _displayingPosterTexture;
  29616. private _settings;
  29617. private _createInternalTextureOnEvent;
  29618. private _frameId;
  29619. /**
  29620. * Creates a video texture.
  29621. * If you want to display a video in your scene, this is the special texture for that.
  29622. * This special texture works similar to other textures, with the exception of a few parameters.
  29623. * @see https://doc.babylonjs.com/how_to/video_texture
  29624. * @param name optional name, will detect from video source, if not defined
  29625. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29626. * @param scene is obviously the current scene.
  29627. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29628. * @param invertY is false by default but can be used to invert video on Y axis
  29629. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29630. * @param settings allows finer control over video usage
  29631. */
  29632. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29633. private _getName;
  29634. private _getVideo;
  29635. private _createInternalTexture;
  29636. private reset;
  29637. /**
  29638. * @hidden Internal method to initiate `update`.
  29639. */
  29640. _rebuild(): void;
  29641. /**
  29642. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29643. */
  29644. update(): void;
  29645. /**
  29646. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29647. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29648. */
  29649. updateTexture(isVisible: boolean): void;
  29650. protected _updateInternalTexture: () => void;
  29651. /**
  29652. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29653. * @param url New url.
  29654. */
  29655. updateURL(url: string): void;
  29656. /**
  29657. * Dispose the texture and release its associated resources.
  29658. */
  29659. dispose(): void;
  29660. /**
  29661. * Creates a video texture straight from a stream.
  29662. * @param scene Define the scene the texture should be created in
  29663. * @param stream Define the stream the texture should be created from
  29664. * @returns The created video texture as a promise
  29665. */
  29666. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29667. /**
  29668. * Creates a video texture straight from your WebCam video feed.
  29669. * @param scene Define the scene the texture should be created in
  29670. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29671. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29672. * @returns The created video texture as a promise
  29673. */
  29674. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29675. minWidth: number;
  29676. maxWidth: number;
  29677. minHeight: number;
  29678. maxHeight: number;
  29679. deviceId: string;
  29680. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29681. /**
  29682. * Creates a video texture straight from your WebCam video feed.
  29683. * @param scene Define the scene the texture should be created in
  29684. * @param onReady Define a callback to triggered once the texture will be ready
  29685. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29686. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29687. */
  29688. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29689. minWidth: number;
  29690. maxWidth: number;
  29691. minHeight: number;
  29692. maxHeight: number;
  29693. deviceId: string;
  29694. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29695. }
  29696. }
  29697. declare module "babylonjs/Engines/thinEngine" {
  29698. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29699. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29700. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29701. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29702. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29703. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29704. import { Observable } from "babylonjs/Misc/observable";
  29705. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29706. import { StencilState } from "babylonjs/States/stencilState";
  29707. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29709. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29710. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29711. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29712. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29713. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29714. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29715. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29716. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29717. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29718. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29719. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29720. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29721. /**
  29722. * Defines the interface used by objects working like Scene
  29723. * @hidden
  29724. */
  29725. interface ISceneLike {
  29726. _addPendingData(data: any): void;
  29727. _removePendingData(data: any): void;
  29728. offlineProvider: IOfflineProvider;
  29729. }
  29730. /** Interface defining initialization parameters for Engine class */
  29731. export interface EngineOptions extends WebGLContextAttributes {
  29732. /**
  29733. * Defines if the engine should no exceed a specified device ratio
  29734. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29735. */
  29736. limitDeviceRatio?: number;
  29737. /**
  29738. * Defines if webvr should be enabled automatically
  29739. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29740. */
  29741. autoEnableWebVR?: boolean;
  29742. /**
  29743. * Defines if webgl2 should be turned off even if supported
  29744. * @see http://doc.babylonjs.com/features/webgl2
  29745. */
  29746. disableWebGL2Support?: boolean;
  29747. /**
  29748. * Defines if webaudio should be initialized as well
  29749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29750. */
  29751. audioEngine?: boolean;
  29752. /**
  29753. * Defines if animations should run using a deterministic lock step
  29754. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29755. */
  29756. deterministicLockstep?: boolean;
  29757. /** Defines the maximum steps to use with deterministic lock step mode */
  29758. lockstepMaxSteps?: number;
  29759. /**
  29760. * Defines that engine should ignore context lost events
  29761. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29762. */
  29763. doNotHandleContextLost?: boolean;
  29764. /**
  29765. * Defines that engine should ignore modifying touch action attribute and style
  29766. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29767. */
  29768. doNotHandleTouchAction?: boolean;
  29769. /**
  29770. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29771. */
  29772. useHighPrecisionFloats?: boolean;
  29773. }
  29774. /**
  29775. * The base engine class (root of all engines)
  29776. */
  29777. export class ThinEngine {
  29778. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29779. static ExceptionList: ({
  29780. key: string;
  29781. capture: string;
  29782. captureConstraint: number;
  29783. targets: string[];
  29784. } | {
  29785. key: string;
  29786. capture: null;
  29787. captureConstraint: null;
  29788. targets: string[];
  29789. })[];
  29790. /** @hidden */
  29791. static _TextureLoaders: IInternalTextureLoader[];
  29792. /**
  29793. * Returns the current npm package of the sdk
  29794. */
  29795. static readonly NpmPackage: string;
  29796. /**
  29797. * Returns the current version of the framework
  29798. */
  29799. static readonly Version: string;
  29800. /**
  29801. * Returns a string describing the current engine
  29802. */
  29803. readonly description: string;
  29804. /**
  29805. * Gets or sets the epsilon value used by collision engine
  29806. */
  29807. static CollisionsEpsilon: number;
  29808. /**
  29809. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29810. */
  29811. static ShadersRepository: string;
  29812. /** @hidden */
  29813. _shaderProcessor: IShaderProcessor;
  29814. /**
  29815. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29816. */
  29817. forcePOTTextures: boolean;
  29818. /**
  29819. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29820. */
  29821. isFullscreen: boolean;
  29822. /**
  29823. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29824. */
  29825. cullBackFaces: boolean;
  29826. /**
  29827. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29828. */
  29829. renderEvenInBackground: boolean;
  29830. /**
  29831. * Gets or sets a boolean indicating that cache can be kept between frames
  29832. */
  29833. preventCacheWipeBetweenFrames: boolean;
  29834. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29835. validateShaderPrograms: boolean;
  29836. /**
  29837. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29838. */
  29839. disableUniformBuffers: boolean;
  29840. /** @hidden */
  29841. _uniformBuffers: UniformBuffer[];
  29842. /**
  29843. * Gets a boolean indicating that the engine supports uniform buffers
  29844. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29845. */
  29846. readonly supportsUniformBuffers: boolean;
  29847. /** @hidden */
  29848. _gl: WebGLRenderingContext;
  29849. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29850. protected _windowIsBackground: boolean;
  29851. protected _webGLVersion: number;
  29852. protected _highPrecisionShadersAllowed: boolean;
  29853. /** @hidden */
  29854. readonly _shouldUseHighPrecisionShader: boolean;
  29855. /**
  29856. * Gets a boolean indicating that only power of 2 textures are supported
  29857. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29858. */
  29859. readonly needPOTTextures: boolean;
  29860. /** @hidden */
  29861. _badOS: boolean;
  29862. /** @hidden */
  29863. _badDesktopOS: boolean;
  29864. private _hardwareScalingLevel;
  29865. /** @hidden */
  29866. _caps: EngineCapabilities;
  29867. private _isStencilEnable;
  29868. protected _colorWrite: boolean;
  29869. private _glVersion;
  29870. private _glRenderer;
  29871. private _glVendor;
  29872. /** @hidden */
  29873. _videoTextureSupported: boolean;
  29874. protected _renderingQueueLaunched: boolean;
  29875. protected _activeRenderLoops: (() => void)[];
  29876. /**
  29877. * Observable signaled when a context lost event is raised
  29878. */
  29879. onContextLostObservable: Observable<ThinEngine>;
  29880. /**
  29881. * Observable signaled when a context restored event is raised
  29882. */
  29883. onContextRestoredObservable: Observable<ThinEngine>;
  29884. private _onContextLost;
  29885. private _onContextRestored;
  29886. protected _contextWasLost: boolean;
  29887. /** @hidden */
  29888. _doNotHandleContextLost: boolean;
  29889. /**
  29890. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29892. */
  29893. doNotHandleContextLost: boolean;
  29894. /**
  29895. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29896. */
  29897. disableVertexArrayObjects: boolean;
  29898. /** @hidden */
  29899. protected _depthCullingState: DepthCullingState;
  29900. /** @hidden */
  29901. protected _stencilState: StencilState;
  29902. /** @hidden */
  29903. protected _alphaState: AlphaState;
  29904. /** @hidden */
  29905. _internalTexturesCache: InternalTexture[];
  29906. /** @hidden */
  29907. protected _activeChannel: number;
  29908. private _currentTextureChannel;
  29909. /** @hidden */
  29910. protected _boundTexturesCache: {
  29911. [key: string]: Nullable<InternalTexture>;
  29912. };
  29913. /** @hidden */
  29914. protected _currentEffect: Nullable<Effect>;
  29915. /** @hidden */
  29916. protected _currentProgram: Nullable<WebGLProgram>;
  29917. private _compiledEffects;
  29918. private _vertexAttribArraysEnabled;
  29919. /** @hidden */
  29920. protected _cachedViewport: Nullable<IViewportLike>;
  29921. private _cachedVertexArrayObject;
  29922. /** @hidden */
  29923. protected _cachedVertexBuffers: any;
  29924. /** @hidden */
  29925. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29926. /** @hidden */
  29927. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29928. /** @hidden */
  29929. _currentRenderTarget: Nullable<InternalTexture>;
  29930. private _uintIndicesCurrentlySet;
  29931. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29932. /** @hidden */
  29933. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29934. private _currentBufferPointers;
  29935. private _currentInstanceLocations;
  29936. private _currentInstanceBuffers;
  29937. private _textureUnits;
  29938. /** @hidden */
  29939. _workingCanvas: Nullable<HTMLCanvasElement>;
  29940. /** @hidden */
  29941. _workingContext: Nullable<CanvasRenderingContext2D>;
  29942. /** @hidden */
  29943. _bindedRenderFunction: any;
  29944. private _vaoRecordInProgress;
  29945. private _mustWipeVertexAttributes;
  29946. private _emptyTexture;
  29947. private _emptyCubeTexture;
  29948. private _emptyTexture3D;
  29949. /** @hidden */
  29950. _frameHandler: number;
  29951. private _nextFreeTextureSlots;
  29952. private _maxSimultaneousTextures;
  29953. private _activeRequests;
  29954. protected _texturesSupported: string[];
  29955. /** @hidden */
  29956. _textureFormatInUse: Nullable<string>;
  29957. protected readonly _supportsHardwareTextureRescaling: boolean;
  29958. /**
  29959. * Gets the list of texture formats supported
  29960. */
  29961. readonly texturesSupported: Array<string>;
  29962. /**
  29963. * Gets the list of texture formats in use
  29964. */
  29965. readonly textureFormatInUse: Nullable<string>;
  29966. /**
  29967. * Gets the current viewport
  29968. */
  29969. readonly currentViewport: Nullable<IViewportLike>;
  29970. /**
  29971. * Gets the default empty texture
  29972. */
  29973. readonly emptyTexture: InternalTexture;
  29974. /**
  29975. * Gets the default empty 3D texture
  29976. */
  29977. readonly emptyTexture3D: InternalTexture;
  29978. /**
  29979. * Gets the default empty cube texture
  29980. */
  29981. readonly emptyCubeTexture: InternalTexture;
  29982. /**
  29983. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29984. */
  29985. readonly premultipliedAlpha: boolean;
  29986. /**
  29987. * Observable event triggered before each texture is initialized
  29988. */
  29989. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29990. /**
  29991. * Creates a new engine
  29992. * @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
  29993. * @param antialias defines enable antialiasing (default: false)
  29994. * @param options defines further options to be sent to the getContext() function
  29995. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29996. */
  29997. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29998. private _rebuildInternalTextures;
  29999. private _rebuildEffects;
  30000. /**
  30001. * Gets a boolean indicating if all created effects are ready
  30002. * @returns true if all effects are ready
  30003. */
  30004. areAllEffectsReady(): boolean;
  30005. protected _rebuildBuffers(): void;
  30006. private _initGLContext;
  30007. /**
  30008. * Gets version of the current webGL context
  30009. */
  30010. readonly webGLVersion: number;
  30011. /**
  30012. * Gets a string idenfifying the name of the class
  30013. * @returns "Engine" string
  30014. */
  30015. getClassName(): string;
  30016. /**
  30017. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30018. */
  30019. readonly isStencilEnable: boolean;
  30020. /** @hidden */
  30021. _prepareWorkingCanvas(): void;
  30022. /**
  30023. * Reset the texture cache to empty state
  30024. */
  30025. resetTextureCache(): void;
  30026. /**
  30027. * Gets an object containing information about the current webGL context
  30028. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30029. */
  30030. getGlInfo(): {
  30031. vendor: string;
  30032. renderer: string;
  30033. version: string;
  30034. };
  30035. /**
  30036. * Defines the hardware scaling level.
  30037. * By default the hardware scaling level is computed from the window device ratio.
  30038. * 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.
  30039. * @param level defines the level to use
  30040. */
  30041. setHardwareScalingLevel(level: number): void;
  30042. /**
  30043. * Gets the current hardware scaling level.
  30044. * By default the hardware scaling level is computed from the window device ratio.
  30045. * 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.
  30046. * @returns a number indicating the current hardware scaling level
  30047. */
  30048. getHardwareScalingLevel(): number;
  30049. /**
  30050. * Gets the list of loaded textures
  30051. * @returns an array containing all loaded textures
  30052. */
  30053. getLoadedTexturesCache(): InternalTexture[];
  30054. /**
  30055. * Gets the object containing all engine capabilities
  30056. * @returns the EngineCapabilities object
  30057. */
  30058. getCaps(): EngineCapabilities;
  30059. /**
  30060. * stop executing a render loop function and remove it from the execution array
  30061. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30062. */
  30063. stopRenderLoop(renderFunction?: () => void): void;
  30064. /** @hidden */
  30065. _renderLoop(): void;
  30066. /**
  30067. * Gets the HTML canvas attached with the current webGL context
  30068. * @returns a HTML canvas
  30069. */
  30070. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30071. /**
  30072. * Gets host window
  30073. * @returns the host window object
  30074. */
  30075. getHostWindow(): Window;
  30076. /**
  30077. * Gets the current render width
  30078. * @param useScreen defines if screen size must be used (or the current render target if any)
  30079. * @returns a number defining the current render width
  30080. */
  30081. getRenderWidth(useScreen?: boolean): number;
  30082. /**
  30083. * Gets the current render height
  30084. * @param useScreen defines if screen size must be used (or the current render target if any)
  30085. * @returns a number defining the current render height
  30086. */
  30087. getRenderHeight(useScreen?: boolean): number;
  30088. /**
  30089. * Can be used to override the current requestAnimationFrame requester.
  30090. * @hidden
  30091. */
  30092. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30093. /**
  30094. * Register and execute a render loop. The engine can have more than one render function
  30095. * @param renderFunction defines the function to continuously execute
  30096. */
  30097. runRenderLoop(renderFunction: () => void): void;
  30098. /**
  30099. * Clear the current render buffer or the current render target (if any is set up)
  30100. * @param color defines the color to use
  30101. * @param backBuffer defines if the back buffer must be cleared
  30102. * @param depth defines if the depth buffer must be cleared
  30103. * @param stencil defines if the stencil buffer must be cleared
  30104. */
  30105. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30106. private _viewportCached;
  30107. /** @hidden */
  30108. _viewport(x: number, y: number, width: number, height: number): void;
  30109. /**
  30110. * Set the WebGL's viewport
  30111. * @param viewport defines the viewport element to be used
  30112. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30113. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30114. */
  30115. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30116. /**
  30117. * Begin a new frame
  30118. */
  30119. beginFrame(): void;
  30120. /**
  30121. * Enf the current frame
  30122. */
  30123. endFrame(): void;
  30124. /**
  30125. * Resize the view according to the canvas' size
  30126. */
  30127. resize(): void;
  30128. /**
  30129. * Force a specific size of the canvas
  30130. * @param width defines the new canvas' width
  30131. * @param height defines the new canvas' height
  30132. */
  30133. setSize(width: number, height: number): void;
  30134. /**
  30135. * Binds the frame buffer to the specified texture.
  30136. * @param texture The texture to render to or null for the default canvas
  30137. * @param faceIndex The face of the texture to render to in case of cube texture
  30138. * @param requiredWidth The width of the target to render to
  30139. * @param requiredHeight The height of the target to render to
  30140. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30141. * @param depthStencilTexture The depth stencil texture to use to render
  30142. * @param lodLevel defines le lod level to bind to the frame buffer
  30143. */
  30144. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30145. /** @hidden */
  30146. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30147. /**
  30148. * Unbind the current render target texture from the webGL context
  30149. * @param texture defines the render target texture to unbind
  30150. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30151. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30152. */
  30153. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30154. /**
  30155. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30156. */
  30157. flushFramebuffer(): void;
  30158. /**
  30159. * Unbind the current render target and bind the default framebuffer
  30160. */
  30161. restoreDefaultFramebuffer(): void;
  30162. private _resetVertexBufferBinding;
  30163. /**
  30164. * Creates a vertex buffer
  30165. * @param data the data for the vertex buffer
  30166. * @returns the new WebGL static buffer
  30167. */
  30168. createVertexBuffer(data: DataArray): DataBuffer;
  30169. private _createVertexBuffer;
  30170. /**
  30171. * Creates a dynamic vertex buffer
  30172. * @param data the data for the dynamic vertex buffer
  30173. * @returns the new WebGL dynamic buffer
  30174. */
  30175. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30176. /**
  30177. * Updates a dynamic vertex buffer.
  30178. * @param vertexBuffer the vertex buffer to update
  30179. * @param data the data used to update the vertex buffer
  30180. * @param byteOffset the byte offset of the data
  30181. * @param byteLength the byte length of the data
  30182. */
  30183. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30184. protected _resetIndexBufferBinding(): void;
  30185. /**
  30186. * Creates a new index buffer
  30187. * @param indices defines the content of the index buffer
  30188. * @param updatable defines if the index buffer must be updatable
  30189. * @returns a new webGL buffer
  30190. */
  30191. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30192. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30193. /**
  30194. * Bind a webGL buffer to the webGL context
  30195. * @param buffer defines the buffer to bind
  30196. */
  30197. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30198. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30199. private bindBuffer;
  30200. /**
  30201. * update the bound buffer with the given data
  30202. * @param data defines the data to update
  30203. */
  30204. updateArrayBuffer(data: Float32Array): void;
  30205. private _vertexAttribPointer;
  30206. private _bindIndexBufferWithCache;
  30207. private _bindVertexBuffersAttributes;
  30208. /**
  30209. * Records a vertex array object
  30210. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30211. * @param vertexBuffers defines the list of vertex buffers to store
  30212. * @param indexBuffer defines the index buffer to store
  30213. * @param effect defines the effect to store
  30214. * @returns the new vertex array object
  30215. */
  30216. recordVertexArrayObject(vertexBuffers: {
  30217. [key: string]: VertexBuffer;
  30218. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30219. /**
  30220. * Bind a specific vertex array object
  30221. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30222. * @param vertexArrayObject defines the vertex array object to bind
  30223. * @param indexBuffer defines the index buffer to bind
  30224. */
  30225. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30226. /**
  30227. * Bind webGl buffers directly to the webGL context
  30228. * @param vertexBuffer defines the vertex buffer to bind
  30229. * @param indexBuffer defines the index buffer to bind
  30230. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30231. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30232. * @param effect defines the effect associated with the vertex buffer
  30233. */
  30234. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30235. private _unbindVertexArrayObject;
  30236. /**
  30237. * Bind a list of vertex buffers to the webGL context
  30238. * @param vertexBuffers defines the list of vertex buffers to bind
  30239. * @param indexBuffer defines the index buffer to bind
  30240. * @param effect defines the effect associated with the vertex buffers
  30241. */
  30242. bindBuffers(vertexBuffers: {
  30243. [key: string]: Nullable<VertexBuffer>;
  30244. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30245. /**
  30246. * Unbind all instance attributes
  30247. */
  30248. unbindInstanceAttributes(): void;
  30249. /**
  30250. * Release and free the memory of a vertex array object
  30251. * @param vao defines the vertex array object to delete
  30252. */
  30253. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30254. /** @hidden */
  30255. _releaseBuffer(buffer: DataBuffer): boolean;
  30256. protected _deleteBuffer(buffer: DataBuffer): void;
  30257. /**
  30258. * Creates a webGL buffer to use with instanciation
  30259. * @param capacity defines the size of the buffer
  30260. * @returns the webGL buffer
  30261. */
  30262. createInstancesBuffer(capacity: number): DataBuffer;
  30263. /**
  30264. * Delete a webGL buffer used with instanciation
  30265. * @param buffer defines the webGL buffer to delete
  30266. */
  30267. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30268. /**
  30269. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30270. * @param instancesBuffer defines the webGL buffer to update and bind
  30271. * @param data defines the data to store in the buffer
  30272. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30273. */
  30274. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30275. /**
  30276. * Apply all cached states (depth, culling, stencil and alpha)
  30277. */
  30278. applyStates(): void;
  30279. /**
  30280. * Send a draw order
  30281. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30282. * @param indexStart defines the starting index
  30283. * @param indexCount defines the number of index to draw
  30284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30285. */
  30286. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30287. /**
  30288. * Draw a list of points
  30289. * @param verticesStart defines the index of first vertex to draw
  30290. * @param verticesCount defines the count of vertices to draw
  30291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30292. */
  30293. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30294. /**
  30295. * Draw a list of unindexed primitives
  30296. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30297. * @param verticesStart defines the index of first vertex to draw
  30298. * @param verticesCount defines the count of vertices to draw
  30299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30300. */
  30301. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30302. /**
  30303. * Draw a list of indexed primitives
  30304. * @param fillMode defines the primitive to use
  30305. * @param indexStart defines the starting index
  30306. * @param indexCount defines the number of index to draw
  30307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30308. */
  30309. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30310. /**
  30311. * Draw a list of unindexed primitives
  30312. * @param fillMode defines the primitive to use
  30313. * @param verticesStart defines the index of first vertex to draw
  30314. * @param verticesCount defines the count of vertices to draw
  30315. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30316. */
  30317. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30318. private _drawMode;
  30319. /** @hidden */
  30320. protected _reportDrawCall(): void;
  30321. /** @hidden */
  30322. _releaseEffect(effect: Effect): void;
  30323. /** @hidden */
  30324. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30325. /**
  30326. * Create a new effect (used to store vertex/fragment shaders)
  30327. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30328. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30329. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30330. * @param samplers defines an array of string used to represent textures
  30331. * @param defines defines the string containing the defines to use to compile the shaders
  30332. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30333. * @param onCompiled defines a function to call when the effect creation is successful
  30334. * @param onError defines a function to call when the effect creation has failed
  30335. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30336. * @returns the new Effect
  30337. */
  30338. 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;
  30339. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30340. private _compileShader;
  30341. private _compileRawShader;
  30342. /**
  30343. * Directly creates a webGL program
  30344. * @param pipelineContext defines the pipeline context to attach to
  30345. * @param vertexCode defines the vertex shader code to use
  30346. * @param fragmentCode defines the fragment shader code to use
  30347. * @param context defines the webGL context to use (if not set, the current one will be used)
  30348. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30349. * @returns the new webGL program
  30350. */
  30351. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30352. /**
  30353. * Creates a webGL program
  30354. * @param pipelineContext defines the pipeline context to attach to
  30355. * @param vertexCode defines the vertex shader code to use
  30356. * @param fragmentCode defines the fragment shader code to use
  30357. * @param defines defines the string containing the defines to use to compile the shaders
  30358. * @param context defines the webGL context to use (if not set, the current one will be used)
  30359. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30360. * @returns the new webGL program
  30361. */
  30362. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30363. /**
  30364. * Creates a new pipeline context
  30365. * @returns the new pipeline
  30366. */
  30367. createPipelineContext(): IPipelineContext;
  30368. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30369. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30370. /** @hidden */
  30371. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30372. /** @hidden */
  30373. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30374. /** @hidden */
  30375. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30376. /**
  30377. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30378. * @param pipelineContext defines the pipeline context to use
  30379. * @param uniformsNames defines the list of uniform names
  30380. * @returns an array of webGL uniform locations
  30381. */
  30382. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30383. /**
  30384. * Gets the lsit of active attributes for a given webGL program
  30385. * @param pipelineContext defines the pipeline context to use
  30386. * @param attributesNames defines the list of attribute names to get
  30387. * @returns an array of indices indicating the offset of each attribute
  30388. */
  30389. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30390. /**
  30391. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30392. * @param effect defines the effect to activate
  30393. */
  30394. enableEffect(effect: Nullable<Effect>): void;
  30395. /**
  30396. * Set the value of an uniform to an array of int32
  30397. * @param uniform defines the webGL uniform location where to store the value
  30398. * @param array defines the array of int32 to store
  30399. */
  30400. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30401. /**
  30402. * Set the value of an uniform to an array of int32 (stored as vec2)
  30403. * @param uniform defines the webGL uniform location where to store the value
  30404. * @param array defines the array of int32 to store
  30405. */
  30406. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30407. /**
  30408. * Set the value of an uniform to an array of int32 (stored as vec3)
  30409. * @param uniform defines the webGL uniform location where to store the value
  30410. * @param array defines the array of int32 to store
  30411. */
  30412. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30413. /**
  30414. * Set the value of an uniform to an array of int32 (stored as vec4)
  30415. * @param uniform defines the webGL uniform location where to store the value
  30416. * @param array defines the array of int32 to store
  30417. */
  30418. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30419. /**
  30420. * Set the value of an uniform to an array of float32
  30421. * @param uniform defines the webGL uniform location where to store the value
  30422. * @param array defines the array of float32 to store
  30423. */
  30424. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30425. /**
  30426. * Set the value of an uniform to an array of float32 (stored as vec2)
  30427. * @param uniform defines the webGL uniform location where to store the value
  30428. * @param array defines the array of float32 to store
  30429. */
  30430. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30431. /**
  30432. * Set the value of an uniform to an array of float32 (stored as vec3)
  30433. * @param uniform defines the webGL uniform location where to store the value
  30434. * @param array defines the array of float32 to store
  30435. */
  30436. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30437. /**
  30438. * Set the value of an uniform to an array of float32 (stored as vec4)
  30439. * @param uniform defines the webGL uniform location where to store the value
  30440. * @param array defines the array of float32 to store
  30441. */
  30442. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30443. /**
  30444. * Set the value of an uniform to an array of number
  30445. * @param uniform defines the webGL uniform location where to store the value
  30446. * @param array defines the array of number to store
  30447. */
  30448. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30449. /**
  30450. * Set the value of an uniform to an array of number (stored as vec2)
  30451. * @param uniform defines the webGL uniform location where to store the value
  30452. * @param array defines the array of number to store
  30453. */
  30454. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30455. /**
  30456. * Set the value of an uniform to an array of number (stored as vec3)
  30457. * @param uniform defines the webGL uniform location where to store the value
  30458. * @param array defines the array of number to store
  30459. */
  30460. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30461. /**
  30462. * Set the value of an uniform to an array of number (stored as vec4)
  30463. * @param uniform defines the webGL uniform location where to store the value
  30464. * @param array defines the array of number to store
  30465. */
  30466. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30467. /**
  30468. * Set the value of an uniform to an array of float32 (stored as matrices)
  30469. * @param uniform defines the webGL uniform location where to store the value
  30470. * @param matrices defines the array of float32 to store
  30471. */
  30472. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30473. /**
  30474. * Set the value of an uniform to a matrix (3x3)
  30475. * @param uniform defines the webGL uniform location where to store the value
  30476. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30477. */
  30478. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30479. /**
  30480. * Set the value of an uniform to a matrix (2x2)
  30481. * @param uniform defines the webGL uniform location where to store the value
  30482. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30483. */
  30484. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30485. /**
  30486. * Set the value of an uniform to a number (int)
  30487. * @param uniform defines the webGL uniform location where to store the value
  30488. * @param value defines the int number to store
  30489. */
  30490. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30491. /**
  30492. * Set the value of an uniform to a number (float)
  30493. * @param uniform defines the webGL uniform location where to store the value
  30494. * @param value defines the float number to store
  30495. */
  30496. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30497. /**
  30498. * Set the value of an uniform to a vec2
  30499. * @param uniform defines the webGL uniform location where to store the value
  30500. * @param x defines the 1st component of the value
  30501. * @param y defines the 2nd component of the value
  30502. */
  30503. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30504. /**
  30505. * Set the value of an uniform to a vec3
  30506. * @param uniform defines the webGL uniform location where to store the value
  30507. * @param x defines the 1st component of the value
  30508. * @param y defines the 2nd component of the value
  30509. * @param z defines the 3rd component of the value
  30510. */
  30511. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30512. /**
  30513. * Set the value of an uniform to a boolean
  30514. * @param uniform defines the webGL uniform location where to store the value
  30515. * @param bool defines the boolean to store
  30516. */
  30517. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30518. /**
  30519. * Set the value of an uniform to a vec4
  30520. * @param uniform defines the webGL uniform location where to store the value
  30521. * @param x defines the 1st component of the value
  30522. * @param y defines the 2nd component of the value
  30523. * @param z defines the 3rd component of the value
  30524. * @param w defines the 4th component of the value
  30525. */
  30526. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30527. /**
  30528. * Sets a Color4 on a uniform variable
  30529. * @param uniform defines the uniform location
  30530. * @param color4 defines the value to be set
  30531. */
  30532. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30533. /**
  30534. * Gets the depth culling state manager
  30535. */
  30536. readonly depthCullingState: DepthCullingState;
  30537. /**
  30538. * Gets the alpha state manager
  30539. */
  30540. readonly alphaState: AlphaState;
  30541. /**
  30542. * Gets the stencil state manager
  30543. */
  30544. readonly stencilState: StencilState;
  30545. /**
  30546. * Clears the list of texture accessible through engine.
  30547. * This can help preventing texture load conflict due to name collision.
  30548. */
  30549. clearInternalTexturesCache(): void;
  30550. /**
  30551. * Force the entire cache to be cleared
  30552. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30553. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30554. */
  30555. wipeCaches(bruteForce?: boolean): void;
  30556. /** @hidden */
  30557. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30558. min: number;
  30559. mag: number;
  30560. };
  30561. /** @hidden */
  30562. _createTexture(): WebGLTexture;
  30563. /**
  30564. * Usually called from Texture.ts.
  30565. * Passed information to create a WebGLTexture
  30566. * @param urlArg defines a value which contains one of the following:
  30567. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30568. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30569. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30570. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30571. * @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)
  30572. * @param scene needed for loading to the correct scene
  30573. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30574. * @param onLoad optional callback to be called upon successful completion
  30575. * @param onError optional callback to be called upon failure
  30576. * @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
  30577. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30578. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30579. * @param forcedExtension defines the extension to use to pick the right loader
  30580. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30581. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30582. */
  30583. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30584. /**
  30585. * @hidden
  30586. */
  30587. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30588. /**
  30589. * Creates a raw texture
  30590. * @param data defines the data to store in the texture
  30591. * @param width defines the width of the texture
  30592. * @param height defines the height of the texture
  30593. * @param format defines the format of the data
  30594. * @param generateMipMaps defines if the engine should generate the mip levels
  30595. * @param invertY defines if data must be stored with Y axis inverted
  30596. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30597. * @param compression defines the compression used (null by default)
  30598. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30599. * @returns the raw texture inside an InternalTexture
  30600. */
  30601. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30602. /**
  30603. * Creates a new raw cube texture
  30604. * @param data defines the array of data to use to create each face
  30605. * @param size defines the size of the textures
  30606. * @param format defines the format of the data
  30607. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30608. * @param generateMipMaps defines if the engine should generate the mip levels
  30609. * @param invertY defines if data must be stored with Y axis inverted
  30610. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30611. * @param compression defines the compression used (null by default)
  30612. * @returns the cube texture as an InternalTexture
  30613. */
  30614. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30615. /**
  30616. * Creates a new raw 3D texture
  30617. * @param data defines the data used to create the texture
  30618. * @param width defines the width of the texture
  30619. * @param height defines the height of the texture
  30620. * @param depth defines the depth of the texture
  30621. * @param format defines the format of the texture
  30622. * @param generateMipMaps defines if the engine must generate mip levels
  30623. * @param invertY defines if data must be stored with Y axis inverted
  30624. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30625. * @param compression defines the compressed used (can be null)
  30626. * @param textureType defines the compressed used (can be null)
  30627. * @returns a new raw 3D texture (stored in an InternalTexture)
  30628. */
  30629. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30630. private _unpackFlipYCached;
  30631. /**
  30632. * In case you are sharing the context with other applications, it might
  30633. * be interested to not cache the unpack flip y state to ensure a consistent
  30634. * value would be set.
  30635. */
  30636. enableUnpackFlipYCached: boolean;
  30637. /** @hidden */
  30638. _unpackFlipY(value: boolean): void;
  30639. /** @hidden */
  30640. _getUnpackAlignement(): number;
  30641. /**
  30642. * Update the sampling mode of a given texture
  30643. * @param samplingMode defines the required sampling mode
  30644. * @param texture defines the texture to update
  30645. */
  30646. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30647. /**
  30648. * Updates a depth texture Comparison Mode and Function.
  30649. * If the comparison Function is equal to 0, the mode will be set to none.
  30650. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30651. * @param texture The texture to set the comparison function for
  30652. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30653. */
  30654. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30655. /** @hidden */
  30656. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30657. width: number;
  30658. height: number;
  30659. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30660. /**
  30661. * Creates a depth stencil texture.
  30662. * This is only available in WebGL 2 or with the depth texture extension available.
  30663. * @param size The size of face edge in the texture.
  30664. * @param options The options defining the texture.
  30665. * @returns The texture
  30666. */
  30667. createDepthStencilTexture(size: number | {
  30668. width: number;
  30669. height: number;
  30670. }, options: DepthTextureCreationOptions): InternalTexture;
  30671. /**
  30672. * Creates a depth stencil texture.
  30673. * This is only available in WebGL 2 or with the depth texture extension available.
  30674. * @param size The size of face edge in the texture.
  30675. * @param options The options defining the texture.
  30676. * @returns The texture
  30677. */
  30678. private _createDepthStencilTexture;
  30679. /** @hidden */
  30680. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30681. /** @hidden */
  30682. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30683. /** @hidden */
  30684. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30685. /** @hidden */
  30686. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30687. /**
  30688. * @hidden
  30689. */
  30690. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30691. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30692. private _prepareWebGLTexture;
  30693. /** @hidden */
  30694. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30695. /** @hidden */
  30696. _releaseFramebufferObjects(texture: InternalTexture): void;
  30697. /** @hidden */
  30698. _releaseTexture(texture: InternalTexture): void;
  30699. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30700. protected _setProgram(program: WebGLProgram): void;
  30701. protected _boundUniforms: {
  30702. [key: number]: WebGLUniformLocation;
  30703. };
  30704. /**
  30705. * Binds an effect to the webGL context
  30706. * @param effect defines the effect to bind
  30707. */
  30708. bindSamplers(effect: Effect): void;
  30709. private _activateCurrentTexture;
  30710. /** @hidden */
  30711. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30712. /** @hidden */
  30713. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30714. /**
  30715. * Unbind all textures from the webGL context
  30716. */
  30717. unbindAllTextures(): void;
  30718. /**
  30719. * Sets a texture to the according uniform.
  30720. * @param channel The texture channel
  30721. * @param uniform The uniform to set
  30722. * @param texture The texture to apply
  30723. */
  30724. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30725. private _bindSamplerUniformToChannel;
  30726. private _getTextureWrapMode;
  30727. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30728. /**
  30729. * Sets an array of texture to the webGL context
  30730. * @param channel defines the channel where the texture array must be set
  30731. * @param uniform defines the associated uniform location
  30732. * @param textures defines the array of textures to bind
  30733. */
  30734. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30735. /** @hidden */
  30736. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30737. private _setTextureParameterFloat;
  30738. private _setTextureParameterInteger;
  30739. /**
  30740. * Unbind all vertex attributes from the webGL context
  30741. */
  30742. unbindAllAttributes(): void;
  30743. /**
  30744. * 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
  30745. */
  30746. releaseEffects(): void;
  30747. /**
  30748. * Dispose and release all associated resources
  30749. */
  30750. dispose(): void;
  30751. /**
  30752. * Attach a new callback raised when context lost event is fired
  30753. * @param callback defines the callback to call
  30754. */
  30755. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30756. /**
  30757. * Attach a new callback raised when context restored event is fired
  30758. * @param callback defines the callback to call
  30759. */
  30760. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30761. /**
  30762. * Get the current error code of the webGL context
  30763. * @returns the error code
  30764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30765. */
  30766. getError(): number;
  30767. private _canRenderToFloatFramebuffer;
  30768. private _canRenderToHalfFloatFramebuffer;
  30769. private _canRenderToFramebuffer;
  30770. /** @hidden */
  30771. _getWebGLTextureType(type: number): number;
  30772. /** @hidden */
  30773. _getInternalFormat(format: number): number;
  30774. /** @hidden */
  30775. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30776. /** @hidden */
  30777. _getRGBAMultiSampleBufferFormat(type: number): number;
  30778. /** @hidden */
  30779. _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;
  30780. /**
  30781. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30782. * @returns true if the engine can be created
  30783. * @ignorenaming
  30784. */
  30785. static isSupported(): boolean;
  30786. /**
  30787. * Find the next highest power of two.
  30788. * @param x Number to start search from.
  30789. * @return Next highest power of two.
  30790. */
  30791. static CeilingPOT(x: number): number;
  30792. /**
  30793. * Find the next lowest power of two.
  30794. * @param x Number to start search from.
  30795. * @return Next lowest power of two.
  30796. */
  30797. static FloorPOT(x: number): number;
  30798. /**
  30799. * Find the nearest power of two.
  30800. * @param x Number to start search from.
  30801. * @return Next nearest power of two.
  30802. */
  30803. static NearestPOT(x: number): number;
  30804. /**
  30805. * Get the closest exponent of two
  30806. * @param value defines the value to approximate
  30807. * @param max defines the maximum value to return
  30808. * @param mode defines how to define the closest value
  30809. * @returns closest exponent of two of the given value
  30810. */
  30811. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30812. /**
  30813. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30814. * @param func - the function to be called
  30815. * @param requester - the object that will request the next frame. Falls back to window.
  30816. * @returns frame number
  30817. */
  30818. static QueueNewFrame(func: () => void, requester?: any): number;
  30819. }
  30820. }
  30821. declare module "babylonjs/Maths/sphericalPolynomial" {
  30822. import { Vector3 } from "babylonjs/Maths/math.vector";
  30823. import { Color3 } from "babylonjs/Maths/math.color";
  30824. /**
  30825. * Class representing spherical harmonics coefficients to the 3rd degree
  30826. */
  30827. export class SphericalHarmonics {
  30828. /**
  30829. * Defines whether or not the harmonics have been prescaled for rendering.
  30830. */
  30831. preScaled: boolean;
  30832. /**
  30833. * The l0,0 coefficients of the spherical harmonics
  30834. */
  30835. l00: Vector3;
  30836. /**
  30837. * The l1,-1 coefficients of the spherical harmonics
  30838. */
  30839. l1_1: Vector3;
  30840. /**
  30841. * The l1,0 coefficients of the spherical harmonics
  30842. */
  30843. l10: Vector3;
  30844. /**
  30845. * The l1,1 coefficients of the spherical harmonics
  30846. */
  30847. l11: Vector3;
  30848. /**
  30849. * The l2,-2 coefficients of the spherical harmonics
  30850. */
  30851. l2_2: Vector3;
  30852. /**
  30853. * The l2,-1 coefficients of the spherical harmonics
  30854. */
  30855. l2_1: Vector3;
  30856. /**
  30857. * The l2,0 coefficients of the spherical harmonics
  30858. */
  30859. l20: Vector3;
  30860. /**
  30861. * The l2,1 coefficients of the spherical harmonics
  30862. */
  30863. l21: Vector3;
  30864. /**
  30865. * The l2,2 coefficients of the spherical harmonics
  30866. */
  30867. l22: Vector3;
  30868. /**
  30869. * Adds a light to the spherical harmonics
  30870. * @param direction the direction of the light
  30871. * @param color the color of the light
  30872. * @param deltaSolidAngle the delta solid angle of the light
  30873. */
  30874. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30875. /**
  30876. * Scales the spherical harmonics by the given amount
  30877. * @param scale the amount to scale
  30878. */
  30879. scaleInPlace(scale: number): void;
  30880. /**
  30881. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30882. *
  30883. * ```
  30884. * E_lm = A_l * L_lm
  30885. * ```
  30886. *
  30887. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30888. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30889. * the scaling factors are given in equation 9.
  30890. */
  30891. convertIncidentRadianceToIrradiance(): void;
  30892. /**
  30893. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30894. *
  30895. * ```
  30896. * L = (1/pi) * E * rho
  30897. * ```
  30898. *
  30899. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30900. */
  30901. convertIrradianceToLambertianRadiance(): void;
  30902. /**
  30903. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30904. * required operations at run time.
  30905. *
  30906. * This is simply done by scaling back the SH with Ylm constants parameter.
  30907. * The trigonometric part being applied by the shader at run time.
  30908. */
  30909. preScaleForRendering(): void;
  30910. /**
  30911. * Constructs a spherical harmonics from an array.
  30912. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30913. * @returns the spherical harmonics
  30914. */
  30915. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30916. /**
  30917. * Gets the spherical harmonics from polynomial
  30918. * @param polynomial the spherical polynomial
  30919. * @returns the spherical harmonics
  30920. */
  30921. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30922. }
  30923. /**
  30924. * Class representing spherical polynomial coefficients to the 3rd degree
  30925. */
  30926. export class SphericalPolynomial {
  30927. private _harmonics;
  30928. /**
  30929. * The spherical harmonics used to create the polynomials.
  30930. */
  30931. readonly preScaledHarmonics: SphericalHarmonics;
  30932. /**
  30933. * The x coefficients of the spherical polynomial
  30934. */
  30935. x: Vector3;
  30936. /**
  30937. * The y coefficients of the spherical polynomial
  30938. */
  30939. y: Vector3;
  30940. /**
  30941. * The z coefficients of the spherical polynomial
  30942. */
  30943. z: Vector3;
  30944. /**
  30945. * The xx coefficients of the spherical polynomial
  30946. */
  30947. xx: Vector3;
  30948. /**
  30949. * The yy coefficients of the spherical polynomial
  30950. */
  30951. yy: Vector3;
  30952. /**
  30953. * The zz coefficients of the spherical polynomial
  30954. */
  30955. zz: Vector3;
  30956. /**
  30957. * The xy coefficients of the spherical polynomial
  30958. */
  30959. xy: Vector3;
  30960. /**
  30961. * The yz coefficients of the spherical polynomial
  30962. */
  30963. yz: Vector3;
  30964. /**
  30965. * The zx coefficients of the spherical polynomial
  30966. */
  30967. zx: Vector3;
  30968. /**
  30969. * Adds an ambient color to the spherical polynomial
  30970. * @param color the color to add
  30971. */
  30972. addAmbient(color: Color3): void;
  30973. /**
  30974. * Scales the spherical polynomial by the given amount
  30975. * @param scale the amount to scale
  30976. */
  30977. scaleInPlace(scale: number): void;
  30978. /**
  30979. * Gets the spherical polynomial from harmonics
  30980. * @param harmonics the spherical harmonics
  30981. * @returns the spherical polynomial
  30982. */
  30983. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30984. /**
  30985. * Constructs a spherical polynomial from an array.
  30986. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30987. * @returns the spherical polynomial
  30988. */
  30989. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30990. }
  30991. }
  30992. declare module "babylonjs/Materials/Textures/internalTexture" {
  30993. import { Observable } from "babylonjs/Misc/observable";
  30994. import { Nullable, int } from "babylonjs/types";
  30995. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30997. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  30998. /**
  30999. * Defines the source of the internal texture
  31000. */
  31001. export enum InternalTextureSource {
  31002. /**
  31003. * The source of the texture data is unknown
  31004. */
  31005. Unknown = 0,
  31006. /**
  31007. * Texture data comes from an URL
  31008. */
  31009. Url = 1,
  31010. /**
  31011. * Texture data is only used for temporary storage
  31012. */
  31013. Temp = 2,
  31014. /**
  31015. * Texture data comes from raw data (ArrayBuffer)
  31016. */
  31017. Raw = 3,
  31018. /**
  31019. * Texture content is dynamic (video or dynamic texture)
  31020. */
  31021. Dynamic = 4,
  31022. /**
  31023. * Texture content is generated by rendering to it
  31024. */
  31025. RenderTarget = 5,
  31026. /**
  31027. * Texture content is part of a multi render target process
  31028. */
  31029. MultiRenderTarget = 6,
  31030. /**
  31031. * Texture data comes from a cube data file
  31032. */
  31033. Cube = 7,
  31034. /**
  31035. * Texture data comes from a raw cube data
  31036. */
  31037. CubeRaw = 8,
  31038. /**
  31039. * Texture data come from a prefiltered cube data file
  31040. */
  31041. CubePrefiltered = 9,
  31042. /**
  31043. * Texture content is raw 3D data
  31044. */
  31045. Raw3D = 10,
  31046. /**
  31047. * Texture content is a depth texture
  31048. */
  31049. Depth = 11,
  31050. /**
  31051. * Texture data comes from a raw cube data encoded with RGBD
  31052. */
  31053. CubeRawRGBD = 12
  31054. }
  31055. /**
  31056. * Class used to store data associated with WebGL texture data for the engine
  31057. * This class should not be used directly
  31058. */
  31059. export class InternalTexture {
  31060. /** @hidden */
  31061. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31062. /**
  31063. * Defines if the texture is ready
  31064. */
  31065. isReady: boolean;
  31066. /**
  31067. * Defines if the texture is a cube texture
  31068. */
  31069. isCube: boolean;
  31070. /**
  31071. * Defines if the texture contains 3D data
  31072. */
  31073. is3D: boolean;
  31074. /**
  31075. * Defines if the texture contains multiview data
  31076. */
  31077. isMultiview: boolean;
  31078. /**
  31079. * Gets the URL used to load this texture
  31080. */
  31081. url: string;
  31082. /**
  31083. * Gets the sampling mode of the texture
  31084. */
  31085. samplingMode: number;
  31086. /**
  31087. * Gets a boolean indicating if the texture needs mipmaps generation
  31088. */
  31089. generateMipMaps: boolean;
  31090. /**
  31091. * Gets the number of samples used by the texture (WebGL2+ only)
  31092. */
  31093. samples: number;
  31094. /**
  31095. * Gets the type of the texture (int, float...)
  31096. */
  31097. type: number;
  31098. /**
  31099. * Gets the format of the texture (RGB, RGBA...)
  31100. */
  31101. format: number;
  31102. /**
  31103. * Observable called when the texture is loaded
  31104. */
  31105. onLoadedObservable: Observable<InternalTexture>;
  31106. /**
  31107. * Gets the width of the texture
  31108. */
  31109. width: number;
  31110. /**
  31111. * Gets the height of the texture
  31112. */
  31113. height: number;
  31114. /**
  31115. * Gets the depth of the texture
  31116. */
  31117. depth: number;
  31118. /**
  31119. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31120. */
  31121. baseWidth: number;
  31122. /**
  31123. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31124. */
  31125. baseHeight: number;
  31126. /**
  31127. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31128. */
  31129. baseDepth: number;
  31130. /**
  31131. * Gets a boolean indicating if the texture is inverted on Y axis
  31132. */
  31133. invertY: boolean;
  31134. /** @hidden */
  31135. _invertVScale: boolean;
  31136. /** @hidden */
  31137. _associatedChannel: number;
  31138. /** @hidden */
  31139. _source: InternalTextureSource;
  31140. /** @hidden */
  31141. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31142. /** @hidden */
  31143. _bufferView: Nullable<ArrayBufferView>;
  31144. /** @hidden */
  31145. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31146. /** @hidden */
  31147. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31148. /** @hidden */
  31149. _size: number;
  31150. /** @hidden */
  31151. _extension: string;
  31152. /** @hidden */
  31153. _files: Nullable<string[]>;
  31154. /** @hidden */
  31155. _workingCanvas: Nullable<HTMLCanvasElement>;
  31156. /** @hidden */
  31157. _workingContext: Nullable<CanvasRenderingContext2D>;
  31158. /** @hidden */
  31159. _framebuffer: Nullable<WebGLFramebuffer>;
  31160. /** @hidden */
  31161. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31162. /** @hidden */
  31163. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31164. /** @hidden */
  31165. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31166. /** @hidden */
  31167. _attachments: Nullable<number[]>;
  31168. /** @hidden */
  31169. _cachedCoordinatesMode: Nullable<number>;
  31170. /** @hidden */
  31171. _cachedWrapU: Nullable<number>;
  31172. /** @hidden */
  31173. _cachedWrapV: Nullable<number>;
  31174. /** @hidden */
  31175. _cachedWrapR: Nullable<number>;
  31176. /** @hidden */
  31177. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31178. /** @hidden */
  31179. _isDisabled: boolean;
  31180. /** @hidden */
  31181. _compression: Nullable<string>;
  31182. /** @hidden */
  31183. _generateStencilBuffer: boolean;
  31184. /** @hidden */
  31185. _generateDepthBuffer: boolean;
  31186. /** @hidden */
  31187. _comparisonFunction: number;
  31188. /** @hidden */
  31189. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31190. /** @hidden */
  31191. _lodGenerationScale: number;
  31192. /** @hidden */
  31193. _lodGenerationOffset: number;
  31194. /** @hidden */
  31195. _colorTextureArray: Nullable<WebGLTexture>;
  31196. /** @hidden */
  31197. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31198. /** @hidden */
  31199. _lodTextureHigh: Nullable<BaseTexture>;
  31200. /** @hidden */
  31201. _lodTextureMid: Nullable<BaseTexture>;
  31202. /** @hidden */
  31203. _lodTextureLow: Nullable<BaseTexture>;
  31204. /** @hidden */
  31205. _isRGBD: boolean;
  31206. /** @hidden */
  31207. _linearSpecularLOD: boolean;
  31208. /** @hidden */
  31209. _irradianceTexture: Nullable<BaseTexture>;
  31210. /** @hidden */
  31211. _webGLTexture: Nullable<WebGLTexture>;
  31212. /** @hidden */
  31213. _references: number;
  31214. private _engine;
  31215. /**
  31216. * Gets the Engine the texture belongs to.
  31217. * @returns The babylon engine
  31218. */
  31219. getEngine(): ThinEngine;
  31220. /**
  31221. * Gets the data source type of the texture
  31222. */
  31223. readonly source: InternalTextureSource;
  31224. /**
  31225. * Creates a new InternalTexture
  31226. * @param engine defines the engine to use
  31227. * @param source defines the type of data that will be used
  31228. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31229. */
  31230. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31231. /**
  31232. * Increments the number of references (ie. the number of Texture that point to it)
  31233. */
  31234. incrementReferences(): void;
  31235. /**
  31236. * Change the size of the texture (not the size of the content)
  31237. * @param width defines the new width
  31238. * @param height defines the new height
  31239. * @param depth defines the new depth (1 by default)
  31240. */
  31241. updateSize(width: int, height: int, depth?: int): void;
  31242. /** @hidden */
  31243. _rebuild(): void;
  31244. /** @hidden */
  31245. _swapAndDie(target: InternalTexture): void;
  31246. /**
  31247. * Dispose the current allocated resources
  31248. */
  31249. dispose(): void;
  31250. }
  31251. }
  31252. declare module "babylonjs/Audio/analyser" {
  31253. import { Scene } from "babylonjs/scene";
  31254. /**
  31255. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31256. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31257. */
  31258. export class Analyser {
  31259. /**
  31260. * Gets or sets the smoothing
  31261. * @ignorenaming
  31262. */
  31263. SMOOTHING: number;
  31264. /**
  31265. * Gets or sets the FFT table size
  31266. * @ignorenaming
  31267. */
  31268. FFT_SIZE: number;
  31269. /**
  31270. * Gets or sets the bar graph amplitude
  31271. * @ignorenaming
  31272. */
  31273. BARGRAPHAMPLITUDE: number;
  31274. /**
  31275. * Gets or sets the position of the debug canvas
  31276. * @ignorenaming
  31277. */
  31278. DEBUGCANVASPOS: {
  31279. x: number;
  31280. y: number;
  31281. };
  31282. /**
  31283. * Gets or sets the debug canvas size
  31284. * @ignorenaming
  31285. */
  31286. DEBUGCANVASSIZE: {
  31287. width: number;
  31288. height: number;
  31289. };
  31290. private _byteFreqs;
  31291. private _byteTime;
  31292. private _floatFreqs;
  31293. private _webAudioAnalyser;
  31294. private _debugCanvas;
  31295. private _debugCanvasContext;
  31296. private _scene;
  31297. private _registerFunc;
  31298. private _audioEngine;
  31299. /**
  31300. * Creates a new analyser
  31301. * @param scene defines hosting scene
  31302. */
  31303. constructor(scene: Scene);
  31304. /**
  31305. * Get the number of data values you will have to play with for the visualization
  31306. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31307. * @returns a number
  31308. */
  31309. getFrequencyBinCount(): number;
  31310. /**
  31311. * Gets the current frequency data as a byte array
  31312. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31313. * @returns a Uint8Array
  31314. */
  31315. getByteFrequencyData(): Uint8Array;
  31316. /**
  31317. * Gets the current waveform as a byte array
  31318. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31319. * @returns a Uint8Array
  31320. */
  31321. getByteTimeDomainData(): Uint8Array;
  31322. /**
  31323. * Gets the current frequency data as a float array
  31324. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31325. * @returns a Float32Array
  31326. */
  31327. getFloatFrequencyData(): Float32Array;
  31328. /**
  31329. * Renders the debug canvas
  31330. */
  31331. drawDebugCanvas(): void;
  31332. /**
  31333. * Stops rendering the debug canvas and removes it
  31334. */
  31335. stopDebugCanvas(): void;
  31336. /**
  31337. * Connects two audio nodes
  31338. * @param inputAudioNode defines first node to connect
  31339. * @param outputAudioNode defines second node to connect
  31340. */
  31341. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31342. /**
  31343. * Releases all associated resources
  31344. */
  31345. dispose(): void;
  31346. }
  31347. }
  31348. declare module "babylonjs/Audio/audioEngine" {
  31349. import { IDisposable } from "babylonjs/scene";
  31350. import { Analyser } from "babylonjs/Audio/analyser";
  31351. import { Nullable } from "babylonjs/types";
  31352. import { Observable } from "babylonjs/Misc/observable";
  31353. /**
  31354. * This represents an audio engine and it is responsible
  31355. * to play, synchronize and analyse sounds throughout the application.
  31356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31357. */
  31358. export interface IAudioEngine extends IDisposable {
  31359. /**
  31360. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31361. */
  31362. readonly canUseWebAudio: boolean;
  31363. /**
  31364. * Gets the current AudioContext if available.
  31365. */
  31366. readonly audioContext: Nullable<AudioContext>;
  31367. /**
  31368. * The master gain node defines the global audio volume of your audio engine.
  31369. */
  31370. readonly masterGain: GainNode;
  31371. /**
  31372. * Gets whether or not mp3 are supported by your browser.
  31373. */
  31374. readonly isMP3supported: boolean;
  31375. /**
  31376. * Gets whether or not ogg are supported by your browser.
  31377. */
  31378. readonly isOGGsupported: boolean;
  31379. /**
  31380. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31381. * @ignoreNaming
  31382. */
  31383. WarnedWebAudioUnsupported: boolean;
  31384. /**
  31385. * Defines if the audio engine relies on a custom unlocked button.
  31386. * In this case, the embedded button will not be displayed.
  31387. */
  31388. useCustomUnlockedButton: boolean;
  31389. /**
  31390. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31391. */
  31392. readonly unlocked: boolean;
  31393. /**
  31394. * Event raised when audio has been unlocked on the browser.
  31395. */
  31396. onAudioUnlockedObservable: Observable<AudioEngine>;
  31397. /**
  31398. * Event raised when audio has been locked on the browser.
  31399. */
  31400. onAudioLockedObservable: Observable<AudioEngine>;
  31401. /**
  31402. * Flags the audio engine in Locked state.
  31403. * This happens due to new browser policies preventing audio to autoplay.
  31404. */
  31405. lock(): void;
  31406. /**
  31407. * Unlocks the audio engine once a user action has been done on the dom.
  31408. * This is helpful to resume play once browser policies have been satisfied.
  31409. */
  31410. unlock(): void;
  31411. }
  31412. /**
  31413. * This represents the default audio engine used in babylon.
  31414. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31416. */
  31417. export class AudioEngine implements IAudioEngine {
  31418. private _audioContext;
  31419. private _audioContextInitialized;
  31420. private _muteButton;
  31421. private _hostElement;
  31422. /**
  31423. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31424. */
  31425. canUseWebAudio: boolean;
  31426. /**
  31427. * The master gain node defines the global audio volume of your audio engine.
  31428. */
  31429. masterGain: GainNode;
  31430. /**
  31431. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31432. * @ignoreNaming
  31433. */
  31434. WarnedWebAudioUnsupported: boolean;
  31435. /**
  31436. * Gets whether or not mp3 are supported by your browser.
  31437. */
  31438. isMP3supported: boolean;
  31439. /**
  31440. * Gets whether or not ogg are supported by your browser.
  31441. */
  31442. isOGGsupported: boolean;
  31443. /**
  31444. * Gets whether audio has been unlocked on the device.
  31445. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31446. * a user interaction has happened.
  31447. */
  31448. unlocked: boolean;
  31449. /**
  31450. * Defines if the audio engine relies on a custom unlocked button.
  31451. * In this case, the embedded button will not be displayed.
  31452. */
  31453. useCustomUnlockedButton: boolean;
  31454. /**
  31455. * Event raised when audio has been unlocked on the browser.
  31456. */
  31457. onAudioUnlockedObservable: Observable<AudioEngine>;
  31458. /**
  31459. * Event raised when audio has been locked on the browser.
  31460. */
  31461. onAudioLockedObservable: Observable<AudioEngine>;
  31462. /**
  31463. * Gets the current AudioContext if available.
  31464. */
  31465. readonly audioContext: Nullable<AudioContext>;
  31466. private _connectedAnalyser;
  31467. /**
  31468. * Instantiates a new audio engine.
  31469. *
  31470. * There should be only one per page as some browsers restrict the number
  31471. * of audio contexts you can create.
  31472. * @param hostElement defines the host element where to display the mute icon if necessary
  31473. */
  31474. constructor(hostElement?: Nullable<HTMLElement>);
  31475. /**
  31476. * Flags the audio engine in Locked state.
  31477. * This happens due to new browser policies preventing audio to autoplay.
  31478. */
  31479. lock(): void;
  31480. /**
  31481. * Unlocks the audio engine once a user action has been done on the dom.
  31482. * This is helpful to resume play once browser policies have been satisfied.
  31483. */
  31484. unlock(): void;
  31485. private _resumeAudioContext;
  31486. private _initializeAudioContext;
  31487. private _tryToRun;
  31488. private _triggerRunningState;
  31489. private _triggerSuspendedState;
  31490. private _displayMuteButton;
  31491. private _moveButtonToTopLeft;
  31492. private _onResize;
  31493. private _hideMuteButton;
  31494. /**
  31495. * Destroy and release the resources associated with the audio ccontext.
  31496. */
  31497. dispose(): void;
  31498. /**
  31499. * Gets the global volume sets on the master gain.
  31500. * @returns the global volume if set or -1 otherwise
  31501. */
  31502. getGlobalVolume(): number;
  31503. /**
  31504. * Sets the global volume of your experience (sets on the master gain).
  31505. * @param newVolume Defines the new global volume of the application
  31506. */
  31507. setGlobalVolume(newVolume: number): void;
  31508. /**
  31509. * Connect the audio engine to an audio analyser allowing some amazing
  31510. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31512. * @param analyser The analyser to connect to the engine
  31513. */
  31514. connectToAnalyser(analyser: Analyser): void;
  31515. }
  31516. }
  31517. declare module "babylonjs/Loading/loadingScreen" {
  31518. /**
  31519. * Interface used to present a loading screen while loading a scene
  31520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31521. */
  31522. export interface ILoadingScreen {
  31523. /**
  31524. * Function called to display the loading screen
  31525. */
  31526. displayLoadingUI: () => void;
  31527. /**
  31528. * Function called to hide the loading screen
  31529. */
  31530. hideLoadingUI: () => void;
  31531. /**
  31532. * Gets or sets the color to use for the background
  31533. */
  31534. loadingUIBackgroundColor: string;
  31535. /**
  31536. * Gets or sets the text to display while loading
  31537. */
  31538. loadingUIText: string;
  31539. }
  31540. /**
  31541. * Class used for the default loading screen
  31542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31543. */
  31544. export class DefaultLoadingScreen implements ILoadingScreen {
  31545. private _renderingCanvas;
  31546. private _loadingText;
  31547. private _loadingDivBackgroundColor;
  31548. private _loadingDiv;
  31549. private _loadingTextDiv;
  31550. /** Gets or sets the logo url to use for the default loading screen */
  31551. static DefaultLogoUrl: string;
  31552. /** Gets or sets the spinner url to use for the default loading screen */
  31553. static DefaultSpinnerUrl: string;
  31554. /**
  31555. * Creates a new default loading screen
  31556. * @param _renderingCanvas defines the canvas used to render the scene
  31557. * @param _loadingText defines the default text to display
  31558. * @param _loadingDivBackgroundColor defines the default background color
  31559. */
  31560. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31561. /**
  31562. * Function called to display the loading screen
  31563. */
  31564. displayLoadingUI(): void;
  31565. /**
  31566. * Function called to hide the loading screen
  31567. */
  31568. hideLoadingUI(): void;
  31569. /**
  31570. * Gets or sets the text to display while loading
  31571. */
  31572. loadingUIText: string;
  31573. /**
  31574. * Gets or sets the color to use for the background
  31575. */
  31576. loadingUIBackgroundColor: string;
  31577. private _resizeLoadingUI;
  31578. }
  31579. }
  31580. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31581. /**
  31582. * Interface for any object that can request an animation frame
  31583. */
  31584. export interface ICustomAnimationFrameRequester {
  31585. /**
  31586. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31587. */
  31588. renderFunction?: Function;
  31589. /**
  31590. * Called to request the next frame to render to
  31591. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31592. */
  31593. requestAnimationFrame: Function;
  31594. /**
  31595. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31596. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31597. */
  31598. requestID?: number;
  31599. }
  31600. }
  31601. declare module "babylonjs/Misc/performanceMonitor" {
  31602. /**
  31603. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31604. */
  31605. export class PerformanceMonitor {
  31606. private _enabled;
  31607. private _rollingFrameTime;
  31608. private _lastFrameTimeMs;
  31609. /**
  31610. * constructor
  31611. * @param frameSampleSize The number of samples required to saturate the sliding window
  31612. */
  31613. constructor(frameSampleSize?: number);
  31614. /**
  31615. * Samples current frame
  31616. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31617. */
  31618. sampleFrame(timeMs?: number): void;
  31619. /**
  31620. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31621. */
  31622. readonly averageFrameTime: number;
  31623. /**
  31624. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31625. */
  31626. readonly averageFrameTimeVariance: number;
  31627. /**
  31628. * Returns the frame time of the most recent frame
  31629. */
  31630. readonly instantaneousFrameTime: number;
  31631. /**
  31632. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31633. */
  31634. readonly averageFPS: number;
  31635. /**
  31636. * Returns the average framerate in frames per second using the most recent frame time
  31637. */
  31638. readonly instantaneousFPS: number;
  31639. /**
  31640. * Returns true if enough samples have been taken to completely fill the sliding window
  31641. */
  31642. readonly isSaturated: boolean;
  31643. /**
  31644. * Enables contributions to the sliding window sample set
  31645. */
  31646. enable(): void;
  31647. /**
  31648. * Disables contributions to the sliding window sample set
  31649. * Samples will not be interpolated over the disabled period
  31650. */
  31651. disable(): void;
  31652. /**
  31653. * Returns true if sampling is enabled
  31654. */
  31655. readonly isEnabled: boolean;
  31656. /**
  31657. * Resets performance monitor
  31658. */
  31659. reset(): void;
  31660. }
  31661. /**
  31662. * RollingAverage
  31663. *
  31664. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31665. */
  31666. export class RollingAverage {
  31667. /**
  31668. * Current average
  31669. */
  31670. average: number;
  31671. /**
  31672. * Current variance
  31673. */
  31674. variance: number;
  31675. protected _samples: Array<number>;
  31676. protected _sampleCount: number;
  31677. protected _pos: number;
  31678. protected _m2: number;
  31679. /**
  31680. * constructor
  31681. * @param length The number of samples required to saturate the sliding window
  31682. */
  31683. constructor(length: number);
  31684. /**
  31685. * Adds a sample to the sample set
  31686. * @param v The sample value
  31687. */
  31688. add(v: number): void;
  31689. /**
  31690. * Returns previously added values or null if outside of history or outside the sliding window domain
  31691. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31692. * @return Value previously recorded with add() or null if outside of range
  31693. */
  31694. history(i: number): number;
  31695. /**
  31696. * Returns true if enough samples have been taken to completely fill the sliding window
  31697. * @return true if sample-set saturated
  31698. */
  31699. isSaturated(): boolean;
  31700. /**
  31701. * Resets the rolling average (equivalent to 0 samples taken so far)
  31702. */
  31703. reset(): void;
  31704. /**
  31705. * Wraps a value around the sample range boundaries
  31706. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31707. * @return Wrapped position in sample range
  31708. */
  31709. protected _wrapPosition(i: number): number;
  31710. }
  31711. }
  31712. declare module "babylonjs/Misc/perfCounter" {
  31713. /**
  31714. * This class is used to track a performance counter which is number based.
  31715. * The user has access to many properties which give statistics of different nature.
  31716. *
  31717. * The implementer can track two kinds of Performance Counter: time and count.
  31718. * 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.
  31719. * 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.
  31720. */
  31721. export class PerfCounter {
  31722. /**
  31723. * Gets or sets a global boolean to turn on and off all the counters
  31724. */
  31725. static Enabled: boolean;
  31726. /**
  31727. * Returns the smallest value ever
  31728. */
  31729. readonly min: number;
  31730. /**
  31731. * Returns the biggest value ever
  31732. */
  31733. readonly max: number;
  31734. /**
  31735. * Returns the average value since the performance counter is running
  31736. */
  31737. readonly average: number;
  31738. /**
  31739. * Returns the average value of the last second the counter was monitored
  31740. */
  31741. readonly lastSecAverage: number;
  31742. /**
  31743. * Returns the current value
  31744. */
  31745. readonly current: number;
  31746. /**
  31747. * Gets the accumulated total
  31748. */
  31749. readonly total: number;
  31750. /**
  31751. * Gets the total value count
  31752. */
  31753. readonly count: number;
  31754. /**
  31755. * Creates a new counter
  31756. */
  31757. constructor();
  31758. /**
  31759. * Call this method to start monitoring a new frame.
  31760. * 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.
  31761. */
  31762. fetchNewFrame(): void;
  31763. /**
  31764. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31765. * @param newCount the count value to add to the monitored count
  31766. * @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.
  31767. */
  31768. addCount(newCount: number, fetchResult: boolean): void;
  31769. /**
  31770. * Start monitoring this performance counter
  31771. */
  31772. beginMonitoring(): void;
  31773. /**
  31774. * Compute the time lapsed since the previous beginMonitoring() call.
  31775. * @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
  31776. */
  31777. endMonitoring(newFrame?: boolean): void;
  31778. private _fetchResult;
  31779. private _startMonitoringTime;
  31780. private _min;
  31781. private _max;
  31782. private _average;
  31783. private _current;
  31784. private _totalValueCount;
  31785. private _totalAccumulated;
  31786. private _lastSecAverage;
  31787. private _lastSecAccumulated;
  31788. private _lastSecTime;
  31789. private _lastSecValueCount;
  31790. }
  31791. }
  31792. declare module "babylonjs/Engines/engine" {
  31793. import { Observable } from "babylonjs/Misc/observable";
  31794. import { Nullable, IndicesArray } from "babylonjs/types";
  31795. import { Scene } from "babylonjs/scene";
  31796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31797. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31798. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31799. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31800. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31801. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31802. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31803. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31804. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31806. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31807. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31808. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31809. import { Material } from "babylonjs/Materials/material";
  31810. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31811. /**
  31812. * Defines the interface used by display changed events
  31813. */
  31814. export interface IDisplayChangedEventArgs {
  31815. /** Gets the vrDisplay object (if any) */
  31816. vrDisplay: Nullable<any>;
  31817. /** Gets a boolean indicating if webVR is supported */
  31818. vrSupported: boolean;
  31819. }
  31820. /**
  31821. * Defines the interface used by objects containing a viewport (like a camera)
  31822. */
  31823. interface IViewportOwnerLike {
  31824. /**
  31825. * Gets or sets the viewport
  31826. */
  31827. viewport: IViewportLike;
  31828. }
  31829. /**
  31830. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31831. */
  31832. export class Engine extends ThinEngine {
  31833. /** Defines that alpha blending is disabled */
  31834. static readonly ALPHA_DISABLE: number;
  31835. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31836. static readonly ALPHA_ADD: number;
  31837. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31838. static readonly ALPHA_COMBINE: number;
  31839. /** Defines that alpha blending to DEST - SRC * DEST */
  31840. static readonly ALPHA_SUBTRACT: number;
  31841. /** Defines that alpha blending to SRC * DEST */
  31842. static readonly ALPHA_MULTIPLY: number;
  31843. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31844. static readonly ALPHA_MAXIMIZED: number;
  31845. /** Defines that alpha blending to SRC + DEST */
  31846. static readonly ALPHA_ONEONE: number;
  31847. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31848. static readonly ALPHA_PREMULTIPLIED: number;
  31849. /**
  31850. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31851. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31852. */
  31853. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31854. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31855. static readonly ALPHA_INTERPOLATE: number;
  31856. /**
  31857. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31858. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31859. */
  31860. static readonly ALPHA_SCREENMODE: number;
  31861. /** Defines that the ressource is not delayed*/
  31862. static readonly DELAYLOADSTATE_NONE: number;
  31863. /** Defines that the ressource was successfully delay loaded */
  31864. static readonly DELAYLOADSTATE_LOADED: number;
  31865. /** Defines that the ressource is currently delay loading */
  31866. static readonly DELAYLOADSTATE_LOADING: number;
  31867. /** Defines that the ressource is delayed and has not started loading */
  31868. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31869. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31870. static readonly NEVER: number;
  31871. /** 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 */
  31872. static readonly ALWAYS: number;
  31873. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31874. static readonly LESS: number;
  31875. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31876. static readonly EQUAL: number;
  31877. /** 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 */
  31878. static readonly LEQUAL: number;
  31879. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31880. static readonly GREATER: number;
  31881. /** 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 */
  31882. static readonly GEQUAL: number;
  31883. /** 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 */
  31884. static readonly NOTEQUAL: number;
  31885. /** Passed to stencilOperation to specify that stencil value must be kept */
  31886. static readonly KEEP: number;
  31887. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31888. static readonly REPLACE: number;
  31889. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31890. static readonly INCR: number;
  31891. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31892. static readonly DECR: number;
  31893. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31894. static readonly INVERT: number;
  31895. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31896. static readonly INCR_WRAP: number;
  31897. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31898. static readonly DECR_WRAP: number;
  31899. /** Texture is not repeating outside of 0..1 UVs */
  31900. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31901. /** Texture is repeating outside of 0..1 UVs */
  31902. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31903. /** Texture is repeating and mirrored */
  31904. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31905. /** ALPHA */
  31906. static readonly TEXTUREFORMAT_ALPHA: number;
  31907. /** LUMINANCE */
  31908. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31909. /** LUMINANCE_ALPHA */
  31910. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31911. /** RGB */
  31912. static readonly TEXTUREFORMAT_RGB: number;
  31913. /** RGBA */
  31914. static readonly TEXTUREFORMAT_RGBA: number;
  31915. /** RED */
  31916. static readonly TEXTUREFORMAT_RED: number;
  31917. /** RED (2nd reference) */
  31918. static readonly TEXTUREFORMAT_R: number;
  31919. /** RG */
  31920. static readonly TEXTUREFORMAT_RG: number;
  31921. /** RED_INTEGER */
  31922. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31923. /** RED_INTEGER (2nd reference) */
  31924. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31925. /** RG_INTEGER */
  31926. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31927. /** RGB_INTEGER */
  31928. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31929. /** RGBA_INTEGER */
  31930. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31931. /** UNSIGNED_BYTE */
  31932. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31933. /** UNSIGNED_BYTE (2nd reference) */
  31934. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31935. /** FLOAT */
  31936. static readonly TEXTURETYPE_FLOAT: number;
  31937. /** HALF_FLOAT */
  31938. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31939. /** BYTE */
  31940. static readonly TEXTURETYPE_BYTE: number;
  31941. /** SHORT */
  31942. static readonly TEXTURETYPE_SHORT: number;
  31943. /** UNSIGNED_SHORT */
  31944. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31945. /** INT */
  31946. static readonly TEXTURETYPE_INT: number;
  31947. /** UNSIGNED_INT */
  31948. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31949. /** UNSIGNED_SHORT_4_4_4_4 */
  31950. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31951. /** UNSIGNED_SHORT_5_5_5_1 */
  31952. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31953. /** UNSIGNED_SHORT_5_6_5 */
  31954. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31955. /** UNSIGNED_INT_2_10_10_10_REV */
  31956. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31957. /** UNSIGNED_INT_24_8 */
  31958. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31959. /** UNSIGNED_INT_10F_11F_11F_REV */
  31960. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31961. /** UNSIGNED_INT_5_9_9_9_REV */
  31962. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31963. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31964. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31965. /** nearest is mag = nearest and min = nearest and mip = linear */
  31966. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31967. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31968. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31969. /** Trilinear is mag = linear and min = linear and mip = linear */
  31970. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31971. /** nearest is mag = nearest and min = nearest and mip = linear */
  31972. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31973. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31974. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31975. /** Trilinear is mag = linear and min = linear and mip = linear */
  31976. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31977. /** mag = nearest and min = nearest and mip = nearest */
  31978. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31979. /** mag = nearest and min = linear and mip = nearest */
  31980. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31981. /** mag = nearest and min = linear and mip = linear */
  31982. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31983. /** mag = nearest and min = linear and mip = none */
  31984. static readonly TEXTURE_NEAREST_LINEAR: number;
  31985. /** mag = nearest and min = nearest and mip = none */
  31986. static readonly TEXTURE_NEAREST_NEAREST: number;
  31987. /** mag = linear and min = nearest and mip = nearest */
  31988. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31989. /** mag = linear and min = nearest and mip = linear */
  31990. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31991. /** mag = linear and min = linear and mip = none */
  31992. static readonly TEXTURE_LINEAR_LINEAR: number;
  31993. /** mag = linear and min = nearest and mip = none */
  31994. static readonly TEXTURE_LINEAR_NEAREST: number;
  31995. /** Explicit coordinates mode */
  31996. static readonly TEXTURE_EXPLICIT_MODE: number;
  31997. /** Spherical coordinates mode */
  31998. static readonly TEXTURE_SPHERICAL_MODE: number;
  31999. /** Planar coordinates mode */
  32000. static readonly TEXTURE_PLANAR_MODE: number;
  32001. /** Cubic coordinates mode */
  32002. static readonly TEXTURE_CUBIC_MODE: number;
  32003. /** Projection coordinates mode */
  32004. static readonly TEXTURE_PROJECTION_MODE: number;
  32005. /** Skybox coordinates mode */
  32006. static readonly TEXTURE_SKYBOX_MODE: number;
  32007. /** Inverse Cubic coordinates mode */
  32008. static readonly TEXTURE_INVCUBIC_MODE: number;
  32009. /** Equirectangular coordinates mode */
  32010. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32011. /** Equirectangular Fixed coordinates mode */
  32012. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32013. /** Equirectangular Fixed Mirrored coordinates mode */
  32014. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32015. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32016. static readonly SCALEMODE_FLOOR: number;
  32017. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32018. static readonly SCALEMODE_NEAREST: number;
  32019. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32020. static readonly SCALEMODE_CEILING: number;
  32021. /**
  32022. * Returns the current npm package of the sdk
  32023. */
  32024. static readonly NpmPackage: string;
  32025. /**
  32026. * Returns the current version of the framework
  32027. */
  32028. static readonly Version: string;
  32029. /** Gets the list of created engines */
  32030. static readonly Instances: Engine[];
  32031. /**
  32032. * Gets the latest created engine
  32033. */
  32034. static readonly LastCreatedEngine: Nullable<Engine>;
  32035. /**
  32036. * Gets the latest created scene
  32037. */
  32038. static readonly LastCreatedScene: Nullable<Scene>;
  32039. /**
  32040. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32041. * @param flag defines which part of the materials must be marked as dirty
  32042. * @param predicate defines a predicate used to filter which materials should be affected
  32043. */
  32044. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32045. /**
  32046. * Method called to create the default loading screen.
  32047. * This can be overriden in your own app.
  32048. * @param canvas The rendering canvas element
  32049. * @returns The loading screen
  32050. */
  32051. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32052. /**
  32053. * Method called to create the default rescale post process on each engine.
  32054. */
  32055. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32056. /**
  32057. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32058. **/
  32059. enableOfflineSupport: boolean;
  32060. /**
  32061. * 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)
  32062. **/
  32063. disableManifestCheck: boolean;
  32064. /**
  32065. * Gets the list of created scenes
  32066. */
  32067. scenes: Scene[];
  32068. /**
  32069. * Event raised when a new scene is created
  32070. */
  32071. onNewSceneAddedObservable: Observable<Scene>;
  32072. /**
  32073. * Gets the list of created postprocesses
  32074. */
  32075. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32076. /**
  32077. * Gets a boolean indicating if the pointer is currently locked
  32078. */
  32079. isPointerLock: boolean;
  32080. /**
  32081. * Observable event triggered each time the rendering canvas is resized
  32082. */
  32083. onResizeObservable: Observable<Engine>;
  32084. /**
  32085. * Observable event triggered each time the canvas loses focus
  32086. */
  32087. onCanvasBlurObservable: Observable<Engine>;
  32088. /**
  32089. * Observable event triggered each time the canvas gains focus
  32090. */
  32091. onCanvasFocusObservable: Observable<Engine>;
  32092. /**
  32093. * Observable event triggered each time the canvas receives pointerout event
  32094. */
  32095. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32096. /**
  32097. * Observable raised when the engine begins a new frame
  32098. */
  32099. onBeginFrameObservable: Observable<Engine>;
  32100. /**
  32101. * If set, will be used to request the next animation frame for the render loop
  32102. */
  32103. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32104. /**
  32105. * Observable raised when the engine ends the current frame
  32106. */
  32107. onEndFrameObservable: Observable<Engine>;
  32108. /**
  32109. * Observable raised when the engine is about to compile a shader
  32110. */
  32111. onBeforeShaderCompilationObservable: Observable<Engine>;
  32112. /**
  32113. * Observable raised when the engine has jsut compiled a shader
  32114. */
  32115. onAfterShaderCompilationObservable: Observable<Engine>;
  32116. /**
  32117. * Gets the audio engine
  32118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32119. * @ignorenaming
  32120. */
  32121. static audioEngine: IAudioEngine;
  32122. /**
  32123. * Default AudioEngine factory responsible of creating the Audio Engine.
  32124. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32125. */
  32126. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32127. /**
  32128. * Default offline support factory responsible of creating a tool used to store data locally.
  32129. * By default, this will create a Database object if the workload has been embedded.
  32130. */
  32131. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32132. private _loadingScreen;
  32133. private _pointerLockRequested;
  32134. private _dummyFramebuffer;
  32135. private _rescalePostProcess;
  32136. /** @hidden */
  32137. protected _alphaMode: number;
  32138. /** @hidden */
  32139. protected _alphaEquation: number;
  32140. private _deterministicLockstep;
  32141. private _lockstepMaxSteps;
  32142. protected readonly _supportsHardwareTextureRescaling: boolean;
  32143. private _fps;
  32144. private _deltaTime;
  32145. /** @hidden */
  32146. _drawCalls: PerfCounter;
  32147. /**
  32148. * Turn this value on if you want to pause FPS computation when in background
  32149. */
  32150. disablePerformanceMonitorInBackground: boolean;
  32151. private _performanceMonitor;
  32152. /**
  32153. * Gets the performance monitor attached to this engine
  32154. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32155. */
  32156. readonly performanceMonitor: PerformanceMonitor;
  32157. private _onFocus;
  32158. private _onBlur;
  32159. private _onCanvasPointerOut;
  32160. private _onCanvasBlur;
  32161. private _onCanvasFocus;
  32162. private _onFullscreenChange;
  32163. private _onPointerLockChange;
  32164. /**
  32165. * Creates a new engine
  32166. * @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
  32167. * @param antialias defines enable antialiasing (default: false)
  32168. * @param options defines further options to be sent to the getContext() function
  32169. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32170. */
  32171. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32172. /**
  32173. * Gets current aspect ratio
  32174. * @param viewportOwner defines the camera to use to get the aspect ratio
  32175. * @param useScreen defines if screen size must be used (or the current render target if any)
  32176. * @returns a number defining the aspect ratio
  32177. */
  32178. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32179. /**
  32180. * Gets current screen aspect ratio
  32181. * @returns a number defining the aspect ratio
  32182. */
  32183. getScreenAspectRatio(): number;
  32184. /**
  32185. * Gets host document
  32186. * @returns the host document object
  32187. */
  32188. getHostDocument(): Document;
  32189. /**
  32190. * Gets the client rect of the HTML canvas attached with the current webGL context
  32191. * @returns a client rectanglee
  32192. */
  32193. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32194. /**
  32195. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32197. * @returns true if engine is in deterministic lock step mode
  32198. */
  32199. isDeterministicLockStep(): boolean;
  32200. /**
  32201. * Gets the max steps when engine is running in deterministic lock step
  32202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32203. * @returns the max steps
  32204. */
  32205. getLockstepMaxSteps(): number;
  32206. /**
  32207. * Force the mipmap generation for the given render target texture
  32208. * @param texture defines the render target texture to use
  32209. */
  32210. generateMipMapsForCubemap(texture: InternalTexture): void;
  32211. /** States */
  32212. /**
  32213. * Set various states to the webGL context
  32214. * @param culling defines backface culling state
  32215. * @param zOffset defines the value to apply to zOffset (0 by default)
  32216. * @param force defines if states must be applied even if cache is up to date
  32217. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32218. */
  32219. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32220. /**
  32221. * Set the z offset to apply to current rendering
  32222. * @param value defines the offset to apply
  32223. */
  32224. setZOffset(value: number): void;
  32225. /**
  32226. * Gets the current value of the zOffset
  32227. * @returns the current zOffset state
  32228. */
  32229. getZOffset(): number;
  32230. /**
  32231. * Enable or disable depth buffering
  32232. * @param enable defines the state to set
  32233. */
  32234. setDepthBuffer(enable: boolean): void;
  32235. /**
  32236. * Gets a boolean indicating if depth writing is enabled
  32237. * @returns the current depth writing state
  32238. */
  32239. getDepthWrite(): boolean;
  32240. /**
  32241. * Enable or disable depth writing
  32242. * @param enable defines the state to set
  32243. */
  32244. setDepthWrite(enable: boolean): void;
  32245. /**
  32246. * Enable or disable color writing
  32247. * @param enable defines the state to set
  32248. */
  32249. setColorWrite(enable: boolean): void;
  32250. /**
  32251. * Gets a boolean indicating if color writing is enabled
  32252. * @returns the current color writing state
  32253. */
  32254. getColorWrite(): boolean;
  32255. /**
  32256. * Sets alpha constants used by some alpha blending modes
  32257. * @param r defines the red component
  32258. * @param g defines the green component
  32259. * @param b defines the blue component
  32260. * @param a defines the alpha component
  32261. */
  32262. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32263. /**
  32264. * Sets the current alpha mode
  32265. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32266. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32268. */
  32269. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32270. /**
  32271. * Gets the current alpha mode
  32272. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32273. * @returns the current alpha mode
  32274. */
  32275. getAlphaMode(): number;
  32276. /**
  32277. * Sets the current alpha equation
  32278. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32279. */
  32280. setAlphaEquation(equation: number): void;
  32281. /**
  32282. * Gets the current alpha equation.
  32283. * @returns the current alpha equation
  32284. */
  32285. getAlphaEquation(): number;
  32286. /**
  32287. * Gets a boolean indicating if stencil buffer is enabled
  32288. * @returns the current stencil buffer state
  32289. */
  32290. getStencilBuffer(): boolean;
  32291. /**
  32292. * Enable or disable the stencil buffer
  32293. * @param enable defines if the stencil buffer must be enabled or disabled
  32294. */
  32295. setStencilBuffer(enable: boolean): void;
  32296. /**
  32297. * Gets the current stencil mask
  32298. * @returns a number defining the new stencil mask to use
  32299. */
  32300. getStencilMask(): number;
  32301. /**
  32302. * Sets the current stencil mask
  32303. * @param mask defines the new stencil mask to use
  32304. */
  32305. setStencilMask(mask: number): void;
  32306. /**
  32307. * Gets the current stencil function
  32308. * @returns a number defining the stencil function to use
  32309. */
  32310. getStencilFunction(): number;
  32311. /**
  32312. * Gets the current stencil reference value
  32313. * @returns a number defining the stencil reference value to use
  32314. */
  32315. getStencilFunctionReference(): number;
  32316. /**
  32317. * Gets the current stencil mask
  32318. * @returns a number defining the stencil mask to use
  32319. */
  32320. getStencilFunctionMask(): number;
  32321. /**
  32322. * Sets the current stencil function
  32323. * @param stencilFunc defines the new stencil function to use
  32324. */
  32325. setStencilFunction(stencilFunc: number): void;
  32326. /**
  32327. * Sets the current stencil reference
  32328. * @param reference defines the new stencil reference to use
  32329. */
  32330. setStencilFunctionReference(reference: number): void;
  32331. /**
  32332. * Sets the current stencil mask
  32333. * @param mask defines the new stencil mask to use
  32334. */
  32335. setStencilFunctionMask(mask: number): void;
  32336. /**
  32337. * Gets the current stencil operation when stencil fails
  32338. * @returns a number defining stencil operation to use when stencil fails
  32339. */
  32340. getStencilOperationFail(): number;
  32341. /**
  32342. * Gets the current stencil operation when depth fails
  32343. * @returns a number defining stencil operation to use when depth fails
  32344. */
  32345. getStencilOperationDepthFail(): number;
  32346. /**
  32347. * Gets the current stencil operation when stencil passes
  32348. * @returns a number defining stencil operation to use when stencil passes
  32349. */
  32350. getStencilOperationPass(): number;
  32351. /**
  32352. * Sets the stencil operation to use when stencil fails
  32353. * @param operation defines the stencil operation to use when stencil fails
  32354. */
  32355. setStencilOperationFail(operation: number): void;
  32356. /**
  32357. * Sets the stencil operation to use when depth fails
  32358. * @param operation defines the stencil operation to use when depth fails
  32359. */
  32360. setStencilOperationDepthFail(operation: number): void;
  32361. /**
  32362. * Sets the stencil operation to use when stencil passes
  32363. * @param operation defines the stencil operation to use when stencil passes
  32364. */
  32365. setStencilOperationPass(operation: number): void;
  32366. /**
  32367. * Sets a boolean indicating if the dithering state is enabled or disabled
  32368. * @param value defines the dithering state
  32369. */
  32370. setDitheringState(value: boolean): void;
  32371. /**
  32372. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32373. * @param value defines the rasterizer state
  32374. */
  32375. setRasterizerState(value: boolean): void;
  32376. /**
  32377. * Gets the current depth function
  32378. * @returns a number defining the depth function
  32379. */
  32380. getDepthFunction(): Nullable<number>;
  32381. /**
  32382. * Sets the current depth function
  32383. * @param depthFunc defines the function to use
  32384. */
  32385. setDepthFunction(depthFunc: number): void;
  32386. /**
  32387. * Sets the current depth function to GREATER
  32388. */
  32389. setDepthFunctionToGreater(): void;
  32390. /**
  32391. * Sets the current depth function to GEQUAL
  32392. */
  32393. setDepthFunctionToGreaterOrEqual(): void;
  32394. /**
  32395. * Sets the current depth function to LESS
  32396. */
  32397. setDepthFunctionToLess(): void;
  32398. /**
  32399. * Sets the current depth function to LEQUAL
  32400. */
  32401. setDepthFunctionToLessOrEqual(): void;
  32402. private _cachedStencilBuffer;
  32403. private _cachedStencilFunction;
  32404. private _cachedStencilMask;
  32405. private _cachedStencilOperationPass;
  32406. private _cachedStencilOperationFail;
  32407. private _cachedStencilOperationDepthFail;
  32408. private _cachedStencilReference;
  32409. /**
  32410. * Caches the the state of the stencil buffer
  32411. */
  32412. cacheStencilState(): void;
  32413. /**
  32414. * Restores the state of the stencil buffer
  32415. */
  32416. restoreStencilState(): void;
  32417. /**
  32418. * Directly set the WebGL Viewport
  32419. * @param x defines the x coordinate of the viewport (in screen space)
  32420. * @param y defines the y coordinate of the viewport (in screen space)
  32421. * @param width defines the width of the viewport (in screen space)
  32422. * @param height defines the height of the viewport (in screen space)
  32423. * @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
  32424. */
  32425. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32426. /**
  32427. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32428. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32429. * @param y defines the y-coordinate of the corner of the clear rectangle
  32430. * @param width defines the width of the clear rectangle
  32431. * @param height defines the height of the clear rectangle
  32432. * @param clearColor defines the clear color
  32433. */
  32434. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32435. /**
  32436. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32437. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32438. * @param y defines the y-coordinate of the corner of the clear rectangle
  32439. * @param width defines the width of the clear rectangle
  32440. * @param height defines the height of the clear rectangle
  32441. */
  32442. enableScissor(x: number, y: number, width: number, height: number): void;
  32443. /**
  32444. * Disable previously set scissor test rectangle
  32445. */
  32446. disableScissor(): void;
  32447. protected _reportDrawCall(): void;
  32448. /**
  32449. * Initializes a webVR display and starts listening to display change events
  32450. * The onVRDisplayChangedObservable will be notified upon these changes
  32451. * @returns The onVRDisplayChangedObservable
  32452. */
  32453. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32454. /** @hidden */
  32455. _prepareVRComponent(): void;
  32456. /** @hidden */
  32457. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32458. /** @hidden */
  32459. _submitVRFrame(): void;
  32460. /**
  32461. * Call this function to leave webVR mode
  32462. * Will do nothing if webVR is not supported or if there is no webVR device
  32463. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32464. */
  32465. disableVR(): void;
  32466. /**
  32467. * Gets a boolean indicating that the system is in VR mode and is presenting
  32468. * @returns true if VR mode is engaged
  32469. */
  32470. isVRPresenting(): boolean;
  32471. /** @hidden */
  32472. _requestVRFrame(): void;
  32473. /** @hidden */
  32474. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32475. /**
  32476. * Gets the source code of the vertex shader associated with a specific webGL program
  32477. * @param program defines the program to use
  32478. * @returns a string containing the source code of the vertex shader associated with the program
  32479. */
  32480. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32481. /**
  32482. * Gets the source code of the fragment shader associated with a specific webGL program
  32483. * @param program defines the program to use
  32484. * @returns a string containing the source code of the fragment shader associated with the program
  32485. */
  32486. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32487. /**
  32488. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32489. * @param x defines the x coordinate of the rectangle where pixels must be read
  32490. * @param y defines the y coordinate of the rectangle where pixels must be read
  32491. * @param width defines the width of the rectangle where pixels must be read
  32492. * @param height defines the height of the rectangle where pixels must be read
  32493. * @returns a Uint8Array containing RGBA colors
  32494. */
  32495. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32496. /**
  32497. * Sets a depth stencil texture from a render target to the according uniform.
  32498. * @param channel The texture channel
  32499. * @param uniform The uniform to set
  32500. * @param texture The render target texture containing the depth stencil texture to apply
  32501. */
  32502. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32503. /**
  32504. * Sets a texture to the webGL context from a postprocess
  32505. * @param channel defines the channel to use
  32506. * @param postProcess defines the source postprocess
  32507. */
  32508. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32509. /**
  32510. * Binds the output of the passed in post process to the texture channel specified
  32511. * @param channel The channel the texture should be bound to
  32512. * @param postProcess The post process which's output should be bound
  32513. */
  32514. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32515. /** @hidden */
  32516. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32517. protected _rebuildBuffers(): void;
  32518. _renderLoop(): void;
  32519. /**
  32520. * Toggle full screen mode
  32521. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32522. */
  32523. switchFullscreen(requestPointerLock: boolean): void;
  32524. /**
  32525. * Enters full screen mode
  32526. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32527. */
  32528. enterFullscreen(requestPointerLock: boolean): void;
  32529. /**
  32530. * Exits full screen mode
  32531. */
  32532. exitFullscreen(): void;
  32533. /**
  32534. * Enters Pointerlock mode
  32535. */
  32536. enterPointerlock(): void;
  32537. /**
  32538. * Exits Pointerlock mode
  32539. */
  32540. exitPointerlock(): void;
  32541. /**
  32542. * Begin a new frame
  32543. */
  32544. beginFrame(): void;
  32545. /**
  32546. * Enf the current frame
  32547. */
  32548. endFrame(): void;
  32549. resize(): void;
  32550. /**
  32551. * Set the compressed texture format to use, based on the formats you have, and the formats
  32552. * supported by the hardware / browser.
  32553. *
  32554. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32555. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32556. * to API arguments needed to compressed textures. This puts the burden on the container
  32557. * generator to house the arcane code for determining these for current & future formats.
  32558. *
  32559. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32560. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32561. *
  32562. * Note: The result of this call is not taken into account when a texture is base64.
  32563. *
  32564. * @param formatsAvailable defines the list of those format families you have created
  32565. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32566. *
  32567. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32568. * @returns The extension selected.
  32569. */
  32570. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32571. /**
  32572. * Force a specific size of the canvas
  32573. * @param width defines the new canvas' width
  32574. * @param height defines the new canvas' height
  32575. */
  32576. setSize(width: number, height: number): void;
  32577. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32578. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32579. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32580. _releaseTexture(texture: InternalTexture): void;
  32581. /**
  32582. * @hidden
  32583. * Rescales a texture
  32584. * @param source input texutre
  32585. * @param destination destination texture
  32586. * @param scene scene to use to render the resize
  32587. * @param internalFormat format to use when resizing
  32588. * @param onComplete callback to be called when resize has completed
  32589. */
  32590. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32591. /**
  32592. * Gets the current framerate
  32593. * @returns a number representing the framerate
  32594. */
  32595. getFps(): number;
  32596. /**
  32597. * Gets the time spent between current and previous frame
  32598. * @returns a number representing the delta time in ms
  32599. */
  32600. getDeltaTime(): number;
  32601. private _measureFps;
  32602. /**
  32603. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32604. * @param renderTarget The render target to set the frame buffer for
  32605. */
  32606. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32607. /**
  32608. * Update a dynamic index buffer
  32609. * @param indexBuffer defines the target index buffer
  32610. * @param indices defines the data to update
  32611. * @param offset defines the offset in the target index buffer where update should start
  32612. */
  32613. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32614. /**
  32615. * Updates the sample count of a render target texture
  32616. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32617. * @param texture defines the texture to update
  32618. * @param samples defines the sample count to set
  32619. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32620. */
  32621. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32622. /** @hidden */
  32623. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32624. dispose(): void;
  32625. private _disableTouchAction;
  32626. /**
  32627. * Display the loading screen
  32628. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32629. */
  32630. displayLoadingUI(): void;
  32631. /**
  32632. * Hide the loading screen
  32633. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32634. */
  32635. hideLoadingUI(): void;
  32636. /**
  32637. * Gets the current loading screen object
  32638. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32639. */
  32640. /**
  32641. * Sets the current loading screen object
  32642. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32643. */
  32644. loadingScreen: ILoadingScreen;
  32645. /**
  32646. * Sets the current loading screen text
  32647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32648. */
  32649. loadingUIText: string;
  32650. /**
  32651. * Sets the current loading screen background color
  32652. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32653. */
  32654. loadingUIBackgroundColor: string;
  32655. /** Pointerlock and fullscreen */
  32656. /**
  32657. * Ask the browser to promote the current element to pointerlock mode
  32658. * @param element defines the DOM element to promote
  32659. */
  32660. static _RequestPointerlock(element: HTMLElement): void;
  32661. /**
  32662. * Asks the browser to exit pointerlock mode
  32663. */
  32664. static _ExitPointerlock(): void;
  32665. /**
  32666. * Ask the browser to promote the current element to fullscreen rendering mode
  32667. * @param element defines the DOM element to promote
  32668. */
  32669. static _RequestFullscreen(element: HTMLElement): void;
  32670. /**
  32671. * Asks the browser to exit fullscreen mode
  32672. */
  32673. static _ExitFullscreen(): void;
  32674. }
  32675. }
  32676. declare module "babylonjs/Engines/engineStore" {
  32677. import { Nullable } from "babylonjs/types";
  32678. import { Engine } from "babylonjs/Engines/engine";
  32679. import { Scene } from "babylonjs/scene";
  32680. /**
  32681. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32682. * during the life time of the application.
  32683. */
  32684. export class EngineStore {
  32685. /** Gets the list of created engines */
  32686. static Instances: import("babylonjs/Engines/engine").Engine[];
  32687. /** @hidden */
  32688. static _LastCreatedScene: Nullable<Scene>;
  32689. /**
  32690. * Gets the latest created engine
  32691. */
  32692. static readonly LastCreatedEngine: Nullable<Engine>;
  32693. /**
  32694. * Gets the latest created scene
  32695. */
  32696. static readonly LastCreatedScene: Nullable<Scene>;
  32697. /**
  32698. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32699. * @ignorenaming
  32700. */
  32701. static UseFallbackTexture: boolean;
  32702. /**
  32703. * Texture content used if a texture cannot loaded
  32704. * @ignorenaming
  32705. */
  32706. static FallbackTexture: string;
  32707. }
  32708. }
  32709. declare module "babylonjs/Misc/promise" {
  32710. /**
  32711. * Helper class that provides a small promise polyfill
  32712. */
  32713. export class PromisePolyfill {
  32714. /**
  32715. * Static function used to check if the polyfill is required
  32716. * If this is the case then the function will inject the polyfill to window.Promise
  32717. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32718. */
  32719. static Apply(force?: boolean): void;
  32720. }
  32721. }
  32722. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32723. /**
  32724. * Interface for screenshot methods with describe argument called `size` as object with options
  32725. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32726. */
  32727. export interface IScreenshotSize {
  32728. /**
  32729. * number in pixels for canvas height
  32730. */
  32731. height?: number;
  32732. /**
  32733. * multiplier allowing render at a higher or lower resolution
  32734. * If value is defined then height and width will be ignored and taken from camera
  32735. */
  32736. precision?: number;
  32737. /**
  32738. * number in pixels for canvas width
  32739. */
  32740. width?: number;
  32741. }
  32742. }
  32743. declare module "babylonjs/Misc/tools" {
  32744. import { Nullable, float } from "babylonjs/types";
  32745. import { DomManagement } from "babylonjs/Misc/domManagement";
  32746. import { WebRequest } from "babylonjs/Misc/webRequest";
  32747. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32748. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32749. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32750. import { Camera } from "babylonjs/Cameras/camera";
  32751. import { Engine } from "babylonjs/Engines/engine";
  32752. interface IColor4Like {
  32753. r: float;
  32754. g: float;
  32755. b: float;
  32756. a: float;
  32757. }
  32758. /**
  32759. * Class containing a set of static utilities functions
  32760. */
  32761. export class Tools {
  32762. /**
  32763. * Gets or sets the base URL to use to load assets
  32764. */
  32765. static BaseUrl: string;
  32766. /**
  32767. * Enable/Disable Custom HTTP Request Headers globally.
  32768. * default = false
  32769. * @see CustomRequestHeaders
  32770. */
  32771. static UseCustomRequestHeaders: boolean;
  32772. /**
  32773. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32774. * i.e. when loading files, where the server/service expects an Authorization header
  32775. */
  32776. static CustomRequestHeaders: {
  32777. [key: string]: string;
  32778. };
  32779. /**
  32780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32781. */
  32782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32783. /**
  32784. * Default behaviour for cors in the application.
  32785. * It can be a string if the expected behavior is identical in the entire app.
  32786. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32787. */
  32788. static CorsBehavior: string | ((url: string | string[]) => string);
  32789. /**
  32790. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32791. * @ignorenaming
  32792. */
  32793. static UseFallbackTexture: boolean;
  32794. /**
  32795. * Use this object to register external classes like custom textures or material
  32796. * to allow the laoders to instantiate them
  32797. */
  32798. static RegisteredExternalClasses: {
  32799. [key: string]: Object;
  32800. };
  32801. /**
  32802. * Texture content used if a texture cannot loaded
  32803. * @ignorenaming
  32804. */
  32805. static fallbackTexture: string;
  32806. /**
  32807. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32808. * @param u defines the coordinate on X axis
  32809. * @param v defines the coordinate on Y axis
  32810. * @param width defines the width of the source data
  32811. * @param height defines the height of the source data
  32812. * @param pixels defines the source byte array
  32813. * @param color defines the output color
  32814. */
  32815. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32816. /**
  32817. * Interpolates between a and b via alpha
  32818. * @param a The lower value (returned when alpha = 0)
  32819. * @param b The upper value (returned when alpha = 1)
  32820. * @param alpha The interpolation-factor
  32821. * @return The mixed value
  32822. */
  32823. static Mix(a: number, b: number, alpha: number): number;
  32824. /**
  32825. * Tries to instantiate a new object from a given class name
  32826. * @param className defines the class name to instantiate
  32827. * @returns the new object or null if the system was not able to do the instantiation
  32828. */
  32829. static Instantiate(className: string): any;
  32830. /**
  32831. * Provides a slice function that will work even on IE
  32832. * @param data defines the array to slice
  32833. * @param start defines the start of the data (optional)
  32834. * @param end defines the end of the data (optional)
  32835. * @returns the new sliced array
  32836. */
  32837. static Slice<T>(data: T, start?: number, end?: number): T;
  32838. /**
  32839. * Polyfill for setImmediate
  32840. * @param action defines the action to execute after the current execution block
  32841. */
  32842. static SetImmediate(action: () => void): void;
  32843. /**
  32844. * Function indicating if a number is an exponent of 2
  32845. * @param value defines the value to test
  32846. * @returns true if the value is an exponent of 2
  32847. */
  32848. static IsExponentOfTwo(value: number): boolean;
  32849. private static _tmpFloatArray;
  32850. /**
  32851. * Returns the nearest 32-bit single precision float representation of a Number
  32852. * @param value A Number. If the parameter is of a different type, it will get converted
  32853. * to a number or to NaN if it cannot be converted
  32854. * @returns number
  32855. */
  32856. static FloatRound(value: number): number;
  32857. /**
  32858. * Extracts the filename from a path
  32859. * @param path defines the path to use
  32860. * @returns the filename
  32861. */
  32862. static GetFilename(path: string): string;
  32863. /**
  32864. * Extracts the "folder" part of a path (everything before the filename).
  32865. * @param uri The URI to extract the info from
  32866. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32867. * @returns The "folder" part of the path
  32868. */
  32869. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32870. /**
  32871. * Extracts text content from a DOM element hierarchy
  32872. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32873. */
  32874. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32875. /**
  32876. * Convert an angle in radians to degrees
  32877. * @param angle defines the angle to convert
  32878. * @returns the angle in degrees
  32879. */
  32880. static ToDegrees(angle: number): number;
  32881. /**
  32882. * Convert an angle in degrees to radians
  32883. * @param angle defines the angle to convert
  32884. * @returns the angle in radians
  32885. */
  32886. static ToRadians(angle: number): number;
  32887. /**
  32888. * Encode a buffer to a base64 string
  32889. * @param buffer defines the buffer to encode
  32890. * @returns the encoded string
  32891. */
  32892. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32893. /**
  32894. * Returns an array if obj is not an array
  32895. * @param obj defines the object to evaluate as an array
  32896. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32897. * @returns either obj directly if obj is an array or a new array containing obj
  32898. */
  32899. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32900. /**
  32901. * Gets the pointer prefix to use
  32902. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32903. */
  32904. static GetPointerPrefix(): string;
  32905. /**
  32906. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32907. * @param url define the url we are trying
  32908. * @param element define the dom element where to configure the cors policy
  32909. */
  32910. static SetCorsBehavior(url: string | string[], element: {
  32911. crossOrigin: string | null;
  32912. }): void;
  32913. /**
  32914. * Removes unwanted characters from an url
  32915. * @param url defines the url to clean
  32916. * @returns the cleaned url
  32917. */
  32918. static CleanUrl(url: string): string;
  32919. /**
  32920. * Gets or sets a function used to pre-process url before using them to load assets
  32921. */
  32922. static PreprocessUrl: (url: string) => string;
  32923. /**
  32924. * Loads an image as an HTMLImageElement.
  32925. * @param input url string, ArrayBuffer, or Blob to load
  32926. * @param onLoad callback called when the image successfully loads
  32927. * @param onError callback called when the image fails to load
  32928. * @param offlineProvider offline provider for caching
  32929. * @returns the HTMLImageElement of the loaded image
  32930. */
  32931. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32932. /**
  32933. * Loads a file
  32934. * @param url url string, ArrayBuffer, or Blob to load
  32935. * @param onSuccess callback called when the file successfully loads
  32936. * @param onProgress callback called while file is loading (if the server supports this mode)
  32937. * @param offlineProvider defines the offline provider for caching
  32938. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32939. * @param onError callback called when the file fails to load
  32940. * @returns a file request object
  32941. */
  32942. 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;
  32943. /**
  32944. * Loads a file from a url
  32945. * @param url the file url to load
  32946. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32947. */
  32948. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32949. /**
  32950. * Load a script (identified by an url). When the url returns, the
  32951. * content of this file is added into a new script element, attached to the DOM (body element)
  32952. * @param scriptUrl defines the url of the script to laod
  32953. * @param onSuccess defines the callback called when the script is loaded
  32954. * @param onError defines the callback to call if an error occurs
  32955. * @param scriptId defines the id of the script element
  32956. */
  32957. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32958. /**
  32959. * Load an asynchronous script (identified by an url). When the url returns, the
  32960. * content of this file is added into a new script element, attached to the DOM (body element)
  32961. * @param scriptUrl defines the url of the script to laod
  32962. * @param scriptId defines the id of the script element
  32963. * @returns a promise request object
  32964. */
  32965. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32966. /**
  32967. * Loads a file from a blob
  32968. * @param fileToLoad defines the blob to use
  32969. * @param callback defines the callback to call when data is loaded
  32970. * @param progressCallback defines the callback to call during loading process
  32971. * @returns a file request object
  32972. */
  32973. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32974. /**
  32975. * Loads a file
  32976. * @param fileToLoad defines the file to load
  32977. * @param callback defines the callback to call when data is loaded
  32978. * @param progressCallBack defines the callback to call during loading process
  32979. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32980. * @returns a file request object
  32981. */
  32982. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32983. /**
  32984. * Creates a data url from a given string content
  32985. * @param content defines the content to convert
  32986. * @returns the new data url link
  32987. */
  32988. static FileAsURL(content: string): string;
  32989. /**
  32990. * Format the given number to a specific decimal format
  32991. * @param value defines the number to format
  32992. * @param decimals defines the number of decimals to use
  32993. * @returns the formatted string
  32994. */
  32995. static Format(value: number, decimals?: number): string;
  32996. /**
  32997. * Tries to copy an object by duplicating every property
  32998. * @param source defines the source object
  32999. * @param destination defines the target object
  33000. * @param doNotCopyList defines a list of properties to avoid
  33001. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33002. */
  33003. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33004. /**
  33005. * Gets a boolean indicating if the given object has no own property
  33006. * @param obj defines the object to test
  33007. * @returns true if object has no own property
  33008. */
  33009. static IsEmpty(obj: any): boolean;
  33010. /**
  33011. * Function used to register events at window level
  33012. * @param windowElement defines the Window object to use
  33013. * @param events defines the events to register
  33014. */
  33015. static RegisterTopRootEvents(windowElement: Window, events: {
  33016. name: string;
  33017. handler: Nullable<(e: FocusEvent) => any>;
  33018. }[]): void;
  33019. /**
  33020. * Function used to unregister events from window level
  33021. * @param windowElement defines the Window object to use
  33022. * @param events defines the events to unregister
  33023. */
  33024. static UnregisterTopRootEvents(windowElement: Window, events: {
  33025. name: string;
  33026. handler: Nullable<(e: FocusEvent) => any>;
  33027. }[]): void;
  33028. /**
  33029. * @ignore
  33030. */
  33031. static _ScreenshotCanvas: HTMLCanvasElement;
  33032. /**
  33033. * Dumps the current bound framebuffer
  33034. * @param width defines the rendering width
  33035. * @param height defines the rendering height
  33036. * @param engine defines the hosting engine
  33037. * @param successCallback defines the callback triggered once the data are available
  33038. * @param mimeType defines the mime type of the result
  33039. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33040. */
  33041. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33042. /**
  33043. * Converts the canvas data to blob.
  33044. * This acts as a polyfill for browsers not supporting the to blob function.
  33045. * @param canvas Defines the canvas to extract the data from
  33046. * @param successCallback Defines the callback triggered once the data are available
  33047. * @param mimeType Defines the mime type of the result
  33048. */
  33049. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33050. /**
  33051. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33052. * @param successCallback defines the callback triggered once the data are available
  33053. * @param mimeType defines the mime type of the result
  33054. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33055. */
  33056. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33057. /**
  33058. * Downloads a blob in the browser
  33059. * @param blob defines the blob to download
  33060. * @param fileName defines the name of the downloaded file
  33061. */
  33062. static Download(blob: Blob, fileName: string): void;
  33063. /**
  33064. * Captures a screenshot of the current rendering
  33065. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33066. * @param engine defines the rendering engine
  33067. * @param camera defines the source camera
  33068. * @param size This parameter can be set to a single number or to an object with the
  33069. * following (optional) properties: precision, width, height. If a single number is passed,
  33070. * it will be used for both width and height. If an object is passed, the screenshot size
  33071. * will be derived from the parameters. The precision property is a multiplier allowing
  33072. * rendering at a higher or lower resolution
  33073. * @param successCallback defines the callback receives a single parameter which contains the
  33074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33075. * src parameter of an <img> to display it
  33076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33077. * Check your browser for supported MIME types
  33078. */
  33079. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33080. /**
  33081. * Captures a screenshot of the current rendering
  33082. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33083. * @param engine defines the rendering engine
  33084. * @param camera defines the source camera
  33085. * @param size This parameter can be set to a single number or to an object with the
  33086. * following (optional) properties: precision, width, height. If a single number is passed,
  33087. * it will be used for both width and height. If an object is passed, the screenshot size
  33088. * will be derived from the parameters. The precision property is a multiplier allowing
  33089. * rendering at a higher or lower resolution
  33090. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33091. * Check your browser for supported MIME types
  33092. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33093. * to the src parameter of an <img> to display it
  33094. */
  33095. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33096. /**
  33097. * Generates an image screenshot from the specified camera.
  33098. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33099. * @param engine The engine to use for rendering
  33100. * @param camera The camera to use for rendering
  33101. * @param size This parameter can be set to a single number or to an object with the
  33102. * following (optional) properties: precision, width, height. If a single number is passed,
  33103. * it will be used for both width and height. If an object is passed, the screenshot size
  33104. * will be derived from the parameters. The precision property is a multiplier allowing
  33105. * rendering at a higher or lower resolution
  33106. * @param successCallback The callback receives a single parameter which contains the
  33107. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33108. * src parameter of an <img> to display it
  33109. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33110. * Check your browser for supported MIME types
  33111. * @param samples Texture samples (default: 1)
  33112. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33113. * @param fileName A name for for the downloaded file.
  33114. */
  33115. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33116. /**
  33117. * Generates an image screenshot from the specified camera.
  33118. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33119. * @param engine The engine to use for rendering
  33120. * @param camera The camera to use for rendering
  33121. * @param size This parameter can be set to a single number or to an object with the
  33122. * following (optional) properties: precision, width, height. If a single number is passed,
  33123. * it will be used for both width and height. If an object is passed, the screenshot size
  33124. * will be derived from the parameters. The precision property is a multiplier allowing
  33125. * rendering at a higher or lower resolution
  33126. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33127. * Check your browser for supported MIME types
  33128. * @param samples Texture samples (default: 1)
  33129. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33130. * @param fileName A name for for the downloaded file.
  33131. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33132. * to the src parameter of an <img> to display it
  33133. */
  33134. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33135. /**
  33136. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33137. * Be aware Math.random() could cause collisions, but:
  33138. * "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"
  33139. * @returns a pseudo random id
  33140. */
  33141. static RandomId(): string;
  33142. /**
  33143. * Test if the given uri is a base64 string
  33144. * @param uri The uri to test
  33145. * @return True if the uri is a base64 string or false otherwise
  33146. */
  33147. static IsBase64(uri: string): boolean;
  33148. /**
  33149. * Decode the given base64 uri.
  33150. * @param uri The uri to decode
  33151. * @return The decoded base64 data.
  33152. */
  33153. static DecodeBase64(uri: string): ArrayBuffer;
  33154. /**
  33155. * Gets the absolute url.
  33156. * @param url the input url
  33157. * @return the absolute url
  33158. */
  33159. static GetAbsoluteUrl(url: string): string;
  33160. /**
  33161. * No log
  33162. */
  33163. static readonly NoneLogLevel: number;
  33164. /**
  33165. * Only message logs
  33166. */
  33167. static readonly MessageLogLevel: number;
  33168. /**
  33169. * Only warning logs
  33170. */
  33171. static readonly WarningLogLevel: number;
  33172. /**
  33173. * Only error logs
  33174. */
  33175. static readonly ErrorLogLevel: number;
  33176. /**
  33177. * All logs
  33178. */
  33179. static readonly AllLogLevel: number;
  33180. /**
  33181. * Gets a value indicating the number of loading errors
  33182. * @ignorenaming
  33183. */
  33184. static readonly errorsCount: number;
  33185. /**
  33186. * Callback called when a new log is added
  33187. */
  33188. static OnNewCacheEntry: (entry: string) => void;
  33189. /**
  33190. * Log a message to the console
  33191. * @param message defines the message to log
  33192. */
  33193. static Log(message: string): void;
  33194. /**
  33195. * Write a warning message to the console
  33196. * @param message defines the message to log
  33197. */
  33198. static Warn(message: string): void;
  33199. /**
  33200. * Write an error message to the console
  33201. * @param message defines the message to log
  33202. */
  33203. static Error(message: string): void;
  33204. /**
  33205. * Gets current log cache (list of logs)
  33206. */
  33207. static readonly LogCache: string;
  33208. /**
  33209. * Clears the log cache
  33210. */
  33211. static ClearLogCache(): void;
  33212. /**
  33213. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33214. */
  33215. static LogLevels: number;
  33216. /**
  33217. * Checks if the window object exists
  33218. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33219. */
  33220. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33221. /**
  33222. * No performance log
  33223. */
  33224. static readonly PerformanceNoneLogLevel: number;
  33225. /**
  33226. * Use user marks to log performance
  33227. */
  33228. static readonly PerformanceUserMarkLogLevel: number;
  33229. /**
  33230. * Log performance to the console
  33231. */
  33232. static readonly PerformanceConsoleLogLevel: number;
  33233. private static _performance;
  33234. /**
  33235. * Sets the current performance log level
  33236. */
  33237. static PerformanceLogLevel: number;
  33238. private static _StartPerformanceCounterDisabled;
  33239. private static _EndPerformanceCounterDisabled;
  33240. private static _StartUserMark;
  33241. private static _EndUserMark;
  33242. private static _StartPerformanceConsole;
  33243. private static _EndPerformanceConsole;
  33244. /**
  33245. * Starts a performance counter
  33246. */
  33247. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33248. /**
  33249. * Ends a specific performance coutner
  33250. */
  33251. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33252. /**
  33253. * Gets either window.performance.now() if supported or Date.now() else
  33254. */
  33255. static readonly Now: number;
  33256. /**
  33257. * This method will return the name of the class used to create the instance of the given object.
  33258. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33259. * @param object the object to get the class name from
  33260. * @param isType defines if the object is actually a type
  33261. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33262. */
  33263. static GetClassName(object: any, isType?: boolean): string;
  33264. /**
  33265. * Gets the first element of an array satisfying a given predicate
  33266. * @param array defines the array to browse
  33267. * @param predicate defines the predicate to use
  33268. * @returns null if not found or the element
  33269. */
  33270. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33271. /**
  33272. * This method will return the name of the full name of the class, including its owning module (if any).
  33273. * 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).
  33274. * @param object the object to get the class name from
  33275. * @param isType defines if the object is actually a type
  33276. * @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.
  33277. * @ignorenaming
  33278. */
  33279. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33280. /**
  33281. * Returns a promise that resolves after the given amount of time.
  33282. * @param delay Number of milliseconds to delay
  33283. * @returns Promise that resolves after the given amount of time
  33284. */
  33285. static DelayAsync(delay: number): Promise<void>;
  33286. }
  33287. /**
  33288. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33289. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33290. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33291. * @param name The name of the class, case should be preserved
  33292. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33293. */
  33294. export function className(name: string, module?: string): (target: Object) => void;
  33295. /**
  33296. * An implementation of a loop for asynchronous functions.
  33297. */
  33298. export class AsyncLoop {
  33299. /**
  33300. * Defines the number of iterations for the loop
  33301. */
  33302. iterations: number;
  33303. /**
  33304. * Defines the current index of the loop.
  33305. */
  33306. index: number;
  33307. private _done;
  33308. private _fn;
  33309. private _successCallback;
  33310. /**
  33311. * Constructor.
  33312. * @param iterations the number of iterations.
  33313. * @param func the function to run each iteration
  33314. * @param successCallback the callback that will be called upon succesful execution
  33315. * @param offset starting offset.
  33316. */
  33317. constructor(
  33318. /**
  33319. * Defines the number of iterations for the loop
  33320. */
  33321. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33322. /**
  33323. * Execute the next iteration. Must be called after the last iteration was finished.
  33324. */
  33325. executeNext(): void;
  33326. /**
  33327. * Break the loop and run the success callback.
  33328. */
  33329. breakLoop(): void;
  33330. /**
  33331. * Create and run an async loop.
  33332. * @param iterations the number of iterations.
  33333. * @param fn the function to run each iteration
  33334. * @param successCallback the callback that will be called upon succesful execution
  33335. * @param offset starting offset.
  33336. * @returns the created async loop object
  33337. */
  33338. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33339. /**
  33340. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33341. * @param iterations total number of iterations
  33342. * @param syncedIterations number of synchronous iterations in each async iteration.
  33343. * @param fn the function to call each iteration.
  33344. * @param callback a success call back that will be called when iterating stops.
  33345. * @param breakFunction a break condition (optional)
  33346. * @param timeout timeout settings for the setTimeout function. default - 0.
  33347. * @returns the created async loop object
  33348. */
  33349. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33350. }
  33351. }
  33352. declare module "babylonjs/Misc/stringDictionary" {
  33353. import { Nullable } from "babylonjs/types";
  33354. /**
  33355. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33356. * The underlying implementation relies on an associative array to ensure the best performances.
  33357. * The value can be anything including 'null' but except 'undefined'
  33358. */
  33359. export class StringDictionary<T> {
  33360. /**
  33361. * This will clear this dictionary and copy the content from the 'source' one.
  33362. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33363. * @param source the dictionary to take the content from and copy to this dictionary
  33364. */
  33365. copyFrom(source: StringDictionary<T>): void;
  33366. /**
  33367. * Get a value based from its key
  33368. * @param key the given key to get the matching value from
  33369. * @return the value if found, otherwise undefined is returned
  33370. */
  33371. get(key: string): T | undefined;
  33372. /**
  33373. * Get a value from its key or add it if it doesn't exist.
  33374. * This method will ensure you that a given key/data will be present in the dictionary.
  33375. * @param key the given key to get the matching value from
  33376. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33377. * The factory will only be invoked if there's no data for the given key.
  33378. * @return the value corresponding to the key.
  33379. */
  33380. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33381. /**
  33382. * Get a value from its key if present in the dictionary otherwise add it
  33383. * @param key the key to get the value from
  33384. * @param val if there's no such key/value pair in the dictionary add it with this value
  33385. * @return the value corresponding to the key
  33386. */
  33387. getOrAdd(key: string, val: T): T;
  33388. /**
  33389. * Check if there's a given key in the dictionary
  33390. * @param key the key to check for
  33391. * @return true if the key is present, false otherwise
  33392. */
  33393. contains(key: string): boolean;
  33394. /**
  33395. * Add a new key and its corresponding value
  33396. * @param key the key to add
  33397. * @param value the value corresponding to the key
  33398. * @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
  33399. */
  33400. add(key: string, value: T): boolean;
  33401. /**
  33402. * Update a specific value associated to a key
  33403. * @param key defines the key to use
  33404. * @param value defines the value to store
  33405. * @returns true if the value was updated (or false if the key was not found)
  33406. */
  33407. set(key: string, value: T): boolean;
  33408. /**
  33409. * Get the element of the given key and remove it from the dictionary
  33410. * @param key defines the key to search
  33411. * @returns the value associated with the key or null if not found
  33412. */
  33413. getAndRemove(key: string): Nullable<T>;
  33414. /**
  33415. * Remove a key/value from the dictionary.
  33416. * @param key the key to remove
  33417. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33418. */
  33419. remove(key: string): boolean;
  33420. /**
  33421. * Clear the whole content of the dictionary
  33422. */
  33423. clear(): void;
  33424. /**
  33425. * Gets the current count
  33426. */
  33427. readonly count: number;
  33428. /**
  33429. * Execute a callback on each key/val of the dictionary.
  33430. * Note that you can remove any element in this dictionary in the callback implementation
  33431. * @param callback the callback to execute on a given key/value pair
  33432. */
  33433. forEach(callback: (key: string, val: T) => void): void;
  33434. /**
  33435. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33436. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33437. * Note that you can remove any element in this dictionary in the callback implementation
  33438. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33439. * @returns the first item
  33440. */
  33441. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33442. private _count;
  33443. private _data;
  33444. }
  33445. }
  33446. declare module "babylonjs/Collisions/collisionCoordinator" {
  33447. import { Nullable } from "babylonjs/types";
  33448. import { Scene } from "babylonjs/scene";
  33449. import { Vector3 } from "babylonjs/Maths/math.vector";
  33450. import { Collider } from "babylonjs/Collisions/collider";
  33451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33452. /** @hidden */
  33453. export interface ICollisionCoordinator {
  33454. createCollider(): Collider;
  33455. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33456. init(scene: Scene): void;
  33457. }
  33458. /** @hidden */
  33459. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33460. private _scene;
  33461. private _scaledPosition;
  33462. private _scaledVelocity;
  33463. private _finalPosition;
  33464. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33465. createCollider(): Collider;
  33466. init(scene: Scene): void;
  33467. private _collideWithWorld;
  33468. }
  33469. }
  33470. declare module "babylonjs/Inputs/scene.inputManager" {
  33471. import { Nullable } from "babylonjs/types";
  33472. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33473. import { Vector2 } from "babylonjs/Maths/math.vector";
  33474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33475. import { Scene } from "babylonjs/scene";
  33476. /**
  33477. * Class used to manage all inputs for the scene.
  33478. */
  33479. export class InputManager {
  33480. /** The distance in pixel that you have to move to prevent some events */
  33481. static DragMovementThreshold: number;
  33482. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33483. static LongPressDelay: number;
  33484. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33485. static DoubleClickDelay: number;
  33486. /** If you need to check double click without raising a single click at first click, enable this flag */
  33487. static ExclusiveDoubleClickMode: boolean;
  33488. private _wheelEventName;
  33489. private _onPointerMove;
  33490. private _onPointerDown;
  33491. private _onPointerUp;
  33492. private _initClickEvent;
  33493. private _initActionManager;
  33494. private _delayedSimpleClick;
  33495. private _delayedSimpleClickTimeout;
  33496. private _previousDelayedSimpleClickTimeout;
  33497. private _meshPickProceed;
  33498. private _previousButtonPressed;
  33499. private _currentPickResult;
  33500. private _previousPickResult;
  33501. private _totalPointersPressed;
  33502. private _doubleClickOccured;
  33503. private _pointerOverMesh;
  33504. private _pickedDownMesh;
  33505. private _pickedUpMesh;
  33506. private _pointerX;
  33507. private _pointerY;
  33508. private _unTranslatedPointerX;
  33509. private _unTranslatedPointerY;
  33510. private _startingPointerPosition;
  33511. private _previousStartingPointerPosition;
  33512. private _startingPointerTime;
  33513. private _previousStartingPointerTime;
  33514. private _pointerCaptures;
  33515. private _onKeyDown;
  33516. private _onKeyUp;
  33517. private _onCanvasFocusObserver;
  33518. private _onCanvasBlurObserver;
  33519. private _scene;
  33520. /**
  33521. * Creates a new InputManager
  33522. * @param scene defines the hosting scene
  33523. */
  33524. constructor(scene: Scene);
  33525. /**
  33526. * Gets the mesh that is currently under the pointer
  33527. */
  33528. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33529. /**
  33530. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33531. */
  33532. readonly unTranslatedPointer: Vector2;
  33533. /**
  33534. * Gets or sets the current on-screen X position of the pointer
  33535. */
  33536. pointerX: number;
  33537. /**
  33538. * Gets or sets the current on-screen Y position of the pointer
  33539. */
  33540. pointerY: number;
  33541. private _updatePointerPosition;
  33542. private _processPointerMove;
  33543. private _setRayOnPointerInfo;
  33544. private _checkPrePointerObservable;
  33545. /**
  33546. * Use this method to simulate a pointer move on a mesh
  33547. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33548. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33549. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33550. */
  33551. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33552. /**
  33553. * Use this method to simulate a pointer down on a mesh
  33554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33557. */
  33558. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33559. private _processPointerDown;
  33560. /** @hidden */
  33561. _isPointerSwiping(): boolean;
  33562. /**
  33563. * Use this method to simulate a pointer up on a mesh
  33564. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33565. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33566. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33567. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33568. */
  33569. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33570. private _processPointerUp;
  33571. /**
  33572. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33573. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33574. * @returns true if the pointer was captured
  33575. */
  33576. isPointerCaptured(pointerId?: number): boolean;
  33577. /**
  33578. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33579. * @param attachUp defines if you want to attach events to pointerup
  33580. * @param attachDown defines if you want to attach events to pointerdown
  33581. * @param attachMove defines if you want to attach events to pointermove
  33582. */
  33583. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33584. /**
  33585. * Detaches all event handlers
  33586. */
  33587. detachControl(): void;
  33588. /**
  33589. * Force the value of meshUnderPointer
  33590. * @param mesh defines the mesh to use
  33591. */
  33592. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33593. /**
  33594. * Gets the mesh under the pointer
  33595. * @returns a Mesh or null if no mesh is under the pointer
  33596. */
  33597. getPointerOverMesh(): Nullable<AbstractMesh>;
  33598. }
  33599. }
  33600. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33601. /**
  33602. * Helper class used to generate session unique ID
  33603. */
  33604. export class UniqueIdGenerator {
  33605. private static _UniqueIdCounter;
  33606. /**
  33607. * Gets an unique (relatively to the current scene) Id
  33608. */
  33609. static readonly UniqueId: number;
  33610. }
  33611. }
  33612. declare module "babylonjs/Animations/animationGroup" {
  33613. import { Animatable } from "babylonjs/Animations/animatable";
  33614. import { Animation } from "babylonjs/Animations/animation";
  33615. import { Scene, IDisposable } from "babylonjs/scene";
  33616. import { Observable } from "babylonjs/Misc/observable";
  33617. import { Nullable } from "babylonjs/types";
  33618. import "babylonjs/Animations/animatable";
  33619. /**
  33620. * This class defines the direct association between an animation and a target
  33621. */
  33622. export class TargetedAnimation {
  33623. /**
  33624. * Animation to perform
  33625. */
  33626. animation: Animation;
  33627. /**
  33628. * Target to animate
  33629. */
  33630. target: any;
  33631. /**
  33632. * Serialize the object
  33633. * @returns the JSON object representing the current entity
  33634. */
  33635. serialize(): any;
  33636. }
  33637. /**
  33638. * Use this class to create coordinated animations on multiple targets
  33639. */
  33640. export class AnimationGroup implements IDisposable {
  33641. /** The name of the animation group */
  33642. name: string;
  33643. private _scene;
  33644. private _targetedAnimations;
  33645. private _animatables;
  33646. private _from;
  33647. private _to;
  33648. private _isStarted;
  33649. private _isPaused;
  33650. private _speedRatio;
  33651. private _loopAnimation;
  33652. /**
  33653. * Gets or sets the unique id of the node
  33654. */
  33655. uniqueId: number;
  33656. /**
  33657. * This observable will notify when one animation have ended
  33658. */
  33659. onAnimationEndObservable: Observable<TargetedAnimation>;
  33660. /**
  33661. * Observer raised when one animation loops
  33662. */
  33663. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33664. /**
  33665. * This observable will notify when all animations have ended.
  33666. */
  33667. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33668. /**
  33669. * This observable will notify when all animations have paused.
  33670. */
  33671. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33672. /**
  33673. * This observable will notify when all animations are playing.
  33674. */
  33675. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33676. /**
  33677. * Gets the first frame
  33678. */
  33679. readonly from: number;
  33680. /**
  33681. * Gets the last frame
  33682. */
  33683. readonly to: number;
  33684. /**
  33685. * Define if the animations are started
  33686. */
  33687. readonly isStarted: boolean;
  33688. /**
  33689. * Gets a value indicating that the current group is playing
  33690. */
  33691. readonly isPlaying: boolean;
  33692. /**
  33693. * Gets or sets the speed ratio to use for all animations
  33694. */
  33695. /**
  33696. * Gets or sets the speed ratio to use for all animations
  33697. */
  33698. speedRatio: number;
  33699. /**
  33700. * Gets or sets if all animations should loop or not
  33701. */
  33702. loopAnimation: boolean;
  33703. /**
  33704. * Gets the targeted animations for this animation group
  33705. */
  33706. readonly targetedAnimations: Array<TargetedAnimation>;
  33707. /**
  33708. * returning the list of animatables controlled by this animation group.
  33709. */
  33710. readonly animatables: Array<Animatable>;
  33711. /**
  33712. * Instantiates a new Animation Group.
  33713. * This helps managing several animations at once.
  33714. * @see http://doc.babylonjs.com/how_to/group
  33715. * @param name Defines the name of the group
  33716. * @param scene Defines the scene the group belongs to
  33717. */
  33718. constructor(
  33719. /** The name of the animation group */
  33720. name: string, scene?: Nullable<Scene>);
  33721. /**
  33722. * Add an animation (with its target) in the group
  33723. * @param animation defines the animation we want to add
  33724. * @param target defines the target of the animation
  33725. * @returns the TargetedAnimation object
  33726. */
  33727. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33728. /**
  33729. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33730. * It can add constant keys at begin or end
  33731. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33732. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33733. * @returns the animation group
  33734. */
  33735. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33736. /**
  33737. * Start all animations on given targets
  33738. * @param loop defines if animations must loop
  33739. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33740. * @param from defines the from key (optional)
  33741. * @param to defines the to key (optional)
  33742. * @returns the current animation group
  33743. */
  33744. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33745. /**
  33746. * Pause all animations
  33747. * @returns the animation group
  33748. */
  33749. pause(): AnimationGroup;
  33750. /**
  33751. * Play all animations to initial state
  33752. * This function will start() the animations if they were not started or will restart() them if they were paused
  33753. * @param loop defines if animations must loop
  33754. * @returns the animation group
  33755. */
  33756. play(loop?: boolean): AnimationGroup;
  33757. /**
  33758. * Reset all animations to initial state
  33759. * @returns the animation group
  33760. */
  33761. reset(): AnimationGroup;
  33762. /**
  33763. * Restart animations from key 0
  33764. * @returns the animation group
  33765. */
  33766. restart(): AnimationGroup;
  33767. /**
  33768. * Stop all animations
  33769. * @returns the animation group
  33770. */
  33771. stop(): AnimationGroup;
  33772. /**
  33773. * Set animation weight for all animatables
  33774. * @param weight defines the weight to use
  33775. * @return the animationGroup
  33776. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33777. */
  33778. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33779. /**
  33780. * Synchronize and normalize all animatables with a source animatable
  33781. * @param root defines the root animatable to synchronize with
  33782. * @return the animationGroup
  33783. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33784. */
  33785. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33786. /**
  33787. * Goes to a specific frame in this animation group
  33788. * @param frame the frame number to go to
  33789. * @return the animationGroup
  33790. */
  33791. goToFrame(frame: number): AnimationGroup;
  33792. /**
  33793. * Dispose all associated resources
  33794. */
  33795. dispose(): void;
  33796. private _checkAnimationGroupEnded;
  33797. /**
  33798. * Clone the current animation group and returns a copy
  33799. * @param newName defines the name of the new group
  33800. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33801. * @returns the new aniamtion group
  33802. */
  33803. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33804. /**
  33805. * Serializes the animationGroup to an object
  33806. * @returns Serialized object
  33807. */
  33808. serialize(): any;
  33809. /**
  33810. * Returns a new AnimationGroup object parsed from the source provided.
  33811. * @param parsedAnimationGroup defines the source
  33812. * @param scene defines the scene that will receive the animationGroup
  33813. * @returns a new AnimationGroup
  33814. */
  33815. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33816. /**
  33817. * Returns the string "AnimationGroup"
  33818. * @returns "AnimationGroup"
  33819. */
  33820. getClassName(): string;
  33821. /**
  33822. * Creates a detailled string about the object
  33823. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33824. * @returns a string representing the object
  33825. */
  33826. toString(fullDetails?: boolean): string;
  33827. }
  33828. }
  33829. declare module "babylonjs/scene" {
  33830. import { Nullable } from "babylonjs/types";
  33831. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33832. import { Observable } from "babylonjs/Misc/observable";
  33833. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33834. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33835. import { Geometry } from "babylonjs/Meshes/geometry";
  33836. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33837. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33839. import { Mesh } from "babylonjs/Meshes/mesh";
  33840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33841. import { Bone } from "babylonjs/Bones/bone";
  33842. import { Skeleton } from "babylonjs/Bones/skeleton";
  33843. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33844. import { Camera } from "babylonjs/Cameras/camera";
  33845. import { AbstractScene } from "babylonjs/abstractScene";
  33846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33847. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33848. import { Material } from "babylonjs/Materials/material";
  33849. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33850. import { Effect } from "babylonjs/Materials/effect";
  33851. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33852. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33853. import { Light } from "babylonjs/Lights/light";
  33854. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33855. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33856. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33857. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33859. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33860. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33861. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33862. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33863. import { Engine } from "babylonjs/Engines/engine";
  33864. import { Node } from "babylonjs/node";
  33865. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33866. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33867. import { WebRequest } from "babylonjs/Misc/webRequest";
  33868. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33869. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33870. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33871. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33872. import { Plane } from "babylonjs/Maths/math.plane";
  33873. import { Ray } from "babylonjs/Culling/ray";
  33874. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33875. import { Animation } from "babylonjs/Animations/animation";
  33876. import { Animatable } from "babylonjs/Animations/animatable";
  33877. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33878. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33879. import { Collider } from "babylonjs/Collisions/collider";
  33880. /**
  33881. * Define an interface for all classes that will hold resources
  33882. */
  33883. export interface IDisposable {
  33884. /**
  33885. * Releases all held resources
  33886. */
  33887. dispose(): void;
  33888. }
  33889. /** Interface defining initialization parameters for Scene class */
  33890. export interface SceneOptions {
  33891. /**
  33892. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33893. * It will improve performance when the number of geometries becomes important.
  33894. */
  33895. useGeometryUniqueIdsMap?: boolean;
  33896. /**
  33897. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33898. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33899. */
  33900. useMaterialMeshMap?: boolean;
  33901. /**
  33902. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33903. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33904. */
  33905. useClonedMeshhMap?: boolean;
  33906. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33907. virtual?: boolean;
  33908. }
  33909. /**
  33910. * Represents a scene to be rendered by the engine.
  33911. * @see http://doc.babylonjs.com/features/scene
  33912. */
  33913. export class Scene extends AbstractScene implements IAnimatable {
  33914. /** The fog is deactivated */
  33915. static readonly FOGMODE_NONE: number;
  33916. /** The fog density is following an exponential function */
  33917. static readonly FOGMODE_EXP: number;
  33918. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33919. static readonly FOGMODE_EXP2: number;
  33920. /** The fog density is following a linear function. */
  33921. static readonly FOGMODE_LINEAR: number;
  33922. /**
  33923. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33925. */
  33926. static MinDeltaTime: number;
  33927. /**
  33928. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33929. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33930. */
  33931. static MaxDeltaTime: number;
  33932. /**
  33933. * Factory used to create the default material.
  33934. * @param name The name of the material to create
  33935. * @param scene The scene to create the material for
  33936. * @returns The default material
  33937. */
  33938. static DefaultMaterialFactory(scene: Scene): Material;
  33939. /**
  33940. * Factory used to create the a collision coordinator.
  33941. * @returns The collision coordinator
  33942. */
  33943. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33944. /** @hidden */
  33945. _inputManager: InputManager;
  33946. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33947. cameraToUseForPointers: Nullable<Camera>;
  33948. /** @hidden */
  33949. readonly _isScene: boolean;
  33950. /**
  33951. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33952. */
  33953. autoClear: boolean;
  33954. /**
  33955. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33956. */
  33957. autoClearDepthAndStencil: boolean;
  33958. /**
  33959. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33960. */
  33961. clearColor: Color4;
  33962. /**
  33963. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33964. */
  33965. ambientColor: Color3;
  33966. /**
  33967. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33968. * It should only be one of the following (if not the default embedded one):
  33969. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33970. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33971. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33972. * The material properties need to be setup according to the type of texture in use.
  33973. */
  33974. environmentBRDFTexture: BaseTexture;
  33975. /** @hidden */
  33976. protected _environmentTexture: Nullable<BaseTexture>;
  33977. /**
  33978. * Texture used in all pbr material as the reflection texture.
  33979. * As in the majority of the scene they are the same (exception for multi room and so on),
  33980. * this is easier to reference from here than from all the materials.
  33981. */
  33982. /**
  33983. * Texture used in all pbr material as the reflection texture.
  33984. * As in the majority of the scene they are the same (exception for multi room and so on),
  33985. * this is easier to set here than in all the materials.
  33986. */
  33987. environmentTexture: Nullable<BaseTexture>;
  33988. /** @hidden */
  33989. protected _environmentIntensity: number;
  33990. /**
  33991. * Intensity of the environment in all pbr material.
  33992. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33993. * As in the majority of the scene they are the same (exception for multi room and so on),
  33994. * this is easier to reference from here than from all the materials.
  33995. */
  33996. /**
  33997. * Intensity of the environment in all pbr material.
  33998. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33999. * As in the majority of the scene they are the same (exception for multi room and so on),
  34000. * this is easier to set here than in all the materials.
  34001. */
  34002. environmentIntensity: number;
  34003. /** @hidden */
  34004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34005. /**
  34006. * Default image processing configuration used either in the rendering
  34007. * Forward main pass or through the imageProcessingPostProcess if present.
  34008. * As in the majority of the scene they are the same (exception for multi camera),
  34009. * this is easier to reference from here than from all the materials and post process.
  34010. *
  34011. * No setter as we it is a shared configuration, you can set the values instead.
  34012. */
  34013. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34014. private _forceWireframe;
  34015. /**
  34016. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34017. */
  34018. forceWireframe: boolean;
  34019. private _forcePointsCloud;
  34020. /**
  34021. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34022. */
  34023. forcePointsCloud: boolean;
  34024. /**
  34025. * Gets or sets the active clipplane 1
  34026. */
  34027. clipPlane: Nullable<Plane>;
  34028. /**
  34029. * Gets or sets the active clipplane 2
  34030. */
  34031. clipPlane2: Nullable<Plane>;
  34032. /**
  34033. * Gets or sets the active clipplane 3
  34034. */
  34035. clipPlane3: Nullable<Plane>;
  34036. /**
  34037. * Gets or sets the active clipplane 4
  34038. */
  34039. clipPlane4: Nullable<Plane>;
  34040. /**
  34041. * Gets or sets a boolean indicating if animations are enabled
  34042. */
  34043. animationsEnabled: boolean;
  34044. private _animationPropertiesOverride;
  34045. /**
  34046. * Gets or sets the animation properties override
  34047. */
  34048. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34049. /**
  34050. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34051. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34052. */
  34053. useConstantAnimationDeltaTime: boolean;
  34054. /**
  34055. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34056. * Please note that it requires to run a ray cast through the scene on every frame
  34057. */
  34058. constantlyUpdateMeshUnderPointer: boolean;
  34059. /**
  34060. * Defines the HTML cursor to use when hovering over interactive elements
  34061. */
  34062. hoverCursor: string;
  34063. /**
  34064. * Defines the HTML default cursor to use (empty by default)
  34065. */
  34066. defaultCursor: string;
  34067. /**
  34068. * This is used to call preventDefault() on pointer down
  34069. * in order to block unwanted artifacts like system double clicks
  34070. */
  34071. preventDefaultOnPointerDown: boolean;
  34072. /**
  34073. * This is used to call preventDefault() on pointer up
  34074. * in order to block unwanted artifacts like system double clicks
  34075. */
  34076. preventDefaultOnPointerUp: boolean;
  34077. /**
  34078. * Gets or sets user defined metadata
  34079. */
  34080. metadata: any;
  34081. /**
  34082. * For internal use only. Please do not use.
  34083. */
  34084. reservedDataStore: any;
  34085. /**
  34086. * Gets the name of the plugin used to load this scene (null by default)
  34087. */
  34088. loadingPluginName: string;
  34089. /**
  34090. * Use this array to add regular expressions used to disable offline support for specific urls
  34091. */
  34092. disableOfflineSupportExceptionRules: RegExp[];
  34093. /**
  34094. * An event triggered when the scene is disposed.
  34095. */
  34096. onDisposeObservable: Observable<Scene>;
  34097. private _onDisposeObserver;
  34098. /** Sets a function to be executed when this scene is disposed. */
  34099. onDispose: () => void;
  34100. /**
  34101. * An event triggered before rendering the scene (right after animations and physics)
  34102. */
  34103. onBeforeRenderObservable: Observable<Scene>;
  34104. private _onBeforeRenderObserver;
  34105. /** Sets a function to be executed before rendering this scene */
  34106. beforeRender: Nullable<() => void>;
  34107. /**
  34108. * An event triggered after rendering the scene
  34109. */
  34110. onAfterRenderObservable: Observable<Scene>;
  34111. /**
  34112. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34113. */
  34114. onAfterRenderCameraObservable: Observable<Camera>;
  34115. private _onAfterRenderObserver;
  34116. /** Sets a function to be executed after rendering this scene */
  34117. afterRender: Nullable<() => void>;
  34118. /**
  34119. * An event triggered before animating the scene
  34120. */
  34121. onBeforeAnimationsObservable: Observable<Scene>;
  34122. /**
  34123. * An event triggered after animations processing
  34124. */
  34125. onAfterAnimationsObservable: Observable<Scene>;
  34126. /**
  34127. * An event triggered before draw calls are ready to be sent
  34128. */
  34129. onBeforeDrawPhaseObservable: Observable<Scene>;
  34130. /**
  34131. * An event triggered after draw calls have been sent
  34132. */
  34133. onAfterDrawPhaseObservable: Observable<Scene>;
  34134. /**
  34135. * An event triggered when the scene is ready
  34136. */
  34137. onReadyObservable: Observable<Scene>;
  34138. /**
  34139. * An event triggered before rendering a camera
  34140. */
  34141. onBeforeCameraRenderObservable: Observable<Camera>;
  34142. private _onBeforeCameraRenderObserver;
  34143. /** Sets a function to be executed before rendering a camera*/
  34144. beforeCameraRender: () => void;
  34145. /**
  34146. * An event triggered after rendering a camera
  34147. */
  34148. onAfterCameraRenderObservable: Observable<Camera>;
  34149. private _onAfterCameraRenderObserver;
  34150. /** Sets a function to be executed after rendering a camera*/
  34151. afterCameraRender: () => void;
  34152. /**
  34153. * An event triggered when active meshes evaluation is about to start
  34154. */
  34155. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34156. /**
  34157. * An event triggered when active meshes evaluation is done
  34158. */
  34159. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34160. /**
  34161. * An event triggered when particles rendering is about to start
  34162. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34163. */
  34164. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34165. /**
  34166. * An event triggered when particles rendering is done
  34167. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34168. */
  34169. onAfterParticlesRenderingObservable: Observable<Scene>;
  34170. /**
  34171. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34172. */
  34173. onDataLoadedObservable: Observable<Scene>;
  34174. /**
  34175. * An event triggered when a camera is created
  34176. */
  34177. onNewCameraAddedObservable: Observable<Camera>;
  34178. /**
  34179. * An event triggered when a camera is removed
  34180. */
  34181. onCameraRemovedObservable: Observable<Camera>;
  34182. /**
  34183. * An event triggered when a light is created
  34184. */
  34185. onNewLightAddedObservable: Observable<Light>;
  34186. /**
  34187. * An event triggered when a light is removed
  34188. */
  34189. onLightRemovedObservable: Observable<Light>;
  34190. /**
  34191. * An event triggered when a geometry is created
  34192. */
  34193. onNewGeometryAddedObservable: Observable<Geometry>;
  34194. /**
  34195. * An event triggered when a geometry is removed
  34196. */
  34197. onGeometryRemovedObservable: Observable<Geometry>;
  34198. /**
  34199. * An event triggered when a transform node is created
  34200. */
  34201. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34202. /**
  34203. * An event triggered when a transform node is removed
  34204. */
  34205. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34206. /**
  34207. * An event triggered when a mesh is created
  34208. */
  34209. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34210. /**
  34211. * An event triggered when a mesh is removed
  34212. */
  34213. onMeshRemovedObservable: Observable<AbstractMesh>;
  34214. /**
  34215. * An event triggered when a skeleton is created
  34216. */
  34217. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34218. /**
  34219. * An event triggered when a skeleton is removed
  34220. */
  34221. onSkeletonRemovedObservable: Observable<Skeleton>;
  34222. /**
  34223. * An event triggered when a material is created
  34224. */
  34225. onNewMaterialAddedObservable: Observable<Material>;
  34226. /**
  34227. * An event triggered when a material is removed
  34228. */
  34229. onMaterialRemovedObservable: Observable<Material>;
  34230. /**
  34231. * An event triggered when a texture is created
  34232. */
  34233. onNewTextureAddedObservable: Observable<BaseTexture>;
  34234. /**
  34235. * An event triggered when a texture is removed
  34236. */
  34237. onTextureRemovedObservable: Observable<BaseTexture>;
  34238. /**
  34239. * An event triggered when render targets are about to be rendered
  34240. * Can happen multiple times per frame.
  34241. */
  34242. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34243. /**
  34244. * An event triggered when render targets were rendered.
  34245. * Can happen multiple times per frame.
  34246. */
  34247. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34248. /**
  34249. * An event triggered before calculating deterministic simulation step
  34250. */
  34251. onBeforeStepObservable: Observable<Scene>;
  34252. /**
  34253. * An event triggered after calculating deterministic simulation step
  34254. */
  34255. onAfterStepObservable: Observable<Scene>;
  34256. /**
  34257. * An event triggered when the activeCamera property is updated
  34258. */
  34259. onActiveCameraChanged: Observable<Scene>;
  34260. /**
  34261. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34262. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34263. * 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)
  34264. */
  34265. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34266. /**
  34267. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34268. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34269. * 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)
  34270. */
  34271. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34272. /**
  34273. * This Observable will when a mesh has been imported into the scene.
  34274. */
  34275. onMeshImportedObservable: Observable<AbstractMesh>;
  34276. /**
  34277. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34278. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34279. */
  34280. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34281. /** @hidden */
  34282. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34283. /**
  34284. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34285. */
  34286. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34287. /**
  34288. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34289. */
  34290. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34291. /**
  34292. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34293. */
  34294. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34295. /** Callback called when a pointer move is detected */
  34296. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34297. /** Callback called when a pointer down is detected */
  34298. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34299. /** Callback called when a pointer up is detected */
  34300. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34301. /** Callback called when a pointer pick is detected */
  34302. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34303. /**
  34304. * 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).
  34305. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34306. */
  34307. onPrePointerObservable: Observable<PointerInfoPre>;
  34308. /**
  34309. * Observable event triggered each time an input event is received from the rendering canvas
  34310. */
  34311. onPointerObservable: Observable<PointerInfo>;
  34312. /**
  34313. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34314. */
  34315. readonly unTranslatedPointer: Vector2;
  34316. /**
  34317. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34318. */
  34319. static DragMovementThreshold: number;
  34320. /**
  34321. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34322. */
  34323. static LongPressDelay: number;
  34324. /**
  34325. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34326. */
  34327. static DoubleClickDelay: number;
  34328. /** If you need to check double click without raising a single click at first click, enable this flag */
  34329. static ExclusiveDoubleClickMode: boolean;
  34330. /** @hidden */
  34331. _mirroredCameraPosition: Nullable<Vector3>;
  34332. /**
  34333. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34334. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34335. */
  34336. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34337. /**
  34338. * Observable event triggered each time an keyboard event is received from the hosting window
  34339. */
  34340. onKeyboardObservable: Observable<KeyboardInfo>;
  34341. private _useRightHandedSystem;
  34342. /**
  34343. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34344. */
  34345. useRightHandedSystem: boolean;
  34346. private _timeAccumulator;
  34347. private _currentStepId;
  34348. private _currentInternalStep;
  34349. /**
  34350. * Sets the step Id used by deterministic lock step
  34351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34352. * @param newStepId defines the step Id
  34353. */
  34354. setStepId(newStepId: number): void;
  34355. /**
  34356. * Gets the step Id used by deterministic lock step
  34357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34358. * @returns the step Id
  34359. */
  34360. getStepId(): number;
  34361. /**
  34362. * Gets the internal step used by deterministic lock step
  34363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34364. * @returns the internal step
  34365. */
  34366. getInternalStep(): number;
  34367. private _fogEnabled;
  34368. /**
  34369. * Gets or sets a boolean indicating if fog is enabled on this scene
  34370. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34371. * (Default is true)
  34372. */
  34373. fogEnabled: boolean;
  34374. private _fogMode;
  34375. /**
  34376. * Gets or sets the fog mode to use
  34377. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34378. * | mode | value |
  34379. * | --- | --- |
  34380. * | FOGMODE_NONE | 0 |
  34381. * | FOGMODE_EXP | 1 |
  34382. * | FOGMODE_EXP2 | 2 |
  34383. * | FOGMODE_LINEAR | 3 |
  34384. */
  34385. fogMode: number;
  34386. /**
  34387. * Gets or sets the fog color to use
  34388. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34389. * (Default is Color3(0.2, 0.2, 0.3))
  34390. */
  34391. fogColor: Color3;
  34392. /**
  34393. * Gets or sets the fog density to use
  34394. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34395. * (Default is 0.1)
  34396. */
  34397. fogDensity: number;
  34398. /**
  34399. * Gets or sets the fog start distance to use
  34400. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34401. * (Default is 0)
  34402. */
  34403. fogStart: number;
  34404. /**
  34405. * Gets or sets the fog end distance to use
  34406. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34407. * (Default is 1000)
  34408. */
  34409. fogEnd: number;
  34410. private _shadowsEnabled;
  34411. /**
  34412. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34413. */
  34414. shadowsEnabled: boolean;
  34415. private _lightsEnabled;
  34416. /**
  34417. * Gets or sets a boolean indicating if lights are enabled on this scene
  34418. */
  34419. lightsEnabled: boolean;
  34420. /** All of the active cameras added to this scene. */
  34421. activeCameras: Camera[];
  34422. /** @hidden */
  34423. _activeCamera: Nullable<Camera>;
  34424. /** Gets or sets the current active camera */
  34425. activeCamera: Nullable<Camera>;
  34426. private _defaultMaterial;
  34427. /** The default material used on meshes when no material is affected */
  34428. /** The default material used on meshes when no material is affected */
  34429. defaultMaterial: Material;
  34430. private _texturesEnabled;
  34431. /**
  34432. * Gets or sets a boolean indicating if textures are enabled on this scene
  34433. */
  34434. texturesEnabled: boolean;
  34435. /**
  34436. * Gets or sets a boolean indicating if particles are enabled on this scene
  34437. */
  34438. particlesEnabled: boolean;
  34439. /**
  34440. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34441. */
  34442. spritesEnabled: boolean;
  34443. private _skeletonsEnabled;
  34444. /**
  34445. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34446. */
  34447. skeletonsEnabled: boolean;
  34448. /**
  34449. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34450. */
  34451. lensFlaresEnabled: boolean;
  34452. /**
  34453. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34455. */
  34456. collisionsEnabled: boolean;
  34457. private _collisionCoordinator;
  34458. /** @hidden */
  34459. readonly collisionCoordinator: ICollisionCoordinator;
  34460. /**
  34461. * Defines the gravity applied to this scene (used only for collisions)
  34462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34463. */
  34464. gravity: Vector3;
  34465. /**
  34466. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34467. */
  34468. postProcessesEnabled: boolean;
  34469. /**
  34470. * The list of postprocesses added to the scene
  34471. */
  34472. postProcesses: PostProcess[];
  34473. /**
  34474. * Gets the current postprocess manager
  34475. */
  34476. postProcessManager: PostProcessManager;
  34477. /**
  34478. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34479. */
  34480. renderTargetsEnabled: boolean;
  34481. /**
  34482. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34483. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34484. */
  34485. dumpNextRenderTargets: boolean;
  34486. /**
  34487. * The list of user defined render targets added to the scene
  34488. */
  34489. customRenderTargets: RenderTargetTexture[];
  34490. /**
  34491. * Defines if texture loading must be delayed
  34492. * If true, textures will only be loaded when they need to be rendered
  34493. */
  34494. useDelayedTextureLoading: boolean;
  34495. /**
  34496. * Gets the list of meshes imported to the scene through SceneLoader
  34497. */
  34498. importedMeshesFiles: String[];
  34499. /**
  34500. * Gets or sets a boolean indicating if probes are enabled on this scene
  34501. */
  34502. probesEnabled: boolean;
  34503. /**
  34504. * Gets or sets the current offline provider to use to store scene data
  34505. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34506. */
  34507. offlineProvider: IOfflineProvider;
  34508. /**
  34509. * Gets or sets the action manager associated with the scene
  34510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34511. */
  34512. actionManager: AbstractActionManager;
  34513. private _meshesForIntersections;
  34514. /**
  34515. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34516. */
  34517. proceduralTexturesEnabled: boolean;
  34518. private _engine;
  34519. private _totalVertices;
  34520. /** @hidden */
  34521. _activeIndices: PerfCounter;
  34522. /** @hidden */
  34523. _activeParticles: PerfCounter;
  34524. /** @hidden */
  34525. _activeBones: PerfCounter;
  34526. private _animationRatio;
  34527. /** @hidden */
  34528. _animationTimeLast: number;
  34529. /** @hidden */
  34530. _animationTime: number;
  34531. /**
  34532. * Gets or sets a general scale for animation speed
  34533. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34534. */
  34535. animationTimeScale: number;
  34536. /** @hidden */
  34537. _cachedMaterial: Nullable<Material>;
  34538. /** @hidden */
  34539. _cachedEffect: Nullable<Effect>;
  34540. /** @hidden */
  34541. _cachedVisibility: Nullable<number>;
  34542. private _renderId;
  34543. private _frameId;
  34544. private _executeWhenReadyTimeoutId;
  34545. private _intermediateRendering;
  34546. private _viewUpdateFlag;
  34547. private _projectionUpdateFlag;
  34548. /** @hidden */
  34549. _toBeDisposed: Nullable<IDisposable>[];
  34550. private _activeRequests;
  34551. /** @hidden */
  34552. _pendingData: any[];
  34553. private _isDisposed;
  34554. /**
  34555. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34556. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34557. */
  34558. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34559. private _activeMeshes;
  34560. private _processedMaterials;
  34561. private _renderTargets;
  34562. /** @hidden */
  34563. _activeParticleSystems: SmartArray<IParticleSystem>;
  34564. private _activeSkeletons;
  34565. private _softwareSkinnedMeshes;
  34566. private _renderingManager;
  34567. /** @hidden */
  34568. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34569. private _transformMatrix;
  34570. private _sceneUbo;
  34571. /** @hidden */
  34572. _viewMatrix: Matrix;
  34573. private _projectionMatrix;
  34574. /** @hidden */
  34575. _forcedViewPosition: Nullable<Vector3>;
  34576. /** @hidden */
  34577. _frustumPlanes: Plane[];
  34578. /**
  34579. * Gets the list of frustum planes (built from the active camera)
  34580. */
  34581. readonly frustumPlanes: Plane[];
  34582. /**
  34583. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34584. * This is useful if there are more lights that the maximum simulteanous authorized
  34585. */
  34586. requireLightSorting: boolean;
  34587. /** @hidden */
  34588. readonly useMaterialMeshMap: boolean;
  34589. /** @hidden */
  34590. readonly useClonedMeshhMap: boolean;
  34591. private _externalData;
  34592. private _uid;
  34593. /**
  34594. * @hidden
  34595. * Backing store of defined scene components.
  34596. */
  34597. _components: ISceneComponent[];
  34598. /**
  34599. * @hidden
  34600. * Backing store of defined scene components.
  34601. */
  34602. _serializableComponents: ISceneSerializableComponent[];
  34603. /**
  34604. * List of components to register on the next registration step.
  34605. */
  34606. private _transientComponents;
  34607. /**
  34608. * Registers the transient components if needed.
  34609. */
  34610. private _registerTransientComponents;
  34611. /**
  34612. * @hidden
  34613. * Add a component to the scene.
  34614. * Note that the ccomponent could be registered on th next frame if this is called after
  34615. * the register component stage.
  34616. * @param component Defines the component to add to the scene
  34617. */
  34618. _addComponent(component: ISceneComponent): void;
  34619. /**
  34620. * @hidden
  34621. * Gets a component from the scene.
  34622. * @param name defines the name of the component to retrieve
  34623. * @returns the component or null if not present
  34624. */
  34625. _getComponent(name: string): Nullable<ISceneComponent>;
  34626. /**
  34627. * @hidden
  34628. * Defines the actions happening before camera updates.
  34629. */
  34630. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34631. /**
  34632. * @hidden
  34633. * Defines the actions happening before clear the canvas.
  34634. */
  34635. _beforeClearStage: Stage<SimpleStageAction>;
  34636. /**
  34637. * @hidden
  34638. * Defines the actions when collecting render targets for the frame.
  34639. */
  34640. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34641. /**
  34642. * @hidden
  34643. * Defines the actions happening for one camera in the frame.
  34644. */
  34645. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34646. /**
  34647. * @hidden
  34648. * Defines the actions happening during the per mesh ready checks.
  34649. */
  34650. _isReadyForMeshStage: Stage<MeshStageAction>;
  34651. /**
  34652. * @hidden
  34653. * Defines the actions happening before evaluate active mesh checks.
  34654. */
  34655. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34656. /**
  34657. * @hidden
  34658. * Defines the actions happening during the evaluate sub mesh checks.
  34659. */
  34660. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34661. /**
  34662. * @hidden
  34663. * Defines the actions happening during the active mesh stage.
  34664. */
  34665. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34666. /**
  34667. * @hidden
  34668. * Defines the actions happening during the per camera render target step.
  34669. */
  34670. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34671. /**
  34672. * @hidden
  34673. * Defines the actions happening just before the active camera is drawing.
  34674. */
  34675. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34676. /**
  34677. * @hidden
  34678. * Defines the actions happening just before a render target is drawing.
  34679. */
  34680. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34681. /**
  34682. * @hidden
  34683. * Defines the actions happening just before a rendering group is drawing.
  34684. */
  34685. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34686. /**
  34687. * @hidden
  34688. * Defines the actions happening just before a mesh is drawing.
  34689. */
  34690. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34691. /**
  34692. * @hidden
  34693. * Defines the actions happening just after a mesh has been drawn.
  34694. */
  34695. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34696. /**
  34697. * @hidden
  34698. * Defines the actions happening just after a rendering group has been drawn.
  34699. */
  34700. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34701. /**
  34702. * @hidden
  34703. * Defines the actions happening just after the active camera has been drawn.
  34704. */
  34705. _afterCameraDrawStage: Stage<CameraStageAction>;
  34706. /**
  34707. * @hidden
  34708. * Defines the actions happening just after a render target has been drawn.
  34709. */
  34710. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34711. /**
  34712. * @hidden
  34713. * Defines the actions happening just after rendering all cameras and computing intersections.
  34714. */
  34715. _afterRenderStage: Stage<SimpleStageAction>;
  34716. /**
  34717. * @hidden
  34718. * Defines the actions happening when a pointer move event happens.
  34719. */
  34720. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34721. /**
  34722. * @hidden
  34723. * Defines the actions happening when a pointer down event happens.
  34724. */
  34725. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34726. /**
  34727. * @hidden
  34728. * Defines the actions happening when a pointer up event happens.
  34729. */
  34730. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34731. /**
  34732. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34733. */
  34734. private geometriesByUniqueId;
  34735. /**
  34736. * Creates a new Scene
  34737. * @param engine defines the engine to use to render this scene
  34738. * @param options defines the scene options
  34739. */
  34740. constructor(engine: Engine, options?: SceneOptions);
  34741. /**
  34742. * Gets a string idenfifying the name of the class
  34743. * @returns "Scene" string
  34744. */
  34745. getClassName(): string;
  34746. private _defaultMeshCandidates;
  34747. /**
  34748. * @hidden
  34749. */
  34750. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34751. private _defaultSubMeshCandidates;
  34752. /**
  34753. * @hidden
  34754. */
  34755. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34756. /**
  34757. * Sets the default candidate providers for the scene.
  34758. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34759. * and getCollidingSubMeshCandidates to their default function
  34760. */
  34761. setDefaultCandidateProviders(): void;
  34762. /**
  34763. * Gets the mesh that is currently under the pointer
  34764. */
  34765. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34766. /**
  34767. * Gets or sets the current on-screen X position of the pointer
  34768. */
  34769. pointerX: number;
  34770. /**
  34771. * Gets or sets the current on-screen Y position of the pointer
  34772. */
  34773. pointerY: number;
  34774. /**
  34775. * Gets the cached material (ie. the latest rendered one)
  34776. * @returns the cached material
  34777. */
  34778. getCachedMaterial(): Nullable<Material>;
  34779. /**
  34780. * Gets the cached effect (ie. the latest rendered one)
  34781. * @returns the cached effect
  34782. */
  34783. getCachedEffect(): Nullable<Effect>;
  34784. /**
  34785. * Gets the cached visibility state (ie. the latest rendered one)
  34786. * @returns the cached visibility state
  34787. */
  34788. getCachedVisibility(): Nullable<number>;
  34789. /**
  34790. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34791. * @param material defines the current material
  34792. * @param effect defines the current effect
  34793. * @param visibility defines the current visibility state
  34794. * @returns true if one parameter is not cached
  34795. */
  34796. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34797. /**
  34798. * Gets the engine associated with the scene
  34799. * @returns an Engine
  34800. */
  34801. getEngine(): Engine;
  34802. /**
  34803. * Gets the total number of vertices rendered per frame
  34804. * @returns the total number of vertices rendered per frame
  34805. */
  34806. getTotalVertices(): number;
  34807. /**
  34808. * Gets the performance counter for total vertices
  34809. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34810. */
  34811. readonly totalVerticesPerfCounter: PerfCounter;
  34812. /**
  34813. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34814. * @returns the total number of active indices rendered per frame
  34815. */
  34816. getActiveIndices(): number;
  34817. /**
  34818. * Gets the performance counter for active indices
  34819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34820. */
  34821. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34822. /**
  34823. * Gets the total number of active particles rendered per frame
  34824. * @returns the total number of active particles rendered per frame
  34825. */
  34826. getActiveParticles(): number;
  34827. /**
  34828. * Gets the performance counter for active particles
  34829. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34830. */
  34831. readonly activeParticlesPerfCounter: PerfCounter;
  34832. /**
  34833. * Gets the total number of active bones rendered per frame
  34834. * @returns the total number of active bones rendered per frame
  34835. */
  34836. getActiveBones(): number;
  34837. /**
  34838. * Gets the performance counter for active bones
  34839. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34840. */
  34841. readonly activeBonesPerfCounter: PerfCounter;
  34842. /**
  34843. * Gets the array of active meshes
  34844. * @returns an array of AbstractMesh
  34845. */
  34846. getActiveMeshes(): SmartArray<AbstractMesh>;
  34847. /**
  34848. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34849. * @returns a number
  34850. */
  34851. getAnimationRatio(): number;
  34852. /**
  34853. * Gets an unique Id for the current render phase
  34854. * @returns a number
  34855. */
  34856. getRenderId(): number;
  34857. /**
  34858. * Gets an unique Id for the current frame
  34859. * @returns a number
  34860. */
  34861. getFrameId(): number;
  34862. /** Call this function if you want to manually increment the render Id*/
  34863. incrementRenderId(): void;
  34864. private _createUbo;
  34865. /**
  34866. * Use this method to simulate a pointer move on a mesh
  34867. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34868. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34869. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34870. * @returns the current scene
  34871. */
  34872. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34873. /**
  34874. * Use this method to simulate a pointer down on a mesh
  34875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34878. * @returns the current scene
  34879. */
  34880. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34881. /**
  34882. * Use this method to simulate a pointer up on a mesh
  34883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34886. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34887. * @returns the current scene
  34888. */
  34889. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34890. /**
  34891. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34892. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34893. * @returns true if the pointer was captured
  34894. */
  34895. isPointerCaptured(pointerId?: number): boolean;
  34896. /**
  34897. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34898. * @param attachUp defines if you want to attach events to pointerup
  34899. * @param attachDown defines if you want to attach events to pointerdown
  34900. * @param attachMove defines if you want to attach events to pointermove
  34901. */
  34902. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34903. /** Detaches all event handlers*/
  34904. detachControl(): void;
  34905. /**
  34906. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34907. * Delay loaded resources are not taking in account
  34908. * @return true if all required resources are ready
  34909. */
  34910. isReady(): boolean;
  34911. /** Resets all cached information relative to material (including effect and visibility) */
  34912. resetCachedMaterial(): void;
  34913. /**
  34914. * Registers a function to be called before every frame render
  34915. * @param func defines the function to register
  34916. */
  34917. registerBeforeRender(func: () => void): void;
  34918. /**
  34919. * Unregisters a function called before every frame render
  34920. * @param func defines the function to unregister
  34921. */
  34922. unregisterBeforeRender(func: () => void): void;
  34923. /**
  34924. * Registers a function to be called after every frame render
  34925. * @param func defines the function to register
  34926. */
  34927. registerAfterRender(func: () => void): void;
  34928. /**
  34929. * Unregisters a function called after every frame render
  34930. * @param func defines the function to unregister
  34931. */
  34932. unregisterAfterRender(func: () => void): void;
  34933. private _executeOnceBeforeRender;
  34934. /**
  34935. * The provided function will run before render once and will be disposed afterwards.
  34936. * A timeout delay can be provided so that the function will be executed in N ms.
  34937. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34938. * @param func The function to be executed.
  34939. * @param timeout optional delay in ms
  34940. */
  34941. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34942. /** @hidden */
  34943. _addPendingData(data: any): void;
  34944. /** @hidden */
  34945. _removePendingData(data: any): void;
  34946. /**
  34947. * Returns the number of items waiting to be loaded
  34948. * @returns the number of items waiting to be loaded
  34949. */
  34950. getWaitingItemsCount(): number;
  34951. /**
  34952. * Returns a boolean indicating if the scene is still loading data
  34953. */
  34954. readonly isLoading: boolean;
  34955. /**
  34956. * Registers a function to be executed when the scene is ready
  34957. * @param {Function} func - the function to be executed
  34958. */
  34959. executeWhenReady(func: () => void): void;
  34960. /**
  34961. * Returns a promise that resolves when the scene is ready
  34962. * @returns A promise that resolves when the scene is ready
  34963. */
  34964. whenReadyAsync(): Promise<void>;
  34965. /** @hidden */
  34966. _checkIsReady(): void;
  34967. /**
  34968. * Gets all animatable attached to the scene
  34969. */
  34970. readonly animatables: Animatable[];
  34971. /**
  34972. * Resets the last animation time frame.
  34973. * Useful to override when animations start running when loading a scene for the first time.
  34974. */
  34975. resetLastAnimationTimeFrame(): void;
  34976. /**
  34977. * Gets the current view matrix
  34978. * @returns a Matrix
  34979. */
  34980. getViewMatrix(): Matrix;
  34981. /**
  34982. * Gets the current projection matrix
  34983. * @returns a Matrix
  34984. */
  34985. getProjectionMatrix(): Matrix;
  34986. /**
  34987. * Gets the current transform matrix
  34988. * @returns a Matrix made of View * Projection
  34989. */
  34990. getTransformMatrix(): Matrix;
  34991. /**
  34992. * Sets the current transform matrix
  34993. * @param viewL defines the View matrix to use
  34994. * @param projectionL defines the Projection matrix to use
  34995. * @param viewR defines the right View matrix to use (if provided)
  34996. * @param projectionR defines the right Projection matrix to use (if provided)
  34997. */
  34998. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34999. /**
  35000. * Gets the uniform buffer used to store scene data
  35001. * @returns a UniformBuffer
  35002. */
  35003. getSceneUniformBuffer(): UniformBuffer;
  35004. /**
  35005. * Gets an unique (relatively to the current scene) Id
  35006. * @returns an unique number for the scene
  35007. */
  35008. getUniqueId(): number;
  35009. /**
  35010. * Add a mesh to the list of scene's meshes
  35011. * @param newMesh defines the mesh to add
  35012. * @param recursive if all child meshes should also be added to the scene
  35013. */
  35014. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35015. /**
  35016. * Remove a mesh for the list of scene's meshes
  35017. * @param toRemove defines the mesh to remove
  35018. * @param recursive if all child meshes should also be removed from the scene
  35019. * @returns the index where the mesh was in the mesh list
  35020. */
  35021. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35022. /**
  35023. * Add a transform node to the list of scene's transform nodes
  35024. * @param newTransformNode defines the transform node to add
  35025. */
  35026. addTransformNode(newTransformNode: TransformNode): void;
  35027. /**
  35028. * Remove a transform node for the list of scene's transform nodes
  35029. * @param toRemove defines the transform node to remove
  35030. * @returns the index where the transform node was in the transform node list
  35031. */
  35032. removeTransformNode(toRemove: TransformNode): number;
  35033. /**
  35034. * Remove a skeleton for the list of scene's skeletons
  35035. * @param toRemove defines the skeleton to remove
  35036. * @returns the index where the skeleton was in the skeleton list
  35037. */
  35038. removeSkeleton(toRemove: Skeleton): number;
  35039. /**
  35040. * Remove a morph target for the list of scene's morph targets
  35041. * @param toRemove defines the morph target to remove
  35042. * @returns the index where the morph target was in the morph target list
  35043. */
  35044. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35045. /**
  35046. * Remove a light for the list of scene's lights
  35047. * @param toRemove defines the light to remove
  35048. * @returns the index where the light was in the light list
  35049. */
  35050. removeLight(toRemove: Light): number;
  35051. /**
  35052. * Remove a camera for the list of scene's cameras
  35053. * @param toRemove defines the camera to remove
  35054. * @returns the index where the camera was in the camera list
  35055. */
  35056. removeCamera(toRemove: Camera): number;
  35057. /**
  35058. * Remove a particle system for the list of scene's particle systems
  35059. * @param toRemove defines the particle system to remove
  35060. * @returns the index where the particle system was in the particle system list
  35061. */
  35062. removeParticleSystem(toRemove: IParticleSystem): number;
  35063. /**
  35064. * Remove a animation for the list of scene's animations
  35065. * @param toRemove defines the animation to remove
  35066. * @returns the index where the animation was in the animation list
  35067. */
  35068. removeAnimation(toRemove: Animation): number;
  35069. /**
  35070. * Will stop the animation of the given target
  35071. * @param target - the target
  35072. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35073. * @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)
  35074. */
  35075. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35076. /**
  35077. * Removes the given animation group from this scene.
  35078. * @param toRemove The animation group to remove
  35079. * @returns The index of the removed animation group
  35080. */
  35081. removeAnimationGroup(toRemove: AnimationGroup): number;
  35082. /**
  35083. * Removes the given multi-material from this scene.
  35084. * @param toRemove The multi-material to remove
  35085. * @returns The index of the removed multi-material
  35086. */
  35087. removeMultiMaterial(toRemove: MultiMaterial): number;
  35088. /**
  35089. * Removes the given material from this scene.
  35090. * @param toRemove The material to remove
  35091. * @returns The index of the removed material
  35092. */
  35093. removeMaterial(toRemove: Material): number;
  35094. /**
  35095. * Removes the given action manager from this scene.
  35096. * @param toRemove The action manager to remove
  35097. * @returns The index of the removed action manager
  35098. */
  35099. removeActionManager(toRemove: AbstractActionManager): number;
  35100. /**
  35101. * Removes the given texture from this scene.
  35102. * @param toRemove The texture to remove
  35103. * @returns The index of the removed texture
  35104. */
  35105. removeTexture(toRemove: BaseTexture): number;
  35106. /**
  35107. * Adds the given light to this scene
  35108. * @param newLight The light to add
  35109. */
  35110. addLight(newLight: Light): void;
  35111. /**
  35112. * Sorts the list list based on light priorities
  35113. */
  35114. sortLightsByPriority(): void;
  35115. /**
  35116. * Adds the given camera to this scene
  35117. * @param newCamera The camera to add
  35118. */
  35119. addCamera(newCamera: Camera): void;
  35120. /**
  35121. * Adds the given skeleton to this scene
  35122. * @param newSkeleton The skeleton to add
  35123. */
  35124. addSkeleton(newSkeleton: Skeleton): void;
  35125. /**
  35126. * Adds the given particle system to this scene
  35127. * @param newParticleSystem The particle system to add
  35128. */
  35129. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35130. /**
  35131. * Adds the given animation to this scene
  35132. * @param newAnimation The animation to add
  35133. */
  35134. addAnimation(newAnimation: Animation): void;
  35135. /**
  35136. * Adds the given animation group to this scene.
  35137. * @param newAnimationGroup The animation group to add
  35138. */
  35139. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35140. /**
  35141. * Adds the given multi-material to this scene
  35142. * @param newMultiMaterial The multi-material to add
  35143. */
  35144. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35145. /**
  35146. * Adds the given material to this scene
  35147. * @param newMaterial The material to add
  35148. */
  35149. addMaterial(newMaterial: Material): void;
  35150. /**
  35151. * Adds the given morph target to this scene
  35152. * @param newMorphTargetManager The morph target to add
  35153. */
  35154. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35155. /**
  35156. * Adds the given geometry to this scene
  35157. * @param newGeometry The geometry to add
  35158. */
  35159. addGeometry(newGeometry: Geometry): void;
  35160. /**
  35161. * Adds the given action manager to this scene
  35162. * @param newActionManager The action manager to add
  35163. */
  35164. addActionManager(newActionManager: AbstractActionManager): void;
  35165. /**
  35166. * Adds the given texture to this scene.
  35167. * @param newTexture The texture to add
  35168. */
  35169. addTexture(newTexture: BaseTexture): void;
  35170. /**
  35171. * Switch active camera
  35172. * @param newCamera defines the new active camera
  35173. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35174. */
  35175. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35176. /**
  35177. * sets the active camera of the scene using its ID
  35178. * @param id defines the camera's ID
  35179. * @return the new active camera or null if none found.
  35180. */
  35181. setActiveCameraByID(id: string): Nullable<Camera>;
  35182. /**
  35183. * sets the active camera of the scene using its name
  35184. * @param name defines the camera's name
  35185. * @returns the new active camera or null if none found.
  35186. */
  35187. setActiveCameraByName(name: string): Nullable<Camera>;
  35188. /**
  35189. * get an animation group using its name
  35190. * @param name defines the material's name
  35191. * @return the animation group or null if none found.
  35192. */
  35193. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35194. /**
  35195. * Get a material using its unique id
  35196. * @param uniqueId defines the material's unique id
  35197. * @return the material or null if none found.
  35198. */
  35199. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35200. /**
  35201. * get a material using its id
  35202. * @param id defines the material's ID
  35203. * @return the material or null if none found.
  35204. */
  35205. getMaterialByID(id: string): Nullable<Material>;
  35206. /**
  35207. * Gets a the last added material using a given id
  35208. * @param id defines the material's ID
  35209. * @return the last material with the given id or null if none found.
  35210. */
  35211. getLastMaterialByID(id: string): Nullable<Material>;
  35212. /**
  35213. * Gets a material using its name
  35214. * @param name defines the material's name
  35215. * @return the material or null if none found.
  35216. */
  35217. getMaterialByName(name: string): Nullable<Material>;
  35218. /**
  35219. * Get a texture using its unique id
  35220. * @param uniqueId defines the texture's unique id
  35221. * @return the texture or null if none found.
  35222. */
  35223. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35224. /**
  35225. * Gets a camera using its id
  35226. * @param id defines the id to look for
  35227. * @returns the camera or null if not found
  35228. */
  35229. getCameraByID(id: string): Nullable<Camera>;
  35230. /**
  35231. * Gets a camera using its unique id
  35232. * @param uniqueId defines the unique id to look for
  35233. * @returns the camera or null if not found
  35234. */
  35235. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35236. /**
  35237. * Gets a camera using its name
  35238. * @param name defines the camera's name
  35239. * @return the camera or null if none found.
  35240. */
  35241. getCameraByName(name: string): Nullable<Camera>;
  35242. /**
  35243. * Gets a bone using its id
  35244. * @param id defines the bone's id
  35245. * @return the bone or null if not found
  35246. */
  35247. getBoneByID(id: string): Nullable<Bone>;
  35248. /**
  35249. * Gets a bone using its id
  35250. * @param name defines the bone's name
  35251. * @return the bone or null if not found
  35252. */
  35253. getBoneByName(name: string): Nullable<Bone>;
  35254. /**
  35255. * Gets a light node using its name
  35256. * @param name defines the the light's name
  35257. * @return the light or null if none found.
  35258. */
  35259. getLightByName(name: string): Nullable<Light>;
  35260. /**
  35261. * Gets a light node using its id
  35262. * @param id defines the light's id
  35263. * @return the light or null if none found.
  35264. */
  35265. getLightByID(id: string): Nullable<Light>;
  35266. /**
  35267. * Gets a light node using its scene-generated unique ID
  35268. * @param uniqueId defines the light's unique id
  35269. * @return the light or null if none found.
  35270. */
  35271. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35272. /**
  35273. * Gets a particle system by id
  35274. * @param id defines the particle system id
  35275. * @return the corresponding system or null if none found
  35276. */
  35277. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35278. /**
  35279. * Gets a geometry using its ID
  35280. * @param id defines the geometry's id
  35281. * @return the geometry or null if none found.
  35282. */
  35283. getGeometryByID(id: string): Nullable<Geometry>;
  35284. private _getGeometryByUniqueID;
  35285. /**
  35286. * Add a new geometry to this scene
  35287. * @param geometry defines the geometry to be added to the scene.
  35288. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35289. * @return a boolean defining if the geometry was added or not
  35290. */
  35291. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35292. /**
  35293. * Removes an existing geometry
  35294. * @param geometry defines the geometry to be removed from the scene
  35295. * @return a boolean defining if the geometry was removed or not
  35296. */
  35297. removeGeometry(geometry: Geometry): boolean;
  35298. /**
  35299. * Gets the list of geometries attached to the scene
  35300. * @returns an array of Geometry
  35301. */
  35302. getGeometries(): Geometry[];
  35303. /**
  35304. * Gets the first added mesh found of a given ID
  35305. * @param id defines the id to search for
  35306. * @return the mesh found or null if not found at all
  35307. */
  35308. getMeshByID(id: string): Nullable<AbstractMesh>;
  35309. /**
  35310. * Gets a list of meshes using their id
  35311. * @param id defines the id to search for
  35312. * @returns a list of meshes
  35313. */
  35314. getMeshesByID(id: string): Array<AbstractMesh>;
  35315. /**
  35316. * Gets the first added transform node found of a given ID
  35317. * @param id defines the id to search for
  35318. * @return the found transform node or null if not found at all.
  35319. */
  35320. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35321. /**
  35322. * Gets a transform node with its auto-generated unique id
  35323. * @param uniqueId efines the unique id to search for
  35324. * @return the found transform node or null if not found at all.
  35325. */
  35326. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35327. /**
  35328. * Gets a list of transform nodes using their id
  35329. * @param id defines the id to search for
  35330. * @returns a list of transform nodes
  35331. */
  35332. getTransformNodesByID(id: string): Array<TransformNode>;
  35333. /**
  35334. * Gets a mesh with its auto-generated unique id
  35335. * @param uniqueId defines the unique id to search for
  35336. * @return the found mesh or null if not found at all.
  35337. */
  35338. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35339. /**
  35340. * Gets a the last added mesh using a given id
  35341. * @param id defines the id to search for
  35342. * @return the found mesh or null if not found at all.
  35343. */
  35344. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35345. /**
  35346. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35347. * @param id defines the id to search for
  35348. * @return the found node or null if not found at all
  35349. */
  35350. getLastEntryByID(id: string): Nullable<Node>;
  35351. /**
  35352. * Gets a node (Mesh, Camera, Light) using a given id
  35353. * @param id defines the id to search for
  35354. * @return the found node or null if not found at all
  35355. */
  35356. getNodeByID(id: string): Nullable<Node>;
  35357. /**
  35358. * Gets a node (Mesh, Camera, Light) using a given name
  35359. * @param name defines the name to search for
  35360. * @return the found node or null if not found at all.
  35361. */
  35362. getNodeByName(name: string): Nullable<Node>;
  35363. /**
  35364. * Gets a mesh using a given name
  35365. * @param name defines the name to search for
  35366. * @return the found mesh or null if not found at all.
  35367. */
  35368. getMeshByName(name: string): Nullable<AbstractMesh>;
  35369. /**
  35370. * Gets a transform node using a given name
  35371. * @param name defines the name to search for
  35372. * @return the found transform node or null if not found at all.
  35373. */
  35374. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35375. /**
  35376. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35377. * @param id defines the id to search for
  35378. * @return the found skeleton or null if not found at all.
  35379. */
  35380. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35381. /**
  35382. * Gets a skeleton using a given auto generated unique id
  35383. * @param uniqueId defines the unique id to search for
  35384. * @return the found skeleton or null if not found at all.
  35385. */
  35386. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35387. /**
  35388. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35389. * @param id defines the id to search for
  35390. * @return the found skeleton or null if not found at all.
  35391. */
  35392. getSkeletonById(id: string): Nullable<Skeleton>;
  35393. /**
  35394. * Gets a skeleton using a given name
  35395. * @param name defines the name to search for
  35396. * @return the found skeleton or null if not found at all.
  35397. */
  35398. getSkeletonByName(name: string): Nullable<Skeleton>;
  35399. /**
  35400. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35401. * @param id defines the id to search for
  35402. * @return the found morph target manager or null if not found at all.
  35403. */
  35404. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35405. /**
  35406. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35407. * @param id defines the id to search for
  35408. * @return the found morph target or null if not found at all.
  35409. */
  35410. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35411. /**
  35412. * Gets a boolean indicating if the given mesh is active
  35413. * @param mesh defines the mesh to look for
  35414. * @returns true if the mesh is in the active list
  35415. */
  35416. isActiveMesh(mesh: AbstractMesh): boolean;
  35417. /**
  35418. * Return a unique id as a string which can serve as an identifier for the scene
  35419. */
  35420. readonly uid: string;
  35421. /**
  35422. * Add an externaly attached data from its key.
  35423. * This method call will fail and return false, if such key already exists.
  35424. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35425. * @param key the unique key that identifies the data
  35426. * @param data the data object to associate to the key for this Engine instance
  35427. * @return true if no such key were already present and the data was added successfully, false otherwise
  35428. */
  35429. addExternalData<T>(key: string, data: T): boolean;
  35430. /**
  35431. * Get an externaly attached data from its key
  35432. * @param key the unique key that identifies the data
  35433. * @return the associated data, if present (can be null), or undefined if not present
  35434. */
  35435. getExternalData<T>(key: string): Nullable<T>;
  35436. /**
  35437. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35438. * @param key the unique key that identifies the data
  35439. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35440. * @return the associated data, can be null if the factory returned null.
  35441. */
  35442. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35443. /**
  35444. * Remove an externaly attached data from the Engine instance
  35445. * @param key the unique key that identifies the data
  35446. * @return true if the data was successfully removed, false if it doesn't exist
  35447. */
  35448. removeExternalData(key: string): boolean;
  35449. private _evaluateSubMesh;
  35450. /**
  35451. * Clear the processed materials smart array preventing retention point in material dispose.
  35452. */
  35453. freeProcessedMaterials(): void;
  35454. private _preventFreeActiveMeshesAndRenderingGroups;
  35455. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35456. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35457. * when disposing several meshes in a row or a hierarchy of meshes.
  35458. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35459. */
  35460. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35461. /**
  35462. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35463. */
  35464. freeActiveMeshes(): void;
  35465. /**
  35466. * Clear the info related to rendering groups preventing retention points during dispose.
  35467. */
  35468. freeRenderingGroups(): void;
  35469. /** @hidden */
  35470. _isInIntermediateRendering(): boolean;
  35471. /**
  35472. * Lambda returning the list of potentially active meshes.
  35473. */
  35474. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35475. /**
  35476. * Lambda returning the list of potentially active sub meshes.
  35477. */
  35478. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35479. /**
  35480. * Lambda returning the list of potentially intersecting sub meshes.
  35481. */
  35482. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35483. /**
  35484. * Lambda returning the list of potentially colliding sub meshes.
  35485. */
  35486. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35487. private _activeMeshesFrozen;
  35488. /**
  35489. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35490. * @returns the current scene
  35491. */
  35492. freezeActiveMeshes(): Scene;
  35493. /**
  35494. * Use this function to restart evaluating active meshes on every frame
  35495. * @returns the current scene
  35496. */
  35497. unfreezeActiveMeshes(): Scene;
  35498. private _evaluateActiveMeshes;
  35499. private _activeMesh;
  35500. /**
  35501. * Update the transform matrix to update from the current active camera
  35502. * @param force defines a boolean used to force the update even if cache is up to date
  35503. */
  35504. updateTransformMatrix(force?: boolean): void;
  35505. private _bindFrameBuffer;
  35506. /** @hidden */
  35507. _allowPostProcessClearColor: boolean;
  35508. /** @hidden */
  35509. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35510. private _processSubCameras;
  35511. private _checkIntersections;
  35512. /** @hidden */
  35513. _advancePhysicsEngineStep(step: number): void;
  35514. /**
  35515. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35516. */
  35517. getDeterministicFrameTime: () => number;
  35518. /** @hidden */
  35519. _animate(): void;
  35520. /** Execute all animations (for a frame) */
  35521. animate(): void;
  35522. /**
  35523. * Render the scene
  35524. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35525. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35526. */
  35527. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35528. /**
  35529. * Freeze all materials
  35530. * A frozen material will not be updatable but should be faster to render
  35531. */
  35532. freezeMaterials(): void;
  35533. /**
  35534. * Unfreeze all materials
  35535. * A frozen material will not be updatable but should be faster to render
  35536. */
  35537. unfreezeMaterials(): void;
  35538. /**
  35539. * Releases all held ressources
  35540. */
  35541. dispose(): void;
  35542. /**
  35543. * Gets if the scene is already disposed
  35544. */
  35545. readonly isDisposed: boolean;
  35546. /**
  35547. * Call this function to reduce memory footprint of the scene.
  35548. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35549. */
  35550. clearCachedVertexData(): void;
  35551. /**
  35552. * This function will remove the local cached buffer data from texture.
  35553. * It will save memory but will prevent the texture from being rebuilt
  35554. */
  35555. cleanCachedTextureBuffer(): void;
  35556. /**
  35557. * Get the world extend vectors with an optional filter
  35558. *
  35559. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35560. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35561. */
  35562. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35563. min: Vector3;
  35564. max: Vector3;
  35565. };
  35566. /**
  35567. * Creates a ray that can be used to pick in the scene
  35568. * @param x defines the x coordinate of the origin (on-screen)
  35569. * @param y defines the y coordinate of the origin (on-screen)
  35570. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35571. * @param camera defines the camera to use for the picking
  35572. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35573. * @returns a Ray
  35574. */
  35575. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35576. /**
  35577. * Creates a ray that can be used to pick in the scene
  35578. * @param x defines the x coordinate of the origin (on-screen)
  35579. * @param y defines the y coordinate of the origin (on-screen)
  35580. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35581. * @param result defines the ray where to store the picking ray
  35582. * @param camera defines the camera to use for the picking
  35583. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35584. * @returns the current scene
  35585. */
  35586. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35587. /**
  35588. * Creates a ray that can be used to pick in the scene
  35589. * @param x defines the x coordinate of the origin (on-screen)
  35590. * @param y defines the y coordinate of the origin (on-screen)
  35591. * @param camera defines the camera to use for the picking
  35592. * @returns a Ray
  35593. */
  35594. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35595. /**
  35596. * Creates a ray that can be used to pick in the scene
  35597. * @param x defines the x coordinate of the origin (on-screen)
  35598. * @param y defines the y coordinate of the origin (on-screen)
  35599. * @param result defines the ray where to store the picking ray
  35600. * @param camera defines the camera to use for the picking
  35601. * @returns the current scene
  35602. */
  35603. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35604. /** Launch a ray to try to pick a mesh in the scene
  35605. * @param x position on screen
  35606. * @param y position on screen
  35607. * @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
  35608. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35609. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35611. * @returns a PickingInfo
  35612. */
  35613. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35614. /** Use the given ray to pick a mesh in the scene
  35615. * @param ray The ray to use to pick meshes
  35616. * @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
  35617. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35618. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35619. * @returns a PickingInfo
  35620. */
  35621. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35622. /**
  35623. * Launch a ray to try to pick a mesh in the scene
  35624. * @param x X position on screen
  35625. * @param y Y position on screen
  35626. * @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
  35627. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35629. * @returns an array of PickingInfo
  35630. */
  35631. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35632. /**
  35633. * Launch a ray to try to pick a mesh in the scene
  35634. * @param ray Ray to use
  35635. * @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
  35636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35637. * @returns an array of PickingInfo
  35638. */
  35639. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35640. /**
  35641. * Force the value of meshUnderPointer
  35642. * @param mesh defines the mesh to use
  35643. */
  35644. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35645. /**
  35646. * Gets the mesh under the pointer
  35647. * @returns a Mesh or null if no mesh is under the pointer
  35648. */
  35649. getPointerOverMesh(): Nullable<AbstractMesh>;
  35650. /** @hidden */
  35651. _rebuildGeometries(): void;
  35652. /** @hidden */
  35653. _rebuildTextures(): void;
  35654. private _getByTags;
  35655. /**
  35656. * Get a list of meshes by tags
  35657. * @param tagsQuery defines the tags query to use
  35658. * @param forEach defines a predicate used to filter results
  35659. * @returns an array of Mesh
  35660. */
  35661. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35662. /**
  35663. * Get a list of cameras by tags
  35664. * @param tagsQuery defines the tags query to use
  35665. * @param forEach defines a predicate used to filter results
  35666. * @returns an array of Camera
  35667. */
  35668. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35669. /**
  35670. * Get a list of lights by tags
  35671. * @param tagsQuery defines the tags query to use
  35672. * @param forEach defines a predicate used to filter results
  35673. * @returns an array of Light
  35674. */
  35675. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35676. /**
  35677. * Get a list of materials by tags
  35678. * @param tagsQuery defines the tags query to use
  35679. * @param forEach defines a predicate used to filter results
  35680. * @returns an array of Material
  35681. */
  35682. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35683. /**
  35684. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35685. * This allowed control for front to back rendering or reversly depending of the special needs.
  35686. *
  35687. * @param renderingGroupId The rendering group id corresponding to its index
  35688. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35689. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35690. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35691. */
  35692. 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;
  35693. /**
  35694. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35695. *
  35696. * @param renderingGroupId The rendering group id corresponding to its index
  35697. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35698. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35699. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35700. */
  35701. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35702. /**
  35703. * Gets the current auto clear configuration for one rendering group of the rendering
  35704. * manager.
  35705. * @param index the rendering group index to get the information for
  35706. * @returns The auto clear setup for the requested rendering group
  35707. */
  35708. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35709. private _blockMaterialDirtyMechanism;
  35710. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35711. blockMaterialDirtyMechanism: boolean;
  35712. /**
  35713. * Will flag all materials as dirty to trigger new shader compilation
  35714. * @param flag defines the flag used to specify which material part must be marked as dirty
  35715. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35716. */
  35717. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35718. /** @hidden */
  35719. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35720. /** @hidden */
  35721. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35722. }
  35723. }
  35724. declare module "babylonjs/assetContainer" {
  35725. import { AbstractScene } from "babylonjs/abstractScene";
  35726. import { Scene } from "babylonjs/scene";
  35727. import { Mesh } from "babylonjs/Meshes/mesh";
  35728. /**
  35729. * Set of assets to keep when moving a scene into an asset container.
  35730. */
  35731. export class KeepAssets extends AbstractScene {
  35732. }
  35733. /**
  35734. * Container with a set of assets that can be added or removed from a scene.
  35735. */
  35736. export class AssetContainer extends AbstractScene {
  35737. /**
  35738. * The scene the AssetContainer belongs to.
  35739. */
  35740. scene: Scene;
  35741. /**
  35742. * Instantiates an AssetContainer.
  35743. * @param scene The scene the AssetContainer belongs to.
  35744. */
  35745. constructor(scene: Scene);
  35746. /**
  35747. * Adds all the assets from the container to the scene.
  35748. */
  35749. addAllToScene(): void;
  35750. /**
  35751. * Removes all the assets in the container from the scene
  35752. */
  35753. removeAllFromScene(): void;
  35754. /**
  35755. * Disposes all the assets in the container
  35756. */
  35757. dispose(): void;
  35758. private _moveAssets;
  35759. /**
  35760. * Removes all the assets contained in the scene and adds them to the container.
  35761. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35762. */
  35763. moveAllFromScene(keepAssets?: KeepAssets): void;
  35764. /**
  35765. * 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.
  35766. * @returns the root mesh
  35767. */
  35768. createRootMesh(): Mesh;
  35769. }
  35770. }
  35771. declare module "babylonjs/abstractScene" {
  35772. import { Scene } from "babylonjs/scene";
  35773. import { Nullable } from "babylonjs/types";
  35774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35775. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35776. import { Geometry } from "babylonjs/Meshes/geometry";
  35777. import { Skeleton } from "babylonjs/Bones/skeleton";
  35778. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35779. import { AssetContainer } from "babylonjs/assetContainer";
  35780. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35781. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35782. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35783. import { Material } from "babylonjs/Materials/material";
  35784. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35785. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35786. import { Camera } from "babylonjs/Cameras/camera";
  35787. import { Light } from "babylonjs/Lights/light";
  35788. import { Node } from "babylonjs/node";
  35789. import { Animation } from "babylonjs/Animations/animation";
  35790. /**
  35791. * Defines how the parser contract is defined.
  35792. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35793. */
  35794. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35795. /**
  35796. * Defines how the individual parser contract is defined.
  35797. * These parser can parse an individual asset
  35798. */
  35799. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35800. /**
  35801. * Base class of the scene acting as a container for the different elements composing a scene.
  35802. * This class is dynamically extended by the different components of the scene increasing
  35803. * flexibility and reducing coupling
  35804. */
  35805. export abstract class AbstractScene {
  35806. /**
  35807. * Stores the list of available parsers in the application.
  35808. */
  35809. private static _BabylonFileParsers;
  35810. /**
  35811. * Stores the list of available individual parsers in the application.
  35812. */
  35813. private static _IndividualBabylonFileParsers;
  35814. /**
  35815. * Adds a parser in the list of available ones
  35816. * @param name Defines the name of the parser
  35817. * @param parser Defines the parser to add
  35818. */
  35819. static AddParser(name: string, parser: BabylonFileParser): void;
  35820. /**
  35821. * Gets a general parser from the list of avaialble ones
  35822. * @param name Defines the name of the parser
  35823. * @returns the requested parser or null
  35824. */
  35825. static GetParser(name: string): Nullable<BabylonFileParser>;
  35826. /**
  35827. * Adds n individual parser in the list of available ones
  35828. * @param name Defines the name of the parser
  35829. * @param parser Defines the parser to add
  35830. */
  35831. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35832. /**
  35833. * Gets an individual parser from the list of avaialble ones
  35834. * @param name Defines the name of the parser
  35835. * @returns the requested parser or null
  35836. */
  35837. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35838. /**
  35839. * Parser json data and populate both a scene and its associated container object
  35840. * @param jsonData Defines the data to parse
  35841. * @param scene Defines the scene to parse the data for
  35842. * @param container Defines the container attached to the parsing sequence
  35843. * @param rootUrl Defines the root url of the data
  35844. */
  35845. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35846. /**
  35847. * Gets the list of root nodes (ie. nodes with no parent)
  35848. */
  35849. rootNodes: Node[];
  35850. /** All of the cameras added to this scene
  35851. * @see http://doc.babylonjs.com/babylon101/cameras
  35852. */
  35853. cameras: Camera[];
  35854. /**
  35855. * All of the lights added to this scene
  35856. * @see http://doc.babylonjs.com/babylon101/lights
  35857. */
  35858. lights: Light[];
  35859. /**
  35860. * All of the (abstract) meshes added to this scene
  35861. */
  35862. meshes: AbstractMesh[];
  35863. /**
  35864. * The list of skeletons added to the scene
  35865. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35866. */
  35867. skeletons: Skeleton[];
  35868. /**
  35869. * All of the particle systems added to this scene
  35870. * @see http://doc.babylonjs.com/babylon101/particles
  35871. */
  35872. particleSystems: IParticleSystem[];
  35873. /**
  35874. * Gets a list of Animations associated with the scene
  35875. */
  35876. animations: Animation[];
  35877. /**
  35878. * All of the animation groups added to this scene
  35879. * @see http://doc.babylonjs.com/how_to/group
  35880. */
  35881. animationGroups: AnimationGroup[];
  35882. /**
  35883. * All of the multi-materials added to this scene
  35884. * @see http://doc.babylonjs.com/how_to/multi_materials
  35885. */
  35886. multiMaterials: MultiMaterial[];
  35887. /**
  35888. * All of the materials added to this scene
  35889. * In the context of a Scene, it is not supposed to be modified manually.
  35890. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35891. * Note also that the order of the Material wihin the array is not significant and might change.
  35892. * @see http://doc.babylonjs.com/babylon101/materials
  35893. */
  35894. materials: Material[];
  35895. /**
  35896. * The list of morph target managers added to the scene
  35897. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35898. */
  35899. morphTargetManagers: MorphTargetManager[];
  35900. /**
  35901. * The list of geometries used in the scene.
  35902. */
  35903. geometries: Geometry[];
  35904. /**
  35905. * All of the tranform nodes added to this scene
  35906. * In the context of a Scene, it is not supposed to be modified manually.
  35907. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35908. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35909. * @see http://doc.babylonjs.com/how_to/transformnode
  35910. */
  35911. transformNodes: TransformNode[];
  35912. /**
  35913. * ActionManagers available on the scene.
  35914. */
  35915. actionManagers: AbstractActionManager[];
  35916. /**
  35917. * Textures to keep.
  35918. */
  35919. textures: BaseTexture[];
  35920. /**
  35921. * Environment texture for the scene
  35922. */
  35923. environmentTexture: Nullable<BaseTexture>;
  35924. }
  35925. }
  35926. declare module "babylonjs/Audio/sound" {
  35927. import { Observable } from "babylonjs/Misc/observable";
  35928. import { Vector3 } from "babylonjs/Maths/math.vector";
  35929. import { Nullable } from "babylonjs/types";
  35930. import { Scene } from "babylonjs/scene";
  35931. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35932. /**
  35933. * Interface used to define options for Sound class
  35934. */
  35935. export interface ISoundOptions {
  35936. /**
  35937. * Does the sound autoplay once loaded.
  35938. */
  35939. autoplay?: boolean;
  35940. /**
  35941. * Does the sound loop after it finishes playing once.
  35942. */
  35943. loop?: boolean;
  35944. /**
  35945. * Sound's volume
  35946. */
  35947. volume?: number;
  35948. /**
  35949. * Is it a spatial sound?
  35950. */
  35951. spatialSound?: boolean;
  35952. /**
  35953. * Maximum distance to hear that sound
  35954. */
  35955. maxDistance?: number;
  35956. /**
  35957. * Uses user defined attenuation function
  35958. */
  35959. useCustomAttenuation?: boolean;
  35960. /**
  35961. * Define the roll off factor of spatial sounds.
  35962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35963. */
  35964. rolloffFactor?: number;
  35965. /**
  35966. * Define the reference distance the sound should be heard perfectly.
  35967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35968. */
  35969. refDistance?: number;
  35970. /**
  35971. * Define the distance attenuation model the sound will follow.
  35972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35973. */
  35974. distanceModel?: string;
  35975. /**
  35976. * Defines the playback speed (1 by default)
  35977. */
  35978. playbackRate?: number;
  35979. /**
  35980. * Defines if the sound is from a streaming source
  35981. */
  35982. streaming?: boolean;
  35983. /**
  35984. * Defines an optional length (in seconds) inside the sound file
  35985. */
  35986. length?: number;
  35987. /**
  35988. * Defines an optional offset (in seconds) inside the sound file
  35989. */
  35990. offset?: number;
  35991. /**
  35992. * If true, URLs will not be required to state the audio file codec to use.
  35993. */
  35994. skipCodecCheck?: boolean;
  35995. }
  35996. /**
  35997. * Defines a sound that can be played in the application.
  35998. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36000. */
  36001. export class Sound {
  36002. /**
  36003. * The name of the sound in the scene.
  36004. */
  36005. name: string;
  36006. /**
  36007. * Does the sound autoplay once loaded.
  36008. */
  36009. autoplay: boolean;
  36010. /**
  36011. * Does the sound loop after it finishes playing once.
  36012. */
  36013. loop: boolean;
  36014. /**
  36015. * Does the sound use a custom attenuation curve to simulate the falloff
  36016. * happening when the source gets further away from the camera.
  36017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36018. */
  36019. useCustomAttenuation: boolean;
  36020. /**
  36021. * The sound track id this sound belongs to.
  36022. */
  36023. soundTrackId: number;
  36024. /**
  36025. * Is this sound currently played.
  36026. */
  36027. isPlaying: boolean;
  36028. /**
  36029. * Is this sound currently paused.
  36030. */
  36031. isPaused: boolean;
  36032. /**
  36033. * Does this sound enables spatial sound.
  36034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36035. */
  36036. spatialSound: boolean;
  36037. /**
  36038. * Define the reference distance the sound should be heard perfectly.
  36039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36040. */
  36041. refDistance: number;
  36042. /**
  36043. * Define the roll off factor of spatial sounds.
  36044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36045. */
  36046. rolloffFactor: number;
  36047. /**
  36048. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36050. */
  36051. maxDistance: number;
  36052. /**
  36053. * Define the distance attenuation model the sound will follow.
  36054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36055. */
  36056. distanceModel: string;
  36057. /**
  36058. * @hidden
  36059. * Back Compat
  36060. **/
  36061. onended: () => any;
  36062. /**
  36063. * Observable event when the current playing sound finishes.
  36064. */
  36065. onEndedObservable: Observable<Sound>;
  36066. private _panningModel;
  36067. private _playbackRate;
  36068. private _streaming;
  36069. private _startTime;
  36070. private _startOffset;
  36071. private _position;
  36072. /** @hidden */
  36073. _positionInEmitterSpace: boolean;
  36074. private _localDirection;
  36075. private _volume;
  36076. private _isReadyToPlay;
  36077. private _isDirectional;
  36078. private _readyToPlayCallback;
  36079. private _audioBuffer;
  36080. private _soundSource;
  36081. private _streamingSource;
  36082. private _soundPanner;
  36083. private _soundGain;
  36084. private _inputAudioNode;
  36085. private _outputAudioNode;
  36086. private _coneInnerAngle;
  36087. private _coneOuterAngle;
  36088. private _coneOuterGain;
  36089. private _scene;
  36090. private _connectedTransformNode;
  36091. private _customAttenuationFunction;
  36092. private _registerFunc;
  36093. private _isOutputConnected;
  36094. private _htmlAudioElement;
  36095. private _urlType;
  36096. private _length?;
  36097. private _offset?;
  36098. /** @hidden */
  36099. static _SceneComponentInitialization: (scene: Scene) => void;
  36100. /**
  36101. * Create a sound and attach it to a scene
  36102. * @param name Name of your sound
  36103. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36104. * @param scene defines the scene the sound belongs to
  36105. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36106. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36107. */
  36108. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36109. /**
  36110. * Release the sound and its associated resources
  36111. */
  36112. dispose(): void;
  36113. /**
  36114. * Gets if the sounds is ready to be played or not.
  36115. * @returns true if ready, otherwise false
  36116. */
  36117. isReady(): boolean;
  36118. private _soundLoaded;
  36119. /**
  36120. * Sets the data of the sound from an audiobuffer
  36121. * @param audioBuffer The audioBuffer containing the data
  36122. */
  36123. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36124. /**
  36125. * Updates the current sounds options such as maxdistance, loop...
  36126. * @param options A JSON object containing values named as the object properties
  36127. */
  36128. updateOptions(options: ISoundOptions): void;
  36129. private _createSpatialParameters;
  36130. private _updateSpatialParameters;
  36131. /**
  36132. * Switch the panning model to HRTF:
  36133. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36135. */
  36136. switchPanningModelToHRTF(): void;
  36137. /**
  36138. * Switch the panning model to Equal Power:
  36139. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36140. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36141. */
  36142. switchPanningModelToEqualPower(): void;
  36143. private _switchPanningModel;
  36144. /**
  36145. * Connect this sound to a sound track audio node like gain...
  36146. * @param soundTrackAudioNode the sound track audio node to connect to
  36147. */
  36148. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36149. /**
  36150. * Transform this sound into a directional source
  36151. * @param coneInnerAngle Size of the inner cone in degree
  36152. * @param coneOuterAngle Size of the outer cone in degree
  36153. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36154. */
  36155. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36156. /**
  36157. * Gets or sets the inner angle for the directional cone.
  36158. */
  36159. /**
  36160. * Gets or sets the inner angle for the directional cone.
  36161. */
  36162. directionalConeInnerAngle: number;
  36163. /**
  36164. * Gets or sets the outer angle for the directional cone.
  36165. */
  36166. /**
  36167. * Gets or sets the outer angle for the directional cone.
  36168. */
  36169. directionalConeOuterAngle: number;
  36170. /**
  36171. * Sets the position of the emitter if spatial sound is enabled
  36172. * @param newPosition Defines the new posisiton
  36173. */
  36174. setPosition(newPosition: Vector3): void;
  36175. /**
  36176. * Sets the local direction of the emitter if spatial sound is enabled
  36177. * @param newLocalDirection Defines the new local direction
  36178. */
  36179. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36180. private _updateDirection;
  36181. /** @hidden */
  36182. updateDistanceFromListener(): void;
  36183. /**
  36184. * Sets a new custom attenuation function for the sound.
  36185. * @param callback Defines the function used for the attenuation
  36186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36187. */
  36188. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36189. /**
  36190. * Play the sound
  36191. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36192. * @param offset (optional) Start the sound at a specific time in seconds
  36193. * @param length (optional) Sound duration (in seconds)
  36194. */
  36195. play(time?: number, offset?: number, length?: number): void;
  36196. private _onended;
  36197. /**
  36198. * Stop the sound
  36199. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36200. */
  36201. stop(time?: number): void;
  36202. /**
  36203. * Put the sound in pause
  36204. */
  36205. pause(): void;
  36206. /**
  36207. * Sets a dedicated volume for this sounds
  36208. * @param newVolume Define the new volume of the sound
  36209. * @param time Define time for gradual change to new volume
  36210. */
  36211. setVolume(newVolume: number, time?: number): void;
  36212. /**
  36213. * Set the sound play back rate
  36214. * @param newPlaybackRate Define the playback rate the sound should be played at
  36215. */
  36216. setPlaybackRate(newPlaybackRate: number): void;
  36217. /**
  36218. * Gets the volume of the sound.
  36219. * @returns the volume of the sound
  36220. */
  36221. getVolume(): number;
  36222. /**
  36223. * Attach the sound to a dedicated mesh
  36224. * @param transformNode The transform node to connect the sound with
  36225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36226. */
  36227. attachToMesh(transformNode: TransformNode): void;
  36228. /**
  36229. * Detach the sound from the previously attached mesh
  36230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36231. */
  36232. detachFromMesh(): void;
  36233. private _onRegisterAfterWorldMatrixUpdate;
  36234. /**
  36235. * Clone the current sound in the scene.
  36236. * @returns the new sound clone
  36237. */
  36238. clone(): Nullable<Sound>;
  36239. /**
  36240. * Gets the current underlying audio buffer containing the data
  36241. * @returns the audio buffer
  36242. */
  36243. getAudioBuffer(): Nullable<AudioBuffer>;
  36244. /**
  36245. * Serializes the Sound in a JSON representation
  36246. * @returns the JSON representation of the sound
  36247. */
  36248. serialize(): any;
  36249. /**
  36250. * Parse a JSON representation of a sound to innstantiate in a given scene
  36251. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36252. * @param scene Define the scene the new parsed sound should be created in
  36253. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36254. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36255. * @returns the newly parsed sound
  36256. */
  36257. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36258. }
  36259. }
  36260. declare module "babylonjs/Actions/directAudioActions" {
  36261. import { Action } from "babylonjs/Actions/action";
  36262. import { Condition } from "babylonjs/Actions/condition";
  36263. import { Sound } from "babylonjs/Audio/sound";
  36264. /**
  36265. * This defines an action helpful to play a defined sound on a triggered action.
  36266. */
  36267. export class PlaySoundAction extends Action {
  36268. private _sound;
  36269. /**
  36270. * Instantiate the action
  36271. * @param triggerOptions defines the trigger options
  36272. * @param sound defines the sound to play
  36273. * @param condition defines the trigger related conditions
  36274. */
  36275. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36276. /** @hidden */
  36277. _prepare(): void;
  36278. /**
  36279. * Execute the action and play the sound.
  36280. */
  36281. execute(): void;
  36282. /**
  36283. * Serializes the actions and its related information.
  36284. * @param parent defines the object to serialize in
  36285. * @returns the serialized object
  36286. */
  36287. serialize(parent: any): any;
  36288. }
  36289. /**
  36290. * This defines an action helpful to stop a defined sound on a triggered action.
  36291. */
  36292. export class StopSoundAction extends Action {
  36293. private _sound;
  36294. /**
  36295. * Instantiate the action
  36296. * @param triggerOptions defines the trigger options
  36297. * @param sound defines the sound to stop
  36298. * @param condition defines the trigger related conditions
  36299. */
  36300. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36301. /** @hidden */
  36302. _prepare(): void;
  36303. /**
  36304. * Execute the action and stop the sound.
  36305. */
  36306. execute(): void;
  36307. /**
  36308. * Serializes the actions and its related information.
  36309. * @param parent defines the object to serialize in
  36310. * @returns the serialized object
  36311. */
  36312. serialize(parent: any): any;
  36313. }
  36314. }
  36315. declare module "babylonjs/Actions/interpolateValueAction" {
  36316. import { Action } from "babylonjs/Actions/action";
  36317. import { Condition } from "babylonjs/Actions/condition";
  36318. import { Observable } from "babylonjs/Misc/observable";
  36319. /**
  36320. * This defines an action responsible to change the value of a property
  36321. * by interpolating between its current value and the newly set one once triggered.
  36322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36323. */
  36324. export class InterpolateValueAction extends Action {
  36325. /**
  36326. * Defines the path of the property where the value should be interpolated
  36327. */
  36328. propertyPath: string;
  36329. /**
  36330. * Defines the target value at the end of the interpolation.
  36331. */
  36332. value: any;
  36333. /**
  36334. * Defines the time it will take for the property to interpolate to the value.
  36335. */
  36336. duration: number;
  36337. /**
  36338. * Defines if the other scene animations should be stopped when the action has been triggered
  36339. */
  36340. stopOtherAnimations?: boolean;
  36341. /**
  36342. * Defines a callback raised once the interpolation animation has been done.
  36343. */
  36344. onInterpolationDone?: () => void;
  36345. /**
  36346. * Observable triggered once the interpolation animation has been done.
  36347. */
  36348. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36349. private _target;
  36350. private _effectiveTarget;
  36351. private _property;
  36352. /**
  36353. * Instantiate the action
  36354. * @param triggerOptions defines the trigger options
  36355. * @param target defines the object containing the value to interpolate
  36356. * @param propertyPath defines the path to the property in the target object
  36357. * @param value defines the target value at the end of the interpolation
  36358. * @param duration deines the time it will take for the property to interpolate to the value.
  36359. * @param condition defines the trigger related conditions
  36360. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36361. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36362. */
  36363. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36364. /** @hidden */
  36365. _prepare(): void;
  36366. /**
  36367. * Execute the action starts the value interpolation.
  36368. */
  36369. execute(): void;
  36370. /**
  36371. * Serializes the actions and its related information.
  36372. * @param parent defines the object to serialize in
  36373. * @returns the serialized object
  36374. */
  36375. serialize(parent: any): any;
  36376. }
  36377. }
  36378. declare module "babylonjs/Actions/index" {
  36379. export * from "babylonjs/Actions/abstractActionManager";
  36380. export * from "babylonjs/Actions/action";
  36381. export * from "babylonjs/Actions/actionEvent";
  36382. export * from "babylonjs/Actions/actionManager";
  36383. export * from "babylonjs/Actions/condition";
  36384. export * from "babylonjs/Actions/directActions";
  36385. export * from "babylonjs/Actions/directAudioActions";
  36386. export * from "babylonjs/Actions/interpolateValueAction";
  36387. }
  36388. declare module "babylonjs/Animations/index" {
  36389. export * from "babylonjs/Animations/animatable";
  36390. export * from "babylonjs/Animations/animation";
  36391. export * from "babylonjs/Animations/animationGroup";
  36392. export * from "babylonjs/Animations/animationPropertiesOverride";
  36393. export * from "babylonjs/Animations/easing";
  36394. export * from "babylonjs/Animations/runtimeAnimation";
  36395. export * from "babylonjs/Animations/animationEvent";
  36396. export * from "babylonjs/Animations/animationGroup";
  36397. export * from "babylonjs/Animations/animationKey";
  36398. export * from "babylonjs/Animations/animationRange";
  36399. export * from "babylonjs/Animations/animatable.interface";
  36400. }
  36401. declare module "babylonjs/Audio/soundTrack" {
  36402. import { Sound } from "babylonjs/Audio/sound";
  36403. import { Analyser } from "babylonjs/Audio/analyser";
  36404. import { Scene } from "babylonjs/scene";
  36405. /**
  36406. * Options allowed during the creation of a sound track.
  36407. */
  36408. export interface ISoundTrackOptions {
  36409. /**
  36410. * The volume the sound track should take during creation
  36411. */
  36412. volume?: number;
  36413. /**
  36414. * Define if the sound track is the main sound track of the scene
  36415. */
  36416. mainTrack?: boolean;
  36417. }
  36418. /**
  36419. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36420. * It will be also used in a future release to apply effects on a specific track.
  36421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36422. */
  36423. export class SoundTrack {
  36424. /**
  36425. * The unique identifier of the sound track in the scene.
  36426. */
  36427. id: number;
  36428. /**
  36429. * The list of sounds included in the sound track.
  36430. */
  36431. soundCollection: Array<Sound>;
  36432. private _outputAudioNode;
  36433. private _scene;
  36434. private _isMainTrack;
  36435. private _connectedAnalyser;
  36436. private _options;
  36437. private _isInitialized;
  36438. /**
  36439. * Creates a new sound track.
  36440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36441. * @param scene Define the scene the sound track belongs to
  36442. * @param options
  36443. */
  36444. constructor(scene: Scene, options?: ISoundTrackOptions);
  36445. private _initializeSoundTrackAudioGraph;
  36446. /**
  36447. * Release the sound track and its associated resources
  36448. */
  36449. dispose(): void;
  36450. /**
  36451. * Adds a sound to this sound track
  36452. * @param sound define the cound to add
  36453. * @ignoreNaming
  36454. */
  36455. AddSound(sound: Sound): void;
  36456. /**
  36457. * Removes a sound to this sound track
  36458. * @param sound define the cound to remove
  36459. * @ignoreNaming
  36460. */
  36461. RemoveSound(sound: Sound): void;
  36462. /**
  36463. * Set a global volume for the full sound track.
  36464. * @param newVolume Define the new volume of the sound track
  36465. */
  36466. setVolume(newVolume: number): void;
  36467. /**
  36468. * Switch the panning model to HRTF:
  36469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36471. */
  36472. switchPanningModelToHRTF(): void;
  36473. /**
  36474. * Switch the panning model to Equal Power:
  36475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36477. */
  36478. switchPanningModelToEqualPower(): void;
  36479. /**
  36480. * Connect the sound track to an audio analyser allowing some amazing
  36481. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36483. * @param analyser The analyser to connect to the engine
  36484. */
  36485. connectToAnalyser(analyser: Analyser): void;
  36486. }
  36487. }
  36488. declare module "babylonjs/Audio/audioSceneComponent" {
  36489. import { Sound } from "babylonjs/Audio/sound";
  36490. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36491. import { Nullable } from "babylonjs/types";
  36492. import { Vector3 } from "babylonjs/Maths/math.vector";
  36493. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36494. import { Scene } from "babylonjs/scene";
  36495. import { AbstractScene } from "babylonjs/abstractScene";
  36496. import "babylonjs/Audio/audioEngine";
  36497. module "babylonjs/abstractScene" {
  36498. interface AbstractScene {
  36499. /**
  36500. * The list of sounds used in the scene.
  36501. */
  36502. sounds: Nullable<Array<Sound>>;
  36503. }
  36504. }
  36505. module "babylonjs/scene" {
  36506. interface Scene {
  36507. /**
  36508. * @hidden
  36509. * Backing field
  36510. */
  36511. _mainSoundTrack: SoundTrack;
  36512. /**
  36513. * The main sound track played by the scene.
  36514. * It cotains your primary collection of sounds.
  36515. */
  36516. mainSoundTrack: SoundTrack;
  36517. /**
  36518. * The list of sound tracks added to the scene
  36519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36520. */
  36521. soundTracks: Nullable<Array<SoundTrack>>;
  36522. /**
  36523. * Gets a sound using a given name
  36524. * @param name defines the name to search for
  36525. * @return the found sound or null if not found at all.
  36526. */
  36527. getSoundByName(name: string): Nullable<Sound>;
  36528. /**
  36529. * Gets or sets if audio support is enabled
  36530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36531. */
  36532. audioEnabled: boolean;
  36533. /**
  36534. * Gets or sets if audio will be output to headphones
  36535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36536. */
  36537. headphone: boolean;
  36538. /**
  36539. * Gets or sets custom audio listener position provider
  36540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36541. */
  36542. audioListenerPositionProvider: Nullable<() => Vector3>;
  36543. }
  36544. }
  36545. /**
  36546. * Defines the sound scene component responsible to manage any sounds
  36547. * in a given scene.
  36548. */
  36549. export class AudioSceneComponent implements ISceneSerializableComponent {
  36550. /**
  36551. * The component name helpfull to identify the component in the list of scene components.
  36552. */
  36553. readonly name: string;
  36554. /**
  36555. * The scene the component belongs to.
  36556. */
  36557. scene: Scene;
  36558. private _audioEnabled;
  36559. /**
  36560. * Gets whether audio is enabled or not.
  36561. * Please use related enable/disable method to switch state.
  36562. */
  36563. readonly audioEnabled: boolean;
  36564. private _headphone;
  36565. /**
  36566. * Gets whether audio is outputing to headphone or not.
  36567. * Please use the according Switch methods to change output.
  36568. */
  36569. readonly headphone: boolean;
  36570. private _audioListenerPositionProvider;
  36571. /**
  36572. * Gets the current audio listener position provider
  36573. */
  36574. /**
  36575. * Sets a custom listener position for all sounds in the scene
  36576. * By default, this is the position of the first active camera
  36577. */
  36578. audioListenerPositionProvider: Nullable<() => Vector3>;
  36579. /**
  36580. * Creates a new instance of the component for the given scene
  36581. * @param scene Defines the scene to register the component in
  36582. */
  36583. constructor(scene: Scene);
  36584. /**
  36585. * Registers the component in a given scene
  36586. */
  36587. register(): void;
  36588. /**
  36589. * Rebuilds the elements related to this component in case of
  36590. * context lost for instance.
  36591. */
  36592. rebuild(): void;
  36593. /**
  36594. * Serializes the component data to the specified json object
  36595. * @param serializationObject The object to serialize to
  36596. */
  36597. serialize(serializationObject: any): void;
  36598. /**
  36599. * Adds all the elements from the container to the scene
  36600. * @param container the container holding the elements
  36601. */
  36602. addFromContainer(container: AbstractScene): void;
  36603. /**
  36604. * Removes all the elements in the container from the scene
  36605. * @param container contains the elements to remove
  36606. * @param dispose if the removed element should be disposed (default: false)
  36607. */
  36608. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36609. /**
  36610. * Disposes the component and the associated ressources.
  36611. */
  36612. dispose(): void;
  36613. /**
  36614. * Disables audio in the associated scene.
  36615. */
  36616. disableAudio(): void;
  36617. /**
  36618. * Enables audio in the associated scene.
  36619. */
  36620. enableAudio(): void;
  36621. /**
  36622. * Switch audio to headphone output.
  36623. */
  36624. switchAudioModeForHeadphones(): void;
  36625. /**
  36626. * Switch audio to normal speakers.
  36627. */
  36628. switchAudioModeForNormalSpeakers(): void;
  36629. private _afterRender;
  36630. }
  36631. }
  36632. declare module "babylonjs/Audio/weightedsound" {
  36633. import { Sound } from "babylonjs/Audio/sound";
  36634. /**
  36635. * Wraps one or more Sound objects and selects one with random weight for playback.
  36636. */
  36637. export class WeightedSound {
  36638. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36639. loop: boolean;
  36640. private _coneInnerAngle;
  36641. private _coneOuterAngle;
  36642. private _volume;
  36643. /** A Sound is currently playing. */
  36644. isPlaying: boolean;
  36645. /** A Sound is currently paused. */
  36646. isPaused: boolean;
  36647. private _sounds;
  36648. private _weights;
  36649. private _currentIndex?;
  36650. /**
  36651. * Creates a new WeightedSound from the list of sounds given.
  36652. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36653. * @param sounds Array of Sounds that will be selected from.
  36654. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36655. */
  36656. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36657. /**
  36658. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36659. */
  36660. /**
  36661. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36662. */
  36663. directionalConeInnerAngle: number;
  36664. /**
  36665. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36666. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36667. */
  36668. /**
  36669. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36670. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36671. */
  36672. directionalConeOuterAngle: number;
  36673. /**
  36674. * Playback volume.
  36675. */
  36676. /**
  36677. * Playback volume.
  36678. */
  36679. volume: number;
  36680. private _onended;
  36681. /**
  36682. * Suspend playback
  36683. */
  36684. pause(): void;
  36685. /**
  36686. * Stop playback
  36687. */
  36688. stop(): void;
  36689. /**
  36690. * Start playback.
  36691. * @param startOffset Position the clip head at a specific time in seconds.
  36692. */
  36693. play(startOffset?: number): void;
  36694. }
  36695. }
  36696. declare module "babylonjs/Audio/index" {
  36697. export * from "babylonjs/Audio/analyser";
  36698. export * from "babylonjs/Audio/audioEngine";
  36699. export * from "babylonjs/Audio/audioSceneComponent";
  36700. export * from "babylonjs/Audio/sound";
  36701. export * from "babylonjs/Audio/soundTrack";
  36702. export * from "babylonjs/Audio/weightedsound";
  36703. }
  36704. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36705. import { Behavior } from "babylonjs/Behaviors/behavior";
  36706. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36707. import { BackEase } from "babylonjs/Animations/easing";
  36708. /**
  36709. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36711. */
  36712. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36713. /**
  36714. * Gets the name of the behavior.
  36715. */
  36716. readonly name: string;
  36717. /**
  36718. * The easing function used by animations
  36719. */
  36720. static EasingFunction: BackEase;
  36721. /**
  36722. * The easing mode used by animations
  36723. */
  36724. static EasingMode: number;
  36725. /**
  36726. * The duration of the animation, in milliseconds
  36727. */
  36728. transitionDuration: number;
  36729. /**
  36730. * Length of the distance animated by the transition when lower radius is reached
  36731. */
  36732. lowerRadiusTransitionRange: number;
  36733. /**
  36734. * Length of the distance animated by the transition when upper radius is reached
  36735. */
  36736. upperRadiusTransitionRange: number;
  36737. private _autoTransitionRange;
  36738. /**
  36739. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36740. */
  36741. /**
  36742. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36743. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36744. */
  36745. autoTransitionRange: boolean;
  36746. private _attachedCamera;
  36747. private _onAfterCheckInputsObserver;
  36748. private _onMeshTargetChangedObserver;
  36749. /**
  36750. * Initializes the behavior.
  36751. */
  36752. init(): void;
  36753. /**
  36754. * Attaches the behavior to its arc rotate camera.
  36755. * @param camera Defines the camera to attach the behavior to
  36756. */
  36757. attach(camera: ArcRotateCamera): void;
  36758. /**
  36759. * Detaches the behavior from its current arc rotate camera.
  36760. */
  36761. detach(): void;
  36762. private _radiusIsAnimating;
  36763. private _radiusBounceTransition;
  36764. private _animatables;
  36765. private _cachedWheelPrecision;
  36766. /**
  36767. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36768. * @param radiusLimit The limit to check against.
  36769. * @return Bool to indicate if at limit.
  36770. */
  36771. private _isRadiusAtLimit;
  36772. /**
  36773. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36774. * @param radiusDelta The delta by which to animate to. Can be negative.
  36775. */
  36776. private _applyBoundRadiusAnimation;
  36777. /**
  36778. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36779. */
  36780. protected _clearAnimationLocks(): void;
  36781. /**
  36782. * Stops and removes all animations that have been applied to the camera
  36783. */
  36784. stopAllAnimations(): void;
  36785. }
  36786. }
  36787. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36788. import { Behavior } from "babylonjs/Behaviors/behavior";
  36789. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36790. import { ExponentialEase } from "babylonjs/Animations/easing";
  36791. import { Nullable } from "babylonjs/types";
  36792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36793. import { Vector3 } from "babylonjs/Maths/math.vector";
  36794. /**
  36795. * 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.
  36796. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36797. */
  36798. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36799. /**
  36800. * Gets the name of the behavior.
  36801. */
  36802. readonly name: string;
  36803. private _mode;
  36804. private _radiusScale;
  36805. private _positionScale;
  36806. private _defaultElevation;
  36807. private _elevationReturnTime;
  36808. private _elevationReturnWaitTime;
  36809. private _zoomStopsAnimation;
  36810. private _framingTime;
  36811. /**
  36812. * The easing function used by animations
  36813. */
  36814. static EasingFunction: ExponentialEase;
  36815. /**
  36816. * The easing mode used by animations
  36817. */
  36818. static EasingMode: number;
  36819. /**
  36820. * Sets the current mode used by the behavior
  36821. */
  36822. /**
  36823. * Gets current mode used by the behavior.
  36824. */
  36825. mode: number;
  36826. /**
  36827. * Sets the scale applied to the radius (1 by default)
  36828. */
  36829. /**
  36830. * Gets the scale applied to the radius
  36831. */
  36832. radiusScale: number;
  36833. /**
  36834. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36835. */
  36836. /**
  36837. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36838. */
  36839. positionScale: number;
  36840. /**
  36841. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36842. * behaviour is triggered, in radians.
  36843. */
  36844. /**
  36845. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36846. * behaviour is triggered, in radians.
  36847. */
  36848. defaultElevation: number;
  36849. /**
  36850. * Sets the time (in milliseconds) taken to return to the default beta position.
  36851. * Negative value indicates camera should not return to default.
  36852. */
  36853. /**
  36854. * Gets the time (in milliseconds) taken to return to the default beta position.
  36855. * Negative value indicates camera should not return to default.
  36856. */
  36857. elevationReturnTime: number;
  36858. /**
  36859. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36860. */
  36861. /**
  36862. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36863. */
  36864. elevationReturnWaitTime: number;
  36865. /**
  36866. * Sets the flag that indicates if user zooming should stop animation.
  36867. */
  36868. /**
  36869. * Gets the flag that indicates if user zooming should stop animation.
  36870. */
  36871. zoomStopsAnimation: boolean;
  36872. /**
  36873. * Sets the transition time when framing the mesh, in milliseconds
  36874. */
  36875. /**
  36876. * Gets the transition time when framing the mesh, in milliseconds
  36877. */
  36878. framingTime: number;
  36879. /**
  36880. * Define if the behavior should automatically change the configured
  36881. * camera limits and sensibilities.
  36882. */
  36883. autoCorrectCameraLimitsAndSensibility: boolean;
  36884. private _onPrePointerObservableObserver;
  36885. private _onAfterCheckInputsObserver;
  36886. private _onMeshTargetChangedObserver;
  36887. private _attachedCamera;
  36888. private _isPointerDown;
  36889. private _lastInteractionTime;
  36890. /**
  36891. * Initializes the behavior.
  36892. */
  36893. init(): void;
  36894. /**
  36895. * Attaches the behavior to its arc rotate camera.
  36896. * @param camera Defines the camera to attach the behavior to
  36897. */
  36898. attach(camera: ArcRotateCamera): void;
  36899. /**
  36900. * Detaches the behavior from its current arc rotate camera.
  36901. */
  36902. detach(): void;
  36903. private _animatables;
  36904. private _betaIsAnimating;
  36905. private _betaTransition;
  36906. private _radiusTransition;
  36907. private _vectorTransition;
  36908. /**
  36909. * Targets the given mesh and updates zoom level accordingly.
  36910. * @param mesh The mesh to target.
  36911. * @param radius Optional. If a cached radius position already exists, overrides default.
  36912. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36913. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36914. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36915. */
  36916. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36917. /**
  36918. * Targets the given mesh with its children and updates zoom level accordingly.
  36919. * @param mesh The mesh to target.
  36920. * @param radius Optional. If a cached radius position already exists, overrides default.
  36921. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36922. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36923. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36924. */
  36925. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36926. /**
  36927. * Targets the given meshes with their children and updates zoom level accordingly.
  36928. * @param meshes The mesh to target.
  36929. * @param radius Optional. If a cached radius position already exists, overrides default.
  36930. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36933. */
  36934. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36935. /**
  36936. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36937. * @param minimumWorld Determines the smaller position of the bounding box extend
  36938. * @param maximumWorld Determines the bigger position of the bounding box extend
  36939. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36940. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36941. */
  36942. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36943. /**
  36944. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36945. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36946. * frustum width.
  36947. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36948. * to fully enclose the mesh in the viewing frustum.
  36949. */
  36950. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36951. /**
  36952. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36953. * is automatically returned to its default position (expected to be above ground plane).
  36954. */
  36955. private _maintainCameraAboveGround;
  36956. /**
  36957. * Returns the frustum slope based on the canvas ratio and camera FOV
  36958. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36959. */
  36960. private _getFrustumSlope;
  36961. /**
  36962. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36963. */
  36964. private _clearAnimationLocks;
  36965. /**
  36966. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36967. */
  36968. private _applyUserInteraction;
  36969. /**
  36970. * Stops and removes all animations that have been applied to the camera
  36971. */
  36972. stopAllAnimations(): void;
  36973. /**
  36974. * Gets a value indicating if the user is moving the camera
  36975. */
  36976. readonly isUserIsMoving: boolean;
  36977. /**
  36978. * The camera can move all the way towards the mesh.
  36979. */
  36980. static IgnoreBoundsSizeMode: number;
  36981. /**
  36982. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36983. */
  36984. static FitFrustumSidesMode: number;
  36985. }
  36986. }
  36987. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36988. import { Nullable } from "babylonjs/types";
  36989. import { Camera } from "babylonjs/Cameras/camera";
  36990. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36991. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36992. /**
  36993. * Base class for Camera Pointer Inputs.
  36994. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36995. * for example usage.
  36996. */
  36997. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36998. /**
  36999. * Defines the camera the input is attached to.
  37000. */
  37001. abstract camera: Camera;
  37002. /**
  37003. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37004. */
  37005. protected _altKey: boolean;
  37006. protected _ctrlKey: boolean;
  37007. protected _metaKey: boolean;
  37008. protected _shiftKey: boolean;
  37009. /**
  37010. * Which mouse buttons were pressed at time of last mouse event.
  37011. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37012. */
  37013. protected _buttonsPressed: number;
  37014. /**
  37015. * Defines the buttons associated with the input to handle camera move.
  37016. */
  37017. buttons: number[];
  37018. /**
  37019. * Attach the input controls to a specific dom element to get the input from.
  37020. * @param element Defines the element the controls should be listened from
  37021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37022. */
  37023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37024. /**
  37025. * Detach the current controls from the specified dom element.
  37026. * @param element Defines the element to stop listening the inputs from
  37027. */
  37028. detachControl(element: Nullable<HTMLElement>): void;
  37029. /**
  37030. * Gets the class name of the current input.
  37031. * @returns the class name
  37032. */
  37033. getClassName(): string;
  37034. /**
  37035. * Get the friendly name associated with the input class.
  37036. * @returns the input friendly name
  37037. */
  37038. getSimpleName(): string;
  37039. /**
  37040. * Called on pointer POINTERDOUBLETAP event.
  37041. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37042. */
  37043. protected onDoubleTap(type: string): void;
  37044. /**
  37045. * Called on pointer POINTERMOVE event if only a single touch is active.
  37046. * Override this method to provide functionality.
  37047. */
  37048. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37049. /**
  37050. * Called on pointer POINTERMOVE event if multiple touches are active.
  37051. * Override this method to provide functionality.
  37052. */
  37053. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37054. /**
  37055. * Called on JS contextmenu event.
  37056. * Override this method to provide functionality.
  37057. */
  37058. protected onContextMenu(evt: PointerEvent): void;
  37059. /**
  37060. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37061. * press.
  37062. * Override this method to provide functionality.
  37063. */
  37064. protected onButtonDown(evt: PointerEvent): void;
  37065. /**
  37066. * Called each time a new POINTERUP event occurs. Ie, for each button
  37067. * release.
  37068. * Override this method to provide functionality.
  37069. */
  37070. protected onButtonUp(evt: PointerEvent): void;
  37071. /**
  37072. * Called when window becomes inactive.
  37073. * Override this method to provide functionality.
  37074. */
  37075. protected onLostFocus(): void;
  37076. private _pointerInput;
  37077. private _observer;
  37078. private _onLostFocus;
  37079. private pointA;
  37080. private pointB;
  37081. }
  37082. }
  37083. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37084. import { Nullable } from "babylonjs/types";
  37085. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37086. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37087. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37088. /**
  37089. * Manage the pointers inputs to control an arc rotate camera.
  37090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37091. */
  37092. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37093. /**
  37094. * Defines the camera the input is attached to.
  37095. */
  37096. camera: ArcRotateCamera;
  37097. /**
  37098. * Gets the class name of the current input.
  37099. * @returns the class name
  37100. */
  37101. getClassName(): string;
  37102. /**
  37103. * Defines the buttons associated with the input to handle camera move.
  37104. */
  37105. buttons: number[];
  37106. /**
  37107. * Defines the pointer angular sensibility along the X axis or how fast is
  37108. * the camera rotating.
  37109. */
  37110. angularSensibilityX: number;
  37111. /**
  37112. * Defines the pointer angular sensibility along the Y axis or how fast is
  37113. * the camera rotating.
  37114. */
  37115. angularSensibilityY: number;
  37116. /**
  37117. * Defines the pointer pinch precision or how fast is the camera zooming.
  37118. */
  37119. pinchPrecision: number;
  37120. /**
  37121. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37122. * from 0.
  37123. * It defines the percentage of current camera.radius to use as delta when
  37124. * pinch zoom is used.
  37125. */
  37126. pinchDeltaPercentage: number;
  37127. /**
  37128. * Defines the pointer panning sensibility or how fast is the camera moving.
  37129. */
  37130. panningSensibility: number;
  37131. /**
  37132. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37133. */
  37134. multiTouchPanning: boolean;
  37135. /**
  37136. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37137. * zoom (pinch) through multitouch.
  37138. */
  37139. multiTouchPanAndZoom: boolean;
  37140. /**
  37141. * Revers pinch action direction.
  37142. */
  37143. pinchInwards: boolean;
  37144. private _isPanClick;
  37145. private _twoFingerActivityCount;
  37146. private _isPinching;
  37147. /**
  37148. * Called on pointer POINTERMOVE event if only a single touch is active.
  37149. */
  37150. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37151. /**
  37152. * Called on pointer POINTERDOUBLETAP event.
  37153. */
  37154. protected onDoubleTap(type: string): void;
  37155. /**
  37156. * Called on pointer POINTERMOVE event if multiple touches are active.
  37157. */
  37158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37159. /**
  37160. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37161. * press.
  37162. */
  37163. protected onButtonDown(evt: PointerEvent): void;
  37164. /**
  37165. * Called each time a new POINTERUP event occurs. Ie, for each button
  37166. * release.
  37167. */
  37168. protected onButtonUp(evt: PointerEvent): void;
  37169. /**
  37170. * Called when window becomes inactive.
  37171. */
  37172. protected onLostFocus(): void;
  37173. }
  37174. }
  37175. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37176. import { Nullable } from "babylonjs/types";
  37177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37179. /**
  37180. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37182. */
  37183. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37184. /**
  37185. * Defines the camera the input is attached to.
  37186. */
  37187. camera: ArcRotateCamera;
  37188. /**
  37189. * Defines the list of key codes associated with the up action (increase alpha)
  37190. */
  37191. keysUp: number[];
  37192. /**
  37193. * Defines the list of key codes associated with the down action (decrease alpha)
  37194. */
  37195. keysDown: number[];
  37196. /**
  37197. * Defines the list of key codes associated with the left action (increase beta)
  37198. */
  37199. keysLeft: number[];
  37200. /**
  37201. * Defines the list of key codes associated with the right action (decrease beta)
  37202. */
  37203. keysRight: number[];
  37204. /**
  37205. * Defines the list of key codes associated with the reset action.
  37206. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37207. */
  37208. keysReset: number[];
  37209. /**
  37210. * Defines the panning sensibility of the inputs.
  37211. * (How fast is the camera paning)
  37212. */
  37213. panningSensibility: number;
  37214. /**
  37215. * Defines the zooming sensibility of the inputs.
  37216. * (How fast is the camera zooming)
  37217. */
  37218. zoomingSensibility: number;
  37219. /**
  37220. * Defines wether maintaining the alt key down switch the movement mode from
  37221. * orientation to zoom.
  37222. */
  37223. useAltToZoom: boolean;
  37224. /**
  37225. * Rotation speed of the camera
  37226. */
  37227. angularSpeed: number;
  37228. private _keys;
  37229. private _ctrlPressed;
  37230. private _altPressed;
  37231. private _onCanvasBlurObserver;
  37232. private _onKeyboardObserver;
  37233. private _engine;
  37234. private _scene;
  37235. /**
  37236. * Attach the input controls to a specific dom element to get the input from.
  37237. * @param element Defines the element the controls should be listened from
  37238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37239. */
  37240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37241. /**
  37242. * Detach the current controls from the specified dom element.
  37243. * @param element Defines the element to stop listening the inputs from
  37244. */
  37245. detachControl(element: Nullable<HTMLElement>): void;
  37246. /**
  37247. * Update the current camera state depending on the inputs that have been used this frame.
  37248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37249. */
  37250. checkInputs(): void;
  37251. /**
  37252. * Gets the class name of the current intput.
  37253. * @returns the class name
  37254. */
  37255. getClassName(): string;
  37256. /**
  37257. * Get the friendly name associated with the input class.
  37258. * @returns the input friendly name
  37259. */
  37260. getSimpleName(): string;
  37261. }
  37262. }
  37263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37264. import { Nullable } from "babylonjs/types";
  37265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37267. /**
  37268. * Manage the mouse wheel inputs to control an arc rotate camera.
  37269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37270. */
  37271. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37272. /**
  37273. * Defines the camera the input is attached to.
  37274. */
  37275. camera: ArcRotateCamera;
  37276. /**
  37277. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37278. */
  37279. wheelPrecision: number;
  37280. /**
  37281. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37282. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37283. */
  37284. wheelDeltaPercentage: number;
  37285. private _wheel;
  37286. private _observer;
  37287. private computeDeltaFromMouseWheelLegacyEvent;
  37288. /**
  37289. * Attach the input controls to a specific dom element to get the input from.
  37290. * @param element Defines the element the controls should be listened from
  37291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37292. */
  37293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37294. /**
  37295. * Detach the current controls from the specified dom element.
  37296. * @param element Defines the element to stop listening the inputs from
  37297. */
  37298. detachControl(element: Nullable<HTMLElement>): void;
  37299. /**
  37300. * Gets the class name of the current intput.
  37301. * @returns the class name
  37302. */
  37303. getClassName(): string;
  37304. /**
  37305. * Get the friendly name associated with the input class.
  37306. * @returns the input friendly name
  37307. */
  37308. getSimpleName(): string;
  37309. }
  37310. }
  37311. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37312. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37313. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37314. /**
  37315. * Default Inputs manager for the ArcRotateCamera.
  37316. * It groups all the default supported inputs for ease of use.
  37317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37318. */
  37319. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37320. /**
  37321. * Instantiates a new ArcRotateCameraInputsManager.
  37322. * @param camera Defines the camera the inputs belong to
  37323. */
  37324. constructor(camera: ArcRotateCamera);
  37325. /**
  37326. * Add mouse wheel input support to the input manager.
  37327. * @returns the current input manager
  37328. */
  37329. addMouseWheel(): ArcRotateCameraInputsManager;
  37330. /**
  37331. * Add pointers input support to the input manager.
  37332. * @returns the current input manager
  37333. */
  37334. addPointers(): ArcRotateCameraInputsManager;
  37335. /**
  37336. * Add keyboard input support to the input manager.
  37337. * @returns the current input manager
  37338. */
  37339. addKeyboard(): ArcRotateCameraInputsManager;
  37340. }
  37341. }
  37342. declare module "babylonjs/Cameras/arcRotateCamera" {
  37343. import { Observable } from "babylonjs/Misc/observable";
  37344. import { Nullable } from "babylonjs/types";
  37345. import { Scene } from "babylonjs/scene";
  37346. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37348. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37349. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37350. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37351. import { Camera } from "babylonjs/Cameras/camera";
  37352. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37353. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37354. import { Collider } from "babylonjs/Collisions/collider";
  37355. /**
  37356. * This represents an orbital type of camera.
  37357. *
  37358. * 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.
  37359. * 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.
  37360. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37361. */
  37362. export class ArcRotateCamera extends TargetCamera {
  37363. /**
  37364. * Defines the rotation angle of the camera along the longitudinal axis.
  37365. */
  37366. alpha: number;
  37367. /**
  37368. * Defines the rotation angle of the camera along the latitudinal axis.
  37369. */
  37370. beta: number;
  37371. /**
  37372. * Defines the radius of the camera from it s target point.
  37373. */
  37374. radius: number;
  37375. protected _target: Vector3;
  37376. protected _targetHost: Nullable<AbstractMesh>;
  37377. /**
  37378. * Defines the target point of the camera.
  37379. * The camera looks towards it form the radius distance.
  37380. */
  37381. target: Vector3;
  37382. /**
  37383. * Define the current local position of the camera in the scene
  37384. */
  37385. position: Vector3;
  37386. protected _upVector: Vector3;
  37387. protected _upToYMatrix: Matrix;
  37388. protected _YToUpMatrix: Matrix;
  37389. /**
  37390. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37391. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37392. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37393. */
  37394. upVector: Vector3;
  37395. /**
  37396. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37397. */
  37398. setMatUp(): void;
  37399. /**
  37400. * Current inertia value on the longitudinal axis.
  37401. * The bigger this number the longer it will take for the camera to stop.
  37402. */
  37403. inertialAlphaOffset: number;
  37404. /**
  37405. * Current inertia value on the latitudinal axis.
  37406. * The bigger this number the longer it will take for the camera to stop.
  37407. */
  37408. inertialBetaOffset: number;
  37409. /**
  37410. * Current inertia value on the radius axis.
  37411. * The bigger this number the longer it will take for the camera to stop.
  37412. */
  37413. inertialRadiusOffset: number;
  37414. /**
  37415. * Minimum allowed angle on the longitudinal axis.
  37416. * This can help limiting how the Camera is able to move in the scene.
  37417. */
  37418. lowerAlphaLimit: Nullable<number>;
  37419. /**
  37420. * Maximum allowed angle on the longitudinal axis.
  37421. * This can help limiting how the Camera is able to move in the scene.
  37422. */
  37423. upperAlphaLimit: Nullable<number>;
  37424. /**
  37425. * Minimum allowed angle on the latitudinal axis.
  37426. * This can help limiting how the Camera is able to move in the scene.
  37427. */
  37428. lowerBetaLimit: number;
  37429. /**
  37430. * Maximum allowed angle on the latitudinal axis.
  37431. * This can help limiting how the Camera is able to move in the scene.
  37432. */
  37433. upperBetaLimit: number;
  37434. /**
  37435. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37436. * This can help limiting how the Camera is able to move in the scene.
  37437. */
  37438. lowerRadiusLimit: Nullable<number>;
  37439. /**
  37440. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37441. * This can help limiting how the Camera is able to move in the scene.
  37442. */
  37443. upperRadiusLimit: Nullable<number>;
  37444. /**
  37445. * Defines the current inertia value used during panning of the camera along the X axis.
  37446. */
  37447. inertialPanningX: number;
  37448. /**
  37449. * Defines the current inertia value used during panning of the camera along the Y axis.
  37450. */
  37451. inertialPanningY: number;
  37452. /**
  37453. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37454. * Basically if your fingers moves away from more than this distance you will be considered
  37455. * in pinch mode.
  37456. */
  37457. pinchToPanMaxDistance: number;
  37458. /**
  37459. * Defines the maximum distance the camera can pan.
  37460. * This could help keeping the cammera always in your scene.
  37461. */
  37462. panningDistanceLimit: Nullable<number>;
  37463. /**
  37464. * Defines the target of the camera before paning.
  37465. */
  37466. panningOriginTarget: Vector3;
  37467. /**
  37468. * Defines the value of the inertia used during panning.
  37469. * 0 would mean stop inertia and one would mean no decelleration at all.
  37470. */
  37471. panningInertia: number;
  37472. /**
  37473. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37474. */
  37475. angularSensibilityX: number;
  37476. /**
  37477. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37478. */
  37479. angularSensibilityY: number;
  37480. /**
  37481. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37482. */
  37483. pinchPrecision: number;
  37484. /**
  37485. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37486. * It will be used instead of pinchDeltaPrecision if different from 0.
  37487. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37488. */
  37489. pinchDeltaPercentage: number;
  37490. /**
  37491. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37492. */
  37493. panningSensibility: number;
  37494. /**
  37495. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37496. */
  37497. keysUp: number[];
  37498. /**
  37499. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37500. */
  37501. keysDown: number[];
  37502. /**
  37503. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37504. */
  37505. keysLeft: number[];
  37506. /**
  37507. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37508. */
  37509. keysRight: number[];
  37510. /**
  37511. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37512. */
  37513. wheelPrecision: number;
  37514. /**
  37515. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37516. * It will be used instead of pinchDeltaPrecision if different from 0.
  37517. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37518. */
  37519. wheelDeltaPercentage: number;
  37520. /**
  37521. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37522. */
  37523. zoomOnFactor: number;
  37524. /**
  37525. * Defines a screen offset for the camera position.
  37526. */
  37527. targetScreenOffset: Vector2;
  37528. /**
  37529. * Allows the camera to be completely reversed.
  37530. * If false the camera can not arrive upside down.
  37531. */
  37532. allowUpsideDown: boolean;
  37533. /**
  37534. * Define if double tap/click is used to restore the previously saved state of the camera.
  37535. */
  37536. useInputToRestoreState: boolean;
  37537. /** @hidden */
  37538. _viewMatrix: Matrix;
  37539. /** @hidden */
  37540. _useCtrlForPanning: boolean;
  37541. /** @hidden */
  37542. _panningMouseButton: number;
  37543. /**
  37544. * Defines the input associated to the camera.
  37545. */
  37546. inputs: ArcRotateCameraInputsManager;
  37547. /** @hidden */
  37548. _reset: () => void;
  37549. /**
  37550. * Defines the allowed panning axis.
  37551. */
  37552. panningAxis: Vector3;
  37553. protected _localDirection: Vector3;
  37554. protected _transformedDirection: Vector3;
  37555. private _bouncingBehavior;
  37556. /**
  37557. * Gets the bouncing behavior of the camera if it has been enabled.
  37558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37559. */
  37560. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37561. /**
  37562. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37563. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37564. */
  37565. useBouncingBehavior: boolean;
  37566. private _framingBehavior;
  37567. /**
  37568. * Gets the framing behavior of the camera if it has been enabled.
  37569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37570. */
  37571. readonly framingBehavior: Nullable<FramingBehavior>;
  37572. /**
  37573. * Defines if the framing behavior of the camera is enabled on the camera.
  37574. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37575. */
  37576. useFramingBehavior: boolean;
  37577. private _autoRotationBehavior;
  37578. /**
  37579. * Gets the auto rotation behavior of the camera if it has been enabled.
  37580. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37581. */
  37582. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37583. /**
  37584. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37585. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37586. */
  37587. useAutoRotationBehavior: boolean;
  37588. /**
  37589. * Observable triggered when the mesh target has been changed on the camera.
  37590. */
  37591. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37592. /**
  37593. * Event raised when the camera is colliding with a mesh.
  37594. */
  37595. onCollide: (collidedMesh: AbstractMesh) => void;
  37596. /**
  37597. * Defines whether the camera should check collision with the objects oh the scene.
  37598. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37599. */
  37600. checkCollisions: boolean;
  37601. /**
  37602. * Defines the collision radius of the camera.
  37603. * This simulates a sphere around the camera.
  37604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37605. */
  37606. collisionRadius: Vector3;
  37607. protected _collider: Collider;
  37608. protected _previousPosition: Vector3;
  37609. protected _collisionVelocity: Vector3;
  37610. protected _newPosition: Vector3;
  37611. protected _previousAlpha: number;
  37612. protected _previousBeta: number;
  37613. protected _previousRadius: number;
  37614. protected _collisionTriggered: boolean;
  37615. protected _targetBoundingCenter: Nullable<Vector3>;
  37616. private _computationVector;
  37617. /**
  37618. * Instantiates a new ArcRotateCamera in a given scene
  37619. * @param name Defines the name of the camera
  37620. * @param alpha Defines the camera rotation along the logitudinal axis
  37621. * @param beta Defines the camera rotation along the latitudinal axis
  37622. * @param radius Defines the camera distance from its target
  37623. * @param target Defines the camera target
  37624. * @param scene Defines the scene the camera belongs to
  37625. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37626. */
  37627. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37628. /** @hidden */
  37629. _initCache(): void;
  37630. /** @hidden */
  37631. _updateCache(ignoreParentClass?: boolean): void;
  37632. protected _getTargetPosition(): Vector3;
  37633. private _storedAlpha;
  37634. private _storedBeta;
  37635. private _storedRadius;
  37636. private _storedTarget;
  37637. private _storedTargetScreenOffset;
  37638. /**
  37639. * Stores the current state of the camera (alpha, beta, radius and target)
  37640. * @returns the camera itself
  37641. */
  37642. storeState(): Camera;
  37643. /**
  37644. * @hidden
  37645. * Restored camera state. You must call storeState() first
  37646. */
  37647. _restoreStateValues(): boolean;
  37648. /** @hidden */
  37649. _isSynchronizedViewMatrix(): boolean;
  37650. /**
  37651. * Attached controls to the current camera.
  37652. * @param element Defines the element the controls should be listened from
  37653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37654. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37655. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37656. */
  37657. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37658. /**
  37659. * Detach the current controls from the camera.
  37660. * The camera will stop reacting to inputs.
  37661. * @param element Defines the element to stop listening the inputs from
  37662. */
  37663. detachControl(element: HTMLElement): void;
  37664. /** @hidden */
  37665. _checkInputs(): void;
  37666. protected _checkLimits(): void;
  37667. /**
  37668. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37669. */
  37670. rebuildAnglesAndRadius(): void;
  37671. /**
  37672. * Use a position to define the current camera related information like alpha, beta and radius
  37673. * @param position Defines the position to set the camera at
  37674. */
  37675. setPosition(position: Vector3): void;
  37676. /**
  37677. * Defines the target the camera should look at.
  37678. * This will automatically adapt alpha beta and radius to fit within the new target.
  37679. * @param target Defines the new target as a Vector or a mesh
  37680. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37681. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37682. */
  37683. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37684. /** @hidden */
  37685. _getViewMatrix(): Matrix;
  37686. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37687. /**
  37688. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37689. * @param meshes Defines the mesh to zoom on
  37690. * @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)
  37691. */
  37692. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37693. /**
  37694. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37695. * The target will be changed but the radius
  37696. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37697. * @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)
  37698. */
  37699. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37700. min: Vector3;
  37701. max: Vector3;
  37702. distance: number;
  37703. }, doNotUpdateMaxZ?: boolean): void;
  37704. /**
  37705. * @override
  37706. * Override Camera.createRigCamera
  37707. */
  37708. createRigCamera(name: string, cameraIndex: number): Camera;
  37709. /**
  37710. * @hidden
  37711. * @override
  37712. * Override Camera._updateRigCameras
  37713. */
  37714. _updateRigCameras(): void;
  37715. /**
  37716. * Destroy the camera and release the current resources hold by it.
  37717. */
  37718. dispose(): void;
  37719. /**
  37720. * Gets the current object class name.
  37721. * @return the class name
  37722. */
  37723. getClassName(): string;
  37724. }
  37725. }
  37726. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37727. import { Behavior } from "babylonjs/Behaviors/behavior";
  37728. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37729. /**
  37730. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37732. */
  37733. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37734. /**
  37735. * Gets the name of the behavior.
  37736. */
  37737. readonly name: string;
  37738. private _zoomStopsAnimation;
  37739. private _idleRotationSpeed;
  37740. private _idleRotationWaitTime;
  37741. private _idleRotationSpinupTime;
  37742. /**
  37743. * Sets the flag that indicates if user zooming should stop animation.
  37744. */
  37745. /**
  37746. * Gets the flag that indicates if user zooming should stop animation.
  37747. */
  37748. zoomStopsAnimation: boolean;
  37749. /**
  37750. * Sets the default speed at which the camera rotates around the model.
  37751. */
  37752. /**
  37753. * Gets the default speed at which the camera rotates around the model.
  37754. */
  37755. idleRotationSpeed: number;
  37756. /**
  37757. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37758. */
  37759. /**
  37760. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37761. */
  37762. idleRotationWaitTime: number;
  37763. /**
  37764. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37765. */
  37766. /**
  37767. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37768. */
  37769. idleRotationSpinupTime: number;
  37770. /**
  37771. * Gets a value indicating if the camera is currently rotating because of this behavior
  37772. */
  37773. readonly rotationInProgress: boolean;
  37774. private _onPrePointerObservableObserver;
  37775. private _onAfterCheckInputsObserver;
  37776. private _attachedCamera;
  37777. private _isPointerDown;
  37778. private _lastFrameTime;
  37779. private _lastInteractionTime;
  37780. private _cameraRotationSpeed;
  37781. /**
  37782. * Initializes the behavior.
  37783. */
  37784. init(): void;
  37785. /**
  37786. * Attaches the behavior to its arc rotate camera.
  37787. * @param camera Defines the camera to attach the behavior to
  37788. */
  37789. attach(camera: ArcRotateCamera): void;
  37790. /**
  37791. * Detaches the behavior from its current arc rotate camera.
  37792. */
  37793. detach(): void;
  37794. /**
  37795. * Returns true if user is scrolling.
  37796. * @return true if user is scrolling.
  37797. */
  37798. private _userIsZooming;
  37799. private _lastFrameRadius;
  37800. private _shouldAnimationStopForInteraction;
  37801. /**
  37802. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37803. */
  37804. private _applyUserInteraction;
  37805. private _userIsMoving;
  37806. }
  37807. }
  37808. declare module "babylonjs/Behaviors/Cameras/index" {
  37809. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37810. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37811. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37812. }
  37813. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37814. import { Mesh } from "babylonjs/Meshes/mesh";
  37815. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37816. import { Behavior } from "babylonjs/Behaviors/behavior";
  37817. /**
  37818. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37819. */
  37820. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37821. private ui;
  37822. /**
  37823. * The name of the behavior
  37824. */
  37825. name: string;
  37826. /**
  37827. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37828. */
  37829. distanceAwayFromFace: number;
  37830. /**
  37831. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37832. */
  37833. distanceAwayFromBottomOfFace: number;
  37834. private _faceVectors;
  37835. private _target;
  37836. private _scene;
  37837. private _onRenderObserver;
  37838. private _tmpMatrix;
  37839. private _tmpVector;
  37840. /**
  37841. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37842. * @param ui The transform node that should be attched to the mesh
  37843. */
  37844. constructor(ui: TransformNode);
  37845. /**
  37846. * Initializes the behavior
  37847. */
  37848. init(): void;
  37849. private _closestFace;
  37850. private _zeroVector;
  37851. private _lookAtTmpMatrix;
  37852. private _lookAtToRef;
  37853. /**
  37854. * Attaches the AttachToBoxBehavior to the passed in mesh
  37855. * @param target The mesh that the specified node will be attached to
  37856. */
  37857. attach(target: Mesh): void;
  37858. /**
  37859. * Detaches the behavior from the mesh
  37860. */
  37861. detach(): void;
  37862. }
  37863. }
  37864. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37865. import { Behavior } from "babylonjs/Behaviors/behavior";
  37866. import { Mesh } from "babylonjs/Meshes/mesh";
  37867. /**
  37868. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37869. */
  37870. export class FadeInOutBehavior implements Behavior<Mesh> {
  37871. /**
  37872. * Time in milliseconds to delay before fading in (Default: 0)
  37873. */
  37874. delay: number;
  37875. /**
  37876. * Time in milliseconds for the mesh to fade in (Default: 300)
  37877. */
  37878. fadeInTime: number;
  37879. private _millisecondsPerFrame;
  37880. private _hovered;
  37881. private _hoverValue;
  37882. private _ownerNode;
  37883. /**
  37884. * Instatiates the FadeInOutBehavior
  37885. */
  37886. constructor();
  37887. /**
  37888. * The name of the behavior
  37889. */
  37890. readonly name: string;
  37891. /**
  37892. * Initializes the behavior
  37893. */
  37894. init(): void;
  37895. /**
  37896. * Attaches the fade behavior on the passed in mesh
  37897. * @param ownerNode The mesh that will be faded in/out once attached
  37898. */
  37899. attach(ownerNode: Mesh): void;
  37900. /**
  37901. * Detaches the behavior from the mesh
  37902. */
  37903. detach(): void;
  37904. /**
  37905. * Triggers the mesh to begin fading in or out
  37906. * @param value if the object should fade in or out (true to fade in)
  37907. */
  37908. fadeIn(value: boolean): void;
  37909. private _update;
  37910. private _setAllVisibility;
  37911. }
  37912. }
  37913. declare module "babylonjs/Misc/pivotTools" {
  37914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37915. /**
  37916. * Class containing a set of static utilities functions for managing Pivots
  37917. * @hidden
  37918. */
  37919. export class PivotTools {
  37920. private static _PivotCached;
  37921. private static _OldPivotPoint;
  37922. private static _PivotTranslation;
  37923. private static _PivotTmpVector;
  37924. /** @hidden */
  37925. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37926. /** @hidden */
  37927. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37928. }
  37929. }
  37930. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37931. import { Scene } from "babylonjs/scene";
  37932. import { Vector4 } from "babylonjs/Maths/math.vector";
  37933. import { Mesh } from "babylonjs/Meshes/mesh";
  37934. import { Nullable } from "babylonjs/types";
  37935. import { Plane } from "babylonjs/Maths/math.plane";
  37936. /**
  37937. * Class containing static functions to help procedurally build meshes
  37938. */
  37939. export class PlaneBuilder {
  37940. /**
  37941. * Creates a plane mesh
  37942. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37943. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37944. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37948. * @param name defines the name of the mesh
  37949. * @param options defines the options used to create the mesh
  37950. * @param scene defines the hosting scene
  37951. * @returns the plane mesh
  37952. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37953. */
  37954. static CreatePlane(name: string, options: {
  37955. size?: number;
  37956. width?: number;
  37957. height?: number;
  37958. sideOrientation?: number;
  37959. frontUVs?: Vector4;
  37960. backUVs?: Vector4;
  37961. updatable?: boolean;
  37962. sourcePlane?: Plane;
  37963. }, scene?: Nullable<Scene>): Mesh;
  37964. }
  37965. }
  37966. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37967. import { Behavior } from "babylonjs/Behaviors/behavior";
  37968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37969. import { Observable } from "babylonjs/Misc/observable";
  37970. import { Vector3 } from "babylonjs/Maths/math.vector";
  37971. import { Ray } from "babylonjs/Culling/ray";
  37972. import "babylonjs/Meshes/Builders/planeBuilder";
  37973. /**
  37974. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37975. */
  37976. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37977. private static _AnyMouseID;
  37978. /**
  37979. * Abstract mesh the behavior is set on
  37980. */
  37981. attachedNode: AbstractMesh;
  37982. private _dragPlane;
  37983. private _scene;
  37984. private _pointerObserver;
  37985. private _beforeRenderObserver;
  37986. private static _planeScene;
  37987. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37988. /**
  37989. * 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)
  37990. */
  37991. maxDragAngle: number;
  37992. /**
  37993. * @hidden
  37994. */
  37995. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37996. /**
  37997. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37998. */
  37999. currentDraggingPointerID: number;
  38000. /**
  38001. * The last position where the pointer hit the drag plane in world space
  38002. */
  38003. lastDragPosition: Vector3;
  38004. /**
  38005. * If the behavior is currently in a dragging state
  38006. */
  38007. dragging: boolean;
  38008. /**
  38009. * 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)
  38010. */
  38011. dragDeltaRatio: number;
  38012. /**
  38013. * If the drag plane orientation should be updated during the dragging (Default: true)
  38014. */
  38015. updateDragPlane: boolean;
  38016. private _debugMode;
  38017. private _moving;
  38018. /**
  38019. * Fires each time the attached mesh is dragged with the pointer
  38020. * * delta between last drag position and current drag position in world space
  38021. * * dragDistance along the drag axis
  38022. * * dragPlaneNormal normal of the current drag plane used during the drag
  38023. * * dragPlanePoint in world space where the drag intersects the drag plane
  38024. */
  38025. onDragObservable: Observable<{
  38026. delta: Vector3;
  38027. dragPlanePoint: Vector3;
  38028. dragPlaneNormal: Vector3;
  38029. dragDistance: number;
  38030. pointerId: number;
  38031. }>;
  38032. /**
  38033. * Fires each time a drag begins (eg. mouse down on mesh)
  38034. */
  38035. onDragStartObservable: Observable<{
  38036. dragPlanePoint: Vector3;
  38037. pointerId: number;
  38038. }>;
  38039. /**
  38040. * Fires each time a drag ends (eg. mouse release after drag)
  38041. */
  38042. onDragEndObservable: Observable<{
  38043. dragPlanePoint: Vector3;
  38044. pointerId: number;
  38045. }>;
  38046. /**
  38047. * If the attached mesh should be moved when dragged
  38048. */
  38049. moveAttached: boolean;
  38050. /**
  38051. * If the drag behavior will react to drag events (Default: true)
  38052. */
  38053. enabled: boolean;
  38054. /**
  38055. * If pointer events should start and release the drag (Default: true)
  38056. */
  38057. startAndReleaseDragOnPointerEvents: boolean;
  38058. /**
  38059. * If camera controls should be detached during the drag
  38060. */
  38061. detachCameraControls: boolean;
  38062. /**
  38063. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38064. */
  38065. useObjectOrienationForDragging: boolean;
  38066. private _options;
  38067. /**
  38068. * Creates a pointer drag behavior that can be attached to a mesh
  38069. * @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)
  38070. */
  38071. constructor(options?: {
  38072. dragAxis?: Vector3;
  38073. dragPlaneNormal?: Vector3;
  38074. });
  38075. /**
  38076. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38077. */
  38078. validateDrag: (targetPosition: Vector3) => boolean;
  38079. /**
  38080. * The name of the behavior
  38081. */
  38082. readonly name: string;
  38083. /**
  38084. * Initializes the behavior
  38085. */
  38086. init(): void;
  38087. private _tmpVector;
  38088. private _alternatePickedPoint;
  38089. private _worldDragAxis;
  38090. private _targetPosition;
  38091. private _attachedElement;
  38092. /**
  38093. * Attaches the drag behavior the passed in mesh
  38094. * @param ownerNode The mesh that will be dragged around once attached
  38095. * @param predicate Predicate to use for pick filtering
  38096. */
  38097. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38098. /**
  38099. * Force relase the drag action by code.
  38100. */
  38101. releaseDrag(): void;
  38102. private _startDragRay;
  38103. private _lastPointerRay;
  38104. /**
  38105. * Simulates the start of a pointer drag event on the behavior
  38106. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38107. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38108. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38109. */
  38110. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38111. private _startDrag;
  38112. private _dragDelta;
  38113. private _moveDrag;
  38114. private _pickWithRayOnDragPlane;
  38115. private _pointA;
  38116. private _pointB;
  38117. private _pointC;
  38118. private _lineA;
  38119. private _lineB;
  38120. private _localAxis;
  38121. private _lookAt;
  38122. private _updateDragPlanePosition;
  38123. /**
  38124. * Detaches the behavior from the mesh
  38125. */
  38126. detach(): void;
  38127. }
  38128. }
  38129. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38130. import { Mesh } from "babylonjs/Meshes/mesh";
  38131. import { Behavior } from "babylonjs/Behaviors/behavior";
  38132. /**
  38133. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38134. */
  38135. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38136. private _dragBehaviorA;
  38137. private _dragBehaviorB;
  38138. private _startDistance;
  38139. private _initialScale;
  38140. private _targetScale;
  38141. private _ownerNode;
  38142. private _sceneRenderObserver;
  38143. /**
  38144. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38145. */
  38146. constructor();
  38147. /**
  38148. * The name of the behavior
  38149. */
  38150. readonly name: string;
  38151. /**
  38152. * Initializes the behavior
  38153. */
  38154. init(): void;
  38155. private _getCurrentDistance;
  38156. /**
  38157. * Attaches the scale behavior the passed in mesh
  38158. * @param ownerNode The mesh that will be scaled around once attached
  38159. */
  38160. attach(ownerNode: Mesh): void;
  38161. /**
  38162. * Detaches the behavior from the mesh
  38163. */
  38164. detach(): void;
  38165. }
  38166. }
  38167. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38168. import { Behavior } from "babylonjs/Behaviors/behavior";
  38169. import { Mesh } from "babylonjs/Meshes/mesh";
  38170. import { Observable } from "babylonjs/Misc/observable";
  38171. /**
  38172. * 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
  38173. */
  38174. export class SixDofDragBehavior implements Behavior<Mesh> {
  38175. private static _virtualScene;
  38176. private _ownerNode;
  38177. private _sceneRenderObserver;
  38178. private _scene;
  38179. private _targetPosition;
  38180. private _virtualOriginMesh;
  38181. private _virtualDragMesh;
  38182. private _pointerObserver;
  38183. private _moving;
  38184. private _startingOrientation;
  38185. /**
  38186. * 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)
  38187. */
  38188. private zDragFactor;
  38189. /**
  38190. * If the object should rotate to face the drag origin
  38191. */
  38192. rotateDraggedObject: boolean;
  38193. /**
  38194. * If the behavior is currently in a dragging state
  38195. */
  38196. dragging: boolean;
  38197. /**
  38198. * 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)
  38199. */
  38200. dragDeltaRatio: number;
  38201. /**
  38202. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38203. */
  38204. currentDraggingPointerID: number;
  38205. /**
  38206. * If camera controls should be detached during the drag
  38207. */
  38208. detachCameraControls: boolean;
  38209. /**
  38210. * Fires each time a drag starts
  38211. */
  38212. onDragStartObservable: Observable<{}>;
  38213. /**
  38214. * Fires each time a drag ends (eg. mouse release after drag)
  38215. */
  38216. onDragEndObservable: Observable<{}>;
  38217. /**
  38218. * 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
  38219. */
  38220. constructor();
  38221. /**
  38222. * The name of the behavior
  38223. */
  38224. readonly name: string;
  38225. /**
  38226. * Initializes the behavior
  38227. */
  38228. init(): void;
  38229. /**
  38230. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38231. */
  38232. private readonly _pointerCamera;
  38233. /**
  38234. * Attaches the scale behavior the passed in mesh
  38235. * @param ownerNode The mesh that will be scaled around once attached
  38236. */
  38237. attach(ownerNode: Mesh): void;
  38238. /**
  38239. * Detaches the behavior from the mesh
  38240. */
  38241. detach(): void;
  38242. }
  38243. }
  38244. declare module "babylonjs/Behaviors/Meshes/index" {
  38245. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38246. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38247. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38248. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38249. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38250. }
  38251. declare module "babylonjs/Behaviors/index" {
  38252. export * from "babylonjs/Behaviors/behavior";
  38253. export * from "babylonjs/Behaviors/Cameras/index";
  38254. export * from "babylonjs/Behaviors/Meshes/index";
  38255. }
  38256. declare module "babylonjs/Bones/boneIKController" {
  38257. import { Bone } from "babylonjs/Bones/bone";
  38258. import { Vector3 } from "babylonjs/Maths/math.vector";
  38259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38260. import { Nullable } from "babylonjs/types";
  38261. /**
  38262. * Class used to apply inverse kinematics to bones
  38263. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38264. */
  38265. export class BoneIKController {
  38266. private static _tmpVecs;
  38267. private static _tmpQuat;
  38268. private static _tmpMats;
  38269. /**
  38270. * Gets or sets the target mesh
  38271. */
  38272. targetMesh: AbstractMesh;
  38273. /** Gets or sets the mesh used as pole */
  38274. poleTargetMesh: AbstractMesh;
  38275. /**
  38276. * Gets or sets the bone used as pole
  38277. */
  38278. poleTargetBone: Nullable<Bone>;
  38279. /**
  38280. * Gets or sets the target position
  38281. */
  38282. targetPosition: Vector3;
  38283. /**
  38284. * Gets or sets the pole target position
  38285. */
  38286. poleTargetPosition: Vector3;
  38287. /**
  38288. * Gets or sets the pole target local offset
  38289. */
  38290. poleTargetLocalOffset: Vector3;
  38291. /**
  38292. * Gets or sets the pole angle
  38293. */
  38294. poleAngle: number;
  38295. /**
  38296. * Gets or sets the mesh associated with the controller
  38297. */
  38298. mesh: AbstractMesh;
  38299. /**
  38300. * 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)
  38301. */
  38302. slerpAmount: number;
  38303. private _bone1Quat;
  38304. private _bone1Mat;
  38305. private _bone2Ang;
  38306. private _bone1;
  38307. private _bone2;
  38308. private _bone1Length;
  38309. private _bone2Length;
  38310. private _maxAngle;
  38311. private _maxReach;
  38312. private _rightHandedSystem;
  38313. private _bendAxis;
  38314. private _slerping;
  38315. private _adjustRoll;
  38316. /**
  38317. * Gets or sets maximum allowed angle
  38318. */
  38319. maxAngle: number;
  38320. /**
  38321. * Creates a new BoneIKController
  38322. * @param mesh defines the mesh to control
  38323. * @param bone defines the bone to control
  38324. * @param options defines options to set up the controller
  38325. */
  38326. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38327. targetMesh?: AbstractMesh;
  38328. poleTargetMesh?: AbstractMesh;
  38329. poleTargetBone?: Bone;
  38330. poleTargetLocalOffset?: Vector3;
  38331. poleAngle?: number;
  38332. bendAxis?: Vector3;
  38333. maxAngle?: number;
  38334. slerpAmount?: number;
  38335. });
  38336. private _setMaxAngle;
  38337. /**
  38338. * Force the controller to update the bones
  38339. */
  38340. update(): void;
  38341. }
  38342. }
  38343. declare module "babylonjs/Bones/boneLookController" {
  38344. import { Vector3 } from "babylonjs/Maths/math.vector";
  38345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38346. import { Bone } from "babylonjs/Bones/bone";
  38347. import { Space } from "babylonjs/Maths/math.axis";
  38348. /**
  38349. * Class used to make a bone look toward a point in space
  38350. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38351. */
  38352. export class BoneLookController {
  38353. private static _tmpVecs;
  38354. private static _tmpQuat;
  38355. private static _tmpMats;
  38356. /**
  38357. * The target Vector3 that the bone will look at
  38358. */
  38359. target: Vector3;
  38360. /**
  38361. * The mesh that the bone is attached to
  38362. */
  38363. mesh: AbstractMesh;
  38364. /**
  38365. * The bone that will be looking to the target
  38366. */
  38367. bone: Bone;
  38368. /**
  38369. * The up axis of the coordinate system that is used when the bone is rotated
  38370. */
  38371. upAxis: Vector3;
  38372. /**
  38373. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38374. */
  38375. upAxisSpace: Space;
  38376. /**
  38377. * Used to make an adjustment to the yaw of the bone
  38378. */
  38379. adjustYaw: number;
  38380. /**
  38381. * Used to make an adjustment to the pitch of the bone
  38382. */
  38383. adjustPitch: number;
  38384. /**
  38385. * Used to make an adjustment to the roll of the bone
  38386. */
  38387. adjustRoll: number;
  38388. /**
  38389. * 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)
  38390. */
  38391. slerpAmount: number;
  38392. private _minYaw;
  38393. private _maxYaw;
  38394. private _minPitch;
  38395. private _maxPitch;
  38396. private _minYawSin;
  38397. private _minYawCos;
  38398. private _maxYawSin;
  38399. private _maxYawCos;
  38400. private _midYawConstraint;
  38401. private _minPitchTan;
  38402. private _maxPitchTan;
  38403. private _boneQuat;
  38404. private _slerping;
  38405. private _transformYawPitch;
  38406. private _transformYawPitchInv;
  38407. private _firstFrameSkipped;
  38408. private _yawRange;
  38409. private _fowardAxis;
  38410. /**
  38411. * Gets or sets the minimum yaw angle that the bone can look to
  38412. */
  38413. minYaw: number;
  38414. /**
  38415. * Gets or sets the maximum yaw angle that the bone can look to
  38416. */
  38417. maxYaw: number;
  38418. /**
  38419. * Gets or sets the minimum pitch angle that the bone can look to
  38420. */
  38421. minPitch: number;
  38422. /**
  38423. * Gets or sets the maximum pitch angle that the bone can look to
  38424. */
  38425. maxPitch: number;
  38426. /**
  38427. * Create a BoneLookController
  38428. * @param mesh the mesh that the bone belongs to
  38429. * @param bone the bone that will be looking to the target
  38430. * @param target the target Vector3 to look at
  38431. * @param options optional settings:
  38432. * * maxYaw: the maximum angle the bone will yaw to
  38433. * * minYaw: the minimum angle the bone will yaw to
  38434. * * maxPitch: the maximum angle the bone will pitch to
  38435. * * minPitch: the minimum angle the bone will yaw to
  38436. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38437. * * upAxis: the up axis of the coordinate system
  38438. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38439. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38440. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38441. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38442. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38443. * * adjustRoll: used to make an adjustment to the roll of the bone
  38444. **/
  38445. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38446. maxYaw?: number;
  38447. minYaw?: number;
  38448. maxPitch?: number;
  38449. minPitch?: number;
  38450. slerpAmount?: number;
  38451. upAxis?: Vector3;
  38452. upAxisSpace?: Space;
  38453. yawAxis?: Vector3;
  38454. pitchAxis?: Vector3;
  38455. adjustYaw?: number;
  38456. adjustPitch?: number;
  38457. adjustRoll?: number;
  38458. });
  38459. /**
  38460. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38461. */
  38462. update(): void;
  38463. private _getAngleDiff;
  38464. private _getAngleBetween;
  38465. private _isAngleBetween;
  38466. }
  38467. }
  38468. declare module "babylonjs/Bones/index" {
  38469. export * from "babylonjs/Bones/bone";
  38470. export * from "babylonjs/Bones/boneIKController";
  38471. export * from "babylonjs/Bones/boneLookController";
  38472. export * from "babylonjs/Bones/skeleton";
  38473. }
  38474. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38475. import { Nullable } from "babylonjs/types";
  38476. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38477. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38478. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38479. /**
  38480. * Manage the gamepad inputs to control an arc rotate camera.
  38481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38482. */
  38483. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38484. /**
  38485. * Defines the camera the input is attached to.
  38486. */
  38487. camera: ArcRotateCamera;
  38488. /**
  38489. * Defines the gamepad the input is gathering event from.
  38490. */
  38491. gamepad: Nullable<Gamepad>;
  38492. /**
  38493. * Defines the gamepad rotation sensiblity.
  38494. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38495. */
  38496. gamepadRotationSensibility: number;
  38497. /**
  38498. * Defines the gamepad move sensiblity.
  38499. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38500. */
  38501. gamepadMoveSensibility: number;
  38502. private _yAxisScale;
  38503. /**
  38504. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38505. */
  38506. invertYAxis: boolean;
  38507. private _onGamepadConnectedObserver;
  38508. private _onGamepadDisconnectedObserver;
  38509. /**
  38510. * Attach the input controls to a specific dom element to get the input from.
  38511. * @param element Defines the element the controls should be listened from
  38512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38513. */
  38514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38515. /**
  38516. * Detach the current controls from the specified dom element.
  38517. * @param element Defines the element to stop listening the inputs from
  38518. */
  38519. detachControl(element: Nullable<HTMLElement>): void;
  38520. /**
  38521. * Update the current camera state depending on the inputs that have been used this frame.
  38522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38523. */
  38524. checkInputs(): void;
  38525. /**
  38526. * Gets the class name of the current intput.
  38527. * @returns the class name
  38528. */
  38529. getClassName(): string;
  38530. /**
  38531. * Get the friendly name associated with the input class.
  38532. * @returns the input friendly name
  38533. */
  38534. getSimpleName(): string;
  38535. }
  38536. }
  38537. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38538. import { Nullable } from "babylonjs/types";
  38539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38540. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38541. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38542. interface ArcRotateCameraInputsManager {
  38543. /**
  38544. * Add orientation input support to the input manager.
  38545. * @returns the current input manager
  38546. */
  38547. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38548. }
  38549. }
  38550. /**
  38551. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38553. */
  38554. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38555. /**
  38556. * Defines the camera the input is attached to.
  38557. */
  38558. camera: ArcRotateCamera;
  38559. /**
  38560. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38561. */
  38562. alphaCorrection: number;
  38563. /**
  38564. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38565. */
  38566. gammaCorrection: number;
  38567. private _alpha;
  38568. private _gamma;
  38569. private _dirty;
  38570. private _deviceOrientationHandler;
  38571. /**
  38572. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38573. */
  38574. constructor();
  38575. /**
  38576. * Attach the input controls to a specific dom element to get the input from.
  38577. * @param element Defines the element the controls should be listened from
  38578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38579. */
  38580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38581. /** @hidden */
  38582. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38583. /**
  38584. * Update the current camera state depending on the inputs that have been used this frame.
  38585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38586. */
  38587. checkInputs(): void;
  38588. /**
  38589. * Detach the current controls from the specified dom element.
  38590. * @param element Defines the element to stop listening the inputs from
  38591. */
  38592. detachControl(element: Nullable<HTMLElement>): void;
  38593. /**
  38594. * Gets the class name of the current intput.
  38595. * @returns the class name
  38596. */
  38597. getClassName(): string;
  38598. /**
  38599. * Get the friendly name associated with the input class.
  38600. * @returns the input friendly name
  38601. */
  38602. getSimpleName(): string;
  38603. }
  38604. }
  38605. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38606. import { Nullable } from "babylonjs/types";
  38607. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38608. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38609. /**
  38610. * Listen to mouse events to control the camera.
  38611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38612. */
  38613. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38614. /**
  38615. * Defines the camera the input is attached to.
  38616. */
  38617. camera: FlyCamera;
  38618. /**
  38619. * Defines if touch is enabled. (Default is true.)
  38620. */
  38621. touchEnabled: boolean;
  38622. /**
  38623. * Defines the buttons associated with the input to handle camera rotation.
  38624. */
  38625. buttons: number[];
  38626. /**
  38627. * Assign buttons for Yaw control.
  38628. */
  38629. buttonsYaw: number[];
  38630. /**
  38631. * Assign buttons for Pitch control.
  38632. */
  38633. buttonsPitch: number[];
  38634. /**
  38635. * Assign buttons for Roll control.
  38636. */
  38637. buttonsRoll: number[];
  38638. /**
  38639. * Detect if any button is being pressed while mouse is moved.
  38640. * -1 = Mouse locked.
  38641. * 0 = Left button.
  38642. * 1 = Middle Button.
  38643. * 2 = Right Button.
  38644. */
  38645. activeButton: number;
  38646. /**
  38647. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38648. * Higher values reduce its sensitivity.
  38649. */
  38650. angularSensibility: number;
  38651. private _mousemoveCallback;
  38652. private _observer;
  38653. private _rollObserver;
  38654. private previousPosition;
  38655. private noPreventDefault;
  38656. private element;
  38657. /**
  38658. * Listen to mouse events to control the camera.
  38659. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38661. */
  38662. constructor(touchEnabled?: boolean);
  38663. /**
  38664. * Attach the mouse control to the HTML DOM element.
  38665. * @param element Defines the element that listens to the input events.
  38666. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38667. */
  38668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38669. /**
  38670. * Detach the current controls from the specified dom element.
  38671. * @param element Defines the element to stop listening the inputs from
  38672. */
  38673. detachControl(element: Nullable<HTMLElement>): void;
  38674. /**
  38675. * Gets the class name of the current input.
  38676. * @returns the class name.
  38677. */
  38678. getClassName(): string;
  38679. /**
  38680. * Get the friendly name associated with the input class.
  38681. * @returns the input's friendly name.
  38682. */
  38683. getSimpleName(): string;
  38684. private _pointerInput;
  38685. private _onMouseMove;
  38686. /**
  38687. * Rotate camera by mouse offset.
  38688. */
  38689. private rotateCamera;
  38690. }
  38691. }
  38692. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38693. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38694. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38695. /**
  38696. * Default Inputs manager for the FlyCamera.
  38697. * It groups all the default supported inputs for ease of use.
  38698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38699. */
  38700. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38701. /**
  38702. * Instantiates a new FlyCameraInputsManager.
  38703. * @param camera Defines the camera the inputs belong to.
  38704. */
  38705. constructor(camera: FlyCamera);
  38706. /**
  38707. * Add keyboard input support to the input manager.
  38708. * @returns the new FlyCameraKeyboardMoveInput().
  38709. */
  38710. addKeyboard(): FlyCameraInputsManager;
  38711. /**
  38712. * Add mouse input support to the input manager.
  38713. * @param touchEnabled Enable touch screen support.
  38714. * @returns the new FlyCameraMouseInput().
  38715. */
  38716. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38717. }
  38718. }
  38719. declare module "babylonjs/Cameras/flyCamera" {
  38720. import { Scene } from "babylonjs/scene";
  38721. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38723. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38724. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38725. /**
  38726. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38727. * such as in a 3D Space Shooter or a Flight Simulator.
  38728. */
  38729. export class FlyCamera extends TargetCamera {
  38730. /**
  38731. * Define the collision ellipsoid of the camera.
  38732. * This is helpful for simulating a camera body, like a player's body.
  38733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38734. */
  38735. ellipsoid: Vector3;
  38736. /**
  38737. * Define an offset for the position of the ellipsoid around the camera.
  38738. * This can be helpful if the camera is attached away from the player's body center,
  38739. * such as at its head.
  38740. */
  38741. ellipsoidOffset: Vector3;
  38742. /**
  38743. * Enable or disable collisions of the camera with the rest of the scene objects.
  38744. */
  38745. checkCollisions: boolean;
  38746. /**
  38747. * Enable or disable gravity on the camera.
  38748. */
  38749. applyGravity: boolean;
  38750. /**
  38751. * Define the current direction the camera is moving to.
  38752. */
  38753. cameraDirection: Vector3;
  38754. /**
  38755. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38756. * This overrides and empties cameraRotation.
  38757. */
  38758. rotationQuaternion: Quaternion;
  38759. /**
  38760. * Track Roll to maintain the wanted Rolling when looking around.
  38761. */
  38762. _trackRoll: number;
  38763. /**
  38764. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38765. */
  38766. rollCorrect: number;
  38767. /**
  38768. * Mimic a banked turn, Rolling the camera when Yawing.
  38769. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38770. */
  38771. bankedTurn: boolean;
  38772. /**
  38773. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38774. */
  38775. bankedTurnLimit: number;
  38776. /**
  38777. * Value of 0 disables the banked Roll.
  38778. * Value of 1 is equal to the Yaw angle in radians.
  38779. */
  38780. bankedTurnMultiplier: number;
  38781. /**
  38782. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38783. */
  38784. inputs: FlyCameraInputsManager;
  38785. /**
  38786. * Gets the input sensibility for mouse input.
  38787. * Higher values reduce sensitivity.
  38788. */
  38789. /**
  38790. * Sets the input sensibility for a mouse input.
  38791. * Higher values reduce sensitivity.
  38792. */
  38793. angularSensibility: number;
  38794. /**
  38795. * Get the keys for camera movement forward.
  38796. */
  38797. /**
  38798. * Set the keys for camera movement forward.
  38799. */
  38800. keysForward: number[];
  38801. /**
  38802. * Get the keys for camera movement backward.
  38803. */
  38804. keysBackward: number[];
  38805. /**
  38806. * Get the keys for camera movement up.
  38807. */
  38808. /**
  38809. * Set the keys for camera movement up.
  38810. */
  38811. keysUp: number[];
  38812. /**
  38813. * Get the keys for camera movement down.
  38814. */
  38815. /**
  38816. * Set the keys for camera movement down.
  38817. */
  38818. keysDown: number[];
  38819. /**
  38820. * Get the keys for camera movement left.
  38821. */
  38822. /**
  38823. * Set the keys for camera movement left.
  38824. */
  38825. keysLeft: number[];
  38826. /**
  38827. * Set the keys for camera movement right.
  38828. */
  38829. /**
  38830. * Set the keys for camera movement right.
  38831. */
  38832. keysRight: number[];
  38833. /**
  38834. * Event raised when the camera collides with a mesh in the scene.
  38835. */
  38836. onCollide: (collidedMesh: AbstractMesh) => void;
  38837. private _collider;
  38838. private _needMoveForGravity;
  38839. private _oldPosition;
  38840. private _diffPosition;
  38841. private _newPosition;
  38842. /** @hidden */
  38843. _localDirection: Vector3;
  38844. /** @hidden */
  38845. _transformedDirection: Vector3;
  38846. /**
  38847. * Instantiates a FlyCamera.
  38848. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38849. * such as in a 3D Space Shooter or a Flight Simulator.
  38850. * @param name Define the name of the camera in the scene.
  38851. * @param position Define the starting position of the camera in the scene.
  38852. * @param scene Define the scene the camera belongs to.
  38853. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38854. */
  38855. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38856. /**
  38857. * Attach a control to the HTML DOM element.
  38858. * @param element Defines the element that listens to the input events.
  38859. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38860. */
  38861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38862. /**
  38863. * Detach a control from the HTML DOM element.
  38864. * The camera will stop reacting to that input.
  38865. * @param element Defines the element that listens to the input events.
  38866. */
  38867. detachControl(element: HTMLElement): void;
  38868. private _collisionMask;
  38869. /**
  38870. * Get the mask that the camera ignores in collision events.
  38871. */
  38872. /**
  38873. * Set the mask that the camera ignores in collision events.
  38874. */
  38875. collisionMask: number;
  38876. /** @hidden */
  38877. _collideWithWorld(displacement: Vector3): void;
  38878. /** @hidden */
  38879. private _onCollisionPositionChange;
  38880. /** @hidden */
  38881. _checkInputs(): void;
  38882. /** @hidden */
  38883. _decideIfNeedsToMove(): boolean;
  38884. /** @hidden */
  38885. _updatePosition(): void;
  38886. /**
  38887. * Restore the Roll to its target value at the rate specified.
  38888. * @param rate - Higher means slower restoring.
  38889. * @hidden
  38890. */
  38891. restoreRoll(rate: number): void;
  38892. /**
  38893. * Destroy the camera and release the current resources held by it.
  38894. */
  38895. dispose(): void;
  38896. /**
  38897. * Get the current object class name.
  38898. * @returns the class name.
  38899. */
  38900. getClassName(): string;
  38901. }
  38902. }
  38903. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38904. import { Nullable } from "babylonjs/types";
  38905. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38906. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38907. /**
  38908. * Listen to keyboard events to control the camera.
  38909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38910. */
  38911. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38912. /**
  38913. * Defines the camera the input is attached to.
  38914. */
  38915. camera: FlyCamera;
  38916. /**
  38917. * The list of keyboard keys used to control the forward move of the camera.
  38918. */
  38919. keysForward: number[];
  38920. /**
  38921. * The list of keyboard keys used to control the backward move of the camera.
  38922. */
  38923. keysBackward: number[];
  38924. /**
  38925. * The list of keyboard keys used to control the forward move of the camera.
  38926. */
  38927. keysUp: number[];
  38928. /**
  38929. * The list of keyboard keys used to control the backward move of the camera.
  38930. */
  38931. keysDown: number[];
  38932. /**
  38933. * The list of keyboard keys used to control the right strafe move of the camera.
  38934. */
  38935. keysRight: number[];
  38936. /**
  38937. * The list of keyboard keys used to control the left strafe move of the camera.
  38938. */
  38939. keysLeft: number[];
  38940. private _keys;
  38941. private _onCanvasBlurObserver;
  38942. private _onKeyboardObserver;
  38943. private _engine;
  38944. private _scene;
  38945. /**
  38946. * Attach the input controls to a specific dom element to get the input from.
  38947. * @param element Defines the element the controls should be listened from
  38948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38949. */
  38950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38951. /**
  38952. * Detach the current controls from the specified dom element.
  38953. * @param element Defines the element to stop listening the inputs from
  38954. */
  38955. detachControl(element: Nullable<HTMLElement>): void;
  38956. /**
  38957. * Gets the class name of the current intput.
  38958. * @returns the class name
  38959. */
  38960. getClassName(): string;
  38961. /** @hidden */
  38962. _onLostFocus(e: FocusEvent): void;
  38963. /**
  38964. * Get the friendly name associated with the input class.
  38965. * @returns the input friendly name
  38966. */
  38967. getSimpleName(): string;
  38968. /**
  38969. * Update the current camera state depending on the inputs that have been used this frame.
  38970. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38971. */
  38972. checkInputs(): void;
  38973. }
  38974. }
  38975. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38976. import { Nullable } from "babylonjs/types";
  38977. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38978. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38979. /**
  38980. * Manage the mouse wheel inputs to control a follow camera.
  38981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38982. */
  38983. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38984. /**
  38985. * Defines the camera the input is attached to.
  38986. */
  38987. camera: FollowCamera;
  38988. /**
  38989. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38990. */
  38991. axisControlRadius: boolean;
  38992. /**
  38993. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38994. */
  38995. axisControlHeight: boolean;
  38996. /**
  38997. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38998. */
  38999. axisControlRotation: boolean;
  39000. /**
  39001. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39002. * relation to mouseWheel events.
  39003. */
  39004. wheelPrecision: number;
  39005. /**
  39006. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39007. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39008. */
  39009. wheelDeltaPercentage: number;
  39010. private _wheel;
  39011. private _observer;
  39012. /**
  39013. * Attach the input controls to a specific dom element to get the input from.
  39014. * @param element Defines the element the controls should be listened from
  39015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39016. */
  39017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39018. /**
  39019. * Detach the current controls from the specified dom element.
  39020. * @param element Defines the element to stop listening the inputs from
  39021. */
  39022. detachControl(element: Nullable<HTMLElement>): void;
  39023. /**
  39024. * Gets the class name of the current intput.
  39025. * @returns the class name
  39026. */
  39027. getClassName(): string;
  39028. /**
  39029. * Get the friendly name associated with the input class.
  39030. * @returns the input friendly name
  39031. */
  39032. getSimpleName(): string;
  39033. }
  39034. }
  39035. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39036. import { Nullable } from "babylonjs/types";
  39037. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39038. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39039. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39040. /**
  39041. * Manage the pointers inputs to control an follow camera.
  39042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39043. */
  39044. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39045. /**
  39046. * Defines the camera the input is attached to.
  39047. */
  39048. camera: FollowCamera;
  39049. /**
  39050. * Gets the class name of the current input.
  39051. * @returns the class name
  39052. */
  39053. getClassName(): string;
  39054. /**
  39055. * Defines the pointer angular sensibility along the X axis or how fast is
  39056. * the camera rotating.
  39057. * A negative number will reverse the axis direction.
  39058. */
  39059. angularSensibilityX: number;
  39060. /**
  39061. * Defines the pointer angular sensibility along the Y axis or how fast is
  39062. * the camera rotating.
  39063. * A negative number will reverse the axis direction.
  39064. */
  39065. angularSensibilityY: number;
  39066. /**
  39067. * Defines the pointer pinch precision or how fast is the camera zooming.
  39068. * A negative number will reverse the axis direction.
  39069. */
  39070. pinchPrecision: number;
  39071. /**
  39072. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39073. * from 0.
  39074. * It defines the percentage of current camera.radius to use as delta when
  39075. * pinch zoom is used.
  39076. */
  39077. pinchDeltaPercentage: number;
  39078. /**
  39079. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39080. */
  39081. axisXControlRadius: boolean;
  39082. /**
  39083. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39084. */
  39085. axisXControlHeight: boolean;
  39086. /**
  39087. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39088. */
  39089. axisXControlRotation: boolean;
  39090. /**
  39091. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39092. */
  39093. axisYControlRadius: boolean;
  39094. /**
  39095. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39096. */
  39097. axisYControlHeight: boolean;
  39098. /**
  39099. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39100. */
  39101. axisYControlRotation: boolean;
  39102. /**
  39103. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39104. */
  39105. axisPinchControlRadius: boolean;
  39106. /**
  39107. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39108. */
  39109. axisPinchControlHeight: boolean;
  39110. /**
  39111. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39112. */
  39113. axisPinchControlRotation: boolean;
  39114. /**
  39115. * Log error messages if basic misconfiguration has occurred.
  39116. */
  39117. warningEnable: boolean;
  39118. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39119. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39120. private _warningCounter;
  39121. private _warning;
  39122. }
  39123. }
  39124. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39125. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39126. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39127. /**
  39128. * Default Inputs manager for the FollowCamera.
  39129. * It groups all the default supported inputs for ease of use.
  39130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39131. */
  39132. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39133. /**
  39134. * Instantiates a new FollowCameraInputsManager.
  39135. * @param camera Defines the camera the inputs belong to
  39136. */
  39137. constructor(camera: FollowCamera);
  39138. /**
  39139. * Add keyboard input support to the input manager.
  39140. * @returns the current input manager
  39141. */
  39142. addKeyboard(): FollowCameraInputsManager;
  39143. /**
  39144. * Add mouse wheel input support to the input manager.
  39145. * @returns the current input manager
  39146. */
  39147. addMouseWheel(): FollowCameraInputsManager;
  39148. /**
  39149. * Add pointers input support to the input manager.
  39150. * @returns the current input manager
  39151. */
  39152. addPointers(): FollowCameraInputsManager;
  39153. /**
  39154. * Add orientation input support to the input manager.
  39155. * @returns the current input manager
  39156. */
  39157. addVRDeviceOrientation(): FollowCameraInputsManager;
  39158. }
  39159. }
  39160. declare module "babylonjs/Cameras/followCamera" {
  39161. import { Nullable } from "babylonjs/types";
  39162. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39163. import { Scene } from "babylonjs/scene";
  39164. import { Vector3 } from "babylonjs/Maths/math.vector";
  39165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39166. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39167. /**
  39168. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39169. * an arc rotate version arcFollowCamera are available.
  39170. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39171. */
  39172. export class FollowCamera extends TargetCamera {
  39173. /**
  39174. * Distance the follow camera should follow an object at
  39175. */
  39176. radius: number;
  39177. /**
  39178. * Minimum allowed distance of the camera to the axis of rotation
  39179. * (The camera can not get closer).
  39180. * This can help limiting how the Camera is able to move in the scene.
  39181. */
  39182. lowerRadiusLimit: Nullable<number>;
  39183. /**
  39184. * Maximum allowed distance of the camera to the axis of rotation
  39185. * (The camera can not get further).
  39186. * This can help limiting how the Camera is able to move in the scene.
  39187. */
  39188. upperRadiusLimit: Nullable<number>;
  39189. /**
  39190. * Define a rotation offset between the camera and the object it follows
  39191. */
  39192. rotationOffset: number;
  39193. /**
  39194. * Minimum allowed angle to camera position relative to target object.
  39195. * This can help limiting how the Camera is able to move in the scene.
  39196. */
  39197. lowerRotationOffsetLimit: Nullable<number>;
  39198. /**
  39199. * Maximum allowed angle to camera position relative to target object.
  39200. * This can help limiting how the Camera is able to move in the scene.
  39201. */
  39202. upperRotationOffsetLimit: Nullable<number>;
  39203. /**
  39204. * Define a height offset between the camera and the object it follows.
  39205. * It can help following an object from the top (like a car chaing a plane)
  39206. */
  39207. heightOffset: number;
  39208. /**
  39209. * Minimum allowed height of camera position relative to target object.
  39210. * This can help limiting how the Camera is able to move in the scene.
  39211. */
  39212. lowerHeightOffsetLimit: Nullable<number>;
  39213. /**
  39214. * Maximum allowed height of camera position relative to target object.
  39215. * This can help limiting how the Camera is able to move in the scene.
  39216. */
  39217. upperHeightOffsetLimit: Nullable<number>;
  39218. /**
  39219. * Define how fast the camera can accelerate to follow it s target.
  39220. */
  39221. cameraAcceleration: number;
  39222. /**
  39223. * Define the speed limit of the camera following an object.
  39224. */
  39225. maxCameraSpeed: number;
  39226. /**
  39227. * Define the target of the camera.
  39228. */
  39229. lockedTarget: Nullable<AbstractMesh>;
  39230. /**
  39231. * Defines the input associated with the camera.
  39232. */
  39233. inputs: FollowCameraInputsManager;
  39234. /**
  39235. * Instantiates the follow camera.
  39236. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39237. * @param name Define the name of the camera in the scene
  39238. * @param position Define the position of the camera
  39239. * @param scene Define the scene the camera belong to
  39240. * @param lockedTarget Define the target of the camera
  39241. */
  39242. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39243. private _follow;
  39244. /**
  39245. * Attached controls to the current camera.
  39246. * @param element Defines the element the controls should be listened from
  39247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39248. */
  39249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39250. /**
  39251. * Detach the current controls from the camera.
  39252. * The camera will stop reacting to inputs.
  39253. * @param element Defines the element to stop listening the inputs from
  39254. */
  39255. detachControl(element: HTMLElement): void;
  39256. /** @hidden */
  39257. _checkInputs(): void;
  39258. private _checkLimits;
  39259. /**
  39260. * Gets the camera class name.
  39261. * @returns the class name
  39262. */
  39263. getClassName(): string;
  39264. }
  39265. /**
  39266. * Arc Rotate version of the follow camera.
  39267. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39268. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39269. */
  39270. export class ArcFollowCamera extends TargetCamera {
  39271. /** The longitudinal angle of the camera */
  39272. alpha: number;
  39273. /** The latitudinal angle of the camera */
  39274. beta: number;
  39275. /** The radius of the camera from its target */
  39276. radius: number;
  39277. /** Define the camera target (the messh it should follow) */
  39278. target: Nullable<AbstractMesh>;
  39279. private _cartesianCoordinates;
  39280. /**
  39281. * Instantiates a new ArcFollowCamera
  39282. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39283. * @param name Define the name of the camera
  39284. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39285. * @param beta Define the rotation angle of the camera around the elevation axis
  39286. * @param radius Define the radius of the camera from its target point
  39287. * @param target Define the target of the camera
  39288. * @param scene Define the scene the camera belongs to
  39289. */
  39290. constructor(name: string,
  39291. /** The longitudinal angle of the camera */
  39292. alpha: number,
  39293. /** The latitudinal angle of the camera */
  39294. beta: number,
  39295. /** The radius of the camera from its target */
  39296. radius: number,
  39297. /** Define the camera target (the messh it should follow) */
  39298. target: Nullable<AbstractMesh>, scene: Scene);
  39299. private _follow;
  39300. /** @hidden */
  39301. _checkInputs(): void;
  39302. /**
  39303. * Returns the class name of the object.
  39304. * It is mostly used internally for serialization purposes.
  39305. */
  39306. getClassName(): string;
  39307. }
  39308. }
  39309. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39310. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39311. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39312. import { Nullable } from "babylonjs/types";
  39313. /**
  39314. * Manage the keyboard inputs to control the movement of a follow camera.
  39315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39316. */
  39317. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39318. /**
  39319. * Defines the camera the input is attached to.
  39320. */
  39321. camera: FollowCamera;
  39322. /**
  39323. * Defines the list of key codes associated with the up action (increase heightOffset)
  39324. */
  39325. keysHeightOffsetIncr: number[];
  39326. /**
  39327. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39328. */
  39329. keysHeightOffsetDecr: number[];
  39330. /**
  39331. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39332. */
  39333. keysHeightOffsetModifierAlt: boolean;
  39334. /**
  39335. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39336. */
  39337. keysHeightOffsetModifierCtrl: boolean;
  39338. /**
  39339. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39340. */
  39341. keysHeightOffsetModifierShift: boolean;
  39342. /**
  39343. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39344. */
  39345. keysRotationOffsetIncr: number[];
  39346. /**
  39347. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39348. */
  39349. keysRotationOffsetDecr: number[];
  39350. /**
  39351. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39352. */
  39353. keysRotationOffsetModifierAlt: boolean;
  39354. /**
  39355. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39356. */
  39357. keysRotationOffsetModifierCtrl: boolean;
  39358. /**
  39359. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39360. */
  39361. keysRotationOffsetModifierShift: boolean;
  39362. /**
  39363. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39364. */
  39365. keysRadiusIncr: number[];
  39366. /**
  39367. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39368. */
  39369. keysRadiusDecr: number[];
  39370. /**
  39371. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39372. */
  39373. keysRadiusModifierAlt: boolean;
  39374. /**
  39375. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39376. */
  39377. keysRadiusModifierCtrl: boolean;
  39378. /**
  39379. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39380. */
  39381. keysRadiusModifierShift: boolean;
  39382. /**
  39383. * Defines the rate of change of heightOffset.
  39384. */
  39385. heightSensibility: number;
  39386. /**
  39387. * Defines the rate of change of rotationOffset.
  39388. */
  39389. rotationSensibility: number;
  39390. /**
  39391. * Defines the rate of change of radius.
  39392. */
  39393. radiusSensibility: number;
  39394. private _keys;
  39395. private _ctrlPressed;
  39396. private _altPressed;
  39397. private _shiftPressed;
  39398. private _onCanvasBlurObserver;
  39399. private _onKeyboardObserver;
  39400. private _engine;
  39401. private _scene;
  39402. /**
  39403. * Attach the input controls to a specific dom element to get the input from.
  39404. * @param element Defines the element the controls should be listened from
  39405. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39406. */
  39407. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39408. /**
  39409. * Detach the current controls from the specified dom element.
  39410. * @param element Defines the element to stop listening the inputs from
  39411. */
  39412. detachControl(element: Nullable<HTMLElement>): void;
  39413. /**
  39414. * Update the current camera state depending on the inputs that have been used this frame.
  39415. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39416. */
  39417. checkInputs(): void;
  39418. /**
  39419. * Gets the class name of the current input.
  39420. * @returns the class name
  39421. */
  39422. getClassName(): string;
  39423. /**
  39424. * Get the friendly name associated with the input class.
  39425. * @returns the input friendly name
  39426. */
  39427. getSimpleName(): string;
  39428. /**
  39429. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39430. * allow modification of the heightOffset value.
  39431. */
  39432. private _modifierHeightOffset;
  39433. /**
  39434. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39435. * allow modification of the rotationOffset value.
  39436. */
  39437. private _modifierRotationOffset;
  39438. /**
  39439. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39440. * allow modification of the radius value.
  39441. */
  39442. private _modifierRadius;
  39443. }
  39444. }
  39445. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39446. import { Nullable } from "babylonjs/types";
  39447. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39448. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39449. import { Observable } from "babylonjs/Misc/observable";
  39450. module "babylonjs/Cameras/freeCameraInputsManager" {
  39451. interface FreeCameraInputsManager {
  39452. /**
  39453. * @hidden
  39454. */
  39455. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39456. /**
  39457. * Add orientation input support to the input manager.
  39458. * @returns the current input manager
  39459. */
  39460. addDeviceOrientation(): FreeCameraInputsManager;
  39461. }
  39462. }
  39463. /**
  39464. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39465. * Screen rotation is taken into account.
  39466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39467. */
  39468. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39469. private _camera;
  39470. private _screenOrientationAngle;
  39471. private _constantTranform;
  39472. private _screenQuaternion;
  39473. private _alpha;
  39474. private _beta;
  39475. private _gamma;
  39476. /**
  39477. * Can be used to detect if a device orientation sensor is availible on a device
  39478. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39479. * @returns a promise that will resolve on orientation change
  39480. */
  39481. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39482. /**
  39483. * @hidden
  39484. */
  39485. _onDeviceOrientationChangedObservable: Observable<void>;
  39486. /**
  39487. * Instantiates a new input
  39488. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39489. */
  39490. constructor();
  39491. /**
  39492. * Define the camera controlled by the input.
  39493. */
  39494. camera: FreeCamera;
  39495. /**
  39496. * Attach the input controls to a specific dom element to get the input from.
  39497. * @param element Defines the element the controls should be listened from
  39498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39499. */
  39500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39501. private _orientationChanged;
  39502. private _deviceOrientation;
  39503. /**
  39504. * Detach the current controls from the specified dom element.
  39505. * @param element Defines the element to stop listening the inputs from
  39506. */
  39507. detachControl(element: Nullable<HTMLElement>): void;
  39508. /**
  39509. * Update the current camera state depending on the inputs that have been used this frame.
  39510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39511. */
  39512. checkInputs(): void;
  39513. /**
  39514. * Gets the class name of the current intput.
  39515. * @returns the class name
  39516. */
  39517. getClassName(): string;
  39518. /**
  39519. * Get the friendly name associated with the input class.
  39520. * @returns the input friendly name
  39521. */
  39522. getSimpleName(): string;
  39523. }
  39524. }
  39525. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39526. import { Nullable } from "babylonjs/types";
  39527. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39528. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39529. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39530. /**
  39531. * Manage the gamepad inputs to control a free camera.
  39532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39533. */
  39534. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39535. /**
  39536. * Define the camera the input is attached to.
  39537. */
  39538. camera: FreeCamera;
  39539. /**
  39540. * Define the Gamepad controlling the input
  39541. */
  39542. gamepad: Nullable<Gamepad>;
  39543. /**
  39544. * Defines the gamepad rotation sensiblity.
  39545. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39546. */
  39547. gamepadAngularSensibility: number;
  39548. /**
  39549. * Defines the gamepad move sensiblity.
  39550. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39551. */
  39552. gamepadMoveSensibility: number;
  39553. private _yAxisScale;
  39554. /**
  39555. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39556. */
  39557. invertYAxis: boolean;
  39558. private _onGamepadConnectedObserver;
  39559. private _onGamepadDisconnectedObserver;
  39560. private _cameraTransform;
  39561. private _deltaTransform;
  39562. private _vector3;
  39563. private _vector2;
  39564. /**
  39565. * Attach the input controls to a specific dom element to get the input from.
  39566. * @param element Defines the element the controls should be listened from
  39567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39568. */
  39569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39570. /**
  39571. * Detach the current controls from the specified dom element.
  39572. * @param element Defines the element to stop listening the inputs from
  39573. */
  39574. detachControl(element: Nullable<HTMLElement>): void;
  39575. /**
  39576. * Update the current camera state depending on the inputs that have been used this frame.
  39577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39578. */
  39579. checkInputs(): void;
  39580. /**
  39581. * Gets the class name of the current intput.
  39582. * @returns the class name
  39583. */
  39584. getClassName(): string;
  39585. /**
  39586. * Get the friendly name associated with the input class.
  39587. * @returns the input friendly name
  39588. */
  39589. getSimpleName(): string;
  39590. }
  39591. }
  39592. declare module "babylonjs/Misc/virtualJoystick" {
  39593. import { Nullable } from "babylonjs/types";
  39594. import { Vector3 } from "babylonjs/Maths/math.vector";
  39595. /**
  39596. * Defines the potential axis of a Joystick
  39597. */
  39598. export enum JoystickAxis {
  39599. /** X axis */
  39600. X = 0,
  39601. /** Y axis */
  39602. Y = 1,
  39603. /** Z axis */
  39604. Z = 2
  39605. }
  39606. /**
  39607. * Class used to define virtual joystick (used in touch mode)
  39608. */
  39609. export class VirtualJoystick {
  39610. /**
  39611. * Gets or sets a boolean indicating that left and right values must be inverted
  39612. */
  39613. reverseLeftRight: boolean;
  39614. /**
  39615. * Gets or sets a boolean indicating that up and down values must be inverted
  39616. */
  39617. reverseUpDown: boolean;
  39618. /**
  39619. * Gets the offset value for the position (ie. the change of the position value)
  39620. */
  39621. deltaPosition: Vector3;
  39622. /**
  39623. * Gets a boolean indicating if the virtual joystick was pressed
  39624. */
  39625. pressed: boolean;
  39626. /**
  39627. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39628. */
  39629. static Canvas: Nullable<HTMLCanvasElement>;
  39630. private static _globalJoystickIndex;
  39631. private static vjCanvasContext;
  39632. private static vjCanvasWidth;
  39633. private static vjCanvasHeight;
  39634. private static halfWidth;
  39635. private _action;
  39636. private _axisTargetedByLeftAndRight;
  39637. private _axisTargetedByUpAndDown;
  39638. private _joystickSensibility;
  39639. private _inversedSensibility;
  39640. private _joystickPointerID;
  39641. private _joystickColor;
  39642. private _joystickPointerPos;
  39643. private _joystickPreviousPointerPos;
  39644. private _joystickPointerStartPos;
  39645. private _deltaJoystickVector;
  39646. private _leftJoystick;
  39647. private _touches;
  39648. private _onPointerDownHandlerRef;
  39649. private _onPointerMoveHandlerRef;
  39650. private _onPointerUpHandlerRef;
  39651. private _onResize;
  39652. /**
  39653. * Creates a new virtual joystick
  39654. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39655. */
  39656. constructor(leftJoystick?: boolean);
  39657. /**
  39658. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39659. * @param newJoystickSensibility defines the new sensibility
  39660. */
  39661. setJoystickSensibility(newJoystickSensibility: number): void;
  39662. private _onPointerDown;
  39663. private _onPointerMove;
  39664. private _onPointerUp;
  39665. /**
  39666. * Change the color of the virtual joystick
  39667. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39668. */
  39669. setJoystickColor(newColor: string): void;
  39670. /**
  39671. * Defines a callback to call when the joystick is touched
  39672. * @param action defines the callback
  39673. */
  39674. setActionOnTouch(action: () => any): void;
  39675. /**
  39676. * Defines which axis you'd like to control for left & right
  39677. * @param axis defines the axis to use
  39678. */
  39679. setAxisForLeftRight(axis: JoystickAxis): void;
  39680. /**
  39681. * Defines which axis you'd like to control for up & down
  39682. * @param axis defines the axis to use
  39683. */
  39684. setAxisForUpDown(axis: JoystickAxis): void;
  39685. private _drawVirtualJoystick;
  39686. /**
  39687. * Release internal HTML canvas
  39688. */
  39689. releaseCanvas(): void;
  39690. }
  39691. }
  39692. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39693. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39694. import { Nullable } from "babylonjs/types";
  39695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39697. module "babylonjs/Cameras/freeCameraInputsManager" {
  39698. interface FreeCameraInputsManager {
  39699. /**
  39700. * Add virtual joystick input support to the input manager.
  39701. * @returns the current input manager
  39702. */
  39703. addVirtualJoystick(): FreeCameraInputsManager;
  39704. }
  39705. }
  39706. /**
  39707. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39709. */
  39710. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39711. /**
  39712. * Defines the camera the input is attached to.
  39713. */
  39714. camera: FreeCamera;
  39715. private _leftjoystick;
  39716. private _rightjoystick;
  39717. /**
  39718. * Gets the left stick of the virtual joystick.
  39719. * @returns The virtual Joystick
  39720. */
  39721. getLeftJoystick(): VirtualJoystick;
  39722. /**
  39723. * Gets the right stick of the virtual joystick.
  39724. * @returns The virtual Joystick
  39725. */
  39726. getRightJoystick(): VirtualJoystick;
  39727. /**
  39728. * Update the current camera state depending on the inputs that have been used this frame.
  39729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39730. */
  39731. checkInputs(): void;
  39732. /**
  39733. * Attach the input controls to a specific dom element to get the input from.
  39734. * @param element Defines the element the controls should be listened from
  39735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39736. */
  39737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39738. /**
  39739. * Detach the current controls from the specified dom element.
  39740. * @param element Defines the element to stop listening the inputs from
  39741. */
  39742. detachControl(element: Nullable<HTMLElement>): void;
  39743. /**
  39744. * Gets the class name of the current intput.
  39745. * @returns the class name
  39746. */
  39747. getClassName(): string;
  39748. /**
  39749. * Get the friendly name associated with the input class.
  39750. * @returns the input friendly name
  39751. */
  39752. getSimpleName(): string;
  39753. }
  39754. }
  39755. declare module "babylonjs/Cameras/Inputs/index" {
  39756. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39757. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39758. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39759. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39760. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39761. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39762. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39763. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39764. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39765. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39766. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39767. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39768. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39769. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39770. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39771. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39772. }
  39773. declare module "babylonjs/Cameras/touchCamera" {
  39774. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39775. import { Scene } from "babylonjs/scene";
  39776. import { Vector3 } from "babylonjs/Maths/math.vector";
  39777. /**
  39778. * This represents a FPS type of camera controlled by touch.
  39779. * This is like a universal camera minus the Gamepad controls.
  39780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39781. */
  39782. export class TouchCamera extends FreeCamera {
  39783. /**
  39784. * Defines the touch sensibility for rotation.
  39785. * The higher the faster.
  39786. */
  39787. touchAngularSensibility: number;
  39788. /**
  39789. * Defines the touch sensibility for move.
  39790. * The higher the faster.
  39791. */
  39792. touchMoveSensibility: number;
  39793. /**
  39794. * Instantiates a new touch camera.
  39795. * This represents a FPS type of camera controlled by touch.
  39796. * This is like a universal camera minus the Gamepad controls.
  39797. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39798. * @param name Define the name of the camera in the scene
  39799. * @param position Define the start position of the camera in the scene
  39800. * @param scene Define the scene the camera belongs to
  39801. */
  39802. constructor(name: string, position: Vector3, scene: Scene);
  39803. /**
  39804. * Gets the current object class name.
  39805. * @return the class name
  39806. */
  39807. getClassName(): string;
  39808. /** @hidden */
  39809. _setupInputs(): void;
  39810. }
  39811. }
  39812. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39814. import { Scene } from "babylonjs/scene";
  39815. import { Vector3 } from "babylonjs/Maths/math.vector";
  39816. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39817. import { Axis } from "babylonjs/Maths/math.axis";
  39818. /**
  39819. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39820. * being tilted forward or back and left or right.
  39821. */
  39822. export class DeviceOrientationCamera extends FreeCamera {
  39823. private _initialQuaternion;
  39824. private _quaternionCache;
  39825. private _tmpDragQuaternion;
  39826. private _disablePointerInputWhenUsingDeviceOrientation;
  39827. /**
  39828. * Creates a new device orientation camera
  39829. * @param name The name of the camera
  39830. * @param position The start position camera
  39831. * @param scene The scene the camera belongs to
  39832. */
  39833. constructor(name: string, position: Vector3, scene: Scene);
  39834. /**
  39835. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39836. */
  39837. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39838. private _dragFactor;
  39839. /**
  39840. * Enabled turning on the y axis when the orientation sensor is active
  39841. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39842. */
  39843. enableHorizontalDragging(dragFactor?: number): void;
  39844. /**
  39845. * Gets the current instance class name ("DeviceOrientationCamera").
  39846. * This helps avoiding instanceof at run time.
  39847. * @returns the class name
  39848. */
  39849. getClassName(): string;
  39850. /**
  39851. * @hidden
  39852. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39853. */
  39854. _checkInputs(): void;
  39855. /**
  39856. * Reset the camera to its default orientation on the specified axis only.
  39857. * @param axis The axis to reset
  39858. */
  39859. resetToCurrentRotation(axis?: Axis): void;
  39860. }
  39861. }
  39862. declare module "babylonjs/Gamepads/xboxGamepad" {
  39863. import { Observable } from "babylonjs/Misc/observable";
  39864. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39865. /**
  39866. * Defines supported buttons for XBox360 compatible gamepads
  39867. */
  39868. export enum Xbox360Button {
  39869. /** A */
  39870. A = 0,
  39871. /** B */
  39872. B = 1,
  39873. /** X */
  39874. X = 2,
  39875. /** Y */
  39876. Y = 3,
  39877. /** Start */
  39878. Start = 4,
  39879. /** Back */
  39880. Back = 5,
  39881. /** Left button */
  39882. LB = 6,
  39883. /** Right button */
  39884. RB = 7,
  39885. /** Left stick */
  39886. LeftStick = 8,
  39887. /** Right stick */
  39888. RightStick = 9
  39889. }
  39890. /** Defines values for XBox360 DPad */
  39891. export enum Xbox360Dpad {
  39892. /** Up */
  39893. Up = 0,
  39894. /** Down */
  39895. Down = 1,
  39896. /** Left */
  39897. Left = 2,
  39898. /** Right */
  39899. Right = 3
  39900. }
  39901. /**
  39902. * Defines a XBox360 gamepad
  39903. */
  39904. export class Xbox360Pad extends Gamepad {
  39905. private _leftTrigger;
  39906. private _rightTrigger;
  39907. private _onlefttriggerchanged;
  39908. private _onrighttriggerchanged;
  39909. private _onbuttondown;
  39910. private _onbuttonup;
  39911. private _ondpaddown;
  39912. private _ondpadup;
  39913. /** Observable raised when a button is pressed */
  39914. onButtonDownObservable: Observable<Xbox360Button>;
  39915. /** Observable raised when a button is released */
  39916. onButtonUpObservable: Observable<Xbox360Button>;
  39917. /** Observable raised when a pad is pressed */
  39918. onPadDownObservable: Observable<Xbox360Dpad>;
  39919. /** Observable raised when a pad is released */
  39920. onPadUpObservable: Observable<Xbox360Dpad>;
  39921. private _buttonA;
  39922. private _buttonB;
  39923. private _buttonX;
  39924. private _buttonY;
  39925. private _buttonBack;
  39926. private _buttonStart;
  39927. private _buttonLB;
  39928. private _buttonRB;
  39929. private _buttonLeftStick;
  39930. private _buttonRightStick;
  39931. private _dPadUp;
  39932. private _dPadDown;
  39933. private _dPadLeft;
  39934. private _dPadRight;
  39935. private _isXboxOnePad;
  39936. /**
  39937. * Creates a new XBox360 gamepad object
  39938. * @param id defines the id of this gamepad
  39939. * @param index defines its index
  39940. * @param gamepad defines the internal HTML gamepad object
  39941. * @param xboxOne defines if it is a XBox One gamepad
  39942. */
  39943. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39944. /**
  39945. * Defines the callback to call when left trigger is pressed
  39946. * @param callback defines the callback to use
  39947. */
  39948. onlefttriggerchanged(callback: (value: number) => void): void;
  39949. /**
  39950. * Defines the callback to call when right trigger is pressed
  39951. * @param callback defines the callback to use
  39952. */
  39953. onrighttriggerchanged(callback: (value: number) => void): void;
  39954. /**
  39955. * Gets the left trigger value
  39956. */
  39957. /**
  39958. * Sets the left trigger value
  39959. */
  39960. leftTrigger: number;
  39961. /**
  39962. * Gets the right trigger value
  39963. */
  39964. /**
  39965. * Sets the right trigger value
  39966. */
  39967. rightTrigger: number;
  39968. /**
  39969. * Defines the callback to call when a button is pressed
  39970. * @param callback defines the callback to use
  39971. */
  39972. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39973. /**
  39974. * Defines the callback to call when a button is released
  39975. * @param callback defines the callback to use
  39976. */
  39977. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39978. /**
  39979. * Defines the callback to call when a pad is pressed
  39980. * @param callback defines the callback to use
  39981. */
  39982. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39983. /**
  39984. * Defines the callback to call when a pad is released
  39985. * @param callback defines the callback to use
  39986. */
  39987. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39988. private _setButtonValue;
  39989. private _setDPadValue;
  39990. /**
  39991. * Gets the value of the `A` button
  39992. */
  39993. /**
  39994. * Sets the value of the `A` button
  39995. */
  39996. buttonA: number;
  39997. /**
  39998. * Gets the value of the `B` button
  39999. */
  40000. /**
  40001. * Sets the value of the `B` button
  40002. */
  40003. buttonB: number;
  40004. /**
  40005. * Gets the value of the `X` button
  40006. */
  40007. /**
  40008. * Sets the value of the `X` button
  40009. */
  40010. buttonX: number;
  40011. /**
  40012. * Gets the value of the `Y` button
  40013. */
  40014. /**
  40015. * Sets the value of the `Y` button
  40016. */
  40017. buttonY: number;
  40018. /**
  40019. * Gets the value of the `Start` button
  40020. */
  40021. /**
  40022. * Sets the value of the `Start` button
  40023. */
  40024. buttonStart: number;
  40025. /**
  40026. * Gets the value of the `Back` button
  40027. */
  40028. /**
  40029. * Sets the value of the `Back` button
  40030. */
  40031. buttonBack: number;
  40032. /**
  40033. * Gets the value of the `Left` button
  40034. */
  40035. /**
  40036. * Sets the value of the `Left` button
  40037. */
  40038. buttonLB: number;
  40039. /**
  40040. * Gets the value of the `Right` button
  40041. */
  40042. /**
  40043. * Sets the value of the `Right` button
  40044. */
  40045. buttonRB: number;
  40046. /**
  40047. * Gets the value of the Left joystick
  40048. */
  40049. /**
  40050. * Sets the value of the Left joystick
  40051. */
  40052. buttonLeftStick: number;
  40053. /**
  40054. * Gets the value of the Right joystick
  40055. */
  40056. /**
  40057. * Sets the value of the Right joystick
  40058. */
  40059. buttonRightStick: number;
  40060. /**
  40061. * Gets the value of D-pad up
  40062. */
  40063. /**
  40064. * Sets the value of D-pad up
  40065. */
  40066. dPadUp: number;
  40067. /**
  40068. * Gets the value of D-pad down
  40069. */
  40070. /**
  40071. * Sets the value of D-pad down
  40072. */
  40073. dPadDown: number;
  40074. /**
  40075. * Gets the value of D-pad left
  40076. */
  40077. /**
  40078. * Sets the value of D-pad left
  40079. */
  40080. dPadLeft: number;
  40081. /**
  40082. * Gets the value of D-pad right
  40083. */
  40084. /**
  40085. * Sets the value of D-pad right
  40086. */
  40087. dPadRight: number;
  40088. /**
  40089. * Force the gamepad to synchronize with device values
  40090. */
  40091. update(): void;
  40092. /**
  40093. * Disposes the gamepad
  40094. */
  40095. dispose(): void;
  40096. }
  40097. }
  40098. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40099. import { Observable } from "babylonjs/Misc/observable";
  40100. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40101. /**
  40102. * Defines supported buttons for DualShock compatible gamepads
  40103. */
  40104. export enum DualShockButton {
  40105. /** Cross */
  40106. Cross = 0,
  40107. /** Circle */
  40108. Circle = 1,
  40109. /** Square */
  40110. Square = 2,
  40111. /** Triangle */
  40112. Triangle = 3,
  40113. /** Options */
  40114. Options = 4,
  40115. /** Share */
  40116. Share = 5,
  40117. /** L1 */
  40118. L1 = 6,
  40119. /** R1 */
  40120. R1 = 7,
  40121. /** Left stick */
  40122. LeftStick = 8,
  40123. /** Right stick */
  40124. RightStick = 9
  40125. }
  40126. /** Defines values for DualShock DPad */
  40127. export enum DualShockDpad {
  40128. /** Up */
  40129. Up = 0,
  40130. /** Down */
  40131. Down = 1,
  40132. /** Left */
  40133. Left = 2,
  40134. /** Right */
  40135. Right = 3
  40136. }
  40137. /**
  40138. * Defines a DualShock gamepad
  40139. */
  40140. export class DualShockPad extends Gamepad {
  40141. private _leftTrigger;
  40142. private _rightTrigger;
  40143. private _onlefttriggerchanged;
  40144. private _onrighttriggerchanged;
  40145. private _onbuttondown;
  40146. private _onbuttonup;
  40147. private _ondpaddown;
  40148. private _ondpadup;
  40149. /** Observable raised when a button is pressed */
  40150. onButtonDownObservable: Observable<DualShockButton>;
  40151. /** Observable raised when a button is released */
  40152. onButtonUpObservable: Observable<DualShockButton>;
  40153. /** Observable raised when a pad is pressed */
  40154. onPadDownObservable: Observable<DualShockDpad>;
  40155. /** Observable raised when a pad is released */
  40156. onPadUpObservable: Observable<DualShockDpad>;
  40157. private _buttonCross;
  40158. private _buttonCircle;
  40159. private _buttonSquare;
  40160. private _buttonTriangle;
  40161. private _buttonShare;
  40162. private _buttonOptions;
  40163. private _buttonL1;
  40164. private _buttonR1;
  40165. private _buttonLeftStick;
  40166. private _buttonRightStick;
  40167. private _dPadUp;
  40168. private _dPadDown;
  40169. private _dPadLeft;
  40170. private _dPadRight;
  40171. /**
  40172. * Creates a new DualShock gamepad object
  40173. * @param id defines the id of this gamepad
  40174. * @param index defines its index
  40175. * @param gamepad defines the internal HTML gamepad object
  40176. */
  40177. constructor(id: string, index: number, gamepad: any);
  40178. /**
  40179. * Defines the callback to call when left trigger is pressed
  40180. * @param callback defines the callback to use
  40181. */
  40182. onlefttriggerchanged(callback: (value: number) => void): void;
  40183. /**
  40184. * Defines the callback to call when right trigger is pressed
  40185. * @param callback defines the callback to use
  40186. */
  40187. onrighttriggerchanged(callback: (value: number) => void): void;
  40188. /**
  40189. * Gets the left trigger value
  40190. */
  40191. /**
  40192. * Sets the left trigger value
  40193. */
  40194. leftTrigger: number;
  40195. /**
  40196. * Gets the right trigger value
  40197. */
  40198. /**
  40199. * Sets the right trigger value
  40200. */
  40201. rightTrigger: number;
  40202. /**
  40203. * Defines the callback to call when a button is pressed
  40204. * @param callback defines the callback to use
  40205. */
  40206. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40207. /**
  40208. * Defines the callback to call when a button is released
  40209. * @param callback defines the callback to use
  40210. */
  40211. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40212. /**
  40213. * Defines the callback to call when a pad is pressed
  40214. * @param callback defines the callback to use
  40215. */
  40216. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40217. /**
  40218. * Defines the callback to call when a pad is released
  40219. * @param callback defines the callback to use
  40220. */
  40221. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40222. private _setButtonValue;
  40223. private _setDPadValue;
  40224. /**
  40225. * Gets the value of the `Cross` button
  40226. */
  40227. /**
  40228. * Sets the value of the `Cross` button
  40229. */
  40230. buttonCross: number;
  40231. /**
  40232. * Gets the value of the `Circle` button
  40233. */
  40234. /**
  40235. * Sets the value of the `Circle` button
  40236. */
  40237. buttonCircle: number;
  40238. /**
  40239. * Gets the value of the `Square` button
  40240. */
  40241. /**
  40242. * Sets the value of the `Square` button
  40243. */
  40244. buttonSquare: number;
  40245. /**
  40246. * Gets the value of the `Triangle` button
  40247. */
  40248. /**
  40249. * Sets the value of the `Triangle` button
  40250. */
  40251. buttonTriangle: number;
  40252. /**
  40253. * Gets the value of the `Options` button
  40254. */
  40255. /**
  40256. * Sets the value of the `Options` button
  40257. */
  40258. buttonOptions: number;
  40259. /**
  40260. * Gets the value of the `Share` button
  40261. */
  40262. /**
  40263. * Sets the value of the `Share` button
  40264. */
  40265. buttonShare: number;
  40266. /**
  40267. * Gets the value of the `L1` button
  40268. */
  40269. /**
  40270. * Sets the value of the `L1` button
  40271. */
  40272. buttonL1: number;
  40273. /**
  40274. * Gets the value of the `R1` button
  40275. */
  40276. /**
  40277. * Sets the value of the `R1` button
  40278. */
  40279. buttonR1: number;
  40280. /**
  40281. * Gets the value of the Left joystick
  40282. */
  40283. /**
  40284. * Sets the value of the Left joystick
  40285. */
  40286. buttonLeftStick: number;
  40287. /**
  40288. * Gets the value of the Right joystick
  40289. */
  40290. /**
  40291. * Sets the value of the Right joystick
  40292. */
  40293. buttonRightStick: number;
  40294. /**
  40295. * Gets the value of D-pad up
  40296. */
  40297. /**
  40298. * Sets the value of D-pad up
  40299. */
  40300. dPadUp: number;
  40301. /**
  40302. * Gets the value of D-pad down
  40303. */
  40304. /**
  40305. * Sets the value of D-pad down
  40306. */
  40307. dPadDown: number;
  40308. /**
  40309. * Gets the value of D-pad left
  40310. */
  40311. /**
  40312. * Sets the value of D-pad left
  40313. */
  40314. dPadLeft: number;
  40315. /**
  40316. * Gets the value of D-pad right
  40317. */
  40318. /**
  40319. * Sets the value of D-pad right
  40320. */
  40321. dPadRight: number;
  40322. /**
  40323. * Force the gamepad to synchronize with device values
  40324. */
  40325. update(): void;
  40326. /**
  40327. * Disposes the gamepad
  40328. */
  40329. dispose(): void;
  40330. }
  40331. }
  40332. declare module "babylonjs/Gamepads/gamepadManager" {
  40333. import { Observable } from "babylonjs/Misc/observable";
  40334. import { Nullable } from "babylonjs/types";
  40335. import { Scene } from "babylonjs/scene";
  40336. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40337. /**
  40338. * Manager for handling gamepads
  40339. */
  40340. export class GamepadManager {
  40341. private _scene?;
  40342. private _babylonGamepads;
  40343. private _oneGamepadConnected;
  40344. /** @hidden */
  40345. _isMonitoring: boolean;
  40346. private _gamepadEventSupported;
  40347. private _gamepadSupport;
  40348. /**
  40349. * observable to be triggered when the gamepad controller has been connected
  40350. */
  40351. onGamepadConnectedObservable: Observable<Gamepad>;
  40352. /**
  40353. * observable to be triggered when the gamepad controller has been disconnected
  40354. */
  40355. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40356. private _onGamepadConnectedEvent;
  40357. private _onGamepadDisconnectedEvent;
  40358. /**
  40359. * Initializes the gamepad manager
  40360. * @param _scene BabylonJS scene
  40361. */
  40362. constructor(_scene?: Scene | undefined);
  40363. /**
  40364. * The gamepads in the game pad manager
  40365. */
  40366. readonly gamepads: Gamepad[];
  40367. /**
  40368. * Get the gamepad controllers based on type
  40369. * @param type The type of gamepad controller
  40370. * @returns Nullable gamepad
  40371. */
  40372. getGamepadByType(type?: number): Nullable<Gamepad>;
  40373. /**
  40374. * Disposes the gamepad manager
  40375. */
  40376. dispose(): void;
  40377. private _addNewGamepad;
  40378. private _startMonitoringGamepads;
  40379. private _stopMonitoringGamepads;
  40380. /** @hidden */
  40381. _checkGamepadsStatus(): void;
  40382. private _updateGamepadObjects;
  40383. }
  40384. }
  40385. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40386. import { Nullable } from "babylonjs/types";
  40387. import { Scene } from "babylonjs/scene";
  40388. import { ISceneComponent } from "babylonjs/sceneComponent";
  40389. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40390. module "babylonjs/scene" {
  40391. interface Scene {
  40392. /** @hidden */
  40393. _gamepadManager: Nullable<GamepadManager>;
  40394. /**
  40395. * Gets the gamepad manager associated with the scene
  40396. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40397. */
  40398. gamepadManager: GamepadManager;
  40399. }
  40400. }
  40401. module "babylonjs/Cameras/freeCameraInputsManager" {
  40402. /**
  40403. * Interface representing a free camera inputs manager
  40404. */
  40405. interface FreeCameraInputsManager {
  40406. /**
  40407. * Adds gamepad input support to the FreeCameraInputsManager.
  40408. * @returns the FreeCameraInputsManager
  40409. */
  40410. addGamepad(): FreeCameraInputsManager;
  40411. }
  40412. }
  40413. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40414. /**
  40415. * Interface representing an arc rotate camera inputs manager
  40416. */
  40417. interface ArcRotateCameraInputsManager {
  40418. /**
  40419. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40420. * @returns the camera inputs manager
  40421. */
  40422. addGamepad(): ArcRotateCameraInputsManager;
  40423. }
  40424. }
  40425. /**
  40426. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40427. */
  40428. export class GamepadSystemSceneComponent implements ISceneComponent {
  40429. /**
  40430. * The component name helpfull to identify the component in the list of scene components.
  40431. */
  40432. readonly name: string;
  40433. /**
  40434. * The scene the component belongs to.
  40435. */
  40436. scene: Scene;
  40437. /**
  40438. * Creates a new instance of the component for the given scene
  40439. * @param scene Defines the scene to register the component in
  40440. */
  40441. constructor(scene: Scene);
  40442. /**
  40443. * Registers the component in a given scene
  40444. */
  40445. register(): void;
  40446. /**
  40447. * Rebuilds the elements related to this component in case of
  40448. * context lost for instance.
  40449. */
  40450. rebuild(): void;
  40451. /**
  40452. * Disposes the component and the associated ressources
  40453. */
  40454. dispose(): void;
  40455. private _beforeCameraUpdate;
  40456. }
  40457. }
  40458. declare module "babylonjs/Cameras/universalCamera" {
  40459. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40460. import { Scene } from "babylonjs/scene";
  40461. import { Vector3 } from "babylonjs/Maths/math.vector";
  40462. import "babylonjs/Gamepads/gamepadSceneComponent";
  40463. /**
  40464. * 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,
  40465. * which still works and will still be found in many Playgrounds.
  40466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40467. */
  40468. export class UniversalCamera extends TouchCamera {
  40469. /**
  40470. * Defines the gamepad rotation sensiblity.
  40471. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40472. */
  40473. gamepadAngularSensibility: number;
  40474. /**
  40475. * Defines the gamepad move sensiblity.
  40476. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40477. */
  40478. gamepadMoveSensibility: number;
  40479. /**
  40480. * 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,
  40481. * which still works and will still be found in many Playgrounds.
  40482. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40483. * @param name Define the name of the camera in the scene
  40484. * @param position Define the start position of the camera in the scene
  40485. * @param scene Define the scene the camera belongs to
  40486. */
  40487. constructor(name: string, position: Vector3, scene: Scene);
  40488. /**
  40489. * Gets the current object class name.
  40490. * @return the class name
  40491. */
  40492. getClassName(): string;
  40493. }
  40494. }
  40495. declare module "babylonjs/Cameras/gamepadCamera" {
  40496. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40497. import { Scene } from "babylonjs/scene";
  40498. import { Vector3 } from "babylonjs/Maths/math.vector";
  40499. /**
  40500. * This represents a FPS type of camera. This is only here for back compat purpose.
  40501. * Please use the UniversalCamera instead as both are identical.
  40502. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40503. */
  40504. export class GamepadCamera extends UniversalCamera {
  40505. /**
  40506. * Instantiates a new Gamepad Camera
  40507. * This represents a FPS type of camera. This is only here for back compat purpose.
  40508. * Please use the UniversalCamera instead as both are identical.
  40509. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40510. * @param name Define the name of the camera in the scene
  40511. * @param position Define the start position of the camera in the scene
  40512. * @param scene Define the scene the camera belongs to
  40513. */
  40514. constructor(name: string, position: Vector3, scene: Scene);
  40515. /**
  40516. * Gets the current object class name.
  40517. * @return the class name
  40518. */
  40519. getClassName(): string;
  40520. }
  40521. }
  40522. declare module "babylonjs/Shaders/pass.fragment" {
  40523. /** @hidden */
  40524. export var passPixelShader: {
  40525. name: string;
  40526. shader: string;
  40527. };
  40528. }
  40529. declare module "babylonjs/Shaders/passCube.fragment" {
  40530. /** @hidden */
  40531. export var passCubePixelShader: {
  40532. name: string;
  40533. shader: string;
  40534. };
  40535. }
  40536. declare module "babylonjs/PostProcesses/passPostProcess" {
  40537. import { Nullable } from "babylonjs/types";
  40538. import { Camera } from "babylonjs/Cameras/camera";
  40539. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40540. import { Engine } from "babylonjs/Engines/engine";
  40541. import "babylonjs/Shaders/pass.fragment";
  40542. import "babylonjs/Shaders/passCube.fragment";
  40543. /**
  40544. * PassPostProcess which produces an output the same as it's input
  40545. */
  40546. export class PassPostProcess extends PostProcess {
  40547. /**
  40548. * Creates the PassPostProcess
  40549. * @param name The name of the effect.
  40550. * @param options The required width/height ratio to downsize to before computing the render pass.
  40551. * @param camera The camera to apply the render pass to.
  40552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40553. * @param engine The engine which the post process will be applied. (default: current engine)
  40554. * @param reusable If the post process can be reused on the same frame. (default: false)
  40555. * @param textureType The type of texture to be used when performing the post processing.
  40556. * @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)
  40557. */
  40558. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40559. }
  40560. /**
  40561. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40562. */
  40563. export class PassCubePostProcess extends PostProcess {
  40564. private _face;
  40565. /**
  40566. * Gets or sets the cube face to display.
  40567. * * 0 is +X
  40568. * * 1 is -X
  40569. * * 2 is +Y
  40570. * * 3 is -Y
  40571. * * 4 is +Z
  40572. * * 5 is -Z
  40573. */
  40574. face: number;
  40575. /**
  40576. * Creates the PassCubePostProcess
  40577. * @param name The name of the effect.
  40578. * @param options The required width/height ratio to downsize to before computing the render pass.
  40579. * @param camera The camera to apply the render pass to.
  40580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40581. * @param engine The engine which the post process will be applied. (default: current engine)
  40582. * @param reusable If the post process can be reused on the same frame. (default: false)
  40583. * @param textureType The type of texture to be used when performing the post processing.
  40584. * @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)
  40585. */
  40586. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40587. }
  40588. }
  40589. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40590. /** @hidden */
  40591. export var anaglyphPixelShader: {
  40592. name: string;
  40593. shader: string;
  40594. };
  40595. }
  40596. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40597. import { Engine } from "babylonjs/Engines/engine";
  40598. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40599. import { Camera } from "babylonjs/Cameras/camera";
  40600. import "babylonjs/Shaders/anaglyph.fragment";
  40601. /**
  40602. * Postprocess used to generate anaglyphic rendering
  40603. */
  40604. export class AnaglyphPostProcess extends PostProcess {
  40605. private _passedProcess;
  40606. /**
  40607. * Creates a new AnaglyphPostProcess
  40608. * @param name defines postprocess name
  40609. * @param options defines creation options or target ratio scale
  40610. * @param rigCameras defines cameras using this postprocess
  40611. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40612. * @param engine defines hosting engine
  40613. * @param reusable defines if the postprocess will be reused multiple times per frame
  40614. */
  40615. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40616. }
  40617. }
  40618. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40619. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40620. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40621. import { Scene } from "babylonjs/scene";
  40622. import { Vector3 } from "babylonjs/Maths/math.vector";
  40623. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40624. /**
  40625. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40626. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40627. */
  40628. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40629. /**
  40630. * Creates a new AnaglyphArcRotateCamera
  40631. * @param name defines camera name
  40632. * @param alpha defines alpha angle (in radians)
  40633. * @param beta defines beta angle (in radians)
  40634. * @param radius defines radius
  40635. * @param target defines camera target
  40636. * @param interaxialDistance defines distance between each color axis
  40637. * @param scene defines the hosting scene
  40638. */
  40639. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40640. /**
  40641. * Gets camera class name
  40642. * @returns AnaglyphArcRotateCamera
  40643. */
  40644. getClassName(): string;
  40645. }
  40646. }
  40647. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40648. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40649. import { Scene } from "babylonjs/scene";
  40650. import { Vector3 } from "babylonjs/Maths/math.vector";
  40651. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40652. /**
  40653. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40654. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40655. */
  40656. export class AnaglyphFreeCamera extends FreeCamera {
  40657. /**
  40658. * Creates a new AnaglyphFreeCamera
  40659. * @param name defines camera name
  40660. * @param position defines initial position
  40661. * @param interaxialDistance defines distance between each color axis
  40662. * @param scene defines the hosting scene
  40663. */
  40664. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40665. /**
  40666. * Gets camera class name
  40667. * @returns AnaglyphFreeCamera
  40668. */
  40669. getClassName(): string;
  40670. }
  40671. }
  40672. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40673. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40674. import { Scene } from "babylonjs/scene";
  40675. import { Vector3 } from "babylonjs/Maths/math.vector";
  40676. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40677. /**
  40678. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40679. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40680. */
  40681. export class AnaglyphGamepadCamera extends GamepadCamera {
  40682. /**
  40683. * Creates a new AnaglyphGamepadCamera
  40684. * @param name defines camera name
  40685. * @param position defines initial position
  40686. * @param interaxialDistance defines distance between each color axis
  40687. * @param scene defines the hosting scene
  40688. */
  40689. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40690. /**
  40691. * Gets camera class name
  40692. * @returns AnaglyphGamepadCamera
  40693. */
  40694. getClassName(): string;
  40695. }
  40696. }
  40697. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40698. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40699. import { Scene } from "babylonjs/scene";
  40700. import { Vector3 } from "babylonjs/Maths/math.vector";
  40701. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40702. /**
  40703. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40704. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40705. */
  40706. export class AnaglyphUniversalCamera extends UniversalCamera {
  40707. /**
  40708. * Creates a new AnaglyphUniversalCamera
  40709. * @param name defines camera name
  40710. * @param position defines initial position
  40711. * @param interaxialDistance defines distance between each color axis
  40712. * @param scene defines the hosting scene
  40713. */
  40714. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40715. /**
  40716. * Gets camera class name
  40717. * @returns AnaglyphUniversalCamera
  40718. */
  40719. getClassName(): string;
  40720. }
  40721. }
  40722. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40723. /** @hidden */
  40724. export var stereoscopicInterlacePixelShader: {
  40725. name: string;
  40726. shader: string;
  40727. };
  40728. }
  40729. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40730. import { Camera } from "babylonjs/Cameras/camera";
  40731. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40732. import { Engine } from "babylonjs/Engines/engine";
  40733. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40734. /**
  40735. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40736. */
  40737. export class StereoscopicInterlacePostProcess extends PostProcess {
  40738. private _stepSize;
  40739. private _passedProcess;
  40740. /**
  40741. * Initializes a StereoscopicInterlacePostProcess
  40742. * @param name The name of the effect.
  40743. * @param rigCameras The rig cameras to be appled to the post process
  40744. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40746. * @param engine The engine which the post process will be applied. (default: current engine)
  40747. * @param reusable If the post process can be reused on the same frame. (default: false)
  40748. */
  40749. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40750. }
  40751. }
  40752. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40753. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40754. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40755. import { Scene } from "babylonjs/scene";
  40756. import { Vector3 } from "babylonjs/Maths/math.vector";
  40757. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40758. /**
  40759. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40760. * @see http://doc.babylonjs.com/features/cameras
  40761. */
  40762. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40763. /**
  40764. * Creates a new StereoscopicArcRotateCamera
  40765. * @param name defines camera name
  40766. * @param alpha defines alpha angle (in radians)
  40767. * @param beta defines beta angle (in radians)
  40768. * @param radius defines radius
  40769. * @param target defines camera target
  40770. * @param interaxialDistance defines distance between each color axis
  40771. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40772. * @param scene defines the hosting scene
  40773. */
  40774. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40775. /**
  40776. * Gets camera class name
  40777. * @returns StereoscopicArcRotateCamera
  40778. */
  40779. getClassName(): string;
  40780. }
  40781. }
  40782. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40783. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40784. import { Scene } from "babylonjs/scene";
  40785. import { Vector3 } from "babylonjs/Maths/math.vector";
  40786. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40787. /**
  40788. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40789. * @see http://doc.babylonjs.com/features/cameras
  40790. */
  40791. export class StereoscopicFreeCamera extends FreeCamera {
  40792. /**
  40793. * Creates a new StereoscopicFreeCamera
  40794. * @param name defines camera name
  40795. * @param position defines initial position
  40796. * @param interaxialDistance defines distance between each color axis
  40797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40798. * @param scene defines the hosting scene
  40799. */
  40800. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40801. /**
  40802. * Gets camera class name
  40803. * @returns StereoscopicFreeCamera
  40804. */
  40805. getClassName(): string;
  40806. }
  40807. }
  40808. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40809. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40810. import { Scene } from "babylonjs/scene";
  40811. import { Vector3 } from "babylonjs/Maths/math.vector";
  40812. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40813. /**
  40814. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40815. * @see http://doc.babylonjs.com/features/cameras
  40816. */
  40817. export class StereoscopicGamepadCamera extends GamepadCamera {
  40818. /**
  40819. * Creates a new StereoscopicGamepadCamera
  40820. * @param name defines camera name
  40821. * @param position defines initial position
  40822. * @param interaxialDistance defines distance between each color axis
  40823. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40824. * @param scene defines the hosting scene
  40825. */
  40826. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40827. /**
  40828. * Gets camera class name
  40829. * @returns StereoscopicGamepadCamera
  40830. */
  40831. getClassName(): string;
  40832. }
  40833. }
  40834. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40835. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40836. import { Scene } from "babylonjs/scene";
  40837. import { Vector3 } from "babylonjs/Maths/math.vector";
  40838. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40839. /**
  40840. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40841. * @see http://doc.babylonjs.com/features/cameras
  40842. */
  40843. export class StereoscopicUniversalCamera extends UniversalCamera {
  40844. /**
  40845. * Creates a new StereoscopicUniversalCamera
  40846. * @param name defines camera name
  40847. * @param position defines initial position
  40848. * @param interaxialDistance defines distance between each color axis
  40849. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40850. * @param scene defines the hosting scene
  40851. */
  40852. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40853. /**
  40854. * Gets camera class name
  40855. * @returns StereoscopicUniversalCamera
  40856. */
  40857. getClassName(): string;
  40858. }
  40859. }
  40860. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40861. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40862. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40863. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40864. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40865. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40866. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40867. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40868. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40869. }
  40870. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40871. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40872. import { Scene } from "babylonjs/scene";
  40873. import { Vector3 } from "babylonjs/Maths/math.vector";
  40874. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40875. /**
  40876. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40877. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40878. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40879. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40880. */
  40881. export class VirtualJoysticksCamera extends FreeCamera {
  40882. /**
  40883. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40884. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40885. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40886. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40887. * @param name Define the name of the camera in the scene
  40888. * @param position Define the start position of the camera in the scene
  40889. * @param scene Define the scene the camera belongs to
  40890. */
  40891. constructor(name: string, position: Vector3, scene: Scene);
  40892. /**
  40893. * Gets the current object class name.
  40894. * @return the class name
  40895. */
  40896. getClassName(): string;
  40897. }
  40898. }
  40899. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40900. import { Matrix } from "babylonjs/Maths/math.vector";
  40901. /**
  40902. * This represents all the required metrics to create a VR camera.
  40903. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40904. */
  40905. export class VRCameraMetrics {
  40906. /**
  40907. * Define the horizontal resolution off the screen.
  40908. */
  40909. hResolution: number;
  40910. /**
  40911. * Define the vertical resolution off the screen.
  40912. */
  40913. vResolution: number;
  40914. /**
  40915. * Define the horizontal screen size.
  40916. */
  40917. hScreenSize: number;
  40918. /**
  40919. * Define the vertical screen size.
  40920. */
  40921. vScreenSize: number;
  40922. /**
  40923. * Define the vertical screen center position.
  40924. */
  40925. vScreenCenter: number;
  40926. /**
  40927. * Define the distance of the eyes to the screen.
  40928. */
  40929. eyeToScreenDistance: number;
  40930. /**
  40931. * Define the distance between both lenses
  40932. */
  40933. lensSeparationDistance: number;
  40934. /**
  40935. * Define the distance between both viewer's eyes.
  40936. */
  40937. interpupillaryDistance: number;
  40938. /**
  40939. * Define the distortion factor of the VR postprocess.
  40940. * Please, touch with care.
  40941. */
  40942. distortionK: number[];
  40943. /**
  40944. * Define the chromatic aberration correction factors for the VR post process.
  40945. */
  40946. chromaAbCorrection: number[];
  40947. /**
  40948. * Define the scale factor of the post process.
  40949. * The smaller the better but the slower.
  40950. */
  40951. postProcessScaleFactor: number;
  40952. /**
  40953. * Define an offset for the lens center.
  40954. */
  40955. lensCenterOffset: number;
  40956. /**
  40957. * Define if the current vr camera should compensate the distortion of the lense or not.
  40958. */
  40959. compensateDistortion: boolean;
  40960. /**
  40961. * Defines if multiview should be enabled when rendering (Default: false)
  40962. */
  40963. multiviewEnabled: boolean;
  40964. /**
  40965. * Gets the rendering aspect ratio based on the provided resolutions.
  40966. */
  40967. readonly aspectRatio: number;
  40968. /**
  40969. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40970. */
  40971. readonly aspectRatioFov: number;
  40972. /**
  40973. * @hidden
  40974. */
  40975. readonly leftHMatrix: Matrix;
  40976. /**
  40977. * @hidden
  40978. */
  40979. readonly rightHMatrix: Matrix;
  40980. /**
  40981. * @hidden
  40982. */
  40983. readonly leftPreViewMatrix: Matrix;
  40984. /**
  40985. * @hidden
  40986. */
  40987. readonly rightPreViewMatrix: Matrix;
  40988. /**
  40989. * Get the default VRMetrics based on the most generic setup.
  40990. * @returns the default vr metrics
  40991. */
  40992. static GetDefault(): VRCameraMetrics;
  40993. }
  40994. }
  40995. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40996. /** @hidden */
  40997. export var vrDistortionCorrectionPixelShader: {
  40998. name: string;
  40999. shader: string;
  41000. };
  41001. }
  41002. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41003. import { Camera } from "babylonjs/Cameras/camera";
  41004. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41005. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41006. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41007. /**
  41008. * VRDistortionCorrectionPostProcess used for mobile VR
  41009. */
  41010. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41011. private _isRightEye;
  41012. private _distortionFactors;
  41013. private _postProcessScaleFactor;
  41014. private _lensCenterOffset;
  41015. private _scaleIn;
  41016. private _scaleFactor;
  41017. private _lensCenter;
  41018. /**
  41019. * Initializes the VRDistortionCorrectionPostProcess
  41020. * @param name The name of the effect.
  41021. * @param camera The camera to apply the render pass to.
  41022. * @param isRightEye If this is for the right eye distortion
  41023. * @param vrMetrics All the required metrics for the VR camera
  41024. */
  41025. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41026. }
  41027. }
  41028. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41029. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41030. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41031. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41032. import { Scene } from "babylonjs/scene";
  41033. import { Vector3 } from "babylonjs/Maths/math.vector";
  41034. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41035. import "babylonjs/Cameras/RigModes/vrRigMode";
  41036. /**
  41037. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41038. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41039. */
  41040. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41041. /**
  41042. * Creates a new VRDeviceOrientationArcRotateCamera
  41043. * @param name defines camera name
  41044. * @param alpha defines the camera rotation along the logitudinal axis
  41045. * @param beta defines the camera rotation along the latitudinal axis
  41046. * @param radius defines the camera distance from its target
  41047. * @param target defines the camera target
  41048. * @param scene defines the scene the camera belongs to
  41049. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41050. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41051. */
  41052. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41053. /**
  41054. * Gets camera class name
  41055. * @returns VRDeviceOrientationArcRotateCamera
  41056. */
  41057. getClassName(): string;
  41058. }
  41059. }
  41060. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41061. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41062. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41063. import { Scene } from "babylonjs/scene";
  41064. import { Vector3 } from "babylonjs/Maths/math.vector";
  41065. import "babylonjs/Cameras/RigModes/vrRigMode";
  41066. /**
  41067. * Camera used to simulate VR rendering (based on FreeCamera)
  41068. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41069. */
  41070. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41071. /**
  41072. * Creates a new VRDeviceOrientationFreeCamera
  41073. * @param name defines camera name
  41074. * @param position defines the start position of the camera
  41075. * @param scene defines the scene the camera belongs to
  41076. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41077. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41078. */
  41079. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41080. /**
  41081. * Gets camera class name
  41082. * @returns VRDeviceOrientationFreeCamera
  41083. */
  41084. getClassName(): string;
  41085. }
  41086. }
  41087. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41088. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41089. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41090. import { Scene } from "babylonjs/scene";
  41091. import { Vector3 } from "babylonjs/Maths/math.vector";
  41092. import "babylonjs/Gamepads/gamepadSceneComponent";
  41093. /**
  41094. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41095. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41096. */
  41097. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41098. /**
  41099. * Creates a new VRDeviceOrientationGamepadCamera
  41100. * @param name defines camera name
  41101. * @param position defines the start position of the camera
  41102. * @param scene defines the scene the camera belongs to
  41103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41105. */
  41106. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41107. /**
  41108. * Gets camera class name
  41109. * @returns VRDeviceOrientationGamepadCamera
  41110. */
  41111. getClassName(): string;
  41112. }
  41113. }
  41114. declare module "babylonjs/Materials/pushMaterial" {
  41115. import { Nullable } from "babylonjs/types";
  41116. import { Scene } from "babylonjs/scene";
  41117. import { Matrix } from "babylonjs/Maths/math.vector";
  41118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41119. import { Mesh } from "babylonjs/Meshes/mesh";
  41120. import { Material } from "babylonjs/Materials/material";
  41121. import { Effect } from "babylonjs/Materials/effect";
  41122. /**
  41123. * Base class of materials working in push mode in babylon JS
  41124. * @hidden
  41125. */
  41126. export class PushMaterial extends Material {
  41127. protected _activeEffect: Effect;
  41128. protected _normalMatrix: Matrix;
  41129. /**
  41130. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41131. * This means that the material can keep using a previous shader while a new one is being compiled.
  41132. * This is mostly used when shader parallel compilation is supported (true by default)
  41133. */
  41134. allowShaderHotSwapping: boolean;
  41135. constructor(name: string, scene: Scene);
  41136. getEffect(): Effect;
  41137. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41138. /**
  41139. * Binds the given world matrix to the active effect
  41140. *
  41141. * @param world the matrix to bind
  41142. */
  41143. bindOnlyWorldMatrix(world: Matrix): void;
  41144. /**
  41145. * Binds the given normal matrix to the active effect
  41146. *
  41147. * @param normalMatrix the matrix to bind
  41148. */
  41149. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41150. bind(world: Matrix, mesh?: Mesh): void;
  41151. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41152. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41153. }
  41154. }
  41155. declare module "babylonjs/Materials/materialFlags" {
  41156. /**
  41157. * This groups all the flags used to control the materials channel.
  41158. */
  41159. export class MaterialFlags {
  41160. private static _DiffuseTextureEnabled;
  41161. /**
  41162. * Are diffuse textures enabled in the application.
  41163. */
  41164. static DiffuseTextureEnabled: boolean;
  41165. private static _AmbientTextureEnabled;
  41166. /**
  41167. * Are ambient textures enabled in the application.
  41168. */
  41169. static AmbientTextureEnabled: boolean;
  41170. private static _OpacityTextureEnabled;
  41171. /**
  41172. * Are opacity textures enabled in the application.
  41173. */
  41174. static OpacityTextureEnabled: boolean;
  41175. private static _ReflectionTextureEnabled;
  41176. /**
  41177. * Are reflection textures enabled in the application.
  41178. */
  41179. static ReflectionTextureEnabled: boolean;
  41180. private static _EmissiveTextureEnabled;
  41181. /**
  41182. * Are emissive textures enabled in the application.
  41183. */
  41184. static EmissiveTextureEnabled: boolean;
  41185. private static _SpecularTextureEnabled;
  41186. /**
  41187. * Are specular textures enabled in the application.
  41188. */
  41189. static SpecularTextureEnabled: boolean;
  41190. private static _BumpTextureEnabled;
  41191. /**
  41192. * Are bump textures enabled in the application.
  41193. */
  41194. static BumpTextureEnabled: boolean;
  41195. private static _LightmapTextureEnabled;
  41196. /**
  41197. * Are lightmap textures enabled in the application.
  41198. */
  41199. static LightmapTextureEnabled: boolean;
  41200. private static _RefractionTextureEnabled;
  41201. /**
  41202. * Are refraction textures enabled in the application.
  41203. */
  41204. static RefractionTextureEnabled: boolean;
  41205. private static _ColorGradingTextureEnabled;
  41206. /**
  41207. * Are color grading textures enabled in the application.
  41208. */
  41209. static ColorGradingTextureEnabled: boolean;
  41210. private static _FresnelEnabled;
  41211. /**
  41212. * Are fresnels enabled in the application.
  41213. */
  41214. static FresnelEnabled: boolean;
  41215. private static _ClearCoatTextureEnabled;
  41216. /**
  41217. * Are clear coat textures enabled in the application.
  41218. */
  41219. static ClearCoatTextureEnabled: boolean;
  41220. private static _ClearCoatBumpTextureEnabled;
  41221. /**
  41222. * Are clear coat bump textures enabled in the application.
  41223. */
  41224. static ClearCoatBumpTextureEnabled: boolean;
  41225. private static _ClearCoatTintTextureEnabled;
  41226. /**
  41227. * Are clear coat tint textures enabled in the application.
  41228. */
  41229. static ClearCoatTintTextureEnabled: boolean;
  41230. private static _SheenTextureEnabled;
  41231. /**
  41232. * Are sheen textures enabled in the application.
  41233. */
  41234. static SheenTextureEnabled: boolean;
  41235. private static _AnisotropicTextureEnabled;
  41236. /**
  41237. * Are anisotropic textures enabled in the application.
  41238. */
  41239. static AnisotropicTextureEnabled: boolean;
  41240. private static _ThicknessTextureEnabled;
  41241. /**
  41242. * Are thickness textures enabled in the application.
  41243. */
  41244. static ThicknessTextureEnabled: boolean;
  41245. }
  41246. }
  41247. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41248. /** @hidden */
  41249. export var defaultFragmentDeclaration: {
  41250. name: string;
  41251. shader: string;
  41252. };
  41253. }
  41254. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41255. /** @hidden */
  41256. export var defaultUboDeclaration: {
  41257. name: string;
  41258. shader: string;
  41259. };
  41260. }
  41261. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41262. /** @hidden */
  41263. export var lightFragmentDeclaration: {
  41264. name: string;
  41265. shader: string;
  41266. };
  41267. }
  41268. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41269. /** @hidden */
  41270. export var lightUboDeclaration: {
  41271. name: string;
  41272. shader: string;
  41273. };
  41274. }
  41275. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41276. /** @hidden */
  41277. export var lightsFragmentFunctions: {
  41278. name: string;
  41279. shader: string;
  41280. };
  41281. }
  41282. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41283. /** @hidden */
  41284. export var shadowsFragmentFunctions: {
  41285. name: string;
  41286. shader: string;
  41287. };
  41288. }
  41289. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41290. /** @hidden */
  41291. export var fresnelFunction: {
  41292. name: string;
  41293. shader: string;
  41294. };
  41295. }
  41296. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41297. /** @hidden */
  41298. export var reflectionFunction: {
  41299. name: string;
  41300. shader: string;
  41301. };
  41302. }
  41303. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41304. /** @hidden */
  41305. export var bumpFragmentFunctions: {
  41306. name: string;
  41307. shader: string;
  41308. };
  41309. }
  41310. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41311. /** @hidden */
  41312. export var logDepthDeclaration: {
  41313. name: string;
  41314. shader: string;
  41315. };
  41316. }
  41317. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41318. /** @hidden */
  41319. export var bumpFragment: {
  41320. name: string;
  41321. shader: string;
  41322. };
  41323. }
  41324. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41325. /** @hidden */
  41326. export var depthPrePass: {
  41327. name: string;
  41328. shader: string;
  41329. };
  41330. }
  41331. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41332. /** @hidden */
  41333. export var lightFragment: {
  41334. name: string;
  41335. shader: string;
  41336. };
  41337. }
  41338. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41339. /** @hidden */
  41340. export var logDepthFragment: {
  41341. name: string;
  41342. shader: string;
  41343. };
  41344. }
  41345. declare module "babylonjs/Shaders/default.fragment" {
  41346. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41347. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41348. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41349. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41350. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41351. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41352. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41353. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41354. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41355. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41356. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41357. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41359. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41360. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41361. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41362. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41363. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41364. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41365. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41366. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41367. /** @hidden */
  41368. export var defaultPixelShader: {
  41369. name: string;
  41370. shader: string;
  41371. };
  41372. }
  41373. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41374. /** @hidden */
  41375. export var defaultVertexDeclaration: {
  41376. name: string;
  41377. shader: string;
  41378. };
  41379. }
  41380. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41381. /** @hidden */
  41382. export var bumpVertexDeclaration: {
  41383. name: string;
  41384. shader: string;
  41385. };
  41386. }
  41387. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41388. /** @hidden */
  41389. export var bumpVertex: {
  41390. name: string;
  41391. shader: string;
  41392. };
  41393. }
  41394. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41395. /** @hidden */
  41396. export var fogVertex: {
  41397. name: string;
  41398. shader: string;
  41399. };
  41400. }
  41401. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41402. /** @hidden */
  41403. export var shadowsVertex: {
  41404. name: string;
  41405. shader: string;
  41406. };
  41407. }
  41408. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41409. /** @hidden */
  41410. export var pointCloudVertex: {
  41411. name: string;
  41412. shader: string;
  41413. };
  41414. }
  41415. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41416. /** @hidden */
  41417. export var logDepthVertex: {
  41418. name: string;
  41419. shader: string;
  41420. };
  41421. }
  41422. declare module "babylonjs/Shaders/default.vertex" {
  41423. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41424. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41426. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41428. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41429. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41430. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41431. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41434. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41437. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41438. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41439. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41440. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41441. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41442. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41443. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41444. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41445. /** @hidden */
  41446. export var defaultVertexShader: {
  41447. name: string;
  41448. shader: string;
  41449. };
  41450. }
  41451. declare module "babylonjs/Materials/standardMaterial" {
  41452. import { SmartArray } from "babylonjs/Misc/smartArray";
  41453. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41454. import { Nullable } from "babylonjs/types";
  41455. import { Scene } from "babylonjs/scene";
  41456. import { Matrix } from "babylonjs/Maths/math.vector";
  41457. import { Color3 } from "babylonjs/Maths/math.color";
  41458. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41460. import { Mesh } from "babylonjs/Meshes/mesh";
  41461. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41462. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41463. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41464. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41465. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41468. import "babylonjs/Shaders/default.fragment";
  41469. import "babylonjs/Shaders/default.vertex";
  41470. /** @hidden */
  41471. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41472. MAINUV1: boolean;
  41473. MAINUV2: boolean;
  41474. DIFFUSE: boolean;
  41475. DIFFUSEDIRECTUV: number;
  41476. AMBIENT: boolean;
  41477. AMBIENTDIRECTUV: number;
  41478. OPACITY: boolean;
  41479. OPACITYDIRECTUV: number;
  41480. OPACITYRGB: boolean;
  41481. REFLECTION: boolean;
  41482. EMISSIVE: boolean;
  41483. EMISSIVEDIRECTUV: number;
  41484. SPECULAR: boolean;
  41485. SPECULARDIRECTUV: number;
  41486. BUMP: boolean;
  41487. BUMPDIRECTUV: number;
  41488. PARALLAX: boolean;
  41489. PARALLAXOCCLUSION: boolean;
  41490. SPECULAROVERALPHA: boolean;
  41491. CLIPPLANE: boolean;
  41492. CLIPPLANE2: boolean;
  41493. CLIPPLANE3: boolean;
  41494. CLIPPLANE4: boolean;
  41495. ALPHATEST: boolean;
  41496. DEPTHPREPASS: boolean;
  41497. ALPHAFROMDIFFUSE: boolean;
  41498. POINTSIZE: boolean;
  41499. FOG: boolean;
  41500. SPECULARTERM: boolean;
  41501. DIFFUSEFRESNEL: boolean;
  41502. OPACITYFRESNEL: boolean;
  41503. REFLECTIONFRESNEL: boolean;
  41504. REFRACTIONFRESNEL: boolean;
  41505. EMISSIVEFRESNEL: boolean;
  41506. FRESNEL: boolean;
  41507. NORMAL: boolean;
  41508. UV1: boolean;
  41509. UV2: boolean;
  41510. VERTEXCOLOR: boolean;
  41511. VERTEXALPHA: boolean;
  41512. NUM_BONE_INFLUENCERS: number;
  41513. BonesPerMesh: number;
  41514. BONETEXTURE: boolean;
  41515. INSTANCES: boolean;
  41516. GLOSSINESS: boolean;
  41517. ROUGHNESS: boolean;
  41518. EMISSIVEASILLUMINATION: boolean;
  41519. LINKEMISSIVEWITHDIFFUSE: boolean;
  41520. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41521. LIGHTMAP: boolean;
  41522. LIGHTMAPDIRECTUV: number;
  41523. OBJECTSPACE_NORMALMAP: boolean;
  41524. USELIGHTMAPASSHADOWMAP: boolean;
  41525. REFLECTIONMAP_3D: boolean;
  41526. REFLECTIONMAP_SPHERICAL: boolean;
  41527. REFLECTIONMAP_PLANAR: boolean;
  41528. REFLECTIONMAP_CUBIC: boolean;
  41529. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41530. REFLECTIONMAP_PROJECTION: boolean;
  41531. REFLECTIONMAP_SKYBOX: boolean;
  41532. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41533. REFLECTIONMAP_EXPLICIT: boolean;
  41534. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41535. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41536. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41537. INVERTCUBICMAP: boolean;
  41538. LOGARITHMICDEPTH: boolean;
  41539. REFRACTION: boolean;
  41540. REFRACTIONMAP_3D: boolean;
  41541. REFLECTIONOVERALPHA: boolean;
  41542. TWOSIDEDLIGHTING: boolean;
  41543. SHADOWFLOAT: boolean;
  41544. MORPHTARGETS: boolean;
  41545. MORPHTARGETS_NORMAL: boolean;
  41546. MORPHTARGETS_TANGENT: boolean;
  41547. MORPHTARGETS_UV: boolean;
  41548. NUM_MORPH_INFLUENCERS: number;
  41549. NONUNIFORMSCALING: boolean;
  41550. PREMULTIPLYALPHA: boolean;
  41551. IMAGEPROCESSING: boolean;
  41552. VIGNETTE: boolean;
  41553. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41554. VIGNETTEBLENDMODEOPAQUE: boolean;
  41555. TONEMAPPING: boolean;
  41556. TONEMAPPING_ACES: boolean;
  41557. CONTRAST: boolean;
  41558. COLORCURVES: boolean;
  41559. COLORGRADING: boolean;
  41560. COLORGRADING3D: boolean;
  41561. SAMPLER3DGREENDEPTH: boolean;
  41562. SAMPLER3DBGRMAP: boolean;
  41563. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41564. MULTIVIEW: boolean;
  41565. /**
  41566. * If the reflection texture on this material is in linear color space
  41567. * @hidden
  41568. */
  41569. IS_REFLECTION_LINEAR: boolean;
  41570. /**
  41571. * If the refraction texture on this material is in linear color space
  41572. * @hidden
  41573. */
  41574. IS_REFRACTION_LINEAR: boolean;
  41575. EXPOSURE: boolean;
  41576. constructor();
  41577. setReflectionMode(modeToEnable: string): void;
  41578. }
  41579. /**
  41580. * This is the default material used in Babylon. It is the best trade off between quality
  41581. * and performances.
  41582. * @see http://doc.babylonjs.com/babylon101/materials
  41583. */
  41584. export class StandardMaterial extends PushMaterial {
  41585. private _diffuseTexture;
  41586. /**
  41587. * The basic texture of the material as viewed under a light.
  41588. */
  41589. diffuseTexture: Nullable<BaseTexture>;
  41590. private _ambientTexture;
  41591. /**
  41592. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41593. */
  41594. ambientTexture: Nullable<BaseTexture>;
  41595. private _opacityTexture;
  41596. /**
  41597. * Define the transparency of the material from a texture.
  41598. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41599. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41600. */
  41601. opacityTexture: Nullable<BaseTexture>;
  41602. private _reflectionTexture;
  41603. /**
  41604. * Define the texture used to display the reflection.
  41605. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41606. */
  41607. reflectionTexture: Nullable<BaseTexture>;
  41608. private _emissiveTexture;
  41609. /**
  41610. * Define texture of the material as if self lit.
  41611. * This will be mixed in the final result even in the absence of light.
  41612. */
  41613. emissiveTexture: Nullable<BaseTexture>;
  41614. private _specularTexture;
  41615. /**
  41616. * Define how the color and intensity of the highlight given by the light in the material.
  41617. */
  41618. specularTexture: Nullable<BaseTexture>;
  41619. private _bumpTexture;
  41620. /**
  41621. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41622. * 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.
  41623. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41624. */
  41625. bumpTexture: Nullable<BaseTexture>;
  41626. private _lightmapTexture;
  41627. /**
  41628. * Complex lighting can be computationally expensive to compute at runtime.
  41629. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41630. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41631. */
  41632. lightmapTexture: Nullable<BaseTexture>;
  41633. private _refractionTexture;
  41634. /**
  41635. * Define the texture used to display the refraction.
  41636. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41637. */
  41638. refractionTexture: Nullable<BaseTexture>;
  41639. /**
  41640. * The color of the material lit by the environmental background lighting.
  41641. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41642. */
  41643. ambientColor: Color3;
  41644. /**
  41645. * The basic color of the material as viewed under a light.
  41646. */
  41647. diffuseColor: Color3;
  41648. /**
  41649. * Define how the color and intensity of the highlight given by the light in the material.
  41650. */
  41651. specularColor: Color3;
  41652. /**
  41653. * Define the color of the material as if self lit.
  41654. * This will be mixed in the final result even in the absence of light.
  41655. */
  41656. emissiveColor: Color3;
  41657. /**
  41658. * Defines how sharp are the highlights in the material.
  41659. * The bigger the value the sharper giving a more glossy feeling to the result.
  41660. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41661. */
  41662. specularPower: number;
  41663. private _useAlphaFromDiffuseTexture;
  41664. /**
  41665. * Does the transparency come from the diffuse texture alpha channel.
  41666. */
  41667. useAlphaFromDiffuseTexture: boolean;
  41668. private _useEmissiveAsIllumination;
  41669. /**
  41670. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41671. */
  41672. useEmissiveAsIllumination: boolean;
  41673. private _linkEmissiveWithDiffuse;
  41674. /**
  41675. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41676. * the emissive level when the final color is close to one.
  41677. */
  41678. linkEmissiveWithDiffuse: boolean;
  41679. private _useSpecularOverAlpha;
  41680. /**
  41681. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41682. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41683. */
  41684. useSpecularOverAlpha: boolean;
  41685. private _useReflectionOverAlpha;
  41686. /**
  41687. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41688. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41689. */
  41690. useReflectionOverAlpha: boolean;
  41691. private _disableLighting;
  41692. /**
  41693. * Does lights from the scene impacts this material.
  41694. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41695. */
  41696. disableLighting: boolean;
  41697. private _useObjectSpaceNormalMap;
  41698. /**
  41699. * Allows using an object space normal map (instead of tangent space).
  41700. */
  41701. useObjectSpaceNormalMap: boolean;
  41702. private _useParallax;
  41703. /**
  41704. * Is parallax enabled or not.
  41705. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41706. */
  41707. useParallax: boolean;
  41708. private _useParallaxOcclusion;
  41709. /**
  41710. * Is parallax occlusion enabled or not.
  41711. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41712. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41713. */
  41714. useParallaxOcclusion: boolean;
  41715. /**
  41716. * 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.
  41717. */
  41718. parallaxScaleBias: number;
  41719. private _roughness;
  41720. /**
  41721. * Helps to define how blurry the reflections should appears in the material.
  41722. */
  41723. roughness: number;
  41724. /**
  41725. * In case of refraction, define the value of the index of refraction.
  41726. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41727. */
  41728. indexOfRefraction: number;
  41729. /**
  41730. * Invert the refraction texture alongside the y axis.
  41731. * It can be useful with procedural textures or probe for instance.
  41732. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41733. */
  41734. invertRefractionY: boolean;
  41735. /**
  41736. * Defines the alpha limits in alpha test mode.
  41737. */
  41738. alphaCutOff: number;
  41739. private _useLightmapAsShadowmap;
  41740. /**
  41741. * In case of light mapping, define whether the map contains light or shadow informations.
  41742. */
  41743. useLightmapAsShadowmap: boolean;
  41744. private _diffuseFresnelParameters;
  41745. /**
  41746. * Define the diffuse fresnel parameters of the material.
  41747. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41748. */
  41749. diffuseFresnelParameters: FresnelParameters;
  41750. private _opacityFresnelParameters;
  41751. /**
  41752. * Define the opacity fresnel parameters of the material.
  41753. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41754. */
  41755. opacityFresnelParameters: FresnelParameters;
  41756. private _reflectionFresnelParameters;
  41757. /**
  41758. * Define the reflection fresnel parameters of the material.
  41759. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41760. */
  41761. reflectionFresnelParameters: FresnelParameters;
  41762. private _refractionFresnelParameters;
  41763. /**
  41764. * Define the refraction fresnel parameters of the material.
  41765. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41766. */
  41767. refractionFresnelParameters: FresnelParameters;
  41768. private _emissiveFresnelParameters;
  41769. /**
  41770. * Define the emissive fresnel parameters of the material.
  41771. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41772. */
  41773. emissiveFresnelParameters: FresnelParameters;
  41774. private _useReflectionFresnelFromSpecular;
  41775. /**
  41776. * If true automatically deducts the fresnels values from the material specularity.
  41777. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41778. */
  41779. useReflectionFresnelFromSpecular: boolean;
  41780. private _useGlossinessFromSpecularMapAlpha;
  41781. /**
  41782. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41783. */
  41784. useGlossinessFromSpecularMapAlpha: boolean;
  41785. private _maxSimultaneousLights;
  41786. /**
  41787. * Defines the maximum number of lights that can be used in the material
  41788. */
  41789. maxSimultaneousLights: number;
  41790. private _invertNormalMapX;
  41791. /**
  41792. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41793. */
  41794. invertNormalMapX: boolean;
  41795. private _invertNormalMapY;
  41796. /**
  41797. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41798. */
  41799. invertNormalMapY: boolean;
  41800. private _twoSidedLighting;
  41801. /**
  41802. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41803. */
  41804. twoSidedLighting: boolean;
  41805. /**
  41806. * Default configuration related to image processing available in the standard Material.
  41807. */
  41808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41809. /**
  41810. * Gets the image processing configuration used either in this material.
  41811. */
  41812. /**
  41813. * Sets the Default image processing configuration used either in the this material.
  41814. *
  41815. * If sets to null, the scene one is in use.
  41816. */
  41817. imageProcessingConfiguration: ImageProcessingConfiguration;
  41818. /**
  41819. * Keep track of the image processing observer to allow dispose and replace.
  41820. */
  41821. private _imageProcessingObserver;
  41822. /**
  41823. * Attaches a new image processing configuration to the Standard Material.
  41824. * @param configuration
  41825. */
  41826. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41827. /**
  41828. * Gets wether the color curves effect is enabled.
  41829. */
  41830. /**
  41831. * Sets wether the color curves effect is enabled.
  41832. */
  41833. cameraColorCurvesEnabled: boolean;
  41834. /**
  41835. * Gets wether the color grading effect is enabled.
  41836. */
  41837. /**
  41838. * Gets wether the color grading effect is enabled.
  41839. */
  41840. cameraColorGradingEnabled: boolean;
  41841. /**
  41842. * Gets wether tonemapping is enabled or not.
  41843. */
  41844. /**
  41845. * Sets wether tonemapping is enabled or not
  41846. */
  41847. cameraToneMappingEnabled: boolean;
  41848. /**
  41849. * The camera exposure used on this material.
  41850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41851. * This corresponds to a photographic exposure.
  41852. */
  41853. /**
  41854. * The camera exposure used on this material.
  41855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41856. * This corresponds to a photographic exposure.
  41857. */
  41858. cameraExposure: number;
  41859. /**
  41860. * Gets The camera contrast used on this material.
  41861. */
  41862. /**
  41863. * Sets The camera contrast used on this material.
  41864. */
  41865. cameraContrast: number;
  41866. /**
  41867. * Gets the Color Grading 2D Lookup Texture.
  41868. */
  41869. /**
  41870. * Sets the Color Grading 2D Lookup Texture.
  41871. */
  41872. cameraColorGradingTexture: Nullable<BaseTexture>;
  41873. /**
  41874. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41875. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41876. * 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;
  41877. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41878. */
  41879. /**
  41880. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41881. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41882. * 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;
  41883. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41884. */
  41885. cameraColorCurves: Nullable<ColorCurves>;
  41886. /**
  41887. * Custom callback helping to override the default shader used in the material.
  41888. */
  41889. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41890. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41891. protected _worldViewProjectionMatrix: Matrix;
  41892. protected _globalAmbientColor: Color3;
  41893. protected _useLogarithmicDepth: boolean;
  41894. protected _rebuildInParallel: boolean;
  41895. /**
  41896. * Instantiates a new standard material.
  41897. * This is the default material used in Babylon. It is the best trade off between quality
  41898. * and performances.
  41899. * @see http://doc.babylonjs.com/babylon101/materials
  41900. * @param name Define the name of the material in the scene
  41901. * @param scene Define the scene the material belong to
  41902. */
  41903. constructor(name: string, scene: Scene);
  41904. /**
  41905. * Gets a boolean indicating that current material needs to register RTT
  41906. */
  41907. readonly hasRenderTargetTextures: boolean;
  41908. /**
  41909. * Gets the current class name of the material e.g. "StandardMaterial"
  41910. * Mainly use in serialization.
  41911. * @returns the class name
  41912. */
  41913. getClassName(): string;
  41914. /**
  41915. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41916. * You can try switching to logarithmic depth.
  41917. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41918. */
  41919. useLogarithmicDepth: boolean;
  41920. /**
  41921. * Specifies if the material will require alpha blending
  41922. * @returns a boolean specifying if alpha blending is needed
  41923. */
  41924. needAlphaBlending(): boolean;
  41925. /**
  41926. * Specifies if this material should be rendered in alpha test mode
  41927. * @returns a boolean specifying if an alpha test is needed.
  41928. */
  41929. needAlphaTesting(): boolean;
  41930. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41931. /**
  41932. * Get the texture used for alpha test purpose.
  41933. * @returns the diffuse texture in case of the standard material.
  41934. */
  41935. getAlphaTestTexture(): Nullable<BaseTexture>;
  41936. /**
  41937. * Get if the submesh is ready to be used and all its information available.
  41938. * Child classes can use it to update shaders
  41939. * @param mesh defines the mesh to check
  41940. * @param subMesh defines which submesh to check
  41941. * @param useInstances specifies that instances should be used
  41942. * @returns a boolean indicating that the submesh is ready or not
  41943. */
  41944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41945. /**
  41946. * Builds the material UBO layouts.
  41947. * Used internally during the effect preparation.
  41948. */
  41949. buildUniformLayout(): void;
  41950. /**
  41951. * Unbinds the material from the mesh
  41952. */
  41953. unbind(): void;
  41954. /**
  41955. * Binds the submesh to this material by preparing the effect and shader to draw
  41956. * @param world defines the world transformation matrix
  41957. * @param mesh defines the mesh containing the submesh
  41958. * @param subMesh defines the submesh to bind the material to
  41959. */
  41960. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41961. /**
  41962. * Get the list of animatables in the material.
  41963. * @returns the list of animatables object used in the material
  41964. */
  41965. getAnimatables(): IAnimatable[];
  41966. /**
  41967. * Gets the active textures from the material
  41968. * @returns an array of textures
  41969. */
  41970. getActiveTextures(): BaseTexture[];
  41971. /**
  41972. * Specifies if the material uses a texture
  41973. * @param texture defines the texture to check against the material
  41974. * @returns a boolean specifying if the material uses the texture
  41975. */
  41976. hasTexture(texture: BaseTexture): boolean;
  41977. /**
  41978. * Disposes the material
  41979. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41980. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41981. */
  41982. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41983. /**
  41984. * Makes a duplicate of the material, and gives it a new name
  41985. * @param name defines the new name for the duplicated material
  41986. * @returns the cloned material
  41987. */
  41988. clone(name: string): StandardMaterial;
  41989. /**
  41990. * Serializes this material in a JSON representation
  41991. * @returns the serialized material object
  41992. */
  41993. serialize(): any;
  41994. /**
  41995. * Creates a standard material from parsed material data
  41996. * @param source defines the JSON representation of the material
  41997. * @param scene defines the hosting scene
  41998. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41999. * @returns a new standard material
  42000. */
  42001. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42002. /**
  42003. * Are diffuse textures enabled in the application.
  42004. */
  42005. static DiffuseTextureEnabled: boolean;
  42006. /**
  42007. * Are ambient textures enabled in the application.
  42008. */
  42009. static AmbientTextureEnabled: boolean;
  42010. /**
  42011. * Are opacity textures enabled in the application.
  42012. */
  42013. static OpacityTextureEnabled: boolean;
  42014. /**
  42015. * Are reflection textures enabled in the application.
  42016. */
  42017. static ReflectionTextureEnabled: boolean;
  42018. /**
  42019. * Are emissive textures enabled in the application.
  42020. */
  42021. static EmissiveTextureEnabled: boolean;
  42022. /**
  42023. * Are specular textures enabled in the application.
  42024. */
  42025. static SpecularTextureEnabled: boolean;
  42026. /**
  42027. * Are bump textures enabled in the application.
  42028. */
  42029. static BumpTextureEnabled: boolean;
  42030. /**
  42031. * Are lightmap textures enabled in the application.
  42032. */
  42033. static LightmapTextureEnabled: boolean;
  42034. /**
  42035. * Are refraction textures enabled in the application.
  42036. */
  42037. static RefractionTextureEnabled: boolean;
  42038. /**
  42039. * Are color grading textures enabled in the application.
  42040. */
  42041. static ColorGradingTextureEnabled: boolean;
  42042. /**
  42043. * Are fresnels enabled in the application.
  42044. */
  42045. static FresnelEnabled: boolean;
  42046. }
  42047. }
  42048. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42049. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42050. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42051. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42052. /** @hidden */
  42053. export var imageProcessingPixelShader: {
  42054. name: string;
  42055. shader: string;
  42056. };
  42057. }
  42058. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42059. import { Nullable } from "babylonjs/types";
  42060. import { Color4 } from "babylonjs/Maths/math.color";
  42061. import { Camera } from "babylonjs/Cameras/camera";
  42062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42063. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42064. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42066. import { Engine } from "babylonjs/Engines/engine";
  42067. import "babylonjs/Shaders/imageProcessing.fragment";
  42068. import "babylonjs/Shaders/postprocess.vertex";
  42069. /**
  42070. * ImageProcessingPostProcess
  42071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42072. */
  42073. export class ImageProcessingPostProcess extends PostProcess {
  42074. /**
  42075. * Default configuration related to image processing available in the PBR Material.
  42076. */
  42077. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42078. /**
  42079. * Gets the image processing configuration used either in this material.
  42080. */
  42081. /**
  42082. * Sets the Default image processing configuration used either in the this material.
  42083. *
  42084. * If sets to null, the scene one is in use.
  42085. */
  42086. imageProcessingConfiguration: ImageProcessingConfiguration;
  42087. /**
  42088. * Keep track of the image processing observer to allow dispose and replace.
  42089. */
  42090. private _imageProcessingObserver;
  42091. /**
  42092. * Attaches a new image processing configuration to the PBR Material.
  42093. * @param configuration
  42094. */
  42095. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42096. /**
  42097. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42098. */
  42099. /**
  42100. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42101. */
  42102. colorCurves: Nullable<ColorCurves>;
  42103. /**
  42104. * Gets wether the color curves effect is enabled.
  42105. */
  42106. /**
  42107. * Sets wether the color curves effect is enabled.
  42108. */
  42109. colorCurvesEnabled: boolean;
  42110. /**
  42111. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42112. */
  42113. /**
  42114. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42115. */
  42116. colorGradingTexture: Nullable<BaseTexture>;
  42117. /**
  42118. * Gets wether the color grading effect is enabled.
  42119. */
  42120. /**
  42121. * Gets wether the color grading effect is enabled.
  42122. */
  42123. colorGradingEnabled: boolean;
  42124. /**
  42125. * Gets exposure used in the effect.
  42126. */
  42127. /**
  42128. * Sets exposure used in the effect.
  42129. */
  42130. exposure: number;
  42131. /**
  42132. * Gets wether tonemapping is enabled or not.
  42133. */
  42134. /**
  42135. * Sets wether tonemapping is enabled or not
  42136. */
  42137. toneMappingEnabled: boolean;
  42138. /**
  42139. * Gets the type of tone mapping effect.
  42140. */
  42141. /**
  42142. * Sets the type of tone mapping effect.
  42143. */
  42144. toneMappingType: number;
  42145. /**
  42146. * Gets contrast used in the effect.
  42147. */
  42148. /**
  42149. * Sets contrast used in the effect.
  42150. */
  42151. contrast: number;
  42152. /**
  42153. * Gets Vignette stretch size.
  42154. */
  42155. /**
  42156. * Sets Vignette stretch size.
  42157. */
  42158. vignetteStretch: number;
  42159. /**
  42160. * Gets Vignette centre X Offset.
  42161. */
  42162. /**
  42163. * Sets Vignette centre X Offset.
  42164. */
  42165. vignetteCentreX: number;
  42166. /**
  42167. * Gets Vignette centre Y Offset.
  42168. */
  42169. /**
  42170. * Sets Vignette centre Y Offset.
  42171. */
  42172. vignetteCentreY: number;
  42173. /**
  42174. * Gets Vignette weight or intensity of the vignette effect.
  42175. */
  42176. /**
  42177. * Sets Vignette weight or intensity of the vignette effect.
  42178. */
  42179. vignetteWeight: number;
  42180. /**
  42181. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42182. * if vignetteEnabled is set to true.
  42183. */
  42184. /**
  42185. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42186. * if vignetteEnabled is set to true.
  42187. */
  42188. vignetteColor: Color4;
  42189. /**
  42190. * Gets Camera field of view used by the Vignette effect.
  42191. */
  42192. /**
  42193. * Sets Camera field of view used by the Vignette effect.
  42194. */
  42195. vignetteCameraFov: number;
  42196. /**
  42197. * Gets the vignette blend mode allowing different kind of effect.
  42198. */
  42199. /**
  42200. * Sets the vignette blend mode allowing different kind of effect.
  42201. */
  42202. vignetteBlendMode: number;
  42203. /**
  42204. * Gets wether the vignette effect is enabled.
  42205. */
  42206. /**
  42207. * Sets wether the vignette effect is enabled.
  42208. */
  42209. vignetteEnabled: boolean;
  42210. private _fromLinearSpace;
  42211. /**
  42212. * Gets wether the input of the processing is in Gamma or Linear Space.
  42213. */
  42214. /**
  42215. * Sets wether the input of the processing is in Gamma or Linear Space.
  42216. */
  42217. fromLinearSpace: boolean;
  42218. /**
  42219. * Defines cache preventing GC.
  42220. */
  42221. private _defines;
  42222. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42223. /**
  42224. * "ImageProcessingPostProcess"
  42225. * @returns "ImageProcessingPostProcess"
  42226. */
  42227. getClassName(): string;
  42228. protected _updateParameters(): void;
  42229. dispose(camera?: Camera): void;
  42230. }
  42231. }
  42232. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42233. import { Scene } from "babylonjs/scene";
  42234. import { Color3 } from "babylonjs/Maths/math.color";
  42235. import { Mesh } from "babylonjs/Meshes/mesh";
  42236. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42237. import { Nullable } from "babylonjs/types";
  42238. /**
  42239. * Class containing static functions to help procedurally build meshes
  42240. */
  42241. export class GroundBuilder {
  42242. /**
  42243. * Creates a ground mesh
  42244. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42245. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42247. * @param name defines the name of the mesh
  42248. * @param options defines the options used to create the mesh
  42249. * @param scene defines the hosting scene
  42250. * @returns the ground mesh
  42251. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42252. */
  42253. static CreateGround(name: string, options: {
  42254. width?: number;
  42255. height?: number;
  42256. subdivisions?: number;
  42257. subdivisionsX?: number;
  42258. subdivisionsY?: number;
  42259. updatable?: boolean;
  42260. }, scene: any): Mesh;
  42261. /**
  42262. * Creates a tiled ground mesh
  42263. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42264. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42265. * * 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
  42266. * * 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
  42267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42268. * @param name defines the name of the mesh
  42269. * @param options defines the options used to create the mesh
  42270. * @param scene defines the hosting scene
  42271. * @returns the tiled ground mesh
  42272. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42273. */
  42274. static CreateTiledGround(name: string, options: {
  42275. xmin: number;
  42276. zmin: number;
  42277. xmax: number;
  42278. zmax: number;
  42279. subdivisions?: {
  42280. w: number;
  42281. h: number;
  42282. };
  42283. precision?: {
  42284. w: number;
  42285. h: number;
  42286. };
  42287. updatable?: boolean;
  42288. }, scene?: Nullable<Scene>): Mesh;
  42289. /**
  42290. * Creates a ground mesh from a height map
  42291. * * The parameter `url` sets the URL of the height map image resource.
  42292. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42293. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42294. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42295. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42296. * * 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.
  42297. * * 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).
  42298. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42300. * @param name defines the name of the mesh
  42301. * @param url defines the url to the height map
  42302. * @param options defines the options used to create the mesh
  42303. * @param scene defines the hosting scene
  42304. * @returns the ground mesh
  42305. * @see https://doc.babylonjs.com/babylon101/height_map
  42306. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42307. */
  42308. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42309. width?: number;
  42310. height?: number;
  42311. subdivisions?: number;
  42312. minHeight?: number;
  42313. maxHeight?: number;
  42314. colorFilter?: Color3;
  42315. alphaFilter?: number;
  42316. updatable?: boolean;
  42317. onReady?: (mesh: GroundMesh) => void;
  42318. }, scene?: Nullable<Scene>): GroundMesh;
  42319. }
  42320. }
  42321. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42322. import { Vector4 } from "babylonjs/Maths/math.vector";
  42323. import { Mesh } from "babylonjs/Meshes/mesh";
  42324. /**
  42325. * Class containing static functions to help procedurally build meshes
  42326. */
  42327. export class TorusBuilder {
  42328. /**
  42329. * Creates a torus mesh
  42330. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42331. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42332. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42336. * @param name defines the name of the mesh
  42337. * @param options defines the options used to create the mesh
  42338. * @param scene defines the hosting scene
  42339. * @returns the torus mesh
  42340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42341. */
  42342. static CreateTorus(name: string, options: {
  42343. diameter?: number;
  42344. thickness?: number;
  42345. tessellation?: number;
  42346. updatable?: boolean;
  42347. sideOrientation?: number;
  42348. frontUVs?: Vector4;
  42349. backUVs?: Vector4;
  42350. }, scene: any): Mesh;
  42351. }
  42352. }
  42353. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42354. import { Vector4 } from "babylonjs/Maths/math.vector";
  42355. import { Color4 } from "babylonjs/Maths/math.color";
  42356. import { Mesh } from "babylonjs/Meshes/mesh";
  42357. /**
  42358. * Class containing static functions to help procedurally build meshes
  42359. */
  42360. export class CylinderBuilder {
  42361. /**
  42362. * Creates a cylinder or a cone mesh
  42363. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42364. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42365. * * 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.
  42366. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42367. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42368. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42369. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42370. * * 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).
  42371. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42372. * * 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).
  42373. * * 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
  42374. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42375. * * 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
  42376. * * 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.
  42377. * * If `enclose` is false, a ring surface is one element.
  42378. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42379. * * 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
  42380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42383. * @param name defines the name of the mesh
  42384. * @param options defines the options used to create the mesh
  42385. * @param scene defines the hosting scene
  42386. * @returns the cylinder mesh
  42387. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42388. */
  42389. static CreateCylinder(name: string, options: {
  42390. height?: number;
  42391. diameterTop?: number;
  42392. diameterBottom?: number;
  42393. diameter?: number;
  42394. tessellation?: number;
  42395. subdivisions?: number;
  42396. arc?: number;
  42397. faceColors?: Color4[];
  42398. faceUV?: Vector4[];
  42399. updatable?: boolean;
  42400. hasRings?: boolean;
  42401. enclose?: boolean;
  42402. cap?: number;
  42403. sideOrientation?: number;
  42404. frontUVs?: Vector4;
  42405. backUVs?: Vector4;
  42406. }, scene: any): Mesh;
  42407. }
  42408. }
  42409. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42410. import { Observable } from "babylonjs/Misc/observable";
  42411. import { Nullable } from "babylonjs/types";
  42412. import { Camera } from "babylonjs/Cameras/camera";
  42413. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42414. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42415. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42416. import { Scene } from "babylonjs/scene";
  42417. import { Vector3 } from "babylonjs/Maths/math.vector";
  42418. import { Color3 } from "babylonjs/Maths/math.color";
  42419. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42421. import { Mesh } from "babylonjs/Meshes/mesh";
  42422. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42423. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42424. import "babylonjs/Meshes/Builders/groundBuilder";
  42425. import "babylonjs/Meshes/Builders/torusBuilder";
  42426. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42427. import "babylonjs/Gamepads/gamepadSceneComponent";
  42428. import "babylonjs/Animations/animatable";
  42429. /**
  42430. * Options to modify the vr teleportation behavior.
  42431. */
  42432. export interface VRTeleportationOptions {
  42433. /**
  42434. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42435. */
  42436. floorMeshName?: string;
  42437. /**
  42438. * A list of meshes to be used as the teleportation floor. (default: empty)
  42439. */
  42440. floorMeshes?: Mesh[];
  42441. }
  42442. /**
  42443. * Options to modify the vr experience helper's behavior.
  42444. */
  42445. export interface VRExperienceHelperOptions extends WebVROptions {
  42446. /**
  42447. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42448. */
  42449. createDeviceOrientationCamera?: boolean;
  42450. /**
  42451. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42452. */
  42453. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42454. /**
  42455. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42456. */
  42457. laserToggle?: boolean;
  42458. /**
  42459. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42460. */
  42461. floorMeshes?: Mesh[];
  42462. /**
  42463. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42464. */
  42465. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42466. }
  42467. /**
  42468. * Event containing information after VR has been entered
  42469. */
  42470. export class OnAfterEnteringVRObservableEvent {
  42471. /**
  42472. * If entering vr was successful
  42473. */
  42474. success: boolean;
  42475. }
  42476. /**
  42477. * Helps to quickly add VR support to an existing scene.
  42478. * See http://doc.babylonjs.com/how_to/webvr_helper
  42479. */
  42480. export class VRExperienceHelper {
  42481. /** Options to modify the vr experience helper's behavior. */
  42482. webVROptions: VRExperienceHelperOptions;
  42483. private _scene;
  42484. private _position;
  42485. private _btnVR;
  42486. private _btnVRDisplayed;
  42487. private _webVRsupported;
  42488. private _webVRready;
  42489. private _webVRrequesting;
  42490. private _webVRpresenting;
  42491. private _hasEnteredVR;
  42492. private _fullscreenVRpresenting;
  42493. private _canvas;
  42494. private _webVRCamera;
  42495. private _vrDeviceOrientationCamera;
  42496. private _deviceOrientationCamera;
  42497. private _existingCamera;
  42498. private _onKeyDown;
  42499. private _onVrDisplayPresentChange;
  42500. private _onVRDisplayChanged;
  42501. private _onVRRequestPresentStart;
  42502. private _onVRRequestPresentComplete;
  42503. /**
  42504. * 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)
  42505. */
  42506. enableGazeEvenWhenNoPointerLock: boolean;
  42507. /**
  42508. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42509. */
  42510. exitVROnDoubleTap: boolean;
  42511. /**
  42512. * Observable raised right before entering VR.
  42513. */
  42514. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42515. /**
  42516. * Observable raised when entering VR has completed.
  42517. */
  42518. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42519. /**
  42520. * Observable raised when exiting VR.
  42521. */
  42522. onExitingVRObservable: Observable<VRExperienceHelper>;
  42523. /**
  42524. * Observable raised when controller mesh is loaded.
  42525. */
  42526. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42527. /** Return this.onEnteringVRObservable
  42528. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42529. */
  42530. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42531. /** Return this.onExitingVRObservable
  42532. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42533. */
  42534. readonly onExitingVR: Observable<VRExperienceHelper>;
  42535. /** Return this.onControllerMeshLoadedObservable
  42536. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42537. */
  42538. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42539. private _rayLength;
  42540. private _useCustomVRButton;
  42541. private _teleportationRequested;
  42542. private _teleportActive;
  42543. private _floorMeshName;
  42544. private _floorMeshesCollection;
  42545. private _rotationAllowed;
  42546. private _teleportBackwardsVector;
  42547. private _teleportationTarget;
  42548. private _isDefaultTeleportationTarget;
  42549. private _postProcessMove;
  42550. private _teleportationFillColor;
  42551. private _teleportationBorderColor;
  42552. private _rotationAngle;
  42553. private _haloCenter;
  42554. private _cameraGazer;
  42555. private _padSensibilityUp;
  42556. private _padSensibilityDown;
  42557. private _leftController;
  42558. private _rightController;
  42559. /**
  42560. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42561. */
  42562. onNewMeshSelected: Observable<AbstractMesh>;
  42563. /**
  42564. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42565. * This observable will provide the mesh and the controller used to select the mesh
  42566. */
  42567. onMeshSelectedWithController: Observable<{
  42568. mesh: AbstractMesh;
  42569. controller: WebVRController;
  42570. }>;
  42571. /**
  42572. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42573. */
  42574. onNewMeshPicked: Observable<PickingInfo>;
  42575. private _circleEase;
  42576. /**
  42577. * Observable raised before camera teleportation
  42578. */
  42579. onBeforeCameraTeleport: Observable<Vector3>;
  42580. /**
  42581. * Observable raised after camera teleportation
  42582. */
  42583. onAfterCameraTeleport: Observable<Vector3>;
  42584. /**
  42585. * Observable raised when current selected mesh gets unselected
  42586. */
  42587. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42588. private _raySelectionPredicate;
  42589. /**
  42590. * To be optionaly changed by user to define custom ray selection
  42591. */
  42592. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42593. /**
  42594. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42595. */
  42596. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42597. /**
  42598. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42599. */
  42600. teleportationEnabled: boolean;
  42601. private _defaultHeight;
  42602. private _teleportationInitialized;
  42603. private _interactionsEnabled;
  42604. private _interactionsRequested;
  42605. private _displayGaze;
  42606. private _displayLaserPointer;
  42607. /**
  42608. * The mesh used to display where the user is going to teleport.
  42609. */
  42610. /**
  42611. * Sets the mesh to be used to display where the user is going to teleport.
  42612. */
  42613. teleportationTarget: Mesh;
  42614. /**
  42615. * 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
  42616. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42617. * See http://doc.babylonjs.com/resources/baking_transformations
  42618. */
  42619. gazeTrackerMesh: Mesh;
  42620. /**
  42621. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42622. */
  42623. updateGazeTrackerScale: boolean;
  42624. /**
  42625. * If the gaze trackers color should be updated when selecting meshes
  42626. */
  42627. updateGazeTrackerColor: boolean;
  42628. /**
  42629. * If the controller laser color should be updated when selecting meshes
  42630. */
  42631. updateControllerLaserColor: boolean;
  42632. /**
  42633. * The gaze tracking mesh corresponding to the left controller
  42634. */
  42635. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42636. /**
  42637. * The gaze tracking mesh corresponding to the right controller
  42638. */
  42639. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42640. /**
  42641. * If the ray of the gaze should be displayed.
  42642. */
  42643. /**
  42644. * Sets if the ray of the gaze should be displayed.
  42645. */
  42646. displayGaze: boolean;
  42647. /**
  42648. * If the ray of the LaserPointer should be displayed.
  42649. */
  42650. /**
  42651. * Sets if the ray of the LaserPointer should be displayed.
  42652. */
  42653. displayLaserPointer: boolean;
  42654. /**
  42655. * The deviceOrientationCamera used as the camera when not in VR.
  42656. */
  42657. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42658. /**
  42659. * Based on the current WebVR support, returns the current VR camera used.
  42660. */
  42661. readonly currentVRCamera: Nullable<Camera>;
  42662. /**
  42663. * The webVRCamera which is used when in VR.
  42664. */
  42665. readonly webVRCamera: WebVRFreeCamera;
  42666. /**
  42667. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42668. */
  42669. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42670. /**
  42671. * The html button that is used to trigger entering into VR.
  42672. */
  42673. readonly vrButton: Nullable<HTMLButtonElement>;
  42674. private readonly _teleportationRequestInitiated;
  42675. /**
  42676. * Defines wether or not Pointer lock should be requested when switching to
  42677. * full screen.
  42678. */
  42679. requestPointerLockOnFullScreen: boolean;
  42680. /**
  42681. * Instantiates a VRExperienceHelper.
  42682. * Helps to quickly add VR support to an existing scene.
  42683. * @param scene The scene the VRExperienceHelper belongs to.
  42684. * @param webVROptions Options to modify the vr experience helper's behavior.
  42685. */
  42686. constructor(scene: Scene,
  42687. /** Options to modify the vr experience helper's behavior. */
  42688. webVROptions?: VRExperienceHelperOptions);
  42689. private _onDefaultMeshLoaded;
  42690. private _onResize;
  42691. private _onFullscreenChange;
  42692. /**
  42693. * Gets a value indicating if we are currently in VR mode.
  42694. */
  42695. readonly isInVRMode: boolean;
  42696. private onVrDisplayPresentChange;
  42697. private onVRDisplayChanged;
  42698. private moveButtonToBottomRight;
  42699. private displayVRButton;
  42700. private updateButtonVisibility;
  42701. private _cachedAngularSensibility;
  42702. /**
  42703. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42704. * Otherwise, will use the fullscreen API.
  42705. */
  42706. enterVR(): void;
  42707. /**
  42708. * Attempt to exit VR, or fullscreen.
  42709. */
  42710. exitVR(): void;
  42711. /**
  42712. * The position of the vr experience helper.
  42713. */
  42714. /**
  42715. * Sets the position of the vr experience helper.
  42716. */
  42717. position: Vector3;
  42718. /**
  42719. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42720. */
  42721. enableInteractions(): void;
  42722. private readonly _noControllerIsActive;
  42723. private beforeRender;
  42724. private _isTeleportationFloor;
  42725. /**
  42726. * Adds a floor mesh to be used for teleportation.
  42727. * @param floorMesh the mesh to be used for teleportation.
  42728. */
  42729. addFloorMesh(floorMesh: Mesh): void;
  42730. /**
  42731. * Removes a floor mesh from being used for teleportation.
  42732. * @param floorMesh the mesh to be removed.
  42733. */
  42734. removeFloorMesh(floorMesh: Mesh): void;
  42735. /**
  42736. * Enables interactions and teleportation using the VR controllers and gaze.
  42737. * @param vrTeleportationOptions options to modify teleportation behavior.
  42738. */
  42739. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42740. private _onNewGamepadConnected;
  42741. private _tryEnableInteractionOnController;
  42742. private _onNewGamepadDisconnected;
  42743. private _enableInteractionOnController;
  42744. private _checkTeleportWithRay;
  42745. private _checkRotate;
  42746. private _checkTeleportBackwards;
  42747. private _enableTeleportationOnController;
  42748. private _createTeleportationCircles;
  42749. private _displayTeleportationTarget;
  42750. private _hideTeleportationTarget;
  42751. private _rotateCamera;
  42752. private _moveTeleportationSelectorTo;
  42753. private _workingVector;
  42754. private _workingQuaternion;
  42755. private _workingMatrix;
  42756. /**
  42757. * Teleports the users feet to the desired location
  42758. * @param location The location where the user's feet should be placed
  42759. */
  42760. teleportCamera(location: Vector3): void;
  42761. private _convertNormalToDirectionOfRay;
  42762. private _castRayAndSelectObject;
  42763. private _notifySelectedMeshUnselected;
  42764. /**
  42765. * Sets the color of the laser ray from the vr controllers.
  42766. * @param color new color for the ray.
  42767. */
  42768. changeLaserColor(color: Color3): void;
  42769. /**
  42770. * Sets the color of the ray from the vr headsets gaze.
  42771. * @param color new color for the ray.
  42772. */
  42773. changeGazeColor(color: Color3): void;
  42774. /**
  42775. * Exits VR and disposes of the vr experience helper
  42776. */
  42777. dispose(): void;
  42778. /**
  42779. * Gets the name of the VRExperienceHelper class
  42780. * @returns "VRExperienceHelper"
  42781. */
  42782. getClassName(): string;
  42783. }
  42784. }
  42785. declare module "babylonjs/Cameras/VR/index" {
  42786. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42787. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42788. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42789. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42790. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42791. export * from "babylonjs/Cameras/VR/webVRCamera";
  42792. }
  42793. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42794. import { Observable } from "babylonjs/Misc/observable";
  42795. import { Nullable } from "babylonjs/types";
  42796. import { IDisposable, Scene } from "babylonjs/scene";
  42797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42798. /**
  42799. * Manages an XRSession to work with Babylon's engine
  42800. * @see https://doc.babylonjs.com/how_to/webxr
  42801. */
  42802. export class WebXRSessionManager implements IDisposable {
  42803. private scene;
  42804. /**
  42805. * Fires every time a new xrFrame arrives which can be used to update the camera
  42806. */
  42807. onXRFrameObservable: Observable<any>;
  42808. /**
  42809. * Fires when the xr session is ended either by the device or manually done
  42810. */
  42811. onXRSessionEnded: Observable<any>;
  42812. /**
  42813. * Underlying xr session
  42814. */
  42815. session: XRSession;
  42816. /**
  42817. * Type of reference space used when creating the session
  42818. */
  42819. referenceSpace: XRReferenceSpace;
  42820. /** @hidden */
  42821. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42822. /**
  42823. * Current XR frame
  42824. */
  42825. currentFrame: Nullable<XRFrame>;
  42826. private _xrNavigator;
  42827. private baseLayer;
  42828. /**
  42829. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42830. * @param scene The scene which the session should be created for
  42831. */
  42832. constructor(scene: Scene);
  42833. /**
  42834. * Initializes the manager
  42835. * After initialization enterXR can be called to start an XR session
  42836. * @returns Promise which resolves after it is initialized
  42837. */
  42838. initializeAsync(): Promise<void>;
  42839. /**
  42840. * Initializes an xr session
  42841. * @param xrSessionMode mode to initialize
  42842. * @returns a promise which will resolve once the session has been initialized
  42843. */
  42844. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42845. /**
  42846. * Sets the reference space on the xr session
  42847. * @param referenceSpace space to set
  42848. * @returns a promise that will resolve once the reference space has been set
  42849. */
  42850. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42851. /**
  42852. * Updates the render state of the session
  42853. * @param state state to set
  42854. * @returns a promise that resolves once the render state has been updated
  42855. */
  42856. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42857. /**
  42858. * Starts rendering to the xr layer
  42859. * @returns a promise that will resolve once rendering has started
  42860. */
  42861. startRenderingToXRAsync(): Promise<void>;
  42862. /**
  42863. * Stops the xrSession and restores the renderloop
  42864. * @returns Promise which resolves after it exits XR
  42865. */
  42866. exitXRAsync(): Promise<unknown>;
  42867. /**
  42868. * Checks if a session would be supported for the creation options specified
  42869. * @param sessionMode session mode to check if supported eg. immersive-vr
  42870. * @returns true if supported
  42871. */
  42872. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42873. /**
  42874. * @hidden
  42875. * Converts the render layer of xrSession to a render target
  42876. * @param session session to create render target for
  42877. * @param scene scene the new render target should be created for
  42878. */
  42879. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42880. /**
  42881. * Disposes of the session manager
  42882. */
  42883. dispose(): void;
  42884. }
  42885. }
  42886. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42887. import { Scene } from "babylonjs/scene";
  42888. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42889. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42890. /**
  42891. * WebXR Camera which holds the views for the xrSession
  42892. * @see https://doc.babylonjs.com/how_to/webxr
  42893. */
  42894. export class WebXRCamera extends FreeCamera {
  42895. private static _TmpMatrix;
  42896. /**
  42897. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42898. * @param name the name of the camera
  42899. * @param scene the scene to add the camera to
  42900. */
  42901. constructor(name: string, scene: Scene);
  42902. private _updateNumberOfRigCameras;
  42903. /** @hidden */
  42904. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42905. /**
  42906. * Updates the cameras position from the current pose information of the XR session
  42907. * @param xrSessionManager the session containing pose information
  42908. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42909. */
  42910. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42911. }
  42912. }
  42913. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42914. import { Nullable } from "babylonjs/types";
  42915. import { IDisposable } from "babylonjs/scene";
  42916. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42917. /**
  42918. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42919. */
  42920. export class WebXRManagedOutputCanvas implements IDisposable {
  42921. private helper;
  42922. private _canvas;
  42923. /**
  42924. * xrpresent context of the canvas which can be used to display/mirror xr content
  42925. */
  42926. canvasContext: WebGLRenderingContext;
  42927. /**
  42928. * xr layer for the canvas
  42929. */
  42930. xrLayer: Nullable<XRWebGLLayer>;
  42931. /**
  42932. * Initializes the xr layer for the session
  42933. * @param xrSession xr session
  42934. * @returns a promise that will resolve once the XR Layer has been created
  42935. */
  42936. initializeXRLayerAsync(xrSession: any): any;
  42937. /**
  42938. * Initializes the canvas to be added/removed upon entering/exiting xr
  42939. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42940. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42941. */
  42942. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42943. /**
  42944. * Disposes of the object
  42945. */
  42946. dispose(): void;
  42947. private _setManagedOutputCanvas;
  42948. private _addCanvas;
  42949. private _removeCanvas;
  42950. }
  42951. }
  42952. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42953. import { Observable } from "babylonjs/Misc/observable";
  42954. import { IDisposable, Scene } from "babylonjs/scene";
  42955. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42957. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42958. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42959. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42960. /**
  42961. * States of the webXR experience
  42962. */
  42963. export enum WebXRState {
  42964. /**
  42965. * Transitioning to being in XR mode
  42966. */
  42967. ENTERING_XR = 0,
  42968. /**
  42969. * Transitioning to non XR mode
  42970. */
  42971. EXITING_XR = 1,
  42972. /**
  42973. * In XR mode and presenting
  42974. */
  42975. IN_XR = 2,
  42976. /**
  42977. * Not entered XR mode
  42978. */
  42979. NOT_IN_XR = 3
  42980. }
  42981. /**
  42982. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42983. * @see https://doc.babylonjs.com/how_to/webxr
  42984. */
  42985. export class WebXRExperienceHelper implements IDisposable {
  42986. private scene;
  42987. /**
  42988. * 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
  42989. */
  42990. container: AbstractMesh;
  42991. /**
  42992. * Camera used to render xr content
  42993. */
  42994. camera: WebXRCamera;
  42995. /**
  42996. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42997. */
  42998. state: WebXRState;
  42999. private _setState;
  43000. private static _TmpVector;
  43001. /**
  43002. * Fires when the state of the experience helper has changed
  43003. */
  43004. onStateChangedObservable: Observable<WebXRState>;
  43005. /** Session manager used to keep track of xr session */
  43006. sessionManager: WebXRSessionManager;
  43007. private _nonVRCamera;
  43008. private _originalSceneAutoClear;
  43009. private _supported;
  43010. /**
  43011. * Creates the experience helper
  43012. * @param scene the scene to attach the experience helper to
  43013. * @returns a promise for the experience helper
  43014. */
  43015. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43016. /**
  43017. * Creates a WebXRExperienceHelper
  43018. * @param scene The scene the helper should be created in
  43019. */
  43020. private constructor();
  43021. /**
  43022. * Exits XR mode and returns the scene to its original state
  43023. * @returns promise that resolves after xr mode has exited
  43024. */
  43025. exitXRAsync(): Promise<unknown>;
  43026. /**
  43027. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43028. * @param sessionCreationOptions options for the XR session
  43029. * @param referenceSpaceType frame of reference of the XR session
  43030. * @param outputCanvas the output canvas that will be used to enter XR mode
  43031. * @returns promise that resolves after xr mode has entered
  43032. */
  43033. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43034. /**
  43035. * Updates the global position of the camera by moving the camera's container
  43036. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43037. * @param position The desired global position of the camera
  43038. */
  43039. setPositionOfCameraUsingContainer(position: Vector3): void;
  43040. /**
  43041. * Rotates the xr camera by rotating the camera's container around the camera's position
  43042. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43043. * @param rotation the desired quaternion rotation to apply to the camera
  43044. */
  43045. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43046. /**
  43047. * Disposes of the experience helper
  43048. */
  43049. dispose(): void;
  43050. }
  43051. }
  43052. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43053. import { Nullable } from "babylonjs/types";
  43054. import { Observable } from "babylonjs/Misc/observable";
  43055. import { IDisposable, Scene } from "babylonjs/scene";
  43056. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43057. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43058. /**
  43059. * Button which can be used to enter a different mode of XR
  43060. */
  43061. export class WebXREnterExitUIButton {
  43062. /** button element */
  43063. element: HTMLElement;
  43064. /** XR initialization options for the button */
  43065. sessionMode: XRSessionMode;
  43066. /** Reference space type */
  43067. referenceSpaceType: XRReferenceSpaceType;
  43068. /**
  43069. * Creates a WebXREnterExitUIButton
  43070. * @param element button element
  43071. * @param sessionMode XR initialization session mode
  43072. * @param referenceSpaceType the type of reference space to be used
  43073. */
  43074. constructor(
  43075. /** button element */
  43076. element: HTMLElement,
  43077. /** XR initialization options for the button */
  43078. sessionMode: XRSessionMode,
  43079. /** Reference space type */
  43080. referenceSpaceType: XRReferenceSpaceType);
  43081. /**
  43082. * Overwritable function which can be used to update the button's visuals when the state changes
  43083. * @param activeButton the current active button in the UI
  43084. */
  43085. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43086. }
  43087. /**
  43088. * Options to create the webXR UI
  43089. */
  43090. export class WebXREnterExitUIOptions {
  43091. /**
  43092. * Context to enter xr with
  43093. */
  43094. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43095. /**
  43096. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43097. */
  43098. customButtons?: Array<WebXREnterExitUIButton>;
  43099. }
  43100. /**
  43101. * UI to allow the user to enter/exit XR mode
  43102. */
  43103. export class WebXREnterExitUI implements IDisposable {
  43104. private scene;
  43105. private _overlay;
  43106. private _buttons;
  43107. private _activeButton;
  43108. /**
  43109. * Fired every time the active button is changed.
  43110. *
  43111. * When xr is entered via a button that launches xr that button will be the callback parameter
  43112. *
  43113. * When exiting xr the callback parameter will be null)
  43114. */
  43115. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43116. /**
  43117. * Creates UI to allow the user to enter/exit XR mode
  43118. * @param scene the scene to add the ui to
  43119. * @param helper the xr experience helper to enter/exit xr with
  43120. * @param options options to configure the UI
  43121. * @returns the created ui
  43122. */
  43123. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43124. private constructor();
  43125. private _updateButtons;
  43126. /**
  43127. * Disposes of the object
  43128. */
  43129. dispose(): void;
  43130. }
  43131. }
  43132. declare module "babylonjs/Cameras/XR/webXRController" {
  43133. import { Nullable } from "babylonjs/types";
  43134. import { Observable } from "babylonjs/Misc/observable";
  43135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43136. import { Ray } from "babylonjs/Culling/ray";
  43137. import { Scene } from "babylonjs/scene";
  43138. /**
  43139. * Represents an XR input
  43140. */
  43141. export class WebXRController {
  43142. private scene;
  43143. /** The underlying input source for the controller */
  43144. inputSource: XRInputSource;
  43145. private parentContainer;
  43146. /**
  43147. * 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
  43148. */
  43149. grip?: AbstractMesh;
  43150. /**
  43151. * Pointer which can be used to select objects or attach a visible laser to
  43152. */
  43153. pointer: AbstractMesh;
  43154. /**
  43155. * Event that fires when the controller is removed/disposed
  43156. */
  43157. onDisposeObservable: Observable<{}>;
  43158. private _tmpMatrix;
  43159. private _tmpQuaternion;
  43160. private _tmpVector;
  43161. /**
  43162. * Creates the controller
  43163. * @see https://doc.babylonjs.com/how_to/webxr
  43164. * @param scene the scene which the controller should be associated to
  43165. * @param inputSource the underlying input source for the controller
  43166. * @param parentContainer parent that the controller meshes should be children of
  43167. */
  43168. constructor(scene: Scene,
  43169. /** The underlying input source for the controller */
  43170. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43171. /**
  43172. * Updates the controller pose based on the given XRFrame
  43173. * @param xrFrame xr frame to update the pose with
  43174. * @param referenceSpace reference space to use
  43175. */
  43176. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43177. /**
  43178. * Gets a world space ray coming from the controller
  43179. * @param result the resulting ray
  43180. */
  43181. getWorldPointerRayToRef(result: Ray): void;
  43182. /**
  43183. * Disposes of the object
  43184. */
  43185. dispose(): void;
  43186. }
  43187. }
  43188. declare module "babylonjs/Cameras/XR/webXRInput" {
  43189. import { Observable } from "babylonjs/Misc/observable";
  43190. import { IDisposable } from "babylonjs/scene";
  43191. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43192. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43193. /**
  43194. * XR input used to track XR inputs such as controllers/rays
  43195. */
  43196. export class WebXRInput implements IDisposable {
  43197. /**
  43198. * Base experience the input listens to
  43199. */
  43200. baseExperience: WebXRExperienceHelper;
  43201. /**
  43202. * XR controllers being tracked
  43203. */
  43204. controllers: Array<WebXRController>;
  43205. private _frameObserver;
  43206. private _stateObserver;
  43207. /**
  43208. * Event when a controller has been connected/added
  43209. */
  43210. onControllerAddedObservable: Observable<WebXRController>;
  43211. /**
  43212. * Event when a controller has been removed/disconnected
  43213. */
  43214. onControllerRemovedObservable: Observable<WebXRController>;
  43215. /**
  43216. * Initializes the WebXRInput
  43217. * @param baseExperience experience helper which the input should be created for
  43218. */
  43219. constructor(
  43220. /**
  43221. * Base experience the input listens to
  43222. */
  43223. baseExperience: WebXRExperienceHelper);
  43224. private _onInputSourcesChange;
  43225. private _addAndRemoveControllers;
  43226. /**
  43227. * Disposes of the object
  43228. */
  43229. dispose(): void;
  43230. }
  43231. }
  43232. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43234. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43235. /**
  43236. * Enables teleportation
  43237. */
  43238. export class WebXRControllerTeleportation {
  43239. private _teleportationFillColor;
  43240. private _teleportationBorderColor;
  43241. private _tmpRay;
  43242. private _tmpVector;
  43243. /**
  43244. * Creates a WebXRControllerTeleportation
  43245. * @param input input manager to add teleportation to
  43246. * @param floorMeshes floormeshes which can be teleported to
  43247. */
  43248. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43249. }
  43250. }
  43251. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43252. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43253. /**
  43254. * Handles pointer input automatically for the pointer of XR controllers
  43255. */
  43256. export class WebXRControllerPointerSelection {
  43257. private static _idCounter;
  43258. private _tmpRay;
  43259. /**
  43260. * Creates a WebXRControllerPointerSelection
  43261. * @param input input manager to setup pointer selection
  43262. */
  43263. constructor(input: WebXRInput);
  43264. private _convertNormalToDirectionOfRay;
  43265. private _updatePointerDistance;
  43266. }
  43267. }
  43268. declare module "babylonjs/Loading/sceneLoader" {
  43269. import { Observable } from "babylonjs/Misc/observable";
  43270. import { Nullable } from "babylonjs/types";
  43271. import { Scene } from "babylonjs/scene";
  43272. import { Engine } from "babylonjs/Engines/engine";
  43273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43274. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43275. import { AssetContainer } from "babylonjs/assetContainer";
  43276. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43277. import { Skeleton } from "babylonjs/Bones/skeleton";
  43278. /**
  43279. * Class used to represent data loading progression
  43280. */
  43281. export class SceneLoaderProgressEvent {
  43282. /** defines if data length to load can be evaluated */
  43283. readonly lengthComputable: boolean;
  43284. /** defines the loaded data length */
  43285. readonly loaded: number;
  43286. /** defines the data length to load */
  43287. readonly total: number;
  43288. /**
  43289. * Create a new progress event
  43290. * @param lengthComputable defines if data length to load can be evaluated
  43291. * @param loaded defines the loaded data length
  43292. * @param total defines the data length to load
  43293. */
  43294. constructor(
  43295. /** defines if data length to load can be evaluated */
  43296. lengthComputable: boolean,
  43297. /** defines the loaded data length */
  43298. loaded: number,
  43299. /** defines the data length to load */
  43300. total: number);
  43301. /**
  43302. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43303. * @param event defines the source event
  43304. * @returns a new SceneLoaderProgressEvent
  43305. */
  43306. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43307. }
  43308. /**
  43309. * Interface used by SceneLoader plugins to define supported file extensions
  43310. */
  43311. export interface ISceneLoaderPluginExtensions {
  43312. /**
  43313. * Defines the list of supported extensions
  43314. */
  43315. [extension: string]: {
  43316. isBinary: boolean;
  43317. };
  43318. }
  43319. /**
  43320. * Interface used by SceneLoader plugin factory
  43321. */
  43322. export interface ISceneLoaderPluginFactory {
  43323. /**
  43324. * Defines the name of the factory
  43325. */
  43326. name: string;
  43327. /**
  43328. * Function called to create a new plugin
  43329. * @return the new plugin
  43330. */
  43331. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43332. /**
  43333. * Boolean indicating if the plugin can direct load specific data
  43334. */
  43335. canDirectLoad?: (data: string) => boolean;
  43336. }
  43337. /**
  43338. * Interface used to define a SceneLoader plugin
  43339. */
  43340. export interface ISceneLoaderPlugin {
  43341. /**
  43342. * The friendly name of this plugin.
  43343. */
  43344. name: string;
  43345. /**
  43346. * The file extensions supported by this plugin.
  43347. */
  43348. extensions: string | ISceneLoaderPluginExtensions;
  43349. /**
  43350. * Import meshes into a scene.
  43351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43352. * @param scene The scene to import into
  43353. * @param data The data to import
  43354. * @param rootUrl The root url for scene and resources
  43355. * @param meshes The meshes array to import into
  43356. * @param particleSystems The particle systems array to import into
  43357. * @param skeletons The skeletons array to import into
  43358. * @param onError The callback when import fails
  43359. * @returns True if successful or false otherwise
  43360. */
  43361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43362. /**
  43363. * Load into a scene.
  43364. * @param scene The scene to load into
  43365. * @param data The data to import
  43366. * @param rootUrl The root url for scene and resources
  43367. * @param onError The callback when import fails
  43368. * @returns true if successful or false otherwise
  43369. */
  43370. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43371. /**
  43372. * The callback that returns true if the data can be directly loaded.
  43373. */
  43374. canDirectLoad?: (data: string) => boolean;
  43375. /**
  43376. * The callback that allows custom handling of the root url based on the response url.
  43377. */
  43378. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43379. /**
  43380. * Load into an asset container.
  43381. * @param scene The scene to load into
  43382. * @param data The data to import
  43383. * @param rootUrl The root url for scene and resources
  43384. * @param onError The callback when import fails
  43385. * @returns The loaded asset container
  43386. */
  43387. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43388. }
  43389. /**
  43390. * Interface used to define an async SceneLoader plugin
  43391. */
  43392. export interface ISceneLoaderPluginAsync {
  43393. /**
  43394. * The friendly name of this plugin.
  43395. */
  43396. name: string;
  43397. /**
  43398. * The file extensions supported by this plugin.
  43399. */
  43400. extensions: string | ISceneLoaderPluginExtensions;
  43401. /**
  43402. * Import meshes into a scene.
  43403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43404. * @param scene The scene to import into
  43405. * @param data The data to import
  43406. * @param rootUrl The root url for scene and resources
  43407. * @param onProgress The callback when the load progresses
  43408. * @param fileName Defines the name of the file to load
  43409. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43410. */
  43411. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43412. meshes: AbstractMesh[];
  43413. particleSystems: IParticleSystem[];
  43414. skeletons: Skeleton[];
  43415. animationGroups: AnimationGroup[];
  43416. }>;
  43417. /**
  43418. * Load into a scene.
  43419. * @param scene The scene to load into
  43420. * @param data The data to import
  43421. * @param rootUrl The root url for scene and resources
  43422. * @param onProgress The callback when the load progresses
  43423. * @param fileName Defines the name of the file to load
  43424. * @returns Nothing
  43425. */
  43426. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43427. /**
  43428. * The callback that returns true if the data can be directly loaded.
  43429. */
  43430. canDirectLoad?: (data: string) => boolean;
  43431. /**
  43432. * The callback that allows custom handling of the root url based on the response url.
  43433. */
  43434. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43435. /**
  43436. * Load into an asset container.
  43437. * @param scene The scene to load into
  43438. * @param data The data to import
  43439. * @param rootUrl The root url for scene and resources
  43440. * @param onProgress The callback when the load progresses
  43441. * @param fileName Defines the name of the file to load
  43442. * @returns The loaded asset container
  43443. */
  43444. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43445. }
  43446. /**
  43447. * Class used to load scene from various file formats using registered plugins
  43448. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43449. */
  43450. export class SceneLoader {
  43451. /**
  43452. * No logging while loading
  43453. */
  43454. static readonly NO_LOGGING: number;
  43455. /**
  43456. * Minimal logging while loading
  43457. */
  43458. static readonly MINIMAL_LOGGING: number;
  43459. /**
  43460. * Summary logging while loading
  43461. */
  43462. static readonly SUMMARY_LOGGING: number;
  43463. /**
  43464. * Detailled logging while loading
  43465. */
  43466. static readonly DETAILED_LOGGING: number;
  43467. /**
  43468. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43469. */
  43470. static ForceFullSceneLoadingForIncremental: boolean;
  43471. /**
  43472. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43473. */
  43474. static ShowLoadingScreen: boolean;
  43475. /**
  43476. * Defines the current logging level (while loading the scene)
  43477. * @ignorenaming
  43478. */
  43479. static loggingLevel: number;
  43480. /**
  43481. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43482. */
  43483. static CleanBoneMatrixWeights: boolean;
  43484. /**
  43485. * Event raised when a plugin is used to load a scene
  43486. */
  43487. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43488. private static _registeredPlugins;
  43489. private static _getDefaultPlugin;
  43490. private static _getPluginForExtension;
  43491. private static _getPluginForDirectLoad;
  43492. private static _getPluginForFilename;
  43493. private static _getDirectLoad;
  43494. private static _loadData;
  43495. private static _getFileInfo;
  43496. /**
  43497. * Gets a plugin that can load the given extension
  43498. * @param extension defines the extension to load
  43499. * @returns a plugin or null if none works
  43500. */
  43501. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43502. /**
  43503. * Gets a boolean indicating that the given extension can be loaded
  43504. * @param extension defines the extension to load
  43505. * @returns true if the extension is supported
  43506. */
  43507. static IsPluginForExtensionAvailable(extension: string): boolean;
  43508. /**
  43509. * Adds a new plugin to the list of registered plugins
  43510. * @param plugin defines the plugin to add
  43511. */
  43512. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43513. /**
  43514. * Import meshes into a scene
  43515. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43516. * @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)
  43517. * @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)
  43518. * @param scene the instance of BABYLON.Scene to append to
  43519. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43520. * @param onProgress a callback with a progress event for each file being loaded
  43521. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43522. * @param pluginExtension the extension used to determine the plugin
  43523. * @returns The loaded plugin
  43524. */
  43525. 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>;
  43526. /**
  43527. * Import meshes into a scene
  43528. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43529. * @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)
  43530. * @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)
  43531. * @param scene the instance of BABYLON.Scene to append to
  43532. * @param onProgress a callback with a progress event for each file being loaded
  43533. * @param pluginExtension the extension used to determine the plugin
  43534. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43535. */
  43536. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43537. meshes: AbstractMesh[];
  43538. particleSystems: IParticleSystem[];
  43539. skeletons: Skeleton[];
  43540. animationGroups: AnimationGroup[];
  43541. }>;
  43542. /**
  43543. * Load a scene
  43544. * @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)
  43545. * @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)
  43546. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43547. * @param onSuccess a callback with the scene when import succeeds
  43548. * @param onProgress a callback with a progress event for each file being loaded
  43549. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43550. * @param pluginExtension the extension used to determine the plugin
  43551. * @returns The loaded plugin
  43552. */
  43553. 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>;
  43554. /**
  43555. * Load a scene
  43556. * @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)
  43557. * @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)
  43558. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43559. * @param onProgress a callback with a progress event for each file being loaded
  43560. * @param pluginExtension the extension used to determine the plugin
  43561. * @returns The loaded scene
  43562. */
  43563. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43564. /**
  43565. * Append a scene
  43566. * @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)
  43567. * @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)
  43568. * @param scene is the instance of BABYLON.Scene to append to
  43569. * @param onSuccess a callback with the scene when import succeeds
  43570. * @param onProgress a callback with a progress event for each file being loaded
  43571. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43572. * @param pluginExtension the extension used to determine the plugin
  43573. * @returns The loaded plugin
  43574. */
  43575. 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>;
  43576. /**
  43577. * Append a scene
  43578. * @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)
  43579. * @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)
  43580. * @param scene is the instance of BABYLON.Scene to append to
  43581. * @param onProgress a callback with a progress event for each file being loaded
  43582. * @param pluginExtension the extension used to determine the plugin
  43583. * @returns The given scene
  43584. */
  43585. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43586. /**
  43587. * Load a scene into an asset container
  43588. * @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)
  43589. * @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)
  43590. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43591. * @param onSuccess a callback with the scene when import succeeds
  43592. * @param onProgress a callback with a progress event for each file being loaded
  43593. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43594. * @param pluginExtension the extension used to determine the plugin
  43595. * @returns The loaded plugin
  43596. */
  43597. 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>;
  43598. /**
  43599. * Load a scene into an asset container
  43600. * @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)
  43601. * @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)
  43602. * @param scene is the instance of Scene to append to
  43603. * @param onProgress a callback with a progress event for each file being loaded
  43604. * @param pluginExtension the extension used to determine the plugin
  43605. * @returns The loaded asset container
  43606. */
  43607. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43608. }
  43609. }
  43610. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43611. import { Scene } from "babylonjs/scene";
  43612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43613. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43614. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43615. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43616. /**
  43617. * Generic Controller
  43618. */
  43619. export class GenericController extends WebVRController {
  43620. /**
  43621. * Base Url for the controller model.
  43622. */
  43623. static readonly MODEL_BASE_URL: string;
  43624. /**
  43625. * File name for the controller model.
  43626. */
  43627. static readonly MODEL_FILENAME: string;
  43628. /**
  43629. * Creates a new GenericController from a gamepad
  43630. * @param vrGamepad the gamepad that the controller should be created from
  43631. */
  43632. constructor(vrGamepad: any);
  43633. /**
  43634. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43635. * @param scene scene in which to add meshes
  43636. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43637. */
  43638. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43639. /**
  43640. * Called once for each button that changed state since the last frame
  43641. * @param buttonIdx Which button index changed
  43642. * @param state New state of the button
  43643. * @param changes Which properties on the state changed since last frame
  43644. */
  43645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43646. }
  43647. }
  43648. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43649. import { Observable } from "babylonjs/Misc/observable";
  43650. import { Scene } from "babylonjs/scene";
  43651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43652. import { Ray } from "babylonjs/Culling/ray";
  43653. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43654. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43655. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43656. /**
  43657. * Defines the WindowsMotionController object that the state of the windows motion controller
  43658. */
  43659. export class WindowsMotionController extends WebVRController {
  43660. /**
  43661. * The base url used to load the left and right controller models
  43662. */
  43663. static MODEL_BASE_URL: string;
  43664. /**
  43665. * The name of the left controller model file
  43666. */
  43667. static MODEL_LEFT_FILENAME: string;
  43668. /**
  43669. * The name of the right controller model file
  43670. */
  43671. static MODEL_RIGHT_FILENAME: string;
  43672. /**
  43673. * The controller name prefix for this controller type
  43674. */
  43675. static readonly GAMEPAD_ID_PREFIX: string;
  43676. /**
  43677. * The controller id pattern for this controller type
  43678. */
  43679. private static readonly GAMEPAD_ID_PATTERN;
  43680. private _loadedMeshInfo;
  43681. private readonly _mapping;
  43682. /**
  43683. * Fired when the trackpad on this controller is clicked
  43684. */
  43685. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43686. /**
  43687. * Fired when the trackpad on this controller is modified
  43688. */
  43689. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43690. /**
  43691. * The current x and y values of this controller's trackpad
  43692. */
  43693. trackpad: StickValues;
  43694. /**
  43695. * Creates a new WindowsMotionController from a gamepad
  43696. * @param vrGamepad the gamepad that the controller should be created from
  43697. */
  43698. constructor(vrGamepad: any);
  43699. /**
  43700. * Fired when the trigger on this controller is modified
  43701. */
  43702. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43703. /**
  43704. * Fired when the menu button on this controller is modified
  43705. */
  43706. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43707. /**
  43708. * Fired when the grip button on this controller is modified
  43709. */
  43710. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43711. /**
  43712. * Fired when the thumbstick button on this controller is modified
  43713. */
  43714. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43715. /**
  43716. * Fired when the touchpad button on this controller is modified
  43717. */
  43718. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43719. /**
  43720. * Fired when the touchpad values on this controller are modified
  43721. */
  43722. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43723. private _updateTrackpad;
  43724. /**
  43725. * Called once per frame by the engine.
  43726. */
  43727. update(): void;
  43728. /**
  43729. * Called once for each button that changed state since the last frame
  43730. * @param buttonIdx Which button index changed
  43731. * @param state New state of the button
  43732. * @param changes Which properties on the state changed since last frame
  43733. */
  43734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43735. /**
  43736. * Moves the buttons on the controller mesh based on their current state
  43737. * @param buttonName the name of the button to move
  43738. * @param buttonValue the value of the button which determines the buttons new position
  43739. */
  43740. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43741. /**
  43742. * Moves the axis on the controller mesh based on its current state
  43743. * @param axis the index of the axis
  43744. * @param axisValue the value of the axis which determines the meshes new position
  43745. * @hidden
  43746. */
  43747. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43748. /**
  43749. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43750. * @param scene scene in which to add meshes
  43751. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43752. */
  43753. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43754. /**
  43755. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43756. * can be transformed by button presses and axes values, based on this._mapping.
  43757. *
  43758. * @param scene scene in which the meshes exist
  43759. * @param meshes list of meshes that make up the controller model to process
  43760. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43761. */
  43762. private processModel;
  43763. private createMeshInfo;
  43764. /**
  43765. * Gets the ray of the controller in the direction the controller is pointing
  43766. * @param length the length the resulting ray should be
  43767. * @returns a ray in the direction the controller is pointing
  43768. */
  43769. getForwardRay(length?: number): Ray;
  43770. /**
  43771. * Disposes of the controller
  43772. */
  43773. dispose(): void;
  43774. }
  43775. }
  43776. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43777. import { Observable } from "babylonjs/Misc/observable";
  43778. import { Scene } from "babylonjs/scene";
  43779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43780. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43781. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43782. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43783. /**
  43784. * Oculus Touch Controller
  43785. */
  43786. export class OculusTouchController extends WebVRController {
  43787. /**
  43788. * Base Url for the controller model.
  43789. */
  43790. static MODEL_BASE_URL: string;
  43791. /**
  43792. * File name for the left controller model.
  43793. */
  43794. static MODEL_LEFT_FILENAME: string;
  43795. /**
  43796. * File name for the right controller model.
  43797. */
  43798. static MODEL_RIGHT_FILENAME: string;
  43799. /**
  43800. * Base Url for the Quest controller model.
  43801. */
  43802. static QUEST_MODEL_BASE_URL: string;
  43803. /**
  43804. * @hidden
  43805. * If the controllers are running on a device that needs the updated Quest controller models
  43806. */
  43807. static _IsQuest: boolean;
  43808. /**
  43809. * Fired when the secondary trigger on this controller is modified
  43810. */
  43811. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43812. /**
  43813. * Fired when the thumb rest on this controller is modified
  43814. */
  43815. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43816. /**
  43817. * Creates a new OculusTouchController from a gamepad
  43818. * @param vrGamepad the gamepad that the controller should be created from
  43819. */
  43820. constructor(vrGamepad: any);
  43821. /**
  43822. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43823. * @param scene scene in which to add meshes
  43824. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43825. */
  43826. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43827. /**
  43828. * Fired when the A button on this controller is modified
  43829. */
  43830. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43831. /**
  43832. * Fired when the B button on this controller is modified
  43833. */
  43834. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43835. /**
  43836. * Fired when the X button on this controller is modified
  43837. */
  43838. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43839. /**
  43840. * Fired when the Y button on this controller is modified
  43841. */
  43842. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43843. /**
  43844. * Called once for each button that changed state since the last frame
  43845. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43846. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43847. * 2) secondary trigger (same)
  43848. * 3) A (right) X (left), touch, pressed = value
  43849. * 4) B / Y
  43850. * 5) thumb rest
  43851. * @param buttonIdx Which button index changed
  43852. * @param state New state of the button
  43853. * @param changes Which properties on the state changed since last frame
  43854. */
  43855. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43859. import { Scene } from "babylonjs/scene";
  43860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43861. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43862. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43863. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43864. import { Observable } from "babylonjs/Misc/observable";
  43865. /**
  43866. * Vive Controller
  43867. */
  43868. export class ViveController extends WebVRController {
  43869. /**
  43870. * Base Url for the controller model.
  43871. */
  43872. static MODEL_BASE_URL: string;
  43873. /**
  43874. * File name for the controller model.
  43875. */
  43876. static MODEL_FILENAME: string;
  43877. /**
  43878. * Creates a new ViveController from a gamepad
  43879. * @param vrGamepad the gamepad that the controller should be created from
  43880. */
  43881. constructor(vrGamepad: any);
  43882. /**
  43883. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43884. * @param scene scene in which to add meshes
  43885. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43886. */
  43887. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43888. /**
  43889. * Fired when the left button on this controller is modified
  43890. */
  43891. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43892. /**
  43893. * Fired when the right button on this controller is modified
  43894. */
  43895. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43896. /**
  43897. * Fired when the menu button on this controller is modified
  43898. */
  43899. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43900. /**
  43901. * Called once for each button that changed state since the last frame
  43902. * Vive mapping:
  43903. * 0: touchpad
  43904. * 1: trigger
  43905. * 2: left AND right buttons
  43906. * 3: menu button
  43907. * @param buttonIdx Which button index changed
  43908. * @param state New state of the button
  43909. * @param changes Which properties on the state changed since last frame
  43910. */
  43911. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43912. }
  43913. }
  43914. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43915. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43916. /**
  43917. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43918. */
  43919. export class WebXRControllerModelLoader {
  43920. /**
  43921. * Creates the WebXRControllerModelLoader
  43922. * @param input xr input that creates the controllers
  43923. */
  43924. constructor(input: WebXRInput);
  43925. }
  43926. }
  43927. declare module "babylonjs/Cameras/XR/index" {
  43928. export * from "babylonjs/Cameras/XR/webXRCamera";
  43929. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43930. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43931. export * from "babylonjs/Cameras/XR/webXRInput";
  43932. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43933. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43934. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43935. export * from "babylonjs/Cameras/XR/webXRController";
  43936. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43937. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43938. }
  43939. declare module "babylonjs/Cameras/RigModes/index" {
  43940. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43941. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43942. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43943. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43944. }
  43945. declare module "babylonjs/Cameras/index" {
  43946. export * from "babylonjs/Cameras/Inputs/index";
  43947. export * from "babylonjs/Cameras/cameraInputsManager";
  43948. export * from "babylonjs/Cameras/camera";
  43949. export * from "babylonjs/Cameras/targetCamera";
  43950. export * from "babylonjs/Cameras/freeCamera";
  43951. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43952. export * from "babylonjs/Cameras/touchCamera";
  43953. export * from "babylonjs/Cameras/arcRotateCamera";
  43954. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43955. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43956. export * from "babylonjs/Cameras/flyCamera";
  43957. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43958. export * from "babylonjs/Cameras/followCamera";
  43959. export * from "babylonjs/Cameras/followCameraInputsManager";
  43960. export * from "babylonjs/Cameras/gamepadCamera";
  43961. export * from "babylonjs/Cameras/Stereoscopic/index";
  43962. export * from "babylonjs/Cameras/universalCamera";
  43963. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43964. export * from "babylonjs/Cameras/VR/index";
  43965. export * from "babylonjs/Cameras/XR/index";
  43966. export * from "babylonjs/Cameras/RigModes/index";
  43967. }
  43968. declare module "babylonjs/Collisions/index" {
  43969. export * from "babylonjs/Collisions/collider";
  43970. export * from "babylonjs/Collisions/collisionCoordinator";
  43971. export * from "babylonjs/Collisions/pickingInfo";
  43972. export * from "babylonjs/Collisions/intersectionInfo";
  43973. export * from "babylonjs/Collisions/meshCollisionData";
  43974. }
  43975. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43976. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43977. import { Vector3 } from "babylonjs/Maths/math.vector";
  43978. import { Ray } from "babylonjs/Culling/ray";
  43979. import { Plane } from "babylonjs/Maths/math.plane";
  43980. /**
  43981. * Contains an array of blocks representing the octree
  43982. */
  43983. export interface IOctreeContainer<T> {
  43984. /**
  43985. * Blocks within the octree
  43986. */
  43987. blocks: Array<OctreeBlock<T>>;
  43988. }
  43989. /**
  43990. * Class used to store a cell in an octree
  43991. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43992. */
  43993. export class OctreeBlock<T> {
  43994. /**
  43995. * Gets the content of the current block
  43996. */
  43997. entries: T[];
  43998. /**
  43999. * Gets the list of block children
  44000. */
  44001. blocks: Array<OctreeBlock<T>>;
  44002. private _depth;
  44003. private _maxDepth;
  44004. private _capacity;
  44005. private _minPoint;
  44006. private _maxPoint;
  44007. private _boundingVectors;
  44008. private _creationFunc;
  44009. /**
  44010. * Creates a new block
  44011. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44012. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44013. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44014. * @param depth defines the current depth of this block in the octree
  44015. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44016. * @param creationFunc defines a callback to call when an element is added to the block
  44017. */
  44018. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44019. /**
  44020. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44021. */
  44022. readonly capacity: number;
  44023. /**
  44024. * Gets the minimum vector (in world space) of the block's bounding box
  44025. */
  44026. readonly minPoint: Vector3;
  44027. /**
  44028. * Gets the maximum vector (in world space) of the block's bounding box
  44029. */
  44030. readonly maxPoint: Vector3;
  44031. /**
  44032. * Add a new element to this block
  44033. * @param entry defines the element to add
  44034. */
  44035. addEntry(entry: T): void;
  44036. /**
  44037. * Remove an element from this block
  44038. * @param entry defines the element to remove
  44039. */
  44040. removeEntry(entry: T): void;
  44041. /**
  44042. * Add an array of elements to this block
  44043. * @param entries defines the array of elements to add
  44044. */
  44045. addEntries(entries: T[]): void;
  44046. /**
  44047. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44048. * @param frustumPlanes defines the frustum planes to test
  44049. * @param selection defines the array to store current content if selection is positive
  44050. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44051. */
  44052. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44053. /**
  44054. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44055. * @param sphereCenter defines the bounding sphere center
  44056. * @param sphereRadius defines the bounding sphere radius
  44057. * @param selection defines the array to store current content if selection is positive
  44058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44059. */
  44060. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44061. /**
  44062. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44063. * @param ray defines the ray to test with
  44064. * @param selection defines the array to store current content if selection is positive
  44065. */
  44066. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44067. /**
  44068. * Subdivide the content into child blocks (this block will then be empty)
  44069. */
  44070. createInnerBlocks(): void;
  44071. /**
  44072. * @hidden
  44073. */
  44074. 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;
  44075. }
  44076. }
  44077. declare module "babylonjs/Culling/Octrees/octree" {
  44078. import { SmartArray } from "babylonjs/Misc/smartArray";
  44079. import { Vector3 } from "babylonjs/Maths/math.vector";
  44080. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44082. import { Ray } from "babylonjs/Culling/ray";
  44083. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44084. import { Plane } from "babylonjs/Maths/math.plane";
  44085. /**
  44086. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44088. */
  44089. export class Octree<T> {
  44090. /** 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.) */
  44091. maxDepth: number;
  44092. /**
  44093. * Blocks within the octree containing objects
  44094. */
  44095. blocks: Array<OctreeBlock<T>>;
  44096. /**
  44097. * Content stored in the octree
  44098. */
  44099. dynamicContent: T[];
  44100. private _maxBlockCapacity;
  44101. private _selectionContent;
  44102. private _creationFunc;
  44103. /**
  44104. * Creates a octree
  44105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44106. * @param creationFunc function to be used to instatiate the octree
  44107. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44108. * @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.)
  44109. */
  44110. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44111. /** 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.) */
  44112. maxDepth?: number);
  44113. /**
  44114. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44115. * @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);
  44116. * @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);
  44117. * @param entries meshes to be added to the octree blocks
  44118. */
  44119. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44120. /**
  44121. * Adds a mesh to the octree
  44122. * @param entry Mesh to add to the octree
  44123. */
  44124. addMesh(entry: T): void;
  44125. /**
  44126. * Remove an element from the octree
  44127. * @param entry defines the element to remove
  44128. */
  44129. removeMesh(entry: T): void;
  44130. /**
  44131. * Selects an array of meshes within the frustum
  44132. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44133. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44134. * @returns array of meshes within the frustum
  44135. */
  44136. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44137. /**
  44138. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44139. * @param sphereCenter defines the bounding sphere center
  44140. * @param sphereRadius defines the bounding sphere radius
  44141. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44142. * @returns an array of objects that intersect the sphere
  44143. */
  44144. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44145. /**
  44146. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44147. * @param ray defines the ray to test with
  44148. * @returns array of intersected objects
  44149. */
  44150. intersectsRay(ray: Ray): SmartArray<T>;
  44151. /**
  44152. * Adds a mesh into the octree block if it intersects the block
  44153. */
  44154. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44155. /**
  44156. * Adds a submesh into the octree block if it intersects the block
  44157. */
  44158. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44159. }
  44160. }
  44161. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44162. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44163. import { Scene } from "babylonjs/scene";
  44164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44166. import { Ray } from "babylonjs/Culling/ray";
  44167. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44168. import { Collider } from "babylonjs/Collisions/collider";
  44169. module "babylonjs/scene" {
  44170. interface Scene {
  44171. /**
  44172. * @hidden
  44173. * Backing Filed
  44174. */
  44175. _selectionOctree: Octree<AbstractMesh>;
  44176. /**
  44177. * Gets the octree used to boost mesh selection (picking)
  44178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44179. */
  44180. selectionOctree: Octree<AbstractMesh>;
  44181. /**
  44182. * Creates or updates the octree used to boost selection (picking)
  44183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44184. * @param maxCapacity defines the maximum capacity per leaf
  44185. * @param maxDepth defines the maximum depth of the octree
  44186. * @returns an octree of AbstractMesh
  44187. */
  44188. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44189. }
  44190. }
  44191. module "babylonjs/Meshes/abstractMesh" {
  44192. interface AbstractMesh {
  44193. /**
  44194. * @hidden
  44195. * Backing Field
  44196. */
  44197. _submeshesOctree: Octree<SubMesh>;
  44198. /**
  44199. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44200. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44201. * @param maxCapacity defines the maximum size of each block (64 by default)
  44202. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44203. * @returns the new octree
  44204. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44206. */
  44207. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44208. }
  44209. }
  44210. /**
  44211. * Defines the octree scene component responsible to manage any octrees
  44212. * in a given scene.
  44213. */
  44214. export class OctreeSceneComponent {
  44215. /**
  44216. * The component name help to identify the component in the list of scene components.
  44217. */
  44218. readonly name: string;
  44219. /**
  44220. * The scene the component belongs to.
  44221. */
  44222. scene: Scene;
  44223. /**
  44224. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44225. */
  44226. readonly checksIsEnabled: boolean;
  44227. /**
  44228. * Creates a new instance of the component for the given scene
  44229. * @param scene Defines the scene to register the component in
  44230. */
  44231. constructor(scene: Scene);
  44232. /**
  44233. * Registers the component in a given scene
  44234. */
  44235. register(): void;
  44236. /**
  44237. * Return the list of active meshes
  44238. * @returns the list of active meshes
  44239. */
  44240. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44241. /**
  44242. * Return the list of active sub meshes
  44243. * @param mesh The mesh to get the candidates sub meshes from
  44244. * @returns the list of active sub meshes
  44245. */
  44246. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44247. private _tempRay;
  44248. /**
  44249. * Return the list of sub meshes intersecting with a given local ray
  44250. * @param mesh defines the mesh to find the submesh for
  44251. * @param localRay defines the ray in local space
  44252. * @returns the list of intersecting sub meshes
  44253. */
  44254. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44255. /**
  44256. * Return the list of sub meshes colliding with a collider
  44257. * @param mesh defines the mesh to find the submesh for
  44258. * @param collider defines the collider to evaluate the collision against
  44259. * @returns the list of colliding sub meshes
  44260. */
  44261. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44262. /**
  44263. * Rebuilds the elements related to this component in case of
  44264. * context lost for instance.
  44265. */
  44266. rebuild(): void;
  44267. /**
  44268. * Disposes the component and the associated ressources.
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Culling/Octrees/index" {
  44274. export * from "babylonjs/Culling/Octrees/octree";
  44275. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44276. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44277. }
  44278. declare module "babylonjs/Culling/index" {
  44279. export * from "babylonjs/Culling/boundingBox";
  44280. export * from "babylonjs/Culling/boundingInfo";
  44281. export * from "babylonjs/Culling/boundingSphere";
  44282. export * from "babylonjs/Culling/Octrees/index";
  44283. export * from "babylonjs/Culling/ray";
  44284. }
  44285. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44286. import { IDisposable, Scene } from "babylonjs/scene";
  44287. import { Nullable } from "babylonjs/types";
  44288. import { Observable } from "babylonjs/Misc/observable";
  44289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44290. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44291. import { Camera } from "babylonjs/Cameras/camera";
  44292. /**
  44293. * Renders a layer on top of an existing scene
  44294. */
  44295. export class UtilityLayerRenderer implements IDisposable {
  44296. /** the original scene that will be rendered on top of */
  44297. originalScene: Scene;
  44298. private _pointerCaptures;
  44299. private _lastPointerEvents;
  44300. private static _DefaultUtilityLayer;
  44301. private static _DefaultKeepDepthUtilityLayer;
  44302. private _sharedGizmoLight;
  44303. private _renderCamera;
  44304. /**
  44305. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44306. * @returns the camera that is used when rendering the utility layer
  44307. */
  44308. getRenderCamera(): Nullable<Camera>;
  44309. /**
  44310. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44311. * @param cam the camera that should be used when rendering the utility layer
  44312. */
  44313. setRenderCamera(cam: Nullable<Camera>): void;
  44314. /**
  44315. * @hidden
  44316. * Light which used by gizmos to get light shading
  44317. */
  44318. _getSharedGizmoLight(): HemisphericLight;
  44319. /**
  44320. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44321. */
  44322. pickUtilitySceneFirst: boolean;
  44323. /**
  44324. * 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)
  44325. */
  44326. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44327. /**
  44328. * 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)
  44329. */
  44330. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44331. /**
  44332. * The scene that is rendered on top of the original scene
  44333. */
  44334. utilityLayerScene: Scene;
  44335. /**
  44336. * If the utility layer should automatically be rendered on top of existing scene
  44337. */
  44338. shouldRender: boolean;
  44339. /**
  44340. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44341. */
  44342. onlyCheckPointerDownEvents: boolean;
  44343. /**
  44344. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44345. */
  44346. processAllEvents: boolean;
  44347. /**
  44348. * Observable raised when the pointer move from the utility layer scene to the main scene
  44349. */
  44350. onPointerOutObservable: Observable<number>;
  44351. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44352. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44353. private _afterRenderObserver;
  44354. private _sceneDisposeObserver;
  44355. private _originalPointerObserver;
  44356. /**
  44357. * Instantiates a UtilityLayerRenderer
  44358. * @param originalScene the original scene that will be rendered on top of
  44359. * @param handleEvents boolean indicating if the utility layer should handle events
  44360. */
  44361. constructor(
  44362. /** the original scene that will be rendered on top of */
  44363. originalScene: Scene, handleEvents?: boolean);
  44364. private _notifyObservers;
  44365. /**
  44366. * Renders the utility layers scene on top of the original scene
  44367. */
  44368. render(): void;
  44369. /**
  44370. * Disposes of the renderer
  44371. */
  44372. dispose(): void;
  44373. private _updateCamera;
  44374. }
  44375. }
  44376. declare module "babylonjs/Gizmos/gizmo" {
  44377. import { Nullable } from "babylonjs/types";
  44378. import { IDisposable } from "babylonjs/scene";
  44379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44380. import { Mesh } from "babylonjs/Meshes/mesh";
  44381. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44382. /**
  44383. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44384. */
  44385. export class Gizmo implements IDisposable {
  44386. /** The utility layer the gizmo will be added to */
  44387. gizmoLayer: UtilityLayerRenderer;
  44388. /**
  44389. * The root mesh of the gizmo
  44390. */
  44391. _rootMesh: Mesh;
  44392. private _attachedMesh;
  44393. /**
  44394. * Ratio for the scale of the gizmo (Default: 1)
  44395. */
  44396. scaleRatio: number;
  44397. /**
  44398. * If a custom mesh has been set (Default: false)
  44399. */
  44400. protected _customMeshSet: boolean;
  44401. /**
  44402. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44403. * * When set, interactions will be enabled
  44404. */
  44405. attachedMesh: Nullable<AbstractMesh>;
  44406. /**
  44407. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44408. * @param mesh The mesh to replace the default mesh of the gizmo
  44409. */
  44410. setCustomMesh(mesh: Mesh): void;
  44411. /**
  44412. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44413. */
  44414. updateGizmoRotationToMatchAttachedMesh: boolean;
  44415. /**
  44416. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44417. */
  44418. updateGizmoPositionToMatchAttachedMesh: boolean;
  44419. /**
  44420. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44421. */
  44422. updateScale: boolean;
  44423. protected _interactionsEnabled: boolean;
  44424. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44425. private _beforeRenderObserver;
  44426. private _tempVector;
  44427. /**
  44428. * Creates a gizmo
  44429. * @param gizmoLayer The utility layer the gizmo will be added to
  44430. */
  44431. constructor(
  44432. /** The utility layer the gizmo will be added to */
  44433. gizmoLayer?: UtilityLayerRenderer);
  44434. /**
  44435. * Updates the gizmo to match the attached mesh's position/rotation
  44436. */
  44437. protected _update(): void;
  44438. /**
  44439. * Disposes of the gizmo
  44440. */
  44441. dispose(): void;
  44442. }
  44443. }
  44444. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44445. import { Observable } from "babylonjs/Misc/observable";
  44446. import { Nullable } from "babylonjs/types";
  44447. import { Vector3 } from "babylonjs/Maths/math.vector";
  44448. import { Color3 } from "babylonjs/Maths/math.color";
  44449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44451. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44452. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44453. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44454. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44455. import { Scene } from "babylonjs/scene";
  44456. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44457. /**
  44458. * Single plane drag gizmo
  44459. */
  44460. export class PlaneDragGizmo extends Gizmo {
  44461. /**
  44462. * Drag behavior responsible for the gizmos dragging interactions
  44463. */
  44464. dragBehavior: PointerDragBehavior;
  44465. private _pointerObserver;
  44466. /**
  44467. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44468. */
  44469. snapDistance: number;
  44470. /**
  44471. * Event that fires each time the gizmo snaps to a new location.
  44472. * * snapDistance is the the change in distance
  44473. */
  44474. onSnapObservable: Observable<{
  44475. snapDistance: number;
  44476. }>;
  44477. private _plane;
  44478. private _coloredMaterial;
  44479. private _hoverMaterial;
  44480. private _isEnabled;
  44481. private _parent;
  44482. /** @hidden */
  44483. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44484. /** @hidden */
  44485. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44486. /**
  44487. * Creates a PlaneDragGizmo
  44488. * @param gizmoLayer The utility layer the gizmo will be added to
  44489. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44490. * @param color The color of the gizmo
  44491. */
  44492. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44493. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44494. /**
  44495. * If the gizmo is enabled
  44496. */
  44497. isEnabled: boolean;
  44498. /**
  44499. * Disposes of the gizmo
  44500. */
  44501. dispose(): void;
  44502. }
  44503. }
  44504. declare module "babylonjs/Gizmos/positionGizmo" {
  44505. import { Observable } from "babylonjs/Misc/observable";
  44506. import { Nullable } from "babylonjs/types";
  44507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44508. import { Mesh } from "babylonjs/Meshes/mesh";
  44509. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44510. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44511. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44513. /**
  44514. * Gizmo that enables dragging a mesh along 3 axis
  44515. */
  44516. export class PositionGizmo extends Gizmo {
  44517. /**
  44518. * Internal gizmo used for interactions on the x axis
  44519. */
  44520. xGizmo: AxisDragGizmo;
  44521. /**
  44522. * Internal gizmo used for interactions on the y axis
  44523. */
  44524. yGizmo: AxisDragGizmo;
  44525. /**
  44526. * Internal gizmo used for interactions on the z axis
  44527. */
  44528. zGizmo: AxisDragGizmo;
  44529. /**
  44530. * Internal gizmo used for interactions on the yz plane
  44531. */
  44532. xPlaneGizmo: PlaneDragGizmo;
  44533. /**
  44534. * Internal gizmo used for interactions on the xz plane
  44535. */
  44536. yPlaneGizmo: PlaneDragGizmo;
  44537. /**
  44538. * Internal gizmo used for interactions on the xy plane
  44539. */
  44540. zPlaneGizmo: PlaneDragGizmo;
  44541. /**
  44542. * private variables
  44543. */
  44544. private _meshAttached;
  44545. private _updateGizmoRotationToMatchAttachedMesh;
  44546. private _snapDistance;
  44547. private _scaleRatio;
  44548. /** Fires an event when any of it's sub gizmos are dragged */
  44549. onDragStartObservable: Observable<unknown>;
  44550. /** Fires an event when any of it's sub gizmos are released from dragging */
  44551. onDragEndObservable: Observable<unknown>;
  44552. /**
  44553. * If set to true, planar drag is enabled
  44554. */
  44555. private _planarGizmoEnabled;
  44556. attachedMesh: Nullable<AbstractMesh>;
  44557. /**
  44558. * Creates a PositionGizmo
  44559. * @param gizmoLayer The utility layer the gizmo will be added to
  44560. */
  44561. constructor(gizmoLayer?: UtilityLayerRenderer);
  44562. /**
  44563. * If the planar drag gizmo is enabled
  44564. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44565. */
  44566. planarGizmoEnabled: boolean;
  44567. updateGizmoRotationToMatchAttachedMesh: boolean;
  44568. /**
  44569. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44570. */
  44571. snapDistance: number;
  44572. /**
  44573. * Ratio for the scale of the gizmo (Default: 1)
  44574. */
  44575. scaleRatio: number;
  44576. /**
  44577. * Disposes of the gizmo
  44578. */
  44579. dispose(): void;
  44580. /**
  44581. * CustomMeshes are not supported by this gizmo
  44582. * @param mesh The mesh to replace the default mesh of the gizmo
  44583. */
  44584. setCustomMesh(mesh: Mesh): void;
  44585. }
  44586. }
  44587. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44588. import { Observable } from "babylonjs/Misc/observable";
  44589. import { Nullable } from "babylonjs/types";
  44590. import { Vector3 } from "babylonjs/Maths/math.vector";
  44591. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44592. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44593. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44594. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44595. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44596. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44597. import { Scene } from "babylonjs/scene";
  44598. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44599. import { Color3 } from "babylonjs/Maths/math.color";
  44600. /**
  44601. * Single axis drag gizmo
  44602. */
  44603. export class AxisDragGizmo extends Gizmo {
  44604. /**
  44605. * Drag behavior responsible for the gizmos dragging interactions
  44606. */
  44607. dragBehavior: PointerDragBehavior;
  44608. private _pointerObserver;
  44609. /**
  44610. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44611. */
  44612. snapDistance: number;
  44613. /**
  44614. * Event that fires each time the gizmo snaps to a new location.
  44615. * * snapDistance is the the change in distance
  44616. */
  44617. onSnapObservable: Observable<{
  44618. snapDistance: number;
  44619. }>;
  44620. private _isEnabled;
  44621. private _parent;
  44622. private _arrow;
  44623. private _coloredMaterial;
  44624. private _hoverMaterial;
  44625. /** @hidden */
  44626. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44627. /** @hidden */
  44628. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44629. /**
  44630. * Creates an AxisDragGizmo
  44631. * @param gizmoLayer The utility layer the gizmo will be added to
  44632. * @param dragAxis The axis which the gizmo will be able to drag on
  44633. * @param color The color of the gizmo
  44634. */
  44635. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44637. /**
  44638. * If the gizmo is enabled
  44639. */
  44640. isEnabled: boolean;
  44641. /**
  44642. * Disposes of the gizmo
  44643. */
  44644. dispose(): void;
  44645. }
  44646. }
  44647. declare module "babylonjs/Debug/axesViewer" {
  44648. import { Vector3 } from "babylonjs/Maths/math.vector";
  44649. import { Nullable } from "babylonjs/types";
  44650. import { Scene } from "babylonjs/scene";
  44651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44652. /**
  44653. * The Axes viewer will show 3 axes in a specific point in space
  44654. */
  44655. export class AxesViewer {
  44656. private _xAxis;
  44657. private _yAxis;
  44658. private _zAxis;
  44659. private _scaleLinesFactor;
  44660. private _instanced;
  44661. /**
  44662. * Gets the hosting scene
  44663. */
  44664. scene: Scene;
  44665. /**
  44666. * Gets or sets a number used to scale line length
  44667. */
  44668. scaleLines: number;
  44669. /** Gets the node hierarchy used to render x-axis */
  44670. readonly xAxis: TransformNode;
  44671. /** Gets the node hierarchy used to render y-axis */
  44672. readonly yAxis: TransformNode;
  44673. /** Gets the node hierarchy used to render z-axis */
  44674. readonly zAxis: TransformNode;
  44675. /**
  44676. * Creates a new AxesViewer
  44677. * @param scene defines the hosting scene
  44678. * @param scaleLines defines a number used to scale line length (1 by default)
  44679. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44680. * @param xAxis defines the node hierarchy used to render the x-axis
  44681. * @param yAxis defines the node hierarchy used to render the y-axis
  44682. * @param zAxis defines the node hierarchy used to render the z-axis
  44683. */
  44684. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44685. /**
  44686. * Force the viewer to update
  44687. * @param position defines the position of the viewer
  44688. * @param xaxis defines the x axis of the viewer
  44689. * @param yaxis defines the y axis of the viewer
  44690. * @param zaxis defines the z axis of the viewer
  44691. */
  44692. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44693. /**
  44694. * Creates an instance of this axes viewer.
  44695. * @returns a new axes viewer with instanced meshes
  44696. */
  44697. createInstance(): AxesViewer;
  44698. /** Releases resources */
  44699. dispose(): void;
  44700. private static _SetRenderingGroupId;
  44701. }
  44702. }
  44703. declare module "babylonjs/Debug/boneAxesViewer" {
  44704. import { Nullable } from "babylonjs/types";
  44705. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44706. import { Vector3 } from "babylonjs/Maths/math.vector";
  44707. import { Mesh } from "babylonjs/Meshes/mesh";
  44708. import { Bone } from "babylonjs/Bones/bone";
  44709. import { Scene } from "babylonjs/scene";
  44710. /**
  44711. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44712. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44713. */
  44714. export class BoneAxesViewer extends AxesViewer {
  44715. /**
  44716. * Gets or sets the target mesh where to display the axes viewer
  44717. */
  44718. mesh: Nullable<Mesh>;
  44719. /**
  44720. * Gets or sets the target bone where to display the axes viewer
  44721. */
  44722. bone: Nullable<Bone>;
  44723. /** Gets current position */
  44724. pos: Vector3;
  44725. /** Gets direction of X axis */
  44726. xaxis: Vector3;
  44727. /** Gets direction of Y axis */
  44728. yaxis: Vector3;
  44729. /** Gets direction of Z axis */
  44730. zaxis: Vector3;
  44731. /**
  44732. * Creates a new BoneAxesViewer
  44733. * @param scene defines the hosting scene
  44734. * @param bone defines the target bone
  44735. * @param mesh defines the target mesh
  44736. * @param scaleLines defines a scaling factor for line length (1 by default)
  44737. */
  44738. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44739. /**
  44740. * Force the viewer to update
  44741. */
  44742. update(): void;
  44743. /** Releases resources */
  44744. dispose(): void;
  44745. }
  44746. }
  44747. declare module "babylonjs/Debug/debugLayer" {
  44748. import { Scene } from "babylonjs/scene";
  44749. /**
  44750. * Interface used to define scene explorer extensibility option
  44751. */
  44752. export interface IExplorerExtensibilityOption {
  44753. /**
  44754. * Define the option label
  44755. */
  44756. label: string;
  44757. /**
  44758. * Defines the action to execute on click
  44759. */
  44760. action: (entity: any) => void;
  44761. }
  44762. /**
  44763. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44764. */
  44765. export interface IExplorerExtensibilityGroup {
  44766. /**
  44767. * Defines a predicate to test if a given type mut be extended
  44768. */
  44769. predicate: (entity: any) => boolean;
  44770. /**
  44771. * Gets the list of options added to a type
  44772. */
  44773. entries: IExplorerExtensibilityOption[];
  44774. }
  44775. /**
  44776. * Interface used to define the options to use to create the Inspector
  44777. */
  44778. export interface IInspectorOptions {
  44779. /**
  44780. * Display in overlay mode (default: false)
  44781. */
  44782. overlay?: boolean;
  44783. /**
  44784. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44785. */
  44786. globalRoot?: HTMLElement;
  44787. /**
  44788. * Display the Scene explorer
  44789. */
  44790. showExplorer?: boolean;
  44791. /**
  44792. * Display the property inspector
  44793. */
  44794. showInspector?: boolean;
  44795. /**
  44796. * Display in embed mode (both panes on the right)
  44797. */
  44798. embedMode?: boolean;
  44799. /**
  44800. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44801. */
  44802. handleResize?: boolean;
  44803. /**
  44804. * Allow the panes to popup (default: true)
  44805. */
  44806. enablePopup?: boolean;
  44807. /**
  44808. * Allow the panes to be closed by users (default: true)
  44809. */
  44810. enableClose?: boolean;
  44811. /**
  44812. * Optional list of extensibility entries
  44813. */
  44814. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44815. /**
  44816. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44817. */
  44818. inspectorURL?: string;
  44819. }
  44820. module "babylonjs/scene" {
  44821. interface Scene {
  44822. /**
  44823. * @hidden
  44824. * Backing field
  44825. */
  44826. _debugLayer: DebugLayer;
  44827. /**
  44828. * Gets the debug layer (aka Inspector) associated with the scene
  44829. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44830. */
  44831. debugLayer: DebugLayer;
  44832. }
  44833. }
  44834. /**
  44835. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44836. * what is happening in your scene
  44837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44838. */
  44839. export class DebugLayer {
  44840. /**
  44841. * Define the url to get the inspector script from.
  44842. * By default it uses the babylonjs CDN.
  44843. * @ignoreNaming
  44844. */
  44845. static InspectorURL: string;
  44846. private _scene;
  44847. private BJSINSPECTOR;
  44848. private _onPropertyChangedObservable?;
  44849. /**
  44850. * Observable triggered when a property is changed through the inspector.
  44851. */
  44852. readonly onPropertyChangedObservable: any;
  44853. /**
  44854. * Instantiates a new debug layer.
  44855. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44856. * what is happening in your scene
  44857. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44858. * @param scene Defines the scene to inspect
  44859. */
  44860. constructor(scene: Scene);
  44861. /** Creates the inspector window. */
  44862. private _createInspector;
  44863. /**
  44864. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44865. * @param entity defines the entity to select
  44866. * @param lineContainerTitle defines the specific block to highlight
  44867. */
  44868. select(entity: any, lineContainerTitle?: string): void;
  44869. /** Get the inspector from bundle or global */
  44870. private _getGlobalInspector;
  44871. /**
  44872. * Get if the inspector is visible or not.
  44873. * @returns true if visible otherwise, false
  44874. */
  44875. isVisible(): boolean;
  44876. /**
  44877. * Hide the inspector and close its window.
  44878. */
  44879. hide(): void;
  44880. /**
  44881. * Launch the debugLayer.
  44882. * @param config Define the configuration of the inspector
  44883. * @return a promise fulfilled when the debug layer is visible
  44884. */
  44885. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44886. }
  44887. }
  44888. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44889. import { Nullable } from "babylonjs/types";
  44890. import { Scene } from "babylonjs/scene";
  44891. import { Vector4 } from "babylonjs/Maths/math.vector";
  44892. import { Color4 } from "babylonjs/Maths/math.color";
  44893. import { Mesh } from "babylonjs/Meshes/mesh";
  44894. /**
  44895. * Class containing static functions to help procedurally build meshes
  44896. */
  44897. export class BoxBuilder {
  44898. /**
  44899. * Creates a box mesh
  44900. * * The parameter `size` sets the size (float) of each box side (default 1)
  44901. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44902. * * 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)
  44903. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44907. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44908. * @param name defines the name of the mesh
  44909. * @param options defines the options used to create the mesh
  44910. * @param scene defines the hosting scene
  44911. * @returns the box mesh
  44912. */
  44913. static CreateBox(name: string, options: {
  44914. size?: number;
  44915. width?: number;
  44916. height?: number;
  44917. depth?: number;
  44918. faceUV?: Vector4[];
  44919. faceColors?: Color4[];
  44920. sideOrientation?: number;
  44921. frontUVs?: Vector4;
  44922. backUVs?: Vector4;
  44923. wrap?: boolean;
  44924. topBaseAt?: number;
  44925. bottomBaseAt?: number;
  44926. updatable?: boolean;
  44927. }, scene?: Nullable<Scene>): Mesh;
  44928. }
  44929. }
  44930. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44931. import { Vector4 } from "babylonjs/Maths/math.vector";
  44932. import { Mesh } from "babylonjs/Meshes/mesh";
  44933. import { Scene } from "babylonjs/scene";
  44934. import { Nullable } from "babylonjs/types";
  44935. /**
  44936. * Class containing static functions to help procedurally build meshes
  44937. */
  44938. export class SphereBuilder {
  44939. /**
  44940. * Creates a sphere mesh
  44941. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44942. * * 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`)
  44943. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44944. * * 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
  44945. * * 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)
  44946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44949. * @param name defines the name of the mesh
  44950. * @param options defines the options used to create the mesh
  44951. * @param scene defines the hosting scene
  44952. * @returns the sphere mesh
  44953. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44954. */
  44955. static CreateSphere(name: string, options: {
  44956. segments?: number;
  44957. diameter?: number;
  44958. diameterX?: number;
  44959. diameterY?: number;
  44960. diameterZ?: number;
  44961. arc?: number;
  44962. slice?: number;
  44963. sideOrientation?: number;
  44964. frontUVs?: Vector4;
  44965. backUVs?: Vector4;
  44966. updatable?: boolean;
  44967. }, scene?: Nullable<Scene>): Mesh;
  44968. }
  44969. }
  44970. declare module "babylonjs/Debug/physicsViewer" {
  44971. import { Nullable } from "babylonjs/types";
  44972. import { Scene } from "babylonjs/scene";
  44973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44974. import { Mesh } from "babylonjs/Meshes/mesh";
  44975. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44976. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44977. /**
  44978. * Used to show the physics impostor around the specific mesh
  44979. */
  44980. export class PhysicsViewer {
  44981. /** @hidden */
  44982. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44983. /** @hidden */
  44984. protected _meshes: Array<Nullable<AbstractMesh>>;
  44985. /** @hidden */
  44986. protected _scene: Nullable<Scene>;
  44987. /** @hidden */
  44988. protected _numMeshes: number;
  44989. /** @hidden */
  44990. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44991. private _renderFunction;
  44992. private _utilityLayer;
  44993. private _debugBoxMesh;
  44994. private _debugSphereMesh;
  44995. private _debugCylinderMesh;
  44996. private _debugMaterial;
  44997. private _debugMeshMeshes;
  44998. /**
  44999. * Creates a new PhysicsViewer
  45000. * @param scene defines the hosting scene
  45001. */
  45002. constructor(scene: Scene);
  45003. /** @hidden */
  45004. protected _updateDebugMeshes(): void;
  45005. /**
  45006. * Renders a specified physic impostor
  45007. * @param impostor defines the impostor to render
  45008. * @param targetMesh defines the mesh represented by the impostor
  45009. * @returns the new debug mesh used to render the impostor
  45010. */
  45011. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45012. /**
  45013. * Hides a specified physic impostor
  45014. * @param impostor defines the impostor to hide
  45015. */
  45016. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45017. private _getDebugMaterial;
  45018. private _getDebugBoxMesh;
  45019. private _getDebugSphereMesh;
  45020. private _getDebugCylinderMesh;
  45021. private _getDebugMeshMesh;
  45022. private _getDebugMesh;
  45023. /** Releases all resources */
  45024. dispose(): void;
  45025. }
  45026. }
  45027. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45028. import { Vector3 } from "babylonjs/Maths/math.vector";
  45029. import { Color4 } from "babylonjs/Maths/math.color";
  45030. import { Nullable } from "babylonjs/types";
  45031. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45032. import { Scene } from "babylonjs/scene";
  45033. /**
  45034. * Class containing static functions to help procedurally build meshes
  45035. */
  45036. export class LinesBuilder {
  45037. /**
  45038. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45039. * * 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
  45040. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45041. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45042. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45043. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45044. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45045. * * 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
  45046. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45048. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45049. * @param name defines the name of the new line system
  45050. * @param options defines the options used to create the line system
  45051. * @param scene defines the hosting scene
  45052. * @returns a new line system mesh
  45053. */
  45054. static CreateLineSystem(name: string, options: {
  45055. lines: Vector3[][];
  45056. updatable?: boolean;
  45057. instance?: Nullable<LinesMesh>;
  45058. colors?: Nullable<Color4[][]>;
  45059. useVertexAlpha?: boolean;
  45060. }, scene: Nullable<Scene>): LinesMesh;
  45061. /**
  45062. * Creates a line mesh
  45063. * 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
  45064. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45065. * * The parameter `points` is an array successive Vector3
  45066. * * 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
  45067. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45068. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45069. * * When updating an instance, remember that only point positions can change, not the number of points
  45070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45072. * @param name defines the name of the new line system
  45073. * @param options defines the options used to create the line system
  45074. * @param scene defines the hosting scene
  45075. * @returns a new line mesh
  45076. */
  45077. static CreateLines(name: string, options: {
  45078. points: Vector3[];
  45079. updatable?: boolean;
  45080. instance?: Nullable<LinesMesh>;
  45081. colors?: Color4[];
  45082. useVertexAlpha?: boolean;
  45083. }, scene?: Nullable<Scene>): LinesMesh;
  45084. /**
  45085. * Creates a dashed line mesh
  45086. * * 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
  45087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45088. * * The parameter `points` is an array successive Vector3
  45089. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45090. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45091. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45092. * * 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
  45093. * * When updating an instance, remember that only point positions can change, not the number of points
  45094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45095. * @param name defines the name of the mesh
  45096. * @param options defines the options used to create the mesh
  45097. * @param scene defines the hosting scene
  45098. * @returns the dashed line mesh
  45099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45100. */
  45101. static CreateDashedLines(name: string, options: {
  45102. points: Vector3[];
  45103. dashSize?: number;
  45104. gapSize?: number;
  45105. dashNb?: number;
  45106. updatable?: boolean;
  45107. instance?: LinesMesh;
  45108. }, scene?: Nullable<Scene>): LinesMesh;
  45109. }
  45110. }
  45111. declare module "babylonjs/Debug/rayHelper" {
  45112. import { Nullable } from "babylonjs/types";
  45113. import { Ray } from "babylonjs/Culling/ray";
  45114. import { Vector3 } from "babylonjs/Maths/math.vector";
  45115. import { Color3 } from "babylonjs/Maths/math.color";
  45116. import { Scene } from "babylonjs/scene";
  45117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45118. import "babylonjs/Meshes/Builders/linesBuilder";
  45119. /**
  45120. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45121. * in order to better appreciate the issue one might have.
  45122. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45123. */
  45124. export class RayHelper {
  45125. /**
  45126. * Defines the ray we are currently tryin to visualize.
  45127. */
  45128. ray: Nullable<Ray>;
  45129. private _renderPoints;
  45130. private _renderLine;
  45131. private _renderFunction;
  45132. private _scene;
  45133. private _updateToMeshFunction;
  45134. private _attachedToMesh;
  45135. private _meshSpaceDirection;
  45136. private _meshSpaceOrigin;
  45137. /**
  45138. * Helper function to create a colored helper in a scene in one line.
  45139. * @param ray Defines the ray we are currently tryin to visualize
  45140. * @param scene Defines the scene the ray is used in
  45141. * @param color Defines the color we want to see the ray in
  45142. * @returns The newly created ray helper.
  45143. */
  45144. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45145. /**
  45146. * Instantiate a new ray helper.
  45147. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45148. * in order to better appreciate the issue one might have.
  45149. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45150. * @param ray Defines the ray we are currently tryin to visualize
  45151. */
  45152. constructor(ray: Ray);
  45153. /**
  45154. * Shows the ray we are willing to debug.
  45155. * @param scene Defines the scene the ray needs to be rendered in
  45156. * @param color Defines the color the ray needs to be rendered in
  45157. */
  45158. show(scene: Scene, color?: Color3): void;
  45159. /**
  45160. * Hides the ray we are debugging.
  45161. */
  45162. hide(): void;
  45163. private _render;
  45164. /**
  45165. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45166. * @param mesh Defines the mesh we want the helper attached to
  45167. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45168. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45169. * @param length Defines the length of the ray
  45170. */
  45171. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45172. /**
  45173. * Detach the ray helper from the mesh it has previously been attached to.
  45174. */
  45175. detachFromMesh(): void;
  45176. private _updateToMesh;
  45177. /**
  45178. * Dispose the helper and release its associated resources.
  45179. */
  45180. dispose(): void;
  45181. }
  45182. }
  45183. declare module "babylonjs/Debug/skeletonViewer" {
  45184. import { Color3 } from "babylonjs/Maths/math.color";
  45185. import { Scene } from "babylonjs/scene";
  45186. import { Nullable } from "babylonjs/types";
  45187. import { Skeleton } from "babylonjs/Bones/skeleton";
  45188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45189. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45190. /**
  45191. * Class used to render a debug view of a given skeleton
  45192. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45193. */
  45194. export class SkeletonViewer {
  45195. /** defines the skeleton to render */
  45196. skeleton: Skeleton;
  45197. /** defines the mesh attached to the skeleton */
  45198. mesh: AbstractMesh;
  45199. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45200. autoUpdateBonesMatrices: boolean;
  45201. /** defines the rendering group id to use with the viewer */
  45202. renderingGroupId: number;
  45203. /** Gets or sets the color used to render the skeleton */
  45204. color: Color3;
  45205. private _scene;
  45206. private _debugLines;
  45207. private _debugMesh;
  45208. private _isEnabled;
  45209. private _renderFunction;
  45210. private _utilityLayer;
  45211. /**
  45212. * Returns the mesh used to render the bones
  45213. */
  45214. readonly debugMesh: Nullable<LinesMesh>;
  45215. /**
  45216. * Creates a new SkeletonViewer
  45217. * @param skeleton defines the skeleton to render
  45218. * @param mesh defines the mesh attached to the skeleton
  45219. * @param scene defines the hosting scene
  45220. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45221. * @param renderingGroupId defines the rendering group id to use with the viewer
  45222. */
  45223. constructor(
  45224. /** defines the skeleton to render */
  45225. skeleton: Skeleton,
  45226. /** defines the mesh attached to the skeleton */
  45227. mesh: AbstractMesh, scene: Scene,
  45228. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45229. autoUpdateBonesMatrices?: boolean,
  45230. /** defines the rendering group id to use with the viewer */
  45231. renderingGroupId?: number);
  45232. /** Gets or sets a boolean indicating if the viewer is enabled */
  45233. isEnabled: boolean;
  45234. private _getBonePosition;
  45235. private _getLinesForBonesWithLength;
  45236. private _getLinesForBonesNoLength;
  45237. /** Update the viewer to sync with current skeleton state */
  45238. update(): void;
  45239. /** Release associated resources */
  45240. dispose(): void;
  45241. }
  45242. }
  45243. declare module "babylonjs/Debug/index" {
  45244. export * from "babylonjs/Debug/axesViewer";
  45245. export * from "babylonjs/Debug/boneAxesViewer";
  45246. export * from "babylonjs/Debug/debugLayer";
  45247. export * from "babylonjs/Debug/physicsViewer";
  45248. export * from "babylonjs/Debug/rayHelper";
  45249. export * from "babylonjs/Debug/skeletonViewer";
  45250. }
  45251. declare module "babylonjs/Engines/nullEngine" {
  45252. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45253. import { Scene } from "babylonjs/scene";
  45254. import { Engine } from "babylonjs/Engines/engine";
  45255. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45256. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45257. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45258. import { Effect } from "babylonjs/Materials/effect";
  45259. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45261. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45262. /**
  45263. * Options to create the null engine
  45264. */
  45265. export class NullEngineOptions {
  45266. /**
  45267. * Render width (Default: 512)
  45268. */
  45269. renderWidth: number;
  45270. /**
  45271. * Render height (Default: 256)
  45272. */
  45273. renderHeight: number;
  45274. /**
  45275. * Texture size (Default: 512)
  45276. */
  45277. textureSize: number;
  45278. /**
  45279. * If delta time between frames should be constant
  45280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45281. */
  45282. deterministicLockstep: boolean;
  45283. /**
  45284. * Maximum about of steps between frames (Default: 4)
  45285. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45286. */
  45287. lockstepMaxSteps: number;
  45288. }
  45289. /**
  45290. * The null engine class provides support for headless version of babylon.js.
  45291. * This can be used in server side scenario or for testing purposes
  45292. */
  45293. export class NullEngine extends Engine {
  45294. private _options;
  45295. /**
  45296. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45298. * @returns true if engine is in deterministic lock step mode
  45299. */
  45300. isDeterministicLockStep(): boolean;
  45301. /**
  45302. * Gets the max steps when engine is running in deterministic lock step
  45303. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45304. * @returns the max steps
  45305. */
  45306. getLockstepMaxSteps(): number;
  45307. /**
  45308. * Gets the current hardware scaling level.
  45309. * By default the hardware scaling level is computed from the window device ratio.
  45310. * 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.
  45311. * @returns a number indicating the current hardware scaling level
  45312. */
  45313. getHardwareScalingLevel(): number;
  45314. constructor(options?: NullEngineOptions);
  45315. /**
  45316. * Creates a vertex buffer
  45317. * @param vertices the data for the vertex buffer
  45318. * @returns the new WebGL static buffer
  45319. */
  45320. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45321. /**
  45322. * Creates a new index buffer
  45323. * @param indices defines the content of the index buffer
  45324. * @param updatable defines if the index buffer must be updatable
  45325. * @returns a new webGL buffer
  45326. */
  45327. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45328. /**
  45329. * Clear the current render buffer or the current render target (if any is set up)
  45330. * @param color defines the color to use
  45331. * @param backBuffer defines if the back buffer must be cleared
  45332. * @param depth defines if the depth buffer must be cleared
  45333. * @param stencil defines if the stencil buffer must be cleared
  45334. */
  45335. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45336. /**
  45337. * Gets the current render width
  45338. * @param useScreen defines if screen size must be used (or the current render target if any)
  45339. * @returns a number defining the current render width
  45340. */
  45341. getRenderWidth(useScreen?: boolean): number;
  45342. /**
  45343. * Gets the current render height
  45344. * @param useScreen defines if screen size must be used (or the current render target if any)
  45345. * @returns a number defining the current render height
  45346. */
  45347. getRenderHeight(useScreen?: boolean): number;
  45348. /**
  45349. * Set the WebGL's viewport
  45350. * @param viewport defines the viewport element to be used
  45351. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45352. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45353. */
  45354. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45355. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45356. /**
  45357. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45358. * @param pipelineContext defines the pipeline context to use
  45359. * @param uniformsNames defines the list of uniform names
  45360. * @returns an array of webGL uniform locations
  45361. */
  45362. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45363. /**
  45364. * Gets the lsit of active attributes for a given webGL program
  45365. * @param pipelineContext defines the pipeline context to use
  45366. * @param attributesNames defines the list of attribute names to get
  45367. * @returns an array of indices indicating the offset of each attribute
  45368. */
  45369. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45370. /**
  45371. * Binds an effect to the webGL context
  45372. * @param effect defines the effect to bind
  45373. */
  45374. bindSamplers(effect: Effect): void;
  45375. /**
  45376. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45377. * @param effect defines the effect to activate
  45378. */
  45379. enableEffect(effect: Effect): void;
  45380. /**
  45381. * Set various states to the webGL context
  45382. * @param culling defines backface culling state
  45383. * @param zOffset defines the value to apply to zOffset (0 by default)
  45384. * @param force defines if states must be applied even if cache is up to date
  45385. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45386. */
  45387. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45388. /**
  45389. * Set the value of an uniform to an array of int32
  45390. * @param uniform defines the webGL uniform location where to store the value
  45391. * @param array defines the array of int32 to store
  45392. */
  45393. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45394. /**
  45395. * Set the value of an uniform to an array of int32 (stored as vec2)
  45396. * @param uniform defines the webGL uniform location where to store the value
  45397. * @param array defines the array of int32 to store
  45398. */
  45399. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45400. /**
  45401. * Set the value of an uniform to an array of int32 (stored as vec3)
  45402. * @param uniform defines the webGL uniform location where to store the value
  45403. * @param array defines the array of int32 to store
  45404. */
  45405. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45406. /**
  45407. * Set the value of an uniform to an array of int32 (stored as vec4)
  45408. * @param uniform defines the webGL uniform location where to store the value
  45409. * @param array defines the array of int32 to store
  45410. */
  45411. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45412. /**
  45413. * Set the value of an uniform to an array of float32
  45414. * @param uniform defines the webGL uniform location where to store the value
  45415. * @param array defines the array of float32 to store
  45416. */
  45417. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45418. /**
  45419. * Set the value of an uniform to an array of float32 (stored as vec2)
  45420. * @param uniform defines the webGL uniform location where to store the value
  45421. * @param array defines the array of float32 to store
  45422. */
  45423. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45424. /**
  45425. * Set the value of an uniform to an array of float32 (stored as vec3)
  45426. * @param uniform defines the webGL uniform location where to store the value
  45427. * @param array defines the array of float32 to store
  45428. */
  45429. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45430. /**
  45431. * Set the value of an uniform to an array of float32 (stored as vec4)
  45432. * @param uniform defines the webGL uniform location where to store the value
  45433. * @param array defines the array of float32 to store
  45434. */
  45435. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45436. /**
  45437. * Set the value of an uniform to an array of number
  45438. * @param uniform defines the webGL uniform location where to store the value
  45439. * @param array defines the array of number to store
  45440. */
  45441. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45442. /**
  45443. * Set the value of an uniform to an array of number (stored as vec2)
  45444. * @param uniform defines the webGL uniform location where to store the value
  45445. * @param array defines the array of number to store
  45446. */
  45447. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45448. /**
  45449. * Set the value of an uniform to an array of number (stored as vec3)
  45450. * @param uniform defines the webGL uniform location where to store the value
  45451. * @param array defines the array of number to store
  45452. */
  45453. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45454. /**
  45455. * Set the value of an uniform to an array of number (stored as vec4)
  45456. * @param uniform defines the webGL uniform location where to store the value
  45457. * @param array defines the array of number to store
  45458. */
  45459. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45460. /**
  45461. * Set the value of an uniform to an array of float32 (stored as matrices)
  45462. * @param uniform defines the webGL uniform location where to store the value
  45463. * @param matrices defines the array of float32 to store
  45464. */
  45465. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45466. /**
  45467. * Set the value of an uniform to a matrix (3x3)
  45468. * @param uniform defines the webGL uniform location where to store the value
  45469. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45470. */
  45471. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45472. /**
  45473. * Set the value of an uniform to a matrix (2x2)
  45474. * @param uniform defines the webGL uniform location where to store the value
  45475. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45476. */
  45477. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45478. /**
  45479. * Set the value of an uniform to a number (float)
  45480. * @param uniform defines the webGL uniform location where to store the value
  45481. * @param value defines the float number to store
  45482. */
  45483. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45484. /**
  45485. * Set the value of an uniform to a vec2
  45486. * @param uniform defines the webGL uniform location where to store the value
  45487. * @param x defines the 1st component of the value
  45488. * @param y defines the 2nd component of the value
  45489. */
  45490. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45491. /**
  45492. * Set the value of an uniform to a vec3
  45493. * @param uniform defines the webGL uniform location where to store the value
  45494. * @param x defines the 1st component of the value
  45495. * @param y defines the 2nd component of the value
  45496. * @param z defines the 3rd component of the value
  45497. */
  45498. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45499. /**
  45500. * Set the value of an uniform to a boolean
  45501. * @param uniform defines the webGL uniform location where to store the value
  45502. * @param bool defines the boolean to store
  45503. */
  45504. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45505. /**
  45506. * Set the value of an uniform to a vec4
  45507. * @param uniform defines the webGL uniform location where to store the value
  45508. * @param x defines the 1st component of the value
  45509. * @param y defines the 2nd component of the value
  45510. * @param z defines the 3rd component of the value
  45511. * @param w defines the 4th component of the value
  45512. */
  45513. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45514. /**
  45515. * Sets the current alpha mode
  45516. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45517. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45518. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45519. */
  45520. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45521. /**
  45522. * Bind webGl buffers directly to the webGL context
  45523. * @param vertexBuffers defines the vertex buffer to bind
  45524. * @param indexBuffer defines the index buffer to bind
  45525. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45526. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45527. * @param effect defines the effect associated with the vertex buffer
  45528. */
  45529. bindBuffers(vertexBuffers: {
  45530. [key: string]: VertexBuffer;
  45531. }, indexBuffer: DataBuffer, effect: Effect): void;
  45532. /**
  45533. * Force the entire cache to be cleared
  45534. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45535. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45536. */
  45537. wipeCaches(bruteForce?: boolean): void;
  45538. /**
  45539. * Send a draw order
  45540. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45541. * @param indexStart defines the starting index
  45542. * @param indexCount defines the number of index to draw
  45543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45544. */
  45545. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45546. /**
  45547. * Draw a list of indexed primitives
  45548. * @param fillMode defines the primitive to use
  45549. * @param indexStart defines the starting index
  45550. * @param indexCount defines the number of index to draw
  45551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45552. */
  45553. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45554. /**
  45555. * Draw a list of unindexed primitives
  45556. * @param fillMode defines the primitive to use
  45557. * @param verticesStart defines the index of first vertex to draw
  45558. * @param verticesCount defines the count of vertices to draw
  45559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45560. */
  45561. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45562. /** @hidden */
  45563. _createTexture(): WebGLTexture;
  45564. /** @hidden */
  45565. _releaseTexture(texture: InternalTexture): void;
  45566. /**
  45567. * Usually called from Texture.ts.
  45568. * Passed information to create a WebGLTexture
  45569. * @param urlArg defines a value which contains one of the following:
  45570. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45571. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45572. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45573. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45574. * @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)
  45575. * @param scene needed for loading to the correct scene
  45576. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45577. * @param onLoad optional callback to be called upon successful completion
  45578. * @param onError optional callback to be called upon failure
  45579. * @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
  45580. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45581. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45582. * @param forcedExtension defines the extension to use to pick the right loader
  45583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45584. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45585. */
  45586. 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;
  45587. /**
  45588. * Creates a new render target texture
  45589. * @param size defines the size of the texture
  45590. * @param options defines the options used to create the texture
  45591. * @returns a new render target texture stored in an InternalTexture
  45592. */
  45593. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45594. /**
  45595. * Update the sampling mode of a given texture
  45596. * @param samplingMode defines the required sampling mode
  45597. * @param texture defines the texture to update
  45598. */
  45599. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45600. /**
  45601. * Binds the frame buffer to the specified texture.
  45602. * @param texture The texture to render to or null for the default canvas
  45603. * @param faceIndex The face of the texture to render to in case of cube texture
  45604. * @param requiredWidth The width of the target to render to
  45605. * @param requiredHeight The height of the target to render to
  45606. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45607. * @param depthStencilTexture The depth stencil texture to use to render
  45608. * @param lodLevel defines le lod level to bind to the frame buffer
  45609. */
  45610. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45611. /**
  45612. * Unbind the current render target texture from the webGL context
  45613. * @param texture defines the render target texture to unbind
  45614. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45615. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45616. */
  45617. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45618. /**
  45619. * Creates a dynamic vertex buffer
  45620. * @param vertices the data for the dynamic vertex buffer
  45621. * @returns the new WebGL dynamic buffer
  45622. */
  45623. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45624. /**
  45625. * Update the content of a dynamic texture
  45626. * @param texture defines the texture to update
  45627. * @param canvas defines the canvas containing the source
  45628. * @param invertY defines if data must be stored with Y axis inverted
  45629. * @param premulAlpha defines if alpha is stored as premultiplied
  45630. * @param format defines the format of the data
  45631. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45632. */
  45633. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45634. /**
  45635. * Gets a boolean indicating if all created effects are ready
  45636. * @returns true if all effects are ready
  45637. */
  45638. areAllEffectsReady(): boolean;
  45639. /**
  45640. * @hidden
  45641. * Get the current error code of the webGL context
  45642. * @returns the error code
  45643. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45644. */
  45645. getError(): number;
  45646. /** @hidden */
  45647. _getUnpackAlignement(): number;
  45648. /** @hidden */
  45649. _unpackFlipY(value: boolean): void;
  45650. /**
  45651. * Update a dynamic index buffer
  45652. * @param indexBuffer defines the target index buffer
  45653. * @param indices defines the data to update
  45654. * @param offset defines the offset in the target index buffer where update should start
  45655. */
  45656. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45657. /**
  45658. * Updates a dynamic vertex buffer.
  45659. * @param vertexBuffer the vertex buffer to update
  45660. * @param vertices the data used to update the vertex buffer
  45661. * @param byteOffset the byte offset of the data (optional)
  45662. * @param byteLength the byte length of the data (optional)
  45663. */
  45664. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45665. /** @hidden */
  45666. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45667. /** @hidden */
  45668. _bindTexture(channel: number, texture: InternalTexture): void;
  45669. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45670. /**
  45671. * 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
  45672. */
  45673. releaseEffects(): void;
  45674. displayLoadingUI(): void;
  45675. hideLoadingUI(): void;
  45676. /** @hidden */
  45677. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45678. /** @hidden */
  45679. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45680. /** @hidden */
  45681. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45682. /** @hidden */
  45683. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45684. }
  45685. }
  45686. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45687. import { Nullable, int } from "babylonjs/types";
  45688. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45689. /** @hidden */
  45690. export class _OcclusionDataStorage {
  45691. /** @hidden */
  45692. occlusionInternalRetryCounter: number;
  45693. /** @hidden */
  45694. isOcclusionQueryInProgress: boolean;
  45695. /** @hidden */
  45696. isOccluded: boolean;
  45697. /** @hidden */
  45698. occlusionRetryCount: number;
  45699. /** @hidden */
  45700. occlusionType: number;
  45701. /** @hidden */
  45702. occlusionQueryAlgorithmType: number;
  45703. }
  45704. module "babylonjs/Engines/engine" {
  45705. interface Engine {
  45706. /**
  45707. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45708. * @return the new query
  45709. */
  45710. createQuery(): WebGLQuery;
  45711. /**
  45712. * Delete and release a webGL query
  45713. * @param query defines the query to delete
  45714. * @return the current engine
  45715. */
  45716. deleteQuery(query: WebGLQuery): Engine;
  45717. /**
  45718. * Check if a given query has resolved and got its value
  45719. * @param query defines the query to check
  45720. * @returns true if the query got its value
  45721. */
  45722. isQueryResultAvailable(query: WebGLQuery): boolean;
  45723. /**
  45724. * Gets the value of a given query
  45725. * @param query defines the query to check
  45726. * @returns the value of the query
  45727. */
  45728. getQueryResult(query: WebGLQuery): number;
  45729. /**
  45730. * Initiates an occlusion query
  45731. * @param algorithmType defines the algorithm to use
  45732. * @param query defines the query to use
  45733. * @returns the current engine
  45734. * @see http://doc.babylonjs.com/features/occlusionquery
  45735. */
  45736. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45737. /**
  45738. * Ends an occlusion query
  45739. * @see http://doc.babylonjs.com/features/occlusionquery
  45740. * @param algorithmType defines the algorithm to use
  45741. * @returns the current engine
  45742. */
  45743. endOcclusionQuery(algorithmType: number): Engine;
  45744. /**
  45745. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45746. * Please note that only one query can be issued at a time
  45747. * @returns a time token used to track the time span
  45748. */
  45749. startTimeQuery(): Nullable<_TimeToken>;
  45750. /**
  45751. * Ends a time query
  45752. * @param token defines the token used to measure the time span
  45753. * @returns the time spent (in ns)
  45754. */
  45755. endTimeQuery(token: _TimeToken): int;
  45756. /** @hidden */
  45757. _currentNonTimestampToken: Nullable<_TimeToken>;
  45758. /** @hidden */
  45759. _createTimeQuery(): WebGLQuery;
  45760. /** @hidden */
  45761. _deleteTimeQuery(query: WebGLQuery): void;
  45762. /** @hidden */
  45763. _getGlAlgorithmType(algorithmType: number): number;
  45764. /** @hidden */
  45765. _getTimeQueryResult(query: WebGLQuery): any;
  45766. /** @hidden */
  45767. _getTimeQueryAvailability(query: WebGLQuery): any;
  45768. }
  45769. }
  45770. module "babylonjs/Meshes/abstractMesh" {
  45771. interface AbstractMesh {
  45772. /**
  45773. * Backing filed
  45774. * @hidden
  45775. */
  45776. __occlusionDataStorage: _OcclusionDataStorage;
  45777. /**
  45778. * Access property
  45779. * @hidden
  45780. */
  45781. _occlusionDataStorage: _OcclusionDataStorage;
  45782. /**
  45783. * 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.
  45784. * The default value is -1 which means don't break the query and wait till the result
  45785. * @see http://doc.babylonjs.com/features/occlusionquery
  45786. */
  45787. occlusionRetryCount: number;
  45788. /**
  45789. * 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:
  45790. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45791. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45792. * * 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.
  45793. * @see http://doc.babylonjs.com/features/occlusionquery
  45794. */
  45795. occlusionType: number;
  45796. /**
  45797. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45798. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45799. * * 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.
  45800. * @see http://doc.babylonjs.com/features/occlusionquery
  45801. */
  45802. occlusionQueryAlgorithmType: number;
  45803. /**
  45804. * 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
  45805. * @see http://doc.babylonjs.com/features/occlusionquery
  45806. */
  45807. isOccluded: boolean;
  45808. /**
  45809. * Flag to check the progress status of the query
  45810. * @see http://doc.babylonjs.com/features/occlusionquery
  45811. */
  45812. isOcclusionQueryInProgress: boolean;
  45813. }
  45814. }
  45815. }
  45816. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45817. import { Nullable } from "babylonjs/types";
  45818. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45819. /** @hidden */
  45820. export var _forceTransformFeedbackToBundle: boolean;
  45821. module "babylonjs/Engines/engine" {
  45822. interface Engine {
  45823. /**
  45824. * Creates a webGL transform feedback object
  45825. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45826. * @returns the webGL transform feedback object
  45827. */
  45828. createTransformFeedback(): WebGLTransformFeedback;
  45829. /**
  45830. * Delete a webGL transform feedback object
  45831. * @param value defines the webGL transform feedback object to delete
  45832. */
  45833. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45834. /**
  45835. * Bind a webGL transform feedback object to the webgl context
  45836. * @param value defines the webGL transform feedback object to bind
  45837. */
  45838. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45839. /**
  45840. * Begins a transform feedback operation
  45841. * @param usePoints defines if points or triangles must be used
  45842. */
  45843. beginTransformFeedback(usePoints: boolean): void;
  45844. /**
  45845. * Ends a transform feedback operation
  45846. */
  45847. endTransformFeedback(): void;
  45848. /**
  45849. * Specify the varyings to use with transform feedback
  45850. * @param program defines the associated webGL program
  45851. * @param value defines the list of strings representing the varying names
  45852. */
  45853. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45854. /**
  45855. * Bind a webGL buffer for a transform feedback operation
  45856. * @param value defines the webGL buffer to bind
  45857. */
  45858. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45859. }
  45860. }
  45861. }
  45862. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45863. import { Scene } from "babylonjs/scene";
  45864. import { Engine } from "babylonjs/Engines/engine";
  45865. import { Texture } from "babylonjs/Materials/Textures/texture";
  45866. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45867. import "babylonjs/Engines/Extensions/engine.multiRender";
  45868. /**
  45869. * Creation options of the multi render target texture.
  45870. */
  45871. export interface IMultiRenderTargetOptions {
  45872. /**
  45873. * Define if the texture needs to create mip maps after render.
  45874. */
  45875. generateMipMaps?: boolean;
  45876. /**
  45877. * Define the types of all the draw buffers we want to create
  45878. */
  45879. types?: number[];
  45880. /**
  45881. * Define the sampling modes of all the draw buffers we want to create
  45882. */
  45883. samplingModes?: number[];
  45884. /**
  45885. * Define if a depth buffer is required
  45886. */
  45887. generateDepthBuffer?: boolean;
  45888. /**
  45889. * Define if a stencil buffer is required
  45890. */
  45891. generateStencilBuffer?: boolean;
  45892. /**
  45893. * Define if a depth texture is required instead of a depth buffer
  45894. */
  45895. generateDepthTexture?: boolean;
  45896. /**
  45897. * Define the number of desired draw buffers
  45898. */
  45899. textureCount?: number;
  45900. /**
  45901. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45902. */
  45903. doNotChangeAspectRatio?: boolean;
  45904. /**
  45905. * Define the default type of the buffers we are creating
  45906. */
  45907. defaultType?: number;
  45908. }
  45909. /**
  45910. * A multi render target, like a render target provides the ability to render to a texture.
  45911. * Unlike the render target, it can render to several draw buffers in one draw.
  45912. * This is specially interesting in deferred rendering or for any effects requiring more than
  45913. * just one color from a single pass.
  45914. */
  45915. export class MultiRenderTarget extends RenderTargetTexture {
  45916. private _internalTextures;
  45917. private _textures;
  45918. private _multiRenderTargetOptions;
  45919. /**
  45920. * Get if draw buffers are currently supported by the used hardware and browser.
  45921. */
  45922. readonly isSupported: boolean;
  45923. /**
  45924. * Get the list of textures generated by the multi render target.
  45925. */
  45926. readonly textures: Texture[];
  45927. /**
  45928. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45929. */
  45930. readonly depthTexture: Texture;
  45931. /**
  45932. * Set the wrapping mode on U of all the textures we are rendering to.
  45933. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45934. */
  45935. wrapU: number;
  45936. /**
  45937. * Set the wrapping mode on V of all the textures we are rendering to.
  45938. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45939. */
  45940. wrapV: number;
  45941. /**
  45942. * Instantiate a new multi render target texture.
  45943. * A multi render target, like a render target provides the ability to render to a texture.
  45944. * Unlike the render target, it can render to several draw buffers in one draw.
  45945. * This is specially interesting in deferred rendering or for any effects requiring more than
  45946. * just one color from a single pass.
  45947. * @param name Define the name of the texture
  45948. * @param size Define the size of the buffers to render to
  45949. * @param count Define the number of target we are rendering into
  45950. * @param scene Define the scene the texture belongs to
  45951. * @param options Define the options used to create the multi render target
  45952. */
  45953. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45954. /** @hidden */
  45955. _rebuild(): void;
  45956. private _createInternalTextures;
  45957. private _createTextures;
  45958. /**
  45959. * Define the number of samples used if MSAA is enabled.
  45960. */
  45961. samples: number;
  45962. /**
  45963. * Resize all the textures in the multi render target.
  45964. * Be carrefull as it will recreate all the data in the new texture.
  45965. * @param size Define the new size
  45966. */
  45967. resize(size: any): void;
  45968. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45969. /**
  45970. * Dispose the render targets and their associated resources
  45971. */
  45972. dispose(): void;
  45973. /**
  45974. * Release all the underlying texture used as draw buffers.
  45975. */
  45976. releaseInternalTextures(): void;
  45977. }
  45978. }
  45979. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45980. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45981. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45982. import { Nullable } from "babylonjs/types";
  45983. module "babylonjs/Engines/thinEngine" {
  45984. interface ThinEngine {
  45985. /**
  45986. * Unbind a list of render target textures from the webGL context
  45987. * This is used only when drawBuffer extension or webGL2 are active
  45988. * @param textures defines the render target textures to unbind
  45989. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45990. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45991. */
  45992. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45993. /**
  45994. * Create a multi render target texture
  45995. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45996. * @param size defines the size of the texture
  45997. * @param options defines the creation options
  45998. * @returns the cube texture as an InternalTexture
  45999. */
  46000. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46001. /**
  46002. * Update the sample count for a given multiple render target texture
  46003. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46004. * @param textures defines the textures to update
  46005. * @param samples defines the sample count to set
  46006. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46007. */
  46008. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46009. }
  46010. }
  46011. }
  46012. declare module "babylonjs/Engines/Extensions/index" {
  46013. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46014. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46015. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46016. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46017. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46018. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46019. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46020. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46021. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46022. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46023. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46024. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46025. }
  46026. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46027. import { Nullable } from "babylonjs/types";
  46028. /**
  46029. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46030. */
  46031. export interface CubeMapInfo {
  46032. /**
  46033. * The pixel array for the front face.
  46034. * This is stored in format, left to right, up to down format.
  46035. */
  46036. front: Nullable<ArrayBufferView>;
  46037. /**
  46038. * The pixel array for the back face.
  46039. * This is stored in format, left to right, up to down format.
  46040. */
  46041. back: Nullable<ArrayBufferView>;
  46042. /**
  46043. * The pixel array for the left face.
  46044. * This is stored in format, left to right, up to down format.
  46045. */
  46046. left: Nullable<ArrayBufferView>;
  46047. /**
  46048. * The pixel array for the right face.
  46049. * This is stored in format, left to right, up to down format.
  46050. */
  46051. right: Nullable<ArrayBufferView>;
  46052. /**
  46053. * The pixel array for the up face.
  46054. * This is stored in format, left to right, up to down format.
  46055. */
  46056. up: Nullable<ArrayBufferView>;
  46057. /**
  46058. * The pixel array for the down face.
  46059. * This is stored in format, left to right, up to down format.
  46060. */
  46061. down: Nullable<ArrayBufferView>;
  46062. /**
  46063. * The size of the cubemap stored.
  46064. *
  46065. * Each faces will be size * size pixels.
  46066. */
  46067. size: number;
  46068. /**
  46069. * The format of the texture.
  46070. *
  46071. * RGBA, RGB.
  46072. */
  46073. format: number;
  46074. /**
  46075. * The type of the texture data.
  46076. *
  46077. * UNSIGNED_INT, FLOAT.
  46078. */
  46079. type: number;
  46080. /**
  46081. * Specifies whether the texture is in gamma space.
  46082. */
  46083. gammaSpace: boolean;
  46084. }
  46085. /**
  46086. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46087. */
  46088. export class PanoramaToCubeMapTools {
  46089. private static FACE_FRONT;
  46090. private static FACE_BACK;
  46091. private static FACE_RIGHT;
  46092. private static FACE_LEFT;
  46093. private static FACE_DOWN;
  46094. private static FACE_UP;
  46095. /**
  46096. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46097. *
  46098. * @param float32Array The source data.
  46099. * @param inputWidth The width of the input panorama.
  46100. * @param inputHeight The height of the input panorama.
  46101. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46102. * @return The cubemap data
  46103. */
  46104. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46105. private static CreateCubemapTexture;
  46106. private static CalcProjectionSpherical;
  46107. }
  46108. }
  46109. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46110. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46112. import { Nullable } from "babylonjs/types";
  46113. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46114. /**
  46115. * Helper class dealing with the extraction of spherical polynomial dataArray
  46116. * from a cube map.
  46117. */
  46118. export class CubeMapToSphericalPolynomialTools {
  46119. private static FileFaces;
  46120. /**
  46121. * Converts a texture to the according Spherical Polynomial data.
  46122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46123. *
  46124. * @param texture The texture to extract the information from.
  46125. * @return The Spherical Polynomial data.
  46126. */
  46127. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46128. /**
  46129. * Converts a cubemap to the according Spherical Polynomial data.
  46130. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46131. *
  46132. * @param cubeInfo The Cube map to extract the information from.
  46133. * @return The Spherical Polynomial data.
  46134. */
  46135. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46136. }
  46137. }
  46138. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46139. import { Nullable } from "babylonjs/types";
  46140. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46141. module "babylonjs/Materials/Textures/baseTexture" {
  46142. interface BaseTexture {
  46143. /**
  46144. * Get the polynomial representation of the texture data.
  46145. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46146. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46147. */
  46148. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46149. }
  46150. }
  46151. }
  46152. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46154. /** @hidden */
  46155. export var rgbdEncodePixelShader: {
  46156. name: string;
  46157. shader: string;
  46158. };
  46159. }
  46160. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46162. /** @hidden */
  46163. export var rgbdDecodePixelShader: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module "babylonjs/Misc/environmentTextureTools" {
  46169. import { Nullable } from "babylonjs/types";
  46170. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46172. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46173. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46174. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46175. import "babylonjs/Shaders/rgbdEncode.fragment";
  46176. import "babylonjs/Shaders/rgbdDecode.fragment";
  46177. /**
  46178. * Raw texture data and descriptor sufficient for WebGL texture upload
  46179. */
  46180. export interface EnvironmentTextureInfo {
  46181. /**
  46182. * Version of the environment map
  46183. */
  46184. version: number;
  46185. /**
  46186. * Width of image
  46187. */
  46188. width: number;
  46189. /**
  46190. * Irradiance information stored in the file.
  46191. */
  46192. irradiance: any;
  46193. /**
  46194. * Specular information stored in the file.
  46195. */
  46196. specular: any;
  46197. }
  46198. /**
  46199. * Defines One Image in the file. It requires only the position in the file
  46200. * as well as the length.
  46201. */
  46202. interface BufferImageData {
  46203. /**
  46204. * Length of the image data.
  46205. */
  46206. length: number;
  46207. /**
  46208. * Position of the data from the null terminator delimiting the end of the JSON.
  46209. */
  46210. position: number;
  46211. }
  46212. /**
  46213. * Defines the specular data enclosed in the file.
  46214. * This corresponds to the version 1 of the data.
  46215. */
  46216. export interface EnvironmentTextureSpecularInfoV1 {
  46217. /**
  46218. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46219. */
  46220. specularDataPosition?: number;
  46221. /**
  46222. * This contains all the images data needed to reconstruct the cubemap.
  46223. */
  46224. mipmaps: Array<BufferImageData>;
  46225. /**
  46226. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46227. */
  46228. lodGenerationScale: number;
  46229. }
  46230. /**
  46231. * Sets of helpers addressing the serialization and deserialization of environment texture
  46232. * stored in a BabylonJS env file.
  46233. * Those files are usually stored as .env files.
  46234. */
  46235. export class EnvironmentTextureTools {
  46236. /**
  46237. * Magic number identifying the env file.
  46238. */
  46239. private static _MagicBytes;
  46240. /**
  46241. * Gets the environment info from an env file.
  46242. * @param data The array buffer containing the .env bytes.
  46243. * @returns the environment file info (the json header) if successfully parsed.
  46244. */
  46245. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46246. /**
  46247. * Creates an environment texture from a loaded cube texture.
  46248. * @param texture defines the cube texture to convert in env file
  46249. * @return a promise containing the environment data if succesfull.
  46250. */
  46251. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46252. /**
  46253. * Creates a JSON representation of the spherical data.
  46254. * @param texture defines the texture containing the polynomials
  46255. * @return the JSON representation of the spherical info
  46256. */
  46257. private static _CreateEnvTextureIrradiance;
  46258. /**
  46259. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46260. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46261. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46262. * @return the views described by info providing access to the underlying buffer
  46263. */
  46264. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46265. /**
  46266. * Uploads the texture info contained in the env file to the GPU.
  46267. * @param texture defines the internal texture to upload to
  46268. * @param arrayBuffer defines the buffer cotaining the data to load
  46269. * @param info defines the texture info retrieved through the GetEnvInfo method
  46270. * @returns a promise
  46271. */
  46272. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46273. /**
  46274. * Uploads the levels of image data to the GPU.
  46275. * @param texture defines the internal texture to upload to
  46276. * @param imageData defines the array buffer views of image data [mipmap][face]
  46277. * @returns a promise
  46278. */
  46279. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46280. /**
  46281. * Uploads spherical polynomials information to the texture.
  46282. * @param texture defines the texture we are trying to upload the information to
  46283. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46284. */
  46285. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46286. /** @hidden */
  46287. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46288. }
  46289. }
  46290. declare module "babylonjs/Maths/math.vertexFormat" {
  46291. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46292. /**
  46293. * Contains position and normal vectors for a vertex
  46294. */
  46295. export class PositionNormalVertex {
  46296. /** the position of the vertex (defaut: 0,0,0) */
  46297. position: Vector3;
  46298. /** the normal of the vertex (defaut: 0,1,0) */
  46299. normal: Vector3;
  46300. /**
  46301. * Creates a PositionNormalVertex
  46302. * @param position the position of the vertex (defaut: 0,0,0)
  46303. * @param normal the normal of the vertex (defaut: 0,1,0)
  46304. */
  46305. constructor(
  46306. /** the position of the vertex (defaut: 0,0,0) */
  46307. position?: Vector3,
  46308. /** the normal of the vertex (defaut: 0,1,0) */
  46309. normal?: Vector3);
  46310. /**
  46311. * Clones the PositionNormalVertex
  46312. * @returns the cloned PositionNormalVertex
  46313. */
  46314. clone(): PositionNormalVertex;
  46315. }
  46316. /**
  46317. * Contains position, normal and uv vectors for a vertex
  46318. */
  46319. export class PositionNormalTextureVertex {
  46320. /** the position of the vertex (defaut: 0,0,0) */
  46321. position: Vector3;
  46322. /** the normal of the vertex (defaut: 0,1,0) */
  46323. normal: Vector3;
  46324. /** the uv of the vertex (default: 0,0) */
  46325. uv: Vector2;
  46326. /**
  46327. * Creates a PositionNormalTextureVertex
  46328. * @param position the position of the vertex (defaut: 0,0,0)
  46329. * @param normal the normal of the vertex (defaut: 0,1,0)
  46330. * @param uv the uv of the vertex (default: 0,0)
  46331. */
  46332. constructor(
  46333. /** the position of the vertex (defaut: 0,0,0) */
  46334. position?: Vector3,
  46335. /** the normal of the vertex (defaut: 0,1,0) */
  46336. normal?: Vector3,
  46337. /** the uv of the vertex (default: 0,0) */
  46338. uv?: Vector2);
  46339. /**
  46340. * Clones the PositionNormalTextureVertex
  46341. * @returns the cloned PositionNormalTextureVertex
  46342. */
  46343. clone(): PositionNormalTextureVertex;
  46344. }
  46345. }
  46346. declare module "babylonjs/Maths/math" {
  46347. export * from "babylonjs/Maths/math.axis";
  46348. export * from "babylonjs/Maths/math.color";
  46349. export * from "babylonjs/Maths/math.constants";
  46350. export * from "babylonjs/Maths/math.frustum";
  46351. export * from "babylonjs/Maths/math.path";
  46352. export * from "babylonjs/Maths/math.plane";
  46353. export * from "babylonjs/Maths/math.size";
  46354. export * from "babylonjs/Maths/math.vector";
  46355. export * from "babylonjs/Maths/math.vertexFormat";
  46356. export * from "babylonjs/Maths/math.viewport";
  46357. }
  46358. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46359. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46360. /** @hidden */
  46361. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46362. private _genericAttributeLocation;
  46363. private _varyingLocationCount;
  46364. private _varyingLocationMap;
  46365. private _replacements;
  46366. private _textureCount;
  46367. private _uniforms;
  46368. lineProcessor(line: string): string;
  46369. attributeProcessor(attribute: string): string;
  46370. varyingProcessor(varying: string, isFragment: boolean): string;
  46371. uniformProcessor(uniform: string): string;
  46372. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46373. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46374. }
  46375. }
  46376. declare module "babylonjs/Engines/nativeEngine" {
  46377. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46378. import { Engine } from "babylonjs/Engines/engine";
  46379. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46382. import { Effect } from "babylonjs/Materials/effect";
  46383. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46384. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46385. import { Scene } from "babylonjs/scene";
  46386. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46387. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46388. /**
  46389. * Container for accessors for natively-stored mesh data buffers.
  46390. */
  46391. class NativeDataBuffer extends DataBuffer {
  46392. /**
  46393. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46394. */
  46395. nativeIndexBuffer?: any;
  46396. /**
  46397. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46398. */
  46399. nativeVertexBuffer?: any;
  46400. }
  46401. /** @hidden */
  46402. export class NativeEngine extends Engine {
  46403. private readonly _native;
  46404. getHardwareScalingLevel(): number;
  46405. constructor();
  46406. /**
  46407. * Can be used to override the current requestAnimationFrame requester.
  46408. * @hidden
  46409. */
  46410. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46411. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46412. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46413. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46414. recordVertexArrayObject(vertexBuffers: {
  46415. [key: string]: VertexBuffer;
  46416. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46417. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46418. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46419. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46420. /**
  46421. * Draw a list of indexed primitives
  46422. * @param fillMode defines the primitive to use
  46423. * @param indexStart defines the starting index
  46424. * @param indexCount defines the number of index to draw
  46425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46426. */
  46427. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46428. /**
  46429. * Draw a list of unindexed primitives
  46430. * @param fillMode defines the primitive to use
  46431. * @param verticesStart defines the index of first vertex to draw
  46432. * @param verticesCount defines the count of vertices to draw
  46433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46434. */
  46435. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46436. createPipelineContext(): IPipelineContext;
  46437. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46438. /** @hidden */
  46439. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46440. /** @hidden */
  46441. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46442. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46443. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46444. protected _setProgram(program: WebGLProgram): void;
  46445. _releaseEffect(effect: Effect): void;
  46446. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46447. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46448. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46449. bindSamplers(effect: Effect): void;
  46450. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46451. getRenderWidth(useScreen?: boolean): number;
  46452. getRenderHeight(useScreen?: boolean): number;
  46453. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46454. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46455. /**
  46456. * Set the z offset to apply to current rendering
  46457. * @param value defines the offset to apply
  46458. */
  46459. setZOffset(value: number): void;
  46460. /**
  46461. * Gets the current value of the zOffset
  46462. * @returns the current zOffset state
  46463. */
  46464. getZOffset(): number;
  46465. /**
  46466. * Enable or disable depth buffering
  46467. * @param enable defines the state to set
  46468. */
  46469. setDepthBuffer(enable: boolean): void;
  46470. /**
  46471. * Gets a boolean indicating if depth writing is enabled
  46472. * @returns the current depth writing state
  46473. */
  46474. getDepthWrite(): boolean;
  46475. /**
  46476. * Enable or disable depth writing
  46477. * @param enable defines the state to set
  46478. */
  46479. setDepthWrite(enable: boolean): void;
  46480. /**
  46481. * Enable or disable color writing
  46482. * @param enable defines the state to set
  46483. */
  46484. setColorWrite(enable: boolean): void;
  46485. /**
  46486. * Gets a boolean indicating if color writing is enabled
  46487. * @returns the current color writing state
  46488. */
  46489. getColorWrite(): boolean;
  46490. /**
  46491. * Sets alpha constants used by some alpha blending modes
  46492. * @param r defines the red component
  46493. * @param g defines the green component
  46494. * @param b defines the blue component
  46495. * @param a defines the alpha component
  46496. */
  46497. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46498. /**
  46499. * Sets the current alpha mode
  46500. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46501. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46502. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46503. */
  46504. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46505. /**
  46506. * Gets the current alpha mode
  46507. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46508. * @returns the current alpha mode
  46509. */
  46510. getAlphaMode(): number;
  46511. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46512. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46513. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46514. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46515. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46516. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46517. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46518. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46520. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46521. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46522. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46523. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46524. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46525. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46526. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46527. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46528. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46529. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46530. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46531. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46532. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46533. wipeCaches(bruteForce?: boolean): void;
  46534. _createTexture(): WebGLTexture;
  46535. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46536. /**
  46537. * Usually called from BABYLON.Texture.ts.
  46538. * Passed information to create a WebGLTexture
  46539. * @param urlArg defines a value which contains one of the following:
  46540. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46541. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46542. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46544. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46545. * @param scene needed for loading to the correct scene
  46546. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46547. * @param onLoad optional callback to be called upon successful completion
  46548. * @param onError optional callback to be called upon failure
  46549. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46550. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46551. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46552. * @param forcedExtension defines the extension to use to pick the right loader
  46553. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46554. */
  46555. 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;
  46556. /**
  46557. * Creates a cube texture
  46558. * @param rootUrl defines the url where the files to load is located
  46559. * @param scene defines the current scene
  46560. * @param files defines the list of files to load (1 per face)
  46561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46562. * @param onLoad defines an optional callback raised when the texture is loaded
  46563. * @param onError defines an optional callback raised if there is an issue to load the texture
  46564. * @param format defines the format of the data
  46565. * @param forcedExtension defines the extension to use to pick the right loader
  46566. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46567. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46568. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46569. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46570. * @returns the cube texture as an InternalTexture
  46571. */
  46572. 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;
  46573. private _getSamplingFilter;
  46574. private static _GetNativeTextureFormat;
  46575. createRenderTargetTexture(size: number | {
  46576. width: number;
  46577. height: number;
  46578. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46579. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46580. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46581. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46582. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46583. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46584. /**
  46585. * Updates a dynamic vertex buffer.
  46586. * @param vertexBuffer the vertex buffer to update
  46587. * @param data the data used to update the vertex buffer
  46588. * @param byteOffset the byte offset of the data (optional)
  46589. * @param byteLength the byte length of the data (optional)
  46590. */
  46591. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46592. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46593. private _updateAnisotropicLevel;
  46594. private _getAddressMode;
  46595. /** @hidden */
  46596. _bindTexture(channel: number, texture: InternalTexture): void;
  46597. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46598. releaseEffects(): void;
  46599. /** @hidden */
  46600. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46601. /** @hidden */
  46602. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46603. /** @hidden */
  46604. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46605. /** @hidden */
  46606. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46607. }
  46608. }
  46609. declare module "babylonjs/Engines/index" {
  46610. export * from "babylonjs/Engines/constants";
  46611. export * from "babylonjs/Engines/engineCapabilities";
  46612. export * from "babylonjs/Engines/instancingAttributeInfo";
  46613. export * from "babylonjs/Engines/thinEngine";
  46614. export * from "babylonjs/Engines/engine";
  46615. export * from "babylonjs/Engines/engineStore";
  46616. export * from "babylonjs/Engines/nullEngine";
  46617. export * from "babylonjs/Engines/Extensions/index";
  46618. export * from "babylonjs/Engines/IPipelineContext";
  46619. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46620. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46621. export * from "babylonjs/Engines/nativeEngine";
  46622. }
  46623. declare module "babylonjs/Events/clipboardEvents" {
  46624. /**
  46625. * Gather the list of clipboard event types as constants.
  46626. */
  46627. export class ClipboardEventTypes {
  46628. /**
  46629. * The clipboard event is fired when a copy command is active (pressed).
  46630. */
  46631. static readonly COPY: number;
  46632. /**
  46633. * The clipboard event is fired when a cut command is active (pressed).
  46634. */
  46635. static readonly CUT: number;
  46636. /**
  46637. * The clipboard event is fired when a paste command is active (pressed).
  46638. */
  46639. static readonly PASTE: number;
  46640. }
  46641. /**
  46642. * This class is used to store clipboard related info for the onClipboardObservable event.
  46643. */
  46644. export class ClipboardInfo {
  46645. /**
  46646. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46647. */
  46648. type: number;
  46649. /**
  46650. * Defines the related dom event
  46651. */
  46652. event: ClipboardEvent;
  46653. /**
  46654. *Creates an instance of ClipboardInfo.
  46655. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46656. * @param event Defines the related dom event
  46657. */
  46658. constructor(
  46659. /**
  46660. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46661. */
  46662. type: number,
  46663. /**
  46664. * Defines the related dom event
  46665. */
  46666. event: ClipboardEvent);
  46667. /**
  46668. * Get the clipboard event's type from the keycode.
  46669. * @param keyCode Defines the keyCode for the current keyboard event.
  46670. * @return {number}
  46671. */
  46672. static GetTypeFromCharacter(keyCode: number): number;
  46673. }
  46674. }
  46675. declare module "babylonjs/Events/index" {
  46676. export * from "babylonjs/Events/keyboardEvents";
  46677. export * from "babylonjs/Events/pointerEvents";
  46678. export * from "babylonjs/Events/clipboardEvents";
  46679. }
  46680. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46681. import { Scene } from "babylonjs/scene";
  46682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46683. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46684. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46685. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46686. /**
  46687. * Google Daydream controller
  46688. */
  46689. export class DaydreamController extends WebVRController {
  46690. /**
  46691. * Base Url for the controller model.
  46692. */
  46693. static MODEL_BASE_URL: string;
  46694. /**
  46695. * File name for the controller model.
  46696. */
  46697. static MODEL_FILENAME: string;
  46698. /**
  46699. * Gamepad Id prefix used to identify Daydream Controller.
  46700. */
  46701. static readonly GAMEPAD_ID_PREFIX: string;
  46702. /**
  46703. * Creates a new DaydreamController from a gamepad
  46704. * @param vrGamepad the gamepad that the controller should be created from
  46705. */
  46706. constructor(vrGamepad: any);
  46707. /**
  46708. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46709. * @param scene scene in which to add meshes
  46710. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46711. */
  46712. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46713. /**
  46714. * Called once for each button that changed state since the last frame
  46715. * @param buttonIdx Which button index changed
  46716. * @param state New state of the button
  46717. * @param changes Which properties on the state changed since last frame
  46718. */
  46719. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46720. }
  46721. }
  46722. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46723. import { Scene } from "babylonjs/scene";
  46724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46725. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46726. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46727. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46728. /**
  46729. * Gear VR Controller
  46730. */
  46731. export class GearVRController extends WebVRController {
  46732. /**
  46733. * Base Url for the controller model.
  46734. */
  46735. static MODEL_BASE_URL: string;
  46736. /**
  46737. * File name for the controller model.
  46738. */
  46739. static MODEL_FILENAME: string;
  46740. /**
  46741. * Gamepad Id prefix used to identify this controller.
  46742. */
  46743. static readonly GAMEPAD_ID_PREFIX: string;
  46744. private readonly _buttonIndexToObservableNameMap;
  46745. /**
  46746. * Creates a new GearVRController from a gamepad
  46747. * @param vrGamepad the gamepad that the controller should be created from
  46748. */
  46749. constructor(vrGamepad: any);
  46750. /**
  46751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46752. * @param scene scene in which to add meshes
  46753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46754. */
  46755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46756. /**
  46757. * Called once for each button that changed state since the last frame
  46758. * @param buttonIdx Which button index changed
  46759. * @param state New state of the button
  46760. * @param changes Which properties on the state changed since last frame
  46761. */
  46762. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46763. }
  46764. }
  46765. declare module "babylonjs/Gamepads/Controllers/index" {
  46766. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46767. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46768. export * from "babylonjs/Gamepads/Controllers/genericController";
  46769. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46770. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46771. export * from "babylonjs/Gamepads/Controllers/viveController";
  46772. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46773. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46774. }
  46775. declare module "babylonjs/Gamepads/index" {
  46776. export * from "babylonjs/Gamepads/Controllers/index";
  46777. export * from "babylonjs/Gamepads/gamepad";
  46778. export * from "babylonjs/Gamepads/gamepadManager";
  46779. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46780. export * from "babylonjs/Gamepads/xboxGamepad";
  46781. export * from "babylonjs/Gamepads/dualShockGamepad";
  46782. }
  46783. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46784. import { Scene } from "babylonjs/scene";
  46785. import { Vector4 } from "babylonjs/Maths/math.vector";
  46786. import { Color4 } from "babylonjs/Maths/math.color";
  46787. import { Mesh } from "babylonjs/Meshes/mesh";
  46788. import { Nullable } from "babylonjs/types";
  46789. /**
  46790. * Class containing static functions to help procedurally build meshes
  46791. */
  46792. export class PolyhedronBuilder {
  46793. /**
  46794. * Creates a polyhedron mesh
  46795. * * 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
  46796. * * The parameter `size` (positive float, default 1) sets the polygon size
  46797. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46798. * * 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`
  46799. * * 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
  46800. * * 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)`)
  46801. * * 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
  46802. * * 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
  46803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46806. * @param name defines the name of the mesh
  46807. * @param options defines the options used to create the mesh
  46808. * @param scene defines the hosting scene
  46809. * @returns the polyhedron mesh
  46810. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46811. */
  46812. static CreatePolyhedron(name: string, options: {
  46813. type?: number;
  46814. size?: number;
  46815. sizeX?: number;
  46816. sizeY?: number;
  46817. sizeZ?: number;
  46818. custom?: any;
  46819. faceUV?: Vector4[];
  46820. faceColors?: Color4[];
  46821. flat?: boolean;
  46822. updatable?: boolean;
  46823. sideOrientation?: number;
  46824. frontUVs?: Vector4;
  46825. backUVs?: Vector4;
  46826. }, scene?: Nullable<Scene>): Mesh;
  46827. }
  46828. }
  46829. declare module "babylonjs/Gizmos/scaleGizmo" {
  46830. import { Observable } from "babylonjs/Misc/observable";
  46831. import { Nullable } from "babylonjs/types";
  46832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46833. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46834. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46835. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46836. /**
  46837. * Gizmo that enables scaling a mesh along 3 axis
  46838. */
  46839. export class ScaleGizmo extends Gizmo {
  46840. /**
  46841. * Internal gizmo used for interactions on the x axis
  46842. */
  46843. xGizmo: AxisScaleGizmo;
  46844. /**
  46845. * Internal gizmo used for interactions on the y axis
  46846. */
  46847. yGizmo: AxisScaleGizmo;
  46848. /**
  46849. * Internal gizmo used for interactions on the z axis
  46850. */
  46851. zGizmo: AxisScaleGizmo;
  46852. /**
  46853. * Internal gizmo used to scale all axis equally
  46854. */
  46855. uniformScaleGizmo: AxisScaleGizmo;
  46856. private _meshAttached;
  46857. private _updateGizmoRotationToMatchAttachedMesh;
  46858. private _snapDistance;
  46859. private _scaleRatio;
  46860. private _uniformScalingMesh;
  46861. private _octahedron;
  46862. /** Fires an event when any of it's sub gizmos are dragged */
  46863. onDragStartObservable: Observable<unknown>;
  46864. /** Fires an event when any of it's sub gizmos are released from dragging */
  46865. onDragEndObservable: Observable<unknown>;
  46866. attachedMesh: Nullable<AbstractMesh>;
  46867. /**
  46868. * Creates a ScaleGizmo
  46869. * @param gizmoLayer The utility layer the gizmo will be added to
  46870. */
  46871. constructor(gizmoLayer?: UtilityLayerRenderer);
  46872. updateGizmoRotationToMatchAttachedMesh: boolean;
  46873. /**
  46874. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46875. */
  46876. snapDistance: number;
  46877. /**
  46878. * Ratio for the scale of the gizmo (Default: 1)
  46879. */
  46880. scaleRatio: number;
  46881. /**
  46882. * Disposes of the gizmo
  46883. */
  46884. dispose(): void;
  46885. }
  46886. }
  46887. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46888. import { Observable } from "babylonjs/Misc/observable";
  46889. import { Nullable } from "babylonjs/types";
  46890. import { Vector3 } from "babylonjs/Maths/math.vector";
  46891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46892. import { Mesh } from "babylonjs/Meshes/mesh";
  46893. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46894. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46895. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46896. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46897. import { Color3 } from "babylonjs/Maths/math.color";
  46898. /**
  46899. * Single axis scale gizmo
  46900. */
  46901. export class AxisScaleGizmo extends Gizmo {
  46902. /**
  46903. * Drag behavior responsible for the gizmos dragging interactions
  46904. */
  46905. dragBehavior: PointerDragBehavior;
  46906. private _pointerObserver;
  46907. /**
  46908. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46909. */
  46910. snapDistance: number;
  46911. /**
  46912. * Event that fires each time the gizmo snaps to a new location.
  46913. * * snapDistance is the the change in distance
  46914. */
  46915. onSnapObservable: Observable<{
  46916. snapDistance: number;
  46917. }>;
  46918. /**
  46919. * If the scaling operation should be done on all axis (default: false)
  46920. */
  46921. uniformScaling: boolean;
  46922. private _isEnabled;
  46923. private _parent;
  46924. private _arrow;
  46925. private _coloredMaterial;
  46926. private _hoverMaterial;
  46927. /**
  46928. * Creates an AxisScaleGizmo
  46929. * @param gizmoLayer The utility layer the gizmo will be added to
  46930. * @param dragAxis The axis which the gizmo will be able to scale on
  46931. * @param color The color of the gizmo
  46932. */
  46933. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46934. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46935. /**
  46936. * If the gizmo is enabled
  46937. */
  46938. isEnabled: boolean;
  46939. /**
  46940. * Disposes of the gizmo
  46941. */
  46942. dispose(): void;
  46943. /**
  46944. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46945. * @param mesh The mesh to replace the default mesh of the gizmo
  46946. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46947. */
  46948. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46949. }
  46950. }
  46951. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46952. import { Observable } from "babylonjs/Misc/observable";
  46953. import { Nullable } from "babylonjs/types";
  46954. import { Vector3 } from "babylonjs/Maths/math.vector";
  46955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46956. import { Mesh } from "babylonjs/Meshes/mesh";
  46957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46958. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46959. import { Color3 } from "babylonjs/Maths/math.color";
  46960. import "babylonjs/Meshes/Builders/boxBuilder";
  46961. /**
  46962. * Bounding box gizmo
  46963. */
  46964. export class BoundingBoxGizmo extends Gizmo {
  46965. private _lineBoundingBox;
  46966. private _rotateSpheresParent;
  46967. private _scaleBoxesParent;
  46968. private _boundingDimensions;
  46969. private _renderObserver;
  46970. private _pointerObserver;
  46971. private _scaleDragSpeed;
  46972. private _tmpQuaternion;
  46973. private _tmpVector;
  46974. private _tmpRotationMatrix;
  46975. /**
  46976. * 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)
  46977. */
  46978. ignoreChildren: boolean;
  46979. /**
  46980. * 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)
  46981. */
  46982. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46983. /**
  46984. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46985. */
  46986. rotationSphereSize: number;
  46987. /**
  46988. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46989. */
  46990. scaleBoxSize: number;
  46991. /**
  46992. * 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)
  46993. */
  46994. fixedDragMeshScreenSize: boolean;
  46995. /**
  46996. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46997. */
  46998. fixedDragMeshScreenSizeDistanceFactor: number;
  46999. /**
  47000. * Fired when a rotation sphere or scale box is dragged
  47001. */
  47002. onDragStartObservable: Observable<{}>;
  47003. /**
  47004. * Fired when a scale box is dragged
  47005. */
  47006. onScaleBoxDragObservable: Observable<{}>;
  47007. /**
  47008. * Fired when a scale box drag is ended
  47009. */
  47010. onScaleBoxDragEndObservable: Observable<{}>;
  47011. /**
  47012. * Fired when a rotation sphere is dragged
  47013. */
  47014. onRotationSphereDragObservable: Observable<{}>;
  47015. /**
  47016. * Fired when a rotation sphere drag is ended
  47017. */
  47018. onRotationSphereDragEndObservable: Observable<{}>;
  47019. /**
  47020. * 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)
  47021. */
  47022. scalePivot: Nullable<Vector3>;
  47023. /**
  47024. * Mesh used as a pivot to rotate the attached mesh
  47025. */
  47026. private _anchorMesh;
  47027. private _existingMeshScale;
  47028. private _dragMesh;
  47029. private pointerDragBehavior;
  47030. private coloredMaterial;
  47031. private hoverColoredMaterial;
  47032. /**
  47033. * Sets the color of the bounding box gizmo
  47034. * @param color the color to set
  47035. */
  47036. setColor(color: Color3): void;
  47037. /**
  47038. * Creates an BoundingBoxGizmo
  47039. * @param gizmoLayer The utility layer the gizmo will be added to
  47040. * @param color The color of the gizmo
  47041. */
  47042. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47043. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47044. private _selectNode;
  47045. /**
  47046. * Updates the bounding box information for the Gizmo
  47047. */
  47048. updateBoundingBox(): void;
  47049. private _updateRotationSpheres;
  47050. private _updateScaleBoxes;
  47051. /**
  47052. * Enables rotation on the specified axis and disables rotation on the others
  47053. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47054. */
  47055. setEnabledRotationAxis(axis: string): void;
  47056. /**
  47057. * Enables/disables scaling
  47058. * @param enable if scaling should be enabled
  47059. */
  47060. setEnabledScaling(enable: boolean): void;
  47061. private _updateDummy;
  47062. /**
  47063. * Enables a pointer drag behavior on the bounding box of the gizmo
  47064. */
  47065. enableDragBehavior(): void;
  47066. /**
  47067. * Disposes of the gizmo
  47068. */
  47069. dispose(): void;
  47070. /**
  47071. * 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)
  47072. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47073. * @returns the bounding box mesh with the passed in mesh as a child
  47074. */
  47075. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47076. /**
  47077. * CustomMeshes are not supported by this gizmo
  47078. * @param mesh The mesh to replace the default mesh of the gizmo
  47079. */
  47080. setCustomMesh(mesh: Mesh): void;
  47081. }
  47082. }
  47083. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47084. import { Observable } from "babylonjs/Misc/observable";
  47085. import { Nullable } from "babylonjs/types";
  47086. import { Vector3 } from "babylonjs/Maths/math.vector";
  47087. import { Color3 } from "babylonjs/Maths/math.color";
  47088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47089. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47090. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47091. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47092. import "babylonjs/Meshes/Builders/linesBuilder";
  47093. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47094. /**
  47095. * Single plane rotation gizmo
  47096. */
  47097. export class PlaneRotationGizmo extends Gizmo {
  47098. /**
  47099. * Drag behavior responsible for the gizmos dragging interactions
  47100. */
  47101. dragBehavior: PointerDragBehavior;
  47102. private _pointerObserver;
  47103. /**
  47104. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47105. */
  47106. snapDistance: number;
  47107. /**
  47108. * Event that fires each time the gizmo snaps to a new location.
  47109. * * snapDistance is the the change in distance
  47110. */
  47111. onSnapObservable: Observable<{
  47112. snapDistance: number;
  47113. }>;
  47114. private _isEnabled;
  47115. private _parent;
  47116. /**
  47117. * Creates a PlaneRotationGizmo
  47118. * @param gizmoLayer The utility layer the gizmo will be added to
  47119. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47120. * @param color The color of the gizmo
  47121. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47122. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47123. */
  47124. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47125. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47126. /**
  47127. * If the gizmo is enabled
  47128. */
  47129. isEnabled: boolean;
  47130. /**
  47131. * Disposes of the gizmo
  47132. */
  47133. dispose(): void;
  47134. }
  47135. }
  47136. declare module "babylonjs/Gizmos/rotationGizmo" {
  47137. import { Observable } from "babylonjs/Misc/observable";
  47138. import { Nullable } from "babylonjs/types";
  47139. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47140. import { Mesh } from "babylonjs/Meshes/mesh";
  47141. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47142. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47143. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47144. /**
  47145. * Gizmo that enables rotating a mesh along 3 axis
  47146. */
  47147. export class RotationGizmo extends Gizmo {
  47148. /**
  47149. * Internal gizmo used for interactions on the x axis
  47150. */
  47151. xGizmo: PlaneRotationGizmo;
  47152. /**
  47153. * Internal gizmo used for interactions on the y axis
  47154. */
  47155. yGizmo: PlaneRotationGizmo;
  47156. /**
  47157. * Internal gizmo used for interactions on the z axis
  47158. */
  47159. zGizmo: PlaneRotationGizmo;
  47160. /** Fires an event when any of it's sub gizmos are dragged */
  47161. onDragStartObservable: Observable<unknown>;
  47162. /** Fires an event when any of it's sub gizmos are released from dragging */
  47163. onDragEndObservable: Observable<unknown>;
  47164. private _meshAttached;
  47165. attachedMesh: Nullable<AbstractMesh>;
  47166. /**
  47167. * Creates a RotationGizmo
  47168. * @param gizmoLayer The utility layer the gizmo will be added to
  47169. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47170. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47171. */
  47172. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47173. updateGizmoRotationToMatchAttachedMesh: boolean;
  47174. /**
  47175. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47176. */
  47177. snapDistance: number;
  47178. /**
  47179. * Ratio for the scale of the gizmo (Default: 1)
  47180. */
  47181. scaleRatio: number;
  47182. /**
  47183. * Disposes of the gizmo
  47184. */
  47185. dispose(): void;
  47186. /**
  47187. * CustomMeshes are not supported by this gizmo
  47188. * @param mesh The mesh to replace the default mesh of the gizmo
  47189. */
  47190. setCustomMesh(mesh: Mesh): void;
  47191. }
  47192. }
  47193. declare module "babylonjs/Gizmos/gizmoManager" {
  47194. import { Observable } from "babylonjs/Misc/observable";
  47195. import { Nullable } from "babylonjs/types";
  47196. import { Scene, IDisposable } from "babylonjs/scene";
  47197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47198. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47199. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47200. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47201. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47202. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47203. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47204. /**
  47205. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47206. */
  47207. export class GizmoManager implements IDisposable {
  47208. private scene;
  47209. /**
  47210. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47211. */
  47212. gizmos: {
  47213. positionGizmo: Nullable<PositionGizmo>;
  47214. rotationGizmo: Nullable<RotationGizmo>;
  47215. scaleGizmo: Nullable<ScaleGizmo>;
  47216. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47217. };
  47218. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47219. clearGizmoOnEmptyPointerEvent: boolean;
  47220. /** Fires an event when the manager is attached to a mesh */
  47221. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47222. private _gizmosEnabled;
  47223. private _pointerObserver;
  47224. private _attachedMesh;
  47225. private _boundingBoxColor;
  47226. private _defaultUtilityLayer;
  47227. private _defaultKeepDepthUtilityLayer;
  47228. /**
  47229. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47230. */
  47231. boundingBoxDragBehavior: SixDofDragBehavior;
  47232. /**
  47233. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47234. */
  47235. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47236. /**
  47237. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47238. */
  47239. usePointerToAttachGizmos: boolean;
  47240. /**
  47241. * Utility layer that the bounding box gizmo belongs to
  47242. */
  47243. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47244. /**
  47245. * Utility layer that all gizmos besides bounding box belong to
  47246. */
  47247. readonly utilityLayer: UtilityLayerRenderer;
  47248. /**
  47249. * Instatiates a gizmo manager
  47250. * @param scene the scene to overlay the gizmos on top of
  47251. */
  47252. constructor(scene: Scene);
  47253. /**
  47254. * Attaches a set of gizmos to the specified mesh
  47255. * @param mesh The mesh the gizmo's should be attached to
  47256. */
  47257. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47258. /**
  47259. * If the position gizmo is enabled
  47260. */
  47261. positionGizmoEnabled: boolean;
  47262. /**
  47263. * If the rotation gizmo is enabled
  47264. */
  47265. rotationGizmoEnabled: boolean;
  47266. /**
  47267. * If the scale gizmo is enabled
  47268. */
  47269. scaleGizmoEnabled: boolean;
  47270. /**
  47271. * If the boundingBox gizmo is enabled
  47272. */
  47273. boundingBoxGizmoEnabled: boolean;
  47274. /**
  47275. * Disposes of the gizmo manager
  47276. */
  47277. dispose(): void;
  47278. }
  47279. }
  47280. declare module "babylonjs/Lights/directionalLight" {
  47281. import { Camera } from "babylonjs/Cameras/camera";
  47282. import { Scene } from "babylonjs/scene";
  47283. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47285. import { Light } from "babylonjs/Lights/light";
  47286. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47287. import { Effect } from "babylonjs/Materials/effect";
  47288. /**
  47289. * A directional light is defined by a direction (what a surprise!).
  47290. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47291. * 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.
  47292. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47293. */
  47294. export class DirectionalLight extends ShadowLight {
  47295. private _shadowFrustumSize;
  47296. /**
  47297. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47298. */
  47299. /**
  47300. * Specifies a fix frustum size for the shadow generation.
  47301. */
  47302. shadowFrustumSize: number;
  47303. private _shadowOrthoScale;
  47304. /**
  47305. * Gets the shadow projection scale against the optimal computed one.
  47306. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47307. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47308. */
  47309. /**
  47310. * Sets the shadow projection scale against the optimal computed one.
  47311. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47312. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47313. */
  47314. shadowOrthoScale: number;
  47315. /**
  47316. * Automatically compute the projection matrix to best fit (including all the casters)
  47317. * on each frame.
  47318. */
  47319. autoUpdateExtends: boolean;
  47320. private _orthoLeft;
  47321. private _orthoRight;
  47322. private _orthoTop;
  47323. private _orthoBottom;
  47324. /**
  47325. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47326. * The directional light is emitted from everywhere in the given direction.
  47327. * It can cast shadows.
  47328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47329. * @param name The friendly name of the light
  47330. * @param direction The direction of the light
  47331. * @param scene The scene the light belongs to
  47332. */
  47333. constructor(name: string, direction: Vector3, scene: Scene);
  47334. /**
  47335. * Returns the string "DirectionalLight".
  47336. * @return The class name
  47337. */
  47338. getClassName(): string;
  47339. /**
  47340. * Returns the integer 1.
  47341. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47342. */
  47343. getTypeID(): number;
  47344. /**
  47345. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47346. * Returns the DirectionalLight Shadow projection matrix.
  47347. */
  47348. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47349. /**
  47350. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47351. * Returns the DirectionalLight Shadow projection matrix.
  47352. */
  47353. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47354. /**
  47355. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47356. * Returns the DirectionalLight Shadow projection matrix.
  47357. */
  47358. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47359. protected _buildUniformLayout(): void;
  47360. /**
  47361. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47362. * @param effect The effect to update
  47363. * @param lightIndex The index of the light in the effect to update
  47364. * @returns The directional light
  47365. */
  47366. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47367. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47368. /**
  47369. * Gets the minZ used for shadow according to both the scene and the light.
  47370. *
  47371. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47372. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47373. * @param activeCamera The camera we are returning the min for
  47374. * @returns the depth min z
  47375. */
  47376. getDepthMinZ(activeCamera: Camera): number;
  47377. /**
  47378. * Gets the maxZ used for shadow according to both the scene and the light.
  47379. *
  47380. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47381. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47382. * @param activeCamera The camera we are returning the max for
  47383. * @returns the depth max z
  47384. */
  47385. getDepthMaxZ(activeCamera: Camera): number;
  47386. /**
  47387. * Prepares the list of defines specific to the light type.
  47388. * @param defines the list of defines
  47389. * @param lightIndex defines the index of the light for the effect
  47390. */
  47391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47392. }
  47393. }
  47394. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47395. import { Mesh } from "babylonjs/Meshes/mesh";
  47396. /**
  47397. * Class containing static functions to help procedurally build meshes
  47398. */
  47399. export class HemisphereBuilder {
  47400. /**
  47401. * Creates a hemisphere mesh
  47402. * @param name defines the name of the mesh
  47403. * @param options defines the options used to create the mesh
  47404. * @param scene defines the hosting scene
  47405. * @returns the hemisphere mesh
  47406. */
  47407. static CreateHemisphere(name: string, options: {
  47408. segments?: number;
  47409. diameter?: number;
  47410. sideOrientation?: number;
  47411. }, scene: any): Mesh;
  47412. }
  47413. }
  47414. declare module "babylonjs/Lights/spotLight" {
  47415. import { Nullable } from "babylonjs/types";
  47416. import { Scene } from "babylonjs/scene";
  47417. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47419. import { Effect } from "babylonjs/Materials/effect";
  47420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47421. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47422. /**
  47423. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47424. * These values define a cone of light starting from the position, emitting toward the direction.
  47425. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47426. * and the exponent defines the speed of the decay of the light with distance (reach).
  47427. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47428. */
  47429. export class SpotLight extends ShadowLight {
  47430. private _angle;
  47431. private _innerAngle;
  47432. private _cosHalfAngle;
  47433. private _lightAngleScale;
  47434. private _lightAngleOffset;
  47435. /**
  47436. * Gets the cone angle of the spot light in Radians.
  47437. */
  47438. /**
  47439. * Sets the cone angle of the spot light in Radians.
  47440. */
  47441. angle: number;
  47442. /**
  47443. * Only used in gltf falloff mode, this defines the angle where
  47444. * the directional falloff will start before cutting at angle which could be seen
  47445. * as outer angle.
  47446. */
  47447. /**
  47448. * Only used in gltf falloff mode, this defines the angle where
  47449. * the directional falloff will start before cutting at angle which could be seen
  47450. * as outer angle.
  47451. */
  47452. innerAngle: number;
  47453. private _shadowAngleScale;
  47454. /**
  47455. * Allows scaling the angle of the light for shadow generation only.
  47456. */
  47457. /**
  47458. * Allows scaling the angle of the light for shadow generation only.
  47459. */
  47460. shadowAngleScale: number;
  47461. /**
  47462. * The light decay speed with the distance from the emission spot.
  47463. */
  47464. exponent: number;
  47465. private _projectionTextureMatrix;
  47466. /**
  47467. * Allows reading the projecton texture
  47468. */
  47469. readonly projectionTextureMatrix: Matrix;
  47470. protected _projectionTextureLightNear: number;
  47471. /**
  47472. * Gets the near clip of the Spotlight for texture projection.
  47473. */
  47474. /**
  47475. * Sets the near clip of the Spotlight for texture projection.
  47476. */
  47477. projectionTextureLightNear: number;
  47478. protected _projectionTextureLightFar: number;
  47479. /**
  47480. * Gets the far clip of the Spotlight for texture projection.
  47481. */
  47482. /**
  47483. * Sets the far clip of the Spotlight for texture projection.
  47484. */
  47485. projectionTextureLightFar: number;
  47486. protected _projectionTextureUpDirection: Vector3;
  47487. /**
  47488. * Gets the Up vector of the Spotlight for texture projection.
  47489. */
  47490. /**
  47491. * Sets the Up vector of the Spotlight for texture projection.
  47492. */
  47493. projectionTextureUpDirection: Vector3;
  47494. private _projectionTexture;
  47495. /**
  47496. * Gets the projection texture of the light.
  47497. */
  47498. /**
  47499. * Sets the projection texture of the light.
  47500. */
  47501. projectionTexture: Nullable<BaseTexture>;
  47502. private _projectionTextureViewLightDirty;
  47503. private _projectionTextureProjectionLightDirty;
  47504. private _projectionTextureDirty;
  47505. private _projectionTextureViewTargetVector;
  47506. private _projectionTextureViewLightMatrix;
  47507. private _projectionTextureProjectionLightMatrix;
  47508. private _projectionTextureScalingMatrix;
  47509. /**
  47510. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47511. * It can cast shadows.
  47512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47513. * @param name The light friendly name
  47514. * @param position The position of the spot light in the scene
  47515. * @param direction The direction of the light in the scene
  47516. * @param angle The cone angle of the light in Radians
  47517. * @param exponent The light decay speed with the distance from the emission spot
  47518. * @param scene The scene the lights belongs to
  47519. */
  47520. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47521. /**
  47522. * Returns the string "SpotLight".
  47523. * @returns the class name
  47524. */
  47525. getClassName(): string;
  47526. /**
  47527. * Returns the integer 2.
  47528. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47529. */
  47530. getTypeID(): number;
  47531. /**
  47532. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47533. */
  47534. protected _setDirection(value: Vector3): void;
  47535. /**
  47536. * Overrides the position setter to recompute the projection texture view light Matrix.
  47537. */
  47538. protected _setPosition(value: Vector3): void;
  47539. /**
  47540. * 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.
  47541. * Returns the SpotLight.
  47542. */
  47543. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47544. protected _computeProjectionTextureViewLightMatrix(): void;
  47545. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47546. /**
  47547. * Main function for light texture projection matrix computing.
  47548. */
  47549. protected _computeProjectionTextureMatrix(): void;
  47550. protected _buildUniformLayout(): void;
  47551. private _computeAngleValues;
  47552. /**
  47553. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47554. * @param effect The effect to update
  47555. * @param lightIndex The index of the light in the effect to update
  47556. * @returns The spot light
  47557. */
  47558. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47559. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47560. /**
  47561. * Disposes the light and the associated resources.
  47562. */
  47563. dispose(): void;
  47564. /**
  47565. * Prepares the list of defines specific to the light type.
  47566. * @param defines the list of defines
  47567. * @param lightIndex defines the index of the light for the effect
  47568. */
  47569. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47570. }
  47571. }
  47572. declare module "babylonjs/Gizmos/lightGizmo" {
  47573. import { Nullable } from "babylonjs/types";
  47574. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47575. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47576. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47577. import { Light } from "babylonjs/Lights/light";
  47578. /**
  47579. * Gizmo that enables viewing a light
  47580. */
  47581. export class LightGizmo extends Gizmo {
  47582. private _lightMesh;
  47583. private _material;
  47584. private cachedPosition;
  47585. private cachedForward;
  47586. /**
  47587. * Creates a LightGizmo
  47588. * @param gizmoLayer The utility layer the gizmo will be added to
  47589. */
  47590. constructor(gizmoLayer?: UtilityLayerRenderer);
  47591. private _light;
  47592. /**
  47593. * The light that the gizmo is attached to
  47594. */
  47595. light: Nullable<Light>;
  47596. /**
  47597. * Gets the material used to render the light gizmo
  47598. */
  47599. readonly material: StandardMaterial;
  47600. /**
  47601. * @hidden
  47602. * Updates the gizmo to match the attached mesh's position/rotation
  47603. */
  47604. protected _update(): void;
  47605. private static _Scale;
  47606. /**
  47607. * Creates the lines for a light mesh
  47608. */
  47609. private static _createLightLines;
  47610. /**
  47611. * Disposes of the light gizmo
  47612. */
  47613. dispose(): void;
  47614. private static _CreateHemisphericLightMesh;
  47615. private static _CreatePointLightMesh;
  47616. private static _CreateSpotLightMesh;
  47617. private static _CreateDirectionalLightMesh;
  47618. }
  47619. }
  47620. declare module "babylonjs/Gizmos/index" {
  47621. export * from "babylonjs/Gizmos/axisDragGizmo";
  47622. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47623. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47624. export * from "babylonjs/Gizmos/gizmo";
  47625. export * from "babylonjs/Gizmos/gizmoManager";
  47626. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47627. export * from "babylonjs/Gizmos/positionGizmo";
  47628. export * from "babylonjs/Gizmos/rotationGizmo";
  47629. export * from "babylonjs/Gizmos/scaleGizmo";
  47630. export * from "babylonjs/Gizmos/lightGizmo";
  47631. export * from "babylonjs/Gizmos/planeDragGizmo";
  47632. }
  47633. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47634. /** @hidden */
  47635. export var backgroundFragmentDeclaration: {
  47636. name: string;
  47637. shader: string;
  47638. };
  47639. }
  47640. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47641. /** @hidden */
  47642. export var backgroundUboDeclaration: {
  47643. name: string;
  47644. shader: string;
  47645. };
  47646. }
  47647. declare module "babylonjs/Shaders/background.fragment" {
  47648. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47649. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47650. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47651. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47652. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47653. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47654. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47655. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47656. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47657. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47658. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47659. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47660. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47661. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47662. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47663. /** @hidden */
  47664. export var backgroundPixelShader: {
  47665. name: string;
  47666. shader: string;
  47667. };
  47668. }
  47669. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47670. /** @hidden */
  47671. export var backgroundVertexDeclaration: {
  47672. name: string;
  47673. shader: string;
  47674. };
  47675. }
  47676. declare module "babylonjs/Shaders/background.vertex" {
  47677. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47678. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47679. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47680. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47681. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47682. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47683. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47684. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47685. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47687. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47688. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47689. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47690. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47691. /** @hidden */
  47692. export var backgroundVertexShader: {
  47693. name: string;
  47694. shader: string;
  47695. };
  47696. }
  47697. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47698. import { Nullable, int, float } from "babylonjs/types";
  47699. import { Scene } from "babylonjs/scene";
  47700. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47703. import { Mesh } from "babylonjs/Meshes/mesh";
  47704. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47705. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47706. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47707. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47708. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47709. import { Color3 } from "babylonjs/Maths/math.color";
  47710. import "babylonjs/Shaders/background.fragment";
  47711. import "babylonjs/Shaders/background.vertex";
  47712. /**
  47713. * Background material used to create an efficient environement around your scene.
  47714. */
  47715. export class BackgroundMaterial extends PushMaterial {
  47716. /**
  47717. * Standard reflectance value at parallel view angle.
  47718. */
  47719. static StandardReflectance0: number;
  47720. /**
  47721. * Standard reflectance value at grazing angle.
  47722. */
  47723. static StandardReflectance90: number;
  47724. protected _primaryColor: Color3;
  47725. /**
  47726. * Key light Color (multiply against the environement texture)
  47727. */
  47728. primaryColor: Color3;
  47729. protected __perceptualColor: Nullable<Color3>;
  47730. /**
  47731. * Experimental Internal Use Only.
  47732. *
  47733. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47734. * This acts as a helper to set the primary color to a more "human friendly" value.
  47735. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47736. * output color as close as possible from the chosen value.
  47737. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47738. * part of lighting setup.)
  47739. */
  47740. _perceptualColor: Nullable<Color3>;
  47741. protected _primaryColorShadowLevel: float;
  47742. /**
  47743. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47744. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47745. */
  47746. primaryColorShadowLevel: float;
  47747. protected _primaryColorHighlightLevel: float;
  47748. /**
  47749. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47750. * The primary color is used at the level chosen to define what the white area would look.
  47751. */
  47752. primaryColorHighlightLevel: float;
  47753. protected _reflectionTexture: Nullable<BaseTexture>;
  47754. /**
  47755. * Reflection Texture used in the material.
  47756. * Should be author in a specific way for the best result (refer to the documentation).
  47757. */
  47758. reflectionTexture: Nullable<BaseTexture>;
  47759. protected _reflectionBlur: float;
  47760. /**
  47761. * Reflection Texture level of blur.
  47762. *
  47763. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47764. * texture twice.
  47765. */
  47766. reflectionBlur: float;
  47767. protected _diffuseTexture: Nullable<BaseTexture>;
  47768. /**
  47769. * Diffuse Texture used in the material.
  47770. * Should be author in a specific way for the best result (refer to the documentation).
  47771. */
  47772. diffuseTexture: Nullable<BaseTexture>;
  47773. protected _shadowLights: Nullable<IShadowLight[]>;
  47774. /**
  47775. * Specify the list of lights casting shadow on the material.
  47776. * All scene shadow lights will be included if null.
  47777. */
  47778. shadowLights: Nullable<IShadowLight[]>;
  47779. protected _shadowLevel: float;
  47780. /**
  47781. * Helps adjusting the shadow to a softer level if required.
  47782. * 0 means black shadows and 1 means no shadows.
  47783. */
  47784. shadowLevel: float;
  47785. protected _sceneCenter: Vector3;
  47786. /**
  47787. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47788. * It is usually zero but might be interesting to modify according to your setup.
  47789. */
  47790. sceneCenter: Vector3;
  47791. protected _opacityFresnel: boolean;
  47792. /**
  47793. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47794. * This helps ensuring a nice transition when the camera goes under the ground.
  47795. */
  47796. opacityFresnel: boolean;
  47797. protected _reflectionFresnel: boolean;
  47798. /**
  47799. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47800. * This helps adding a mirror texture on the ground.
  47801. */
  47802. reflectionFresnel: boolean;
  47803. protected _reflectionFalloffDistance: number;
  47804. /**
  47805. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47806. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47807. */
  47808. reflectionFalloffDistance: number;
  47809. protected _reflectionAmount: number;
  47810. /**
  47811. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47812. */
  47813. reflectionAmount: number;
  47814. protected _reflectionReflectance0: number;
  47815. /**
  47816. * This specifies the weight of the reflection at grazing angle.
  47817. */
  47818. reflectionReflectance0: number;
  47819. protected _reflectionReflectance90: number;
  47820. /**
  47821. * This specifies the weight of the reflection at a perpendicular point of view.
  47822. */
  47823. reflectionReflectance90: number;
  47824. /**
  47825. * Sets the reflection reflectance fresnel values according to the default standard
  47826. * empirically know to work well :-)
  47827. */
  47828. reflectionStandardFresnelWeight: number;
  47829. protected _useRGBColor: boolean;
  47830. /**
  47831. * Helps to directly use the maps channels instead of their level.
  47832. */
  47833. useRGBColor: boolean;
  47834. protected _enableNoise: boolean;
  47835. /**
  47836. * This helps reducing the banding effect that could occur on the background.
  47837. */
  47838. enableNoise: boolean;
  47839. /**
  47840. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47841. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47842. * Recommended to be keep at 1.0 except for special cases.
  47843. */
  47844. fovMultiplier: number;
  47845. private _fovMultiplier;
  47846. /**
  47847. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47848. */
  47849. useEquirectangularFOV: boolean;
  47850. private _maxSimultaneousLights;
  47851. /**
  47852. * Number of Simultaneous lights allowed on the material.
  47853. */
  47854. maxSimultaneousLights: int;
  47855. /**
  47856. * Default configuration related to image processing available in the Background Material.
  47857. */
  47858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47859. /**
  47860. * Keep track of the image processing observer to allow dispose and replace.
  47861. */
  47862. private _imageProcessingObserver;
  47863. /**
  47864. * Attaches a new image processing configuration to the PBR Material.
  47865. * @param configuration (if null the scene configuration will be use)
  47866. */
  47867. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47868. /**
  47869. * Gets the image processing configuration used either in this material.
  47870. */
  47871. /**
  47872. * Sets the Default image processing configuration used either in the this material.
  47873. *
  47874. * If sets to null, the scene one is in use.
  47875. */
  47876. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47877. /**
  47878. * Gets wether the color curves effect is enabled.
  47879. */
  47880. /**
  47881. * Sets wether the color curves effect is enabled.
  47882. */
  47883. cameraColorCurvesEnabled: boolean;
  47884. /**
  47885. * Gets wether the color grading effect is enabled.
  47886. */
  47887. /**
  47888. * Gets wether the color grading effect is enabled.
  47889. */
  47890. cameraColorGradingEnabled: boolean;
  47891. /**
  47892. * Gets wether tonemapping is enabled or not.
  47893. */
  47894. /**
  47895. * Sets wether tonemapping is enabled or not
  47896. */
  47897. cameraToneMappingEnabled: boolean;
  47898. /**
  47899. * The camera exposure used on this material.
  47900. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47901. * This corresponds to a photographic exposure.
  47902. */
  47903. /**
  47904. * The camera exposure used on this material.
  47905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47906. * This corresponds to a photographic exposure.
  47907. */
  47908. cameraExposure: float;
  47909. /**
  47910. * Gets The camera contrast used on this material.
  47911. */
  47912. /**
  47913. * Sets The camera contrast used on this material.
  47914. */
  47915. cameraContrast: float;
  47916. /**
  47917. * Gets the Color Grading 2D Lookup Texture.
  47918. */
  47919. /**
  47920. * Sets the Color Grading 2D Lookup Texture.
  47921. */
  47922. cameraColorGradingTexture: Nullable<BaseTexture>;
  47923. /**
  47924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47926. * 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;
  47927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47928. */
  47929. /**
  47930. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47931. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47932. * 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;
  47933. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47934. */
  47935. cameraColorCurves: Nullable<ColorCurves>;
  47936. /**
  47937. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47938. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47939. */
  47940. switchToBGR: boolean;
  47941. private _renderTargets;
  47942. private _reflectionControls;
  47943. private _white;
  47944. private _primaryShadowColor;
  47945. private _primaryHighlightColor;
  47946. /**
  47947. * Instantiates a Background Material in the given scene
  47948. * @param name The friendly name of the material
  47949. * @param scene The scene to add the material to
  47950. */
  47951. constructor(name: string, scene: Scene);
  47952. /**
  47953. * Gets a boolean indicating that current material needs to register RTT
  47954. */
  47955. readonly hasRenderTargetTextures: boolean;
  47956. /**
  47957. * The entire material has been created in order to prevent overdraw.
  47958. * @returns false
  47959. */
  47960. needAlphaTesting(): boolean;
  47961. /**
  47962. * The entire material has been created in order to prevent overdraw.
  47963. * @returns true if blending is enable
  47964. */
  47965. needAlphaBlending(): boolean;
  47966. /**
  47967. * Checks wether the material is ready to be rendered for a given mesh.
  47968. * @param mesh The mesh to render
  47969. * @param subMesh The submesh to check against
  47970. * @param useInstances Specify wether or not the material is used with instances
  47971. * @returns true if all the dependencies are ready (Textures, Effects...)
  47972. */
  47973. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47974. /**
  47975. * Compute the primary color according to the chosen perceptual color.
  47976. */
  47977. private _computePrimaryColorFromPerceptualColor;
  47978. /**
  47979. * Compute the highlights and shadow colors according to their chosen levels.
  47980. */
  47981. private _computePrimaryColors;
  47982. /**
  47983. * Build the uniform buffer used in the material.
  47984. */
  47985. buildUniformLayout(): void;
  47986. /**
  47987. * Unbind the material.
  47988. */
  47989. unbind(): void;
  47990. /**
  47991. * Bind only the world matrix to the material.
  47992. * @param world The world matrix to bind.
  47993. */
  47994. bindOnlyWorldMatrix(world: Matrix): void;
  47995. /**
  47996. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47997. * @param world The world matrix to bind.
  47998. * @param subMesh The submesh to bind for.
  47999. */
  48000. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48001. /**
  48002. * Checks to see if a texture is used in the material.
  48003. * @param texture - Base texture to use.
  48004. * @returns - Boolean specifying if a texture is used in the material.
  48005. */
  48006. hasTexture(texture: BaseTexture): boolean;
  48007. /**
  48008. * Dispose the material.
  48009. * @param forceDisposeEffect Force disposal of the associated effect.
  48010. * @param forceDisposeTextures Force disposal of the associated textures.
  48011. */
  48012. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48013. /**
  48014. * Clones the material.
  48015. * @param name The cloned name.
  48016. * @returns The cloned material.
  48017. */
  48018. clone(name: string): BackgroundMaterial;
  48019. /**
  48020. * Serializes the current material to its JSON representation.
  48021. * @returns The JSON representation.
  48022. */
  48023. serialize(): any;
  48024. /**
  48025. * Gets the class name of the material
  48026. * @returns "BackgroundMaterial"
  48027. */
  48028. getClassName(): string;
  48029. /**
  48030. * Parse a JSON input to create back a background material.
  48031. * @param source The JSON data to parse
  48032. * @param scene The scene to create the parsed material in
  48033. * @param rootUrl The root url of the assets the material depends upon
  48034. * @returns the instantiated BackgroundMaterial.
  48035. */
  48036. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48037. }
  48038. }
  48039. declare module "babylonjs/Helpers/environmentHelper" {
  48040. import { Observable } from "babylonjs/Misc/observable";
  48041. import { Nullable } from "babylonjs/types";
  48042. import { Scene } from "babylonjs/scene";
  48043. import { Vector3 } from "babylonjs/Maths/math.vector";
  48044. import { Color3 } from "babylonjs/Maths/math.color";
  48045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48046. import { Mesh } from "babylonjs/Meshes/mesh";
  48047. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48048. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48049. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48050. import "babylonjs/Meshes/Builders/planeBuilder";
  48051. import "babylonjs/Meshes/Builders/boxBuilder";
  48052. /**
  48053. * Represents the different options available during the creation of
  48054. * a Environment helper.
  48055. *
  48056. * This can control the default ground, skybox and image processing setup of your scene.
  48057. */
  48058. export interface IEnvironmentHelperOptions {
  48059. /**
  48060. * Specifies wether or not to create a ground.
  48061. * True by default.
  48062. */
  48063. createGround: boolean;
  48064. /**
  48065. * Specifies the ground size.
  48066. * 15 by default.
  48067. */
  48068. groundSize: number;
  48069. /**
  48070. * The texture used on the ground for the main color.
  48071. * Comes from the BabylonJS CDN by default.
  48072. *
  48073. * Remarks: Can be either a texture or a url.
  48074. */
  48075. groundTexture: string | BaseTexture;
  48076. /**
  48077. * The color mixed in the ground texture by default.
  48078. * BabylonJS clearColor by default.
  48079. */
  48080. groundColor: Color3;
  48081. /**
  48082. * Specifies the ground opacity.
  48083. * 1 by default.
  48084. */
  48085. groundOpacity: number;
  48086. /**
  48087. * Enables the ground to receive shadows.
  48088. * True by default.
  48089. */
  48090. enableGroundShadow: boolean;
  48091. /**
  48092. * Helps preventing the shadow to be fully black on the ground.
  48093. * 0.5 by default.
  48094. */
  48095. groundShadowLevel: number;
  48096. /**
  48097. * Creates a mirror texture attach to the ground.
  48098. * false by default.
  48099. */
  48100. enableGroundMirror: boolean;
  48101. /**
  48102. * Specifies the ground mirror size ratio.
  48103. * 0.3 by default as the default kernel is 64.
  48104. */
  48105. groundMirrorSizeRatio: number;
  48106. /**
  48107. * Specifies the ground mirror blur kernel size.
  48108. * 64 by default.
  48109. */
  48110. groundMirrorBlurKernel: number;
  48111. /**
  48112. * Specifies the ground mirror visibility amount.
  48113. * 1 by default
  48114. */
  48115. groundMirrorAmount: number;
  48116. /**
  48117. * Specifies the ground mirror reflectance weight.
  48118. * This uses the standard weight of the background material to setup the fresnel effect
  48119. * of the mirror.
  48120. * 1 by default.
  48121. */
  48122. groundMirrorFresnelWeight: number;
  48123. /**
  48124. * Specifies the ground mirror Falloff distance.
  48125. * This can helps reducing the size of the reflection.
  48126. * 0 by Default.
  48127. */
  48128. groundMirrorFallOffDistance: number;
  48129. /**
  48130. * Specifies the ground mirror texture type.
  48131. * Unsigned Int by Default.
  48132. */
  48133. groundMirrorTextureType: number;
  48134. /**
  48135. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48136. * the shown objects.
  48137. */
  48138. groundYBias: number;
  48139. /**
  48140. * Specifies wether or not to create a skybox.
  48141. * True by default.
  48142. */
  48143. createSkybox: boolean;
  48144. /**
  48145. * Specifies the skybox size.
  48146. * 20 by default.
  48147. */
  48148. skyboxSize: number;
  48149. /**
  48150. * The texture used on the skybox for the main color.
  48151. * Comes from the BabylonJS CDN by default.
  48152. *
  48153. * Remarks: Can be either a texture or a url.
  48154. */
  48155. skyboxTexture: string | BaseTexture;
  48156. /**
  48157. * The color mixed in the skybox texture by default.
  48158. * BabylonJS clearColor by default.
  48159. */
  48160. skyboxColor: Color3;
  48161. /**
  48162. * The background rotation around the Y axis of the scene.
  48163. * This helps aligning the key lights of your scene with the background.
  48164. * 0 by default.
  48165. */
  48166. backgroundYRotation: number;
  48167. /**
  48168. * Compute automatically the size of the elements to best fit with the scene.
  48169. */
  48170. sizeAuto: boolean;
  48171. /**
  48172. * Default position of the rootMesh if autoSize is not true.
  48173. */
  48174. rootPosition: Vector3;
  48175. /**
  48176. * Sets up the image processing in the scene.
  48177. * true by default.
  48178. */
  48179. setupImageProcessing: boolean;
  48180. /**
  48181. * The texture used as your environment texture in the scene.
  48182. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48183. *
  48184. * Remarks: Can be either a texture or a url.
  48185. */
  48186. environmentTexture: string | BaseTexture;
  48187. /**
  48188. * The value of the exposure to apply to the scene.
  48189. * 0.6 by default if setupImageProcessing is true.
  48190. */
  48191. cameraExposure: number;
  48192. /**
  48193. * The value of the contrast to apply to the scene.
  48194. * 1.6 by default if setupImageProcessing is true.
  48195. */
  48196. cameraContrast: number;
  48197. /**
  48198. * Specifies wether or not tonemapping should be enabled in the scene.
  48199. * true by default if setupImageProcessing is true.
  48200. */
  48201. toneMappingEnabled: boolean;
  48202. }
  48203. /**
  48204. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48205. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48206. * It also helps with the default setup of your imageProcessing configuration.
  48207. */
  48208. export class EnvironmentHelper {
  48209. /**
  48210. * Default ground texture URL.
  48211. */
  48212. private static _groundTextureCDNUrl;
  48213. /**
  48214. * Default skybox texture URL.
  48215. */
  48216. private static _skyboxTextureCDNUrl;
  48217. /**
  48218. * Default environment texture URL.
  48219. */
  48220. private static _environmentTextureCDNUrl;
  48221. /**
  48222. * Creates the default options for the helper.
  48223. */
  48224. private static _getDefaultOptions;
  48225. private _rootMesh;
  48226. /**
  48227. * Gets the root mesh created by the helper.
  48228. */
  48229. readonly rootMesh: Mesh;
  48230. private _skybox;
  48231. /**
  48232. * Gets the skybox created by the helper.
  48233. */
  48234. readonly skybox: Nullable<Mesh>;
  48235. private _skyboxTexture;
  48236. /**
  48237. * Gets the skybox texture created by the helper.
  48238. */
  48239. readonly skyboxTexture: Nullable<BaseTexture>;
  48240. private _skyboxMaterial;
  48241. /**
  48242. * Gets the skybox material created by the helper.
  48243. */
  48244. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48245. private _ground;
  48246. /**
  48247. * Gets the ground mesh created by the helper.
  48248. */
  48249. readonly ground: Nullable<Mesh>;
  48250. private _groundTexture;
  48251. /**
  48252. * Gets the ground texture created by the helper.
  48253. */
  48254. readonly groundTexture: Nullable<BaseTexture>;
  48255. private _groundMirror;
  48256. /**
  48257. * Gets the ground mirror created by the helper.
  48258. */
  48259. readonly groundMirror: Nullable<MirrorTexture>;
  48260. /**
  48261. * Gets the ground mirror render list to helps pushing the meshes
  48262. * you wish in the ground reflection.
  48263. */
  48264. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48265. private _groundMaterial;
  48266. /**
  48267. * Gets the ground material created by the helper.
  48268. */
  48269. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48270. /**
  48271. * Stores the creation options.
  48272. */
  48273. private readonly _scene;
  48274. private _options;
  48275. /**
  48276. * This observable will be notified with any error during the creation of the environment,
  48277. * mainly texture creation errors.
  48278. */
  48279. onErrorObservable: Observable<{
  48280. message?: string;
  48281. exception?: any;
  48282. }>;
  48283. /**
  48284. * constructor
  48285. * @param options Defines the options we want to customize the helper
  48286. * @param scene The scene to add the material to
  48287. */
  48288. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48289. /**
  48290. * Updates the background according to the new options
  48291. * @param options
  48292. */
  48293. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48294. /**
  48295. * Sets the primary color of all the available elements.
  48296. * @param color the main color to affect to the ground and the background
  48297. */
  48298. setMainColor(color: Color3): void;
  48299. /**
  48300. * Setup the image processing according to the specified options.
  48301. */
  48302. private _setupImageProcessing;
  48303. /**
  48304. * Setup the environment texture according to the specified options.
  48305. */
  48306. private _setupEnvironmentTexture;
  48307. /**
  48308. * Setup the background according to the specified options.
  48309. */
  48310. private _setupBackground;
  48311. /**
  48312. * Get the scene sizes according to the setup.
  48313. */
  48314. private _getSceneSize;
  48315. /**
  48316. * Setup the ground according to the specified options.
  48317. */
  48318. private _setupGround;
  48319. /**
  48320. * Setup the ground material according to the specified options.
  48321. */
  48322. private _setupGroundMaterial;
  48323. /**
  48324. * Setup the ground diffuse texture according to the specified options.
  48325. */
  48326. private _setupGroundDiffuseTexture;
  48327. /**
  48328. * Setup the ground mirror texture according to the specified options.
  48329. */
  48330. private _setupGroundMirrorTexture;
  48331. /**
  48332. * Setup the ground to receive the mirror texture.
  48333. */
  48334. private _setupMirrorInGroundMaterial;
  48335. /**
  48336. * Setup the skybox according to the specified options.
  48337. */
  48338. private _setupSkybox;
  48339. /**
  48340. * Setup the skybox material according to the specified options.
  48341. */
  48342. private _setupSkyboxMaterial;
  48343. /**
  48344. * Setup the skybox reflection texture according to the specified options.
  48345. */
  48346. private _setupSkyboxReflectionTexture;
  48347. private _errorHandler;
  48348. /**
  48349. * Dispose all the elements created by the Helper.
  48350. */
  48351. dispose(): void;
  48352. }
  48353. }
  48354. declare module "babylonjs/Helpers/photoDome" {
  48355. import { Observable } from "babylonjs/Misc/observable";
  48356. import { Nullable } from "babylonjs/types";
  48357. import { Scene } from "babylonjs/scene";
  48358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48359. import { Mesh } from "babylonjs/Meshes/mesh";
  48360. import { Texture } from "babylonjs/Materials/Textures/texture";
  48361. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48362. import "babylonjs/Meshes/Builders/sphereBuilder";
  48363. /**
  48364. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48365. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48366. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48367. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48368. */
  48369. export class PhotoDome extends TransformNode {
  48370. /**
  48371. * Define the image as a Monoscopic panoramic 360 image.
  48372. */
  48373. static readonly MODE_MONOSCOPIC: number;
  48374. /**
  48375. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48376. */
  48377. static readonly MODE_TOPBOTTOM: number;
  48378. /**
  48379. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48380. */
  48381. static readonly MODE_SIDEBYSIDE: number;
  48382. private _useDirectMapping;
  48383. /**
  48384. * The texture being displayed on the sphere
  48385. */
  48386. protected _photoTexture: Texture;
  48387. /**
  48388. * Gets or sets the texture being displayed on the sphere
  48389. */
  48390. photoTexture: Texture;
  48391. /**
  48392. * Observable raised when an error occured while loading the 360 image
  48393. */
  48394. onLoadErrorObservable: Observable<string>;
  48395. /**
  48396. * The skybox material
  48397. */
  48398. protected _material: BackgroundMaterial;
  48399. /**
  48400. * The surface used for the skybox
  48401. */
  48402. protected _mesh: Mesh;
  48403. /**
  48404. * Gets the mesh used for the skybox.
  48405. */
  48406. readonly mesh: Mesh;
  48407. /**
  48408. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48409. * Also see the options.resolution property.
  48410. */
  48411. fovMultiplier: number;
  48412. private _imageMode;
  48413. /**
  48414. * Gets or set the current video mode for the video. It can be:
  48415. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48416. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48417. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48418. */
  48419. imageMode: number;
  48420. /**
  48421. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48422. * @param name Element's name, child elements will append suffixes for their own names.
  48423. * @param urlsOfPhoto defines the url of the photo to display
  48424. * @param options defines an object containing optional or exposed sub element properties
  48425. * @param onError defines a callback called when an error occured while loading the texture
  48426. */
  48427. constructor(name: string, urlOfPhoto: string, options: {
  48428. resolution?: number;
  48429. size?: number;
  48430. useDirectMapping?: boolean;
  48431. faceForward?: boolean;
  48432. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48433. private _onBeforeCameraRenderObserver;
  48434. private _changeImageMode;
  48435. /**
  48436. * Releases resources associated with this node.
  48437. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48438. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48439. */
  48440. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48441. }
  48442. }
  48443. declare module "babylonjs/Misc/rgbdTextureTools" {
  48444. import "babylonjs/Shaders/rgbdDecode.fragment";
  48445. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48446. import { Texture } from "babylonjs/Materials/Textures/texture";
  48447. /**
  48448. * Class used to host RGBD texture specific utilities
  48449. */
  48450. export class RGBDTextureTools {
  48451. /**
  48452. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48453. * @param texture the texture to expand.
  48454. */
  48455. static ExpandRGBDTexture(texture: Texture): void;
  48456. }
  48457. }
  48458. declare module "babylonjs/Misc/brdfTextureTools" {
  48459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48460. import { Scene } from "babylonjs/scene";
  48461. /**
  48462. * Class used to host texture specific utilities
  48463. */
  48464. export class BRDFTextureTools {
  48465. /**
  48466. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48467. * @param scene defines the hosting scene
  48468. * @returns the environment BRDF texture
  48469. */
  48470. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48471. private static _environmentBRDFBase64Texture;
  48472. }
  48473. }
  48474. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48475. import { Nullable } from "babylonjs/types";
  48476. import { Color3 } from "babylonjs/Maths/math.color";
  48477. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48478. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48479. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48480. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48481. import { Engine } from "babylonjs/Engines/engine";
  48482. import { Scene } from "babylonjs/scene";
  48483. /**
  48484. * @hidden
  48485. */
  48486. export interface IMaterialClearCoatDefines {
  48487. CLEARCOAT: boolean;
  48488. CLEARCOAT_DEFAULTIOR: boolean;
  48489. CLEARCOAT_TEXTURE: boolean;
  48490. CLEARCOAT_TEXTUREDIRECTUV: number;
  48491. CLEARCOAT_BUMP: boolean;
  48492. CLEARCOAT_BUMPDIRECTUV: number;
  48493. CLEARCOAT_TINT: boolean;
  48494. CLEARCOAT_TINT_TEXTURE: boolean;
  48495. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48496. /** @hidden */
  48497. _areTexturesDirty: boolean;
  48498. }
  48499. /**
  48500. * Define the code related to the clear coat parameters of the pbr material.
  48501. */
  48502. export class PBRClearCoatConfiguration {
  48503. /**
  48504. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48505. * The default fits with a polyurethane material.
  48506. */
  48507. private static readonly _DefaultIndexOfRefraction;
  48508. private _isEnabled;
  48509. /**
  48510. * Defines if the clear coat is enabled in the material.
  48511. */
  48512. isEnabled: boolean;
  48513. /**
  48514. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48515. */
  48516. intensity: number;
  48517. /**
  48518. * Defines the clear coat layer roughness.
  48519. */
  48520. roughness: number;
  48521. private _indexOfRefraction;
  48522. /**
  48523. * Defines the index of refraction of the clear coat.
  48524. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48525. * The default fits with a polyurethane material.
  48526. * Changing the default value is more performance intensive.
  48527. */
  48528. indexOfRefraction: number;
  48529. private _texture;
  48530. /**
  48531. * Stores the clear coat values in a texture.
  48532. */
  48533. texture: Nullable<BaseTexture>;
  48534. private _bumpTexture;
  48535. /**
  48536. * Define the clear coat specific bump texture.
  48537. */
  48538. bumpTexture: Nullable<BaseTexture>;
  48539. private _isTintEnabled;
  48540. /**
  48541. * Defines if the clear coat tint is enabled in the material.
  48542. */
  48543. isTintEnabled: boolean;
  48544. /**
  48545. * Defines the clear coat tint of the material.
  48546. * This is only use if tint is enabled
  48547. */
  48548. tintColor: Color3;
  48549. /**
  48550. * Defines the distance at which the tint color should be found in the
  48551. * clear coat media.
  48552. * This is only use if tint is enabled
  48553. */
  48554. tintColorAtDistance: number;
  48555. /**
  48556. * Defines the clear coat layer thickness.
  48557. * This is only use if tint is enabled
  48558. */
  48559. tintThickness: number;
  48560. private _tintTexture;
  48561. /**
  48562. * Stores the clear tint values in a texture.
  48563. * rgb is tint
  48564. * a is a thickness factor
  48565. */
  48566. tintTexture: Nullable<BaseTexture>;
  48567. /** @hidden */
  48568. private _internalMarkAllSubMeshesAsTexturesDirty;
  48569. /** @hidden */
  48570. _markAllSubMeshesAsTexturesDirty(): void;
  48571. /**
  48572. * Instantiate a new istance of clear coat configuration.
  48573. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48574. */
  48575. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48576. /**
  48577. * Gets wehter the submesh is ready to be used or not.
  48578. * @param defines the list of "defines" to update.
  48579. * @param scene defines the scene the material belongs to.
  48580. * @param engine defines the engine the material belongs to.
  48581. * @param disableBumpMap defines wether the material disables bump or not.
  48582. * @returns - boolean indicating that the submesh is ready or not.
  48583. */
  48584. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48585. /**
  48586. * Checks to see if a texture is used in the material.
  48587. * @param defines the list of "defines" to update.
  48588. * @param scene defines the scene to the material belongs to.
  48589. */
  48590. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48591. /**
  48592. * Binds the material data.
  48593. * @param uniformBuffer defines the Uniform buffer to fill in.
  48594. * @param scene defines the scene the material belongs to.
  48595. * @param engine defines the engine the material belongs to.
  48596. * @param disableBumpMap defines wether the material disables bump or not.
  48597. * @param isFrozen defines wether the material is frozen or not.
  48598. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48599. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48600. */
  48601. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48602. /**
  48603. * Checks to see if a texture is used in the material.
  48604. * @param texture - Base texture to use.
  48605. * @returns - Boolean specifying if a texture is used in the material.
  48606. */
  48607. hasTexture(texture: BaseTexture): boolean;
  48608. /**
  48609. * Returns an array of the actively used textures.
  48610. * @param activeTextures Array of BaseTextures
  48611. */
  48612. getActiveTextures(activeTextures: BaseTexture[]): void;
  48613. /**
  48614. * Returns the animatable textures.
  48615. * @param animatables Array of animatable textures.
  48616. */
  48617. getAnimatables(animatables: IAnimatable[]): void;
  48618. /**
  48619. * Disposes the resources of the material.
  48620. * @param forceDisposeTextures - Forces the disposal of all textures.
  48621. */
  48622. dispose(forceDisposeTextures?: boolean): void;
  48623. /**
  48624. * Get the current class name of the texture useful for serialization or dynamic coding.
  48625. * @returns "PBRClearCoatConfiguration"
  48626. */
  48627. getClassName(): string;
  48628. /**
  48629. * Add fallbacks to the effect fallbacks list.
  48630. * @param defines defines the Base texture to use.
  48631. * @param fallbacks defines the current fallback list.
  48632. * @param currentRank defines the current fallback rank.
  48633. * @returns the new fallback rank.
  48634. */
  48635. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48636. /**
  48637. * Add the required uniforms to the current list.
  48638. * @param uniforms defines the current uniform list.
  48639. */
  48640. static AddUniforms(uniforms: string[]): void;
  48641. /**
  48642. * Add the required samplers to the current list.
  48643. * @param samplers defines the current sampler list.
  48644. */
  48645. static AddSamplers(samplers: string[]): void;
  48646. /**
  48647. * Add the required uniforms to the current buffer.
  48648. * @param uniformBuffer defines the current uniform buffer.
  48649. */
  48650. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48651. /**
  48652. * Makes a duplicate of the current configuration into another one.
  48653. * @param clearCoatConfiguration define the config where to copy the info
  48654. */
  48655. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48656. /**
  48657. * Serializes this clear coat configuration.
  48658. * @returns - An object with the serialized config.
  48659. */
  48660. serialize(): any;
  48661. /**
  48662. * Parses a anisotropy Configuration from a serialized object.
  48663. * @param source - Serialized object.
  48664. * @param scene Defines the scene we are parsing for
  48665. * @param rootUrl Defines the rootUrl to load from
  48666. */
  48667. parse(source: any, scene: Scene, rootUrl: string): void;
  48668. }
  48669. }
  48670. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48673. import { Vector2 } from "babylonjs/Maths/math.vector";
  48674. import { Scene } from "babylonjs/scene";
  48675. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48676. import { Nullable } from "babylonjs/types";
  48677. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48678. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48679. /**
  48680. * @hidden
  48681. */
  48682. export interface IMaterialAnisotropicDefines {
  48683. ANISOTROPIC: boolean;
  48684. ANISOTROPIC_TEXTURE: boolean;
  48685. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48686. MAINUV1: boolean;
  48687. _areTexturesDirty: boolean;
  48688. _needUVs: boolean;
  48689. }
  48690. /**
  48691. * Define the code related to the anisotropic parameters of the pbr material.
  48692. */
  48693. export class PBRAnisotropicConfiguration {
  48694. private _isEnabled;
  48695. /**
  48696. * Defines if the anisotropy is enabled in the material.
  48697. */
  48698. isEnabled: boolean;
  48699. /**
  48700. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48701. */
  48702. intensity: number;
  48703. /**
  48704. * Defines if the effect is along the tangents, bitangents or in between.
  48705. * By default, the effect is "strectching" the highlights along the tangents.
  48706. */
  48707. direction: Vector2;
  48708. private _texture;
  48709. /**
  48710. * Stores the anisotropy values in a texture.
  48711. * rg is direction (like normal from -1 to 1)
  48712. * b is a intensity
  48713. */
  48714. texture: Nullable<BaseTexture>;
  48715. /** @hidden */
  48716. private _internalMarkAllSubMeshesAsTexturesDirty;
  48717. /** @hidden */
  48718. _markAllSubMeshesAsTexturesDirty(): void;
  48719. /**
  48720. * Instantiate a new istance of anisotropy configuration.
  48721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48722. */
  48723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48724. /**
  48725. * Specifies that the submesh is ready to be used.
  48726. * @param defines the list of "defines" to update.
  48727. * @param scene defines the scene the material belongs to.
  48728. * @returns - boolean indicating that the submesh is ready or not.
  48729. */
  48730. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48731. /**
  48732. * Checks to see if a texture is used in the material.
  48733. * @param defines the list of "defines" to update.
  48734. * @param mesh the mesh we are preparing the defines for.
  48735. * @param scene defines the scene the material belongs to.
  48736. */
  48737. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48738. /**
  48739. * Binds the material data.
  48740. * @param uniformBuffer defines the Uniform buffer to fill in.
  48741. * @param scene defines the scene the material belongs to.
  48742. * @param isFrozen defines wether the material is frozen or not.
  48743. */
  48744. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48745. /**
  48746. * Checks to see if a texture is used in the material.
  48747. * @param texture - Base texture to use.
  48748. * @returns - Boolean specifying if a texture is used in the material.
  48749. */
  48750. hasTexture(texture: BaseTexture): boolean;
  48751. /**
  48752. * Returns an array of the actively used textures.
  48753. * @param activeTextures Array of BaseTextures
  48754. */
  48755. getActiveTextures(activeTextures: BaseTexture[]): void;
  48756. /**
  48757. * Returns the animatable textures.
  48758. * @param animatables Array of animatable textures.
  48759. */
  48760. getAnimatables(animatables: IAnimatable[]): void;
  48761. /**
  48762. * Disposes the resources of the material.
  48763. * @param forceDisposeTextures - Forces the disposal of all textures.
  48764. */
  48765. dispose(forceDisposeTextures?: boolean): void;
  48766. /**
  48767. * Get the current class name of the texture useful for serialization or dynamic coding.
  48768. * @returns "PBRAnisotropicConfiguration"
  48769. */
  48770. getClassName(): string;
  48771. /**
  48772. * Add fallbacks to the effect fallbacks list.
  48773. * @param defines defines the Base texture to use.
  48774. * @param fallbacks defines the current fallback list.
  48775. * @param currentRank defines the current fallback rank.
  48776. * @returns the new fallback rank.
  48777. */
  48778. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48779. /**
  48780. * Add the required uniforms to the current list.
  48781. * @param uniforms defines the current uniform list.
  48782. */
  48783. static AddUniforms(uniforms: string[]): void;
  48784. /**
  48785. * Add the required uniforms to the current buffer.
  48786. * @param uniformBuffer defines the current uniform buffer.
  48787. */
  48788. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48789. /**
  48790. * Add the required samplers to the current list.
  48791. * @param samplers defines the current sampler list.
  48792. */
  48793. static AddSamplers(samplers: string[]): void;
  48794. /**
  48795. * Makes a duplicate of the current configuration into another one.
  48796. * @param anisotropicConfiguration define the config where to copy the info
  48797. */
  48798. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48799. /**
  48800. * Serializes this anisotropy configuration.
  48801. * @returns - An object with the serialized config.
  48802. */
  48803. serialize(): any;
  48804. /**
  48805. * Parses a anisotropy Configuration from a serialized object.
  48806. * @param source - Serialized object.
  48807. * @param scene Defines the scene we are parsing for
  48808. * @param rootUrl Defines the rootUrl to load from
  48809. */
  48810. parse(source: any, scene: Scene, rootUrl: string): void;
  48811. }
  48812. }
  48813. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48814. import { Scene } from "babylonjs/scene";
  48815. /**
  48816. * @hidden
  48817. */
  48818. export interface IMaterialBRDFDefines {
  48819. BRDF_V_HEIGHT_CORRELATED: boolean;
  48820. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48821. SPHERICAL_HARMONICS: boolean;
  48822. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48823. /** @hidden */
  48824. _areMiscDirty: boolean;
  48825. }
  48826. /**
  48827. * Define the code related to the BRDF parameters of the pbr material.
  48828. */
  48829. export class PBRBRDFConfiguration {
  48830. /**
  48831. * Default value used for the energy conservation.
  48832. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48833. */
  48834. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48835. /**
  48836. * Default value used for the Smith Visibility Height Correlated mode.
  48837. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48838. */
  48839. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48840. /**
  48841. * Default value used for the IBL diffuse part.
  48842. * This can help switching back to the polynomials mode globally which is a tiny bit
  48843. * less GPU intensive at the drawback of a lower quality.
  48844. */
  48845. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48846. /**
  48847. * Default value used for activating energy conservation for the specular workflow.
  48848. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48849. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48850. */
  48851. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48852. private _useEnergyConservation;
  48853. /**
  48854. * Defines if the material uses energy conservation.
  48855. */
  48856. useEnergyConservation: boolean;
  48857. private _useSmithVisibilityHeightCorrelated;
  48858. /**
  48859. * LEGACY Mode set to false
  48860. * Defines if the material uses height smith correlated visibility term.
  48861. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48862. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48863. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48864. * Not relying on height correlated will also disable energy conservation.
  48865. */
  48866. useSmithVisibilityHeightCorrelated: boolean;
  48867. private _useSphericalHarmonics;
  48868. /**
  48869. * LEGACY Mode set to false
  48870. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48871. * diffuse part of the IBL.
  48872. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48873. * to the ground truth.
  48874. */
  48875. useSphericalHarmonics: boolean;
  48876. private _useSpecularGlossinessInputEnergyConservation;
  48877. /**
  48878. * Defines if the material uses energy conservation, when the specular workflow is active.
  48879. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48880. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48881. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48882. */
  48883. useSpecularGlossinessInputEnergyConservation: boolean;
  48884. /** @hidden */
  48885. private _internalMarkAllSubMeshesAsMiscDirty;
  48886. /** @hidden */
  48887. _markAllSubMeshesAsMiscDirty(): void;
  48888. /**
  48889. * Instantiate a new istance of clear coat configuration.
  48890. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48891. */
  48892. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48893. /**
  48894. * Checks to see if a texture is used in the material.
  48895. * @param defines the list of "defines" to update.
  48896. */
  48897. prepareDefines(defines: IMaterialBRDFDefines): void;
  48898. /**
  48899. * Get the current class name of the texture useful for serialization or dynamic coding.
  48900. * @returns "PBRClearCoatConfiguration"
  48901. */
  48902. getClassName(): string;
  48903. /**
  48904. * Makes a duplicate of the current configuration into another one.
  48905. * @param brdfConfiguration define the config where to copy the info
  48906. */
  48907. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48908. /**
  48909. * Serializes this BRDF configuration.
  48910. * @returns - An object with the serialized config.
  48911. */
  48912. serialize(): any;
  48913. /**
  48914. * Parses a anisotropy Configuration from a serialized object.
  48915. * @param source - Serialized object.
  48916. * @param scene Defines the scene we are parsing for
  48917. * @param rootUrl Defines the rootUrl to load from
  48918. */
  48919. parse(source: any, scene: Scene, rootUrl: string): void;
  48920. }
  48921. }
  48922. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48923. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48924. import { Color3 } from "babylonjs/Maths/math.color";
  48925. import { Scene } from "babylonjs/scene";
  48926. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48927. import { Nullable } from "babylonjs/types";
  48928. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48929. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48930. /**
  48931. * @hidden
  48932. */
  48933. export interface IMaterialSheenDefines {
  48934. SHEEN: boolean;
  48935. SHEEN_TEXTURE: boolean;
  48936. SHEEN_TEXTUREDIRECTUV: number;
  48937. SHEEN_LINKWITHALBEDO: boolean;
  48938. /** @hidden */
  48939. _areTexturesDirty: boolean;
  48940. }
  48941. /**
  48942. * Define the code related to the Sheen parameters of the pbr material.
  48943. */
  48944. export class PBRSheenConfiguration {
  48945. private _isEnabled;
  48946. /**
  48947. * Defines if the material uses sheen.
  48948. */
  48949. isEnabled: boolean;
  48950. private _linkSheenWithAlbedo;
  48951. /**
  48952. * Defines if the sheen is linked to the sheen color.
  48953. */
  48954. linkSheenWithAlbedo: boolean;
  48955. /**
  48956. * Defines the sheen intensity.
  48957. */
  48958. intensity: number;
  48959. /**
  48960. * Defines the sheen color.
  48961. */
  48962. color: Color3;
  48963. private _texture;
  48964. /**
  48965. * Stores the sheen tint values in a texture.
  48966. * rgb is tint
  48967. * a is a intensity
  48968. */
  48969. texture: Nullable<BaseTexture>;
  48970. /** @hidden */
  48971. private _internalMarkAllSubMeshesAsTexturesDirty;
  48972. /** @hidden */
  48973. _markAllSubMeshesAsTexturesDirty(): void;
  48974. /**
  48975. * Instantiate a new istance of clear coat configuration.
  48976. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48977. */
  48978. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48979. /**
  48980. * Specifies that the submesh is ready to be used.
  48981. * @param defines the list of "defines" to update.
  48982. * @param scene defines the scene the material belongs to.
  48983. * @returns - boolean indicating that the submesh is ready or not.
  48984. */
  48985. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48986. /**
  48987. * Checks to see if a texture is used in the material.
  48988. * @param defines the list of "defines" to update.
  48989. * @param scene defines the scene the material belongs to.
  48990. */
  48991. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48992. /**
  48993. * Binds the material data.
  48994. * @param uniformBuffer defines the Uniform buffer to fill in.
  48995. * @param scene defines the scene the material belongs to.
  48996. * @param isFrozen defines wether the material is frozen or not.
  48997. */
  48998. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48999. /**
  49000. * Checks to see if a texture is used in the material.
  49001. * @param texture - Base texture to use.
  49002. * @returns - Boolean specifying if a texture is used in the material.
  49003. */
  49004. hasTexture(texture: BaseTexture): boolean;
  49005. /**
  49006. * Returns an array of the actively used textures.
  49007. * @param activeTextures Array of BaseTextures
  49008. */
  49009. getActiveTextures(activeTextures: BaseTexture[]): void;
  49010. /**
  49011. * Returns the animatable textures.
  49012. * @param animatables Array of animatable textures.
  49013. */
  49014. getAnimatables(animatables: IAnimatable[]): void;
  49015. /**
  49016. * Disposes the resources of the material.
  49017. * @param forceDisposeTextures - Forces the disposal of all textures.
  49018. */
  49019. dispose(forceDisposeTextures?: boolean): void;
  49020. /**
  49021. * Get the current class name of the texture useful for serialization or dynamic coding.
  49022. * @returns "PBRSheenConfiguration"
  49023. */
  49024. getClassName(): string;
  49025. /**
  49026. * Add fallbacks to the effect fallbacks list.
  49027. * @param defines defines the Base texture to use.
  49028. * @param fallbacks defines the current fallback list.
  49029. * @param currentRank defines the current fallback rank.
  49030. * @returns the new fallback rank.
  49031. */
  49032. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49033. /**
  49034. * Add the required uniforms to the current list.
  49035. * @param uniforms defines the current uniform list.
  49036. */
  49037. static AddUniforms(uniforms: string[]): void;
  49038. /**
  49039. * Add the required uniforms to the current buffer.
  49040. * @param uniformBuffer defines the current uniform buffer.
  49041. */
  49042. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49043. /**
  49044. * Add the required samplers to the current list.
  49045. * @param samplers defines the current sampler list.
  49046. */
  49047. static AddSamplers(samplers: string[]): void;
  49048. /**
  49049. * Makes a duplicate of the current configuration into another one.
  49050. * @param sheenConfiguration define the config where to copy the info
  49051. */
  49052. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49053. /**
  49054. * Serializes this BRDF configuration.
  49055. * @returns - An object with the serialized config.
  49056. */
  49057. serialize(): any;
  49058. /**
  49059. * Parses a anisotropy Configuration from a serialized object.
  49060. * @param source - Serialized object.
  49061. * @param scene Defines the scene we are parsing for
  49062. * @param rootUrl Defines the rootUrl to load from
  49063. */
  49064. parse(source: any, scene: Scene, rootUrl: string): void;
  49065. }
  49066. }
  49067. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49068. import { Nullable } from "babylonjs/types";
  49069. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49070. import { Color3 } from "babylonjs/Maths/math.color";
  49071. import { SmartArray } from "babylonjs/Misc/smartArray";
  49072. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49073. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49074. import { Effect } from "babylonjs/Materials/effect";
  49075. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49076. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49077. import { Engine } from "babylonjs/Engines/engine";
  49078. import { Scene } from "babylonjs/scene";
  49079. /**
  49080. * @hidden
  49081. */
  49082. export interface IMaterialSubSurfaceDefines {
  49083. SUBSURFACE: boolean;
  49084. SS_REFRACTION: boolean;
  49085. SS_TRANSLUCENCY: boolean;
  49086. SS_SCATERRING: boolean;
  49087. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49088. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49089. SS_REFRACTIONMAP_3D: boolean;
  49090. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49091. SS_LODINREFRACTIONALPHA: boolean;
  49092. SS_GAMMAREFRACTION: boolean;
  49093. SS_RGBDREFRACTION: boolean;
  49094. SS_LINEARSPECULARREFRACTION: boolean;
  49095. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49096. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49097. /** @hidden */
  49098. _areTexturesDirty: boolean;
  49099. }
  49100. /**
  49101. * Define the code related to the sub surface parameters of the pbr material.
  49102. */
  49103. export class PBRSubSurfaceConfiguration {
  49104. private _isRefractionEnabled;
  49105. /**
  49106. * Defines if the refraction is enabled in the material.
  49107. */
  49108. isRefractionEnabled: boolean;
  49109. private _isTranslucencyEnabled;
  49110. /**
  49111. * Defines if the translucency is enabled in the material.
  49112. */
  49113. isTranslucencyEnabled: boolean;
  49114. private _isScatteringEnabled;
  49115. /**
  49116. * Defines the refraction intensity of the material.
  49117. * The refraction when enabled replaces the Diffuse part of the material.
  49118. * The intensity helps transitionning between diffuse and refraction.
  49119. */
  49120. refractionIntensity: number;
  49121. /**
  49122. * Defines the translucency intensity of the material.
  49123. * When translucency has been enabled, this defines how much of the "translucency"
  49124. * is addded to the diffuse part of the material.
  49125. */
  49126. translucencyIntensity: number;
  49127. /**
  49128. * Defines the scattering intensity of the material.
  49129. * When scattering has been enabled, this defines how much of the "scattered light"
  49130. * is addded to the diffuse part of the material.
  49131. */
  49132. scatteringIntensity: number;
  49133. private _thicknessTexture;
  49134. /**
  49135. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49136. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49137. * 0 would mean minimumThickness
  49138. * 1 would mean maximumThickness
  49139. * The other channels might be use as a mask to vary the different effects intensity.
  49140. */
  49141. thicknessTexture: Nullable<BaseTexture>;
  49142. private _refractionTexture;
  49143. /**
  49144. * Defines the texture to use for refraction.
  49145. */
  49146. refractionTexture: Nullable<BaseTexture>;
  49147. private _indexOfRefraction;
  49148. /**
  49149. * Defines the index of refraction used in the material.
  49150. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49151. */
  49152. indexOfRefraction: number;
  49153. private _invertRefractionY;
  49154. /**
  49155. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49156. */
  49157. invertRefractionY: boolean;
  49158. private _linkRefractionWithTransparency;
  49159. /**
  49160. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49161. * Materials half opaque for instance using refraction could benefit from this control.
  49162. */
  49163. linkRefractionWithTransparency: boolean;
  49164. /**
  49165. * Defines the minimum thickness stored in the thickness map.
  49166. * If no thickness map is defined, this value will be used to simulate thickness.
  49167. */
  49168. minimumThickness: number;
  49169. /**
  49170. * Defines the maximum thickness stored in the thickness map.
  49171. */
  49172. maximumThickness: number;
  49173. /**
  49174. * Defines the volume tint of the material.
  49175. * This is used for both translucency and scattering.
  49176. */
  49177. tintColor: Color3;
  49178. /**
  49179. * Defines the distance at which the tint color should be found in the media.
  49180. * This is used for refraction only.
  49181. */
  49182. tintColorAtDistance: number;
  49183. /**
  49184. * Defines how far each channel transmit through the media.
  49185. * It is defined as a color to simplify it selection.
  49186. */
  49187. diffusionDistance: Color3;
  49188. private _useMaskFromThicknessTexture;
  49189. /**
  49190. * Stores the intensity of the different subsurface effects in the thickness texture.
  49191. * * the green channel is the translucency intensity.
  49192. * * the blue channel is the scattering intensity.
  49193. * * the alpha channel is the refraction intensity.
  49194. */
  49195. useMaskFromThicknessTexture: boolean;
  49196. /** @hidden */
  49197. private _internalMarkAllSubMeshesAsTexturesDirty;
  49198. /** @hidden */
  49199. _markAllSubMeshesAsTexturesDirty(): void;
  49200. /**
  49201. * Instantiate a new istance of sub surface configuration.
  49202. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49203. */
  49204. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49205. /**
  49206. * Gets wehter the submesh is ready to be used or not.
  49207. * @param defines the list of "defines" to update.
  49208. * @param scene defines the scene the material belongs to.
  49209. * @returns - boolean indicating that the submesh is ready or not.
  49210. */
  49211. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49212. /**
  49213. * Checks to see if a texture is used in the material.
  49214. * @param defines the list of "defines" to update.
  49215. * @param scene defines the scene to the material belongs to.
  49216. */
  49217. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49218. /**
  49219. * Binds the material data.
  49220. * @param uniformBuffer defines the Uniform buffer to fill in.
  49221. * @param scene defines the scene the material belongs to.
  49222. * @param engine defines the engine the material belongs to.
  49223. * @param isFrozen defines wether the material is frozen or not.
  49224. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49225. */
  49226. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49227. /**
  49228. * Unbinds the material from the mesh.
  49229. * @param activeEffect defines the effect that should be unbound from.
  49230. * @returns true if unbound, otherwise false
  49231. */
  49232. unbind(activeEffect: Effect): boolean;
  49233. /**
  49234. * Returns the texture used for refraction or null if none is used.
  49235. * @param scene defines the scene the material belongs to.
  49236. * @returns - Refraction texture if present. If no refraction texture and refraction
  49237. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49238. */
  49239. private _getRefractionTexture;
  49240. /**
  49241. * Returns true if alpha blending should be disabled.
  49242. */
  49243. readonly disableAlphaBlending: boolean;
  49244. /**
  49245. * Fills the list of render target textures.
  49246. * @param renderTargets the list of render targets to update
  49247. */
  49248. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49249. /**
  49250. * Checks to see if a texture is used in the material.
  49251. * @param texture - Base texture to use.
  49252. * @returns - Boolean specifying if a texture is used in the material.
  49253. */
  49254. hasTexture(texture: BaseTexture): boolean;
  49255. /**
  49256. * Gets a boolean indicating that current material needs to register RTT
  49257. * @returns true if this uses a render target otherwise false.
  49258. */
  49259. hasRenderTargetTextures(): boolean;
  49260. /**
  49261. * Returns an array of the actively used textures.
  49262. * @param activeTextures Array of BaseTextures
  49263. */
  49264. getActiveTextures(activeTextures: BaseTexture[]): void;
  49265. /**
  49266. * Returns the animatable textures.
  49267. * @param animatables Array of animatable textures.
  49268. */
  49269. getAnimatables(animatables: IAnimatable[]): void;
  49270. /**
  49271. * Disposes the resources of the material.
  49272. * @param forceDisposeTextures - Forces the disposal of all textures.
  49273. */
  49274. dispose(forceDisposeTextures?: boolean): void;
  49275. /**
  49276. * Get the current class name of the texture useful for serialization or dynamic coding.
  49277. * @returns "PBRSubSurfaceConfiguration"
  49278. */
  49279. getClassName(): string;
  49280. /**
  49281. * Add fallbacks to the effect fallbacks list.
  49282. * @param defines defines the Base texture to use.
  49283. * @param fallbacks defines the current fallback list.
  49284. * @param currentRank defines the current fallback rank.
  49285. * @returns the new fallback rank.
  49286. */
  49287. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49288. /**
  49289. * Add the required uniforms to the current list.
  49290. * @param uniforms defines the current uniform list.
  49291. */
  49292. static AddUniforms(uniforms: string[]): void;
  49293. /**
  49294. * Add the required samplers to the current list.
  49295. * @param samplers defines the current sampler list.
  49296. */
  49297. static AddSamplers(samplers: string[]): void;
  49298. /**
  49299. * Add the required uniforms to the current buffer.
  49300. * @param uniformBuffer defines the current uniform buffer.
  49301. */
  49302. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49303. /**
  49304. * Makes a duplicate of the current configuration into another one.
  49305. * @param configuration define the config where to copy the info
  49306. */
  49307. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49308. /**
  49309. * Serializes this Sub Surface configuration.
  49310. * @returns - An object with the serialized config.
  49311. */
  49312. serialize(): any;
  49313. /**
  49314. * Parses a anisotropy Configuration from a serialized object.
  49315. * @param source - Serialized object.
  49316. * @param scene Defines the scene we are parsing for
  49317. * @param rootUrl Defines the rootUrl to load from
  49318. */
  49319. parse(source: any, scene: Scene, rootUrl: string): void;
  49320. }
  49321. }
  49322. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49323. /** @hidden */
  49324. export var pbrFragmentDeclaration: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49330. /** @hidden */
  49331. export var pbrUboDeclaration: {
  49332. name: string;
  49333. shader: string;
  49334. };
  49335. }
  49336. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49337. /** @hidden */
  49338. export var pbrFragmentExtraDeclaration: {
  49339. name: string;
  49340. shader: string;
  49341. };
  49342. }
  49343. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49344. /** @hidden */
  49345. export var pbrFragmentSamplersDeclaration: {
  49346. name: string;
  49347. shader: string;
  49348. };
  49349. }
  49350. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49351. /** @hidden */
  49352. export var pbrHelperFunctions: {
  49353. name: string;
  49354. shader: string;
  49355. };
  49356. }
  49357. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49358. /** @hidden */
  49359. export var harmonicsFunctions: {
  49360. name: string;
  49361. shader: string;
  49362. };
  49363. }
  49364. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49365. /** @hidden */
  49366. export var pbrDirectLightingSetupFunctions: {
  49367. name: string;
  49368. shader: string;
  49369. };
  49370. }
  49371. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49372. /** @hidden */
  49373. export var pbrDirectLightingFalloffFunctions: {
  49374. name: string;
  49375. shader: string;
  49376. };
  49377. }
  49378. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49379. /** @hidden */
  49380. export var pbrBRDFFunctions: {
  49381. name: string;
  49382. shader: string;
  49383. };
  49384. }
  49385. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49386. /** @hidden */
  49387. export var pbrDirectLightingFunctions: {
  49388. name: string;
  49389. shader: string;
  49390. };
  49391. }
  49392. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49393. /** @hidden */
  49394. export var pbrIBLFunctions: {
  49395. name: string;
  49396. shader: string;
  49397. };
  49398. }
  49399. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49400. /** @hidden */
  49401. export var pbrDebug: {
  49402. name: string;
  49403. shader: string;
  49404. };
  49405. }
  49406. declare module "babylonjs/Shaders/pbr.fragment" {
  49407. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49408. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49409. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49410. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49411. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49412. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49413. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49415. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49418. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49419. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49420. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49421. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49422. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49423. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49424. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49425. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49429. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49430. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49431. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49432. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49433. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49434. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49435. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49436. /** @hidden */
  49437. export var pbrPixelShader: {
  49438. name: string;
  49439. shader: string;
  49440. };
  49441. }
  49442. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49443. /** @hidden */
  49444. export var pbrVertexDeclaration: {
  49445. name: string;
  49446. shader: string;
  49447. };
  49448. }
  49449. declare module "babylonjs/Shaders/pbr.vertex" {
  49450. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49451. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49454. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49455. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49456. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49457. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49458. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49459. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49465. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49466. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49467. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49468. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49469. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49470. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49471. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49472. /** @hidden */
  49473. export var pbrVertexShader: {
  49474. name: string;
  49475. shader: string;
  49476. };
  49477. }
  49478. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49479. import { Nullable } from "babylonjs/types";
  49480. import { Scene } from "babylonjs/scene";
  49481. import { Matrix } from "babylonjs/Maths/math.vector";
  49482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49484. import { Mesh } from "babylonjs/Meshes/mesh";
  49485. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49486. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49487. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49488. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49489. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49490. import { Color3 } from "babylonjs/Maths/math.color";
  49491. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49492. import { Material } from "babylonjs/Materials/material";
  49493. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49494. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49496. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49497. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49498. import "babylonjs/Shaders/pbr.fragment";
  49499. import "babylonjs/Shaders/pbr.vertex";
  49500. /**
  49501. * Manages the defines for the PBR Material.
  49502. * @hidden
  49503. */
  49504. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49505. PBR: boolean;
  49506. MAINUV1: boolean;
  49507. MAINUV2: boolean;
  49508. UV1: boolean;
  49509. UV2: boolean;
  49510. ALBEDO: boolean;
  49511. ALBEDODIRECTUV: number;
  49512. VERTEXCOLOR: boolean;
  49513. AMBIENT: boolean;
  49514. AMBIENTDIRECTUV: number;
  49515. AMBIENTINGRAYSCALE: boolean;
  49516. OPACITY: boolean;
  49517. VERTEXALPHA: boolean;
  49518. OPACITYDIRECTUV: number;
  49519. OPACITYRGB: boolean;
  49520. ALPHATEST: boolean;
  49521. DEPTHPREPASS: boolean;
  49522. ALPHABLEND: boolean;
  49523. ALPHAFROMALBEDO: boolean;
  49524. ALPHATESTVALUE: string;
  49525. SPECULAROVERALPHA: boolean;
  49526. RADIANCEOVERALPHA: boolean;
  49527. ALPHAFRESNEL: boolean;
  49528. LINEARALPHAFRESNEL: boolean;
  49529. PREMULTIPLYALPHA: boolean;
  49530. EMISSIVE: boolean;
  49531. EMISSIVEDIRECTUV: number;
  49532. REFLECTIVITY: boolean;
  49533. REFLECTIVITYDIRECTUV: number;
  49534. SPECULARTERM: boolean;
  49535. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49536. MICROSURFACEAUTOMATIC: boolean;
  49537. LODBASEDMICROSFURACE: boolean;
  49538. MICROSURFACEMAP: boolean;
  49539. MICROSURFACEMAPDIRECTUV: number;
  49540. METALLICWORKFLOW: boolean;
  49541. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49542. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49543. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49544. AOSTOREINMETALMAPRED: boolean;
  49545. ENVIRONMENTBRDF: boolean;
  49546. ENVIRONMENTBRDF_RGBD: boolean;
  49547. NORMAL: boolean;
  49548. TANGENT: boolean;
  49549. BUMP: boolean;
  49550. BUMPDIRECTUV: number;
  49551. OBJECTSPACE_NORMALMAP: boolean;
  49552. PARALLAX: boolean;
  49553. PARALLAXOCCLUSION: boolean;
  49554. NORMALXYSCALE: boolean;
  49555. LIGHTMAP: boolean;
  49556. LIGHTMAPDIRECTUV: number;
  49557. USELIGHTMAPASSHADOWMAP: boolean;
  49558. GAMMALIGHTMAP: boolean;
  49559. RGBDLIGHTMAP: boolean;
  49560. REFLECTION: boolean;
  49561. REFLECTIONMAP_3D: boolean;
  49562. REFLECTIONMAP_SPHERICAL: boolean;
  49563. REFLECTIONMAP_PLANAR: boolean;
  49564. REFLECTIONMAP_CUBIC: boolean;
  49565. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49566. REFLECTIONMAP_PROJECTION: boolean;
  49567. REFLECTIONMAP_SKYBOX: boolean;
  49568. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49569. REFLECTIONMAP_EXPLICIT: boolean;
  49570. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49571. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49572. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49573. INVERTCUBICMAP: boolean;
  49574. USESPHERICALFROMREFLECTIONMAP: boolean;
  49575. USEIRRADIANCEMAP: boolean;
  49576. SPHERICAL_HARMONICS: boolean;
  49577. USESPHERICALINVERTEX: boolean;
  49578. REFLECTIONMAP_OPPOSITEZ: boolean;
  49579. LODINREFLECTIONALPHA: boolean;
  49580. GAMMAREFLECTION: boolean;
  49581. RGBDREFLECTION: boolean;
  49582. LINEARSPECULARREFLECTION: boolean;
  49583. RADIANCEOCCLUSION: boolean;
  49584. HORIZONOCCLUSION: boolean;
  49585. INSTANCES: boolean;
  49586. NUM_BONE_INFLUENCERS: number;
  49587. BonesPerMesh: number;
  49588. BONETEXTURE: boolean;
  49589. NONUNIFORMSCALING: boolean;
  49590. MORPHTARGETS: boolean;
  49591. MORPHTARGETS_NORMAL: boolean;
  49592. MORPHTARGETS_TANGENT: boolean;
  49593. MORPHTARGETS_UV: boolean;
  49594. NUM_MORPH_INFLUENCERS: number;
  49595. IMAGEPROCESSING: boolean;
  49596. VIGNETTE: boolean;
  49597. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49598. VIGNETTEBLENDMODEOPAQUE: boolean;
  49599. TONEMAPPING: boolean;
  49600. TONEMAPPING_ACES: boolean;
  49601. CONTRAST: boolean;
  49602. COLORCURVES: boolean;
  49603. COLORGRADING: boolean;
  49604. COLORGRADING3D: boolean;
  49605. SAMPLER3DGREENDEPTH: boolean;
  49606. SAMPLER3DBGRMAP: boolean;
  49607. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49608. EXPOSURE: boolean;
  49609. MULTIVIEW: boolean;
  49610. USEPHYSICALLIGHTFALLOFF: boolean;
  49611. USEGLTFLIGHTFALLOFF: boolean;
  49612. TWOSIDEDLIGHTING: boolean;
  49613. SHADOWFLOAT: boolean;
  49614. CLIPPLANE: boolean;
  49615. CLIPPLANE2: boolean;
  49616. CLIPPLANE3: boolean;
  49617. CLIPPLANE4: boolean;
  49618. POINTSIZE: boolean;
  49619. FOG: boolean;
  49620. LOGARITHMICDEPTH: boolean;
  49621. FORCENORMALFORWARD: boolean;
  49622. SPECULARAA: boolean;
  49623. CLEARCOAT: boolean;
  49624. CLEARCOAT_DEFAULTIOR: boolean;
  49625. CLEARCOAT_TEXTURE: boolean;
  49626. CLEARCOAT_TEXTUREDIRECTUV: number;
  49627. CLEARCOAT_BUMP: boolean;
  49628. CLEARCOAT_BUMPDIRECTUV: number;
  49629. CLEARCOAT_TINT: boolean;
  49630. CLEARCOAT_TINT_TEXTURE: boolean;
  49631. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49632. ANISOTROPIC: boolean;
  49633. ANISOTROPIC_TEXTURE: boolean;
  49634. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49635. BRDF_V_HEIGHT_CORRELATED: boolean;
  49636. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49637. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49638. SHEEN: boolean;
  49639. SHEEN_TEXTURE: boolean;
  49640. SHEEN_TEXTUREDIRECTUV: number;
  49641. SHEEN_LINKWITHALBEDO: boolean;
  49642. SUBSURFACE: boolean;
  49643. SS_REFRACTION: boolean;
  49644. SS_TRANSLUCENCY: boolean;
  49645. SS_SCATERRING: boolean;
  49646. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49647. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49648. SS_REFRACTIONMAP_3D: boolean;
  49649. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49650. SS_LODINREFRACTIONALPHA: boolean;
  49651. SS_GAMMAREFRACTION: boolean;
  49652. SS_RGBDREFRACTION: boolean;
  49653. SS_LINEARSPECULARREFRACTION: boolean;
  49654. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49655. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49656. UNLIT: boolean;
  49657. DEBUGMODE: number;
  49658. /**
  49659. * Initializes the PBR Material defines.
  49660. */
  49661. constructor();
  49662. /**
  49663. * Resets the PBR Material defines.
  49664. */
  49665. reset(): void;
  49666. }
  49667. /**
  49668. * The Physically based material base class of BJS.
  49669. *
  49670. * This offers the main features of a standard PBR material.
  49671. * For more information, please refer to the documentation :
  49672. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49673. */
  49674. export abstract class PBRBaseMaterial extends PushMaterial {
  49675. /**
  49676. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49677. */
  49678. static readonly PBRMATERIAL_OPAQUE: number;
  49679. /**
  49680. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49681. */
  49682. static readonly PBRMATERIAL_ALPHATEST: number;
  49683. /**
  49684. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49685. */
  49686. static readonly PBRMATERIAL_ALPHABLEND: number;
  49687. /**
  49688. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49689. * They are also discarded below the alpha cutoff threshold to improve performances.
  49690. */
  49691. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49692. /**
  49693. * Defines the default value of how much AO map is occluding the analytical lights
  49694. * (point spot...).
  49695. */
  49696. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49697. /**
  49698. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49699. */
  49700. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49701. /**
  49702. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49703. * to enhance interoperability with other engines.
  49704. */
  49705. static readonly LIGHTFALLOFF_GLTF: number;
  49706. /**
  49707. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49708. * to enhance interoperability with other materials.
  49709. */
  49710. static readonly LIGHTFALLOFF_STANDARD: number;
  49711. /**
  49712. * Intensity of the direct lights e.g. the four lights available in your scene.
  49713. * This impacts both the direct diffuse and specular highlights.
  49714. */
  49715. protected _directIntensity: number;
  49716. /**
  49717. * Intensity of the emissive part of the material.
  49718. * This helps controlling the emissive effect without modifying the emissive color.
  49719. */
  49720. protected _emissiveIntensity: number;
  49721. /**
  49722. * Intensity of the environment e.g. how much the environment will light the object
  49723. * either through harmonics for rough material or through the refelction for shiny ones.
  49724. */
  49725. protected _environmentIntensity: number;
  49726. /**
  49727. * This is a special control allowing the reduction of the specular highlights coming from the
  49728. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49729. */
  49730. protected _specularIntensity: number;
  49731. /**
  49732. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49733. */
  49734. private _lightingInfos;
  49735. /**
  49736. * Debug Control allowing disabling the bump map on this material.
  49737. */
  49738. protected _disableBumpMap: boolean;
  49739. /**
  49740. * AKA Diffuse Texture in standard nomenclature.
  49741. */
  49742. protected _albedoTexture: Nullable<BaseTexture>;
  49743. /**
  49744. * AKA Occlusion Texture in other nomenclature.
  49745. */
  49746. protected _ambientTexture: Nullable<BaseTexture>;
  49747. /**
  49748. * AKA Occlusion Texture Intensity in other nomenclature.
  49749. */
  49750. protected _ambientTextureStrength: number;
  49751. /**
  49752. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49753. * 1 means it completely occludes it
  49754. * 0 mean it has no impact
  49755. */
  49756. protected _ambientTextureImpactOnAnalyticalLights: number;
  49757. /**
  49758. * Stores the alpha values in a texture.
  49759. */
  49760. protected _opacityTexture: Nullable<BaseTexture>;
  49761. /**
  49762. * Stores the reflection values in a texture.
  49763. */
  49764. protected _reflectionTexture: Nullable<BaseTexture>;
  49765. /**
  49766. * Stores the emissive values in a texture.
  49767. */
  49768. protected _emissiveTexture: Nullable<BaseTexture>;
  49769. /**
  49770. * AKA Specular texture in other nomenclature.
  49771. */
  49772. protected _reflectivityTexture: Nullable<BaseTexture>;
  49773. /**
  49774. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49775. */
  49776. protected _metallicTexture: Nullable<BaseTexture>;
  49777. /**
  49778. * Specifies the metallic scalar of the metallic/roughness workflow.
  49779. * Can also be used to scale the metalness values of the metallic texture.
  49780. */
  49781. protected _metallic: Nullable<number>;
  49782. /**
  49783. * Specifies the roughness scalar of the metallic/roughness workflow.
  49784. * Can also be used to scale the roughness values of the metallic texture.
  49785. */
  49786. protected _roughness: Nullable<number>;
  49787. /**
  49788. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49789. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49790. */
  49791. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49792. /**
  49793. * Stores surface normal data used to displace a mesh in a texture.
  49794. */
  49795. protected _bumpTexture: Nullable<BaseTexture>;
  49796. /**
  49797. * Stores the pre-calculated light information of a mesh in a texture.
  49798. */
  49799. protected _lightmapTexture: Nullable<BaseTexture>;
  49800. /**
  49801. * The color of a material in ambient lighting.
  49802. */
  49803. protected _ambientColor: Color3;
  49804. /**
  49805. * AKA Diffuse Color in other nomenclature.
  49806. */
  49807. protected _albedoColor: Color3;
  49808. /**
  49809. * AKA Specular Color in other nomenclature.
  49810. */
  49811. protected _reflectivityColor: Color3;
  49812. /**
  49813. * The color applied when light is reflected from a material.
  49814. */
  49815. protected _reflectionColor: Color3;
  49816. /**
  49817. * The color applied when light is emitted from a material.
  49818. */
  49819. protected _emissiveColor: Color3;
  49820. /**
  49821. * AKA Glossiness in other nomenclature.
  49822. */
  49823. protected _microSurface: number;
  49824. /**
  49825. * Specifies that the material will use the light map as a show map.
  49826. */
  49827. protected _useLightmapAsShadowmap: boolean;
  49828. /**
  49829. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49830. * makes the reflect vector face the model (under horizon).
  49831. */
  49832. protected _useHorizonOcclusion: boolean;
  49833. /**
  49834. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49835. * too much the area relying on ambient texture to define their ambient occlusion.
  49836. */
  49837. protected _useRadianceOcclusion: boolean;
  49838. /**
  49839. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49840. */
  49841. protected _useAlphaFromAlbedoTexture: boolean;
  49842. /**
  49843. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49844. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49845. */
  49846. protected _useSpecularOverAlpha: boolean;
  49847. /**
  49848. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49849. */
  49850. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49851. /**
  49852. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49853. */
  49854. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49855. /**
  49856. * Specifies if the metallic texture contains the roughness information in its green channel.
  49857. */
  49858. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49859. /**
  49860. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49861. */
  49862. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49863. /**
  49864. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49865. */
  49866. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49867. /**
  49868. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49869. */
  49870. protected _useAmbientInGrayScale: boolean;
  49871. /**
  49872. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49873. * The material will try to infer what glossiness each pixel should be.
  49874. */
  49875. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49876. /**
  49877. * Defines the falloff type used in this material.
  49878. * It by default is Physical.
  49879. */
  49880. protected _lightFalloff: number;
  49881. /**
  49882. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49883. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49884. */
  49885. protected _useRadianceOverAlpha: boolean;
  49886. /**
  49887. * Allows using an object space normal map (instead of tangent space).
  49888. */
  49889. protected _useObjectSpaceNormalMap: boolean;
  49890. /**
  49891. * Allows using the bump map in parallax mode.
  49892. */
  49893. protected _useParallax: boolean;
  49894. /**
  49895. * Allows using the bump map in parallax occlusion mode.
  49896. */
  49897. protected _useParallaxOcclusion: boolean;
  49898. /**
  49899. * Controls the scale bias of the parallax mode.
  49900. */
  49901. protected _parallaxScaleBias: number;
  49902. /**
  49903. * If sets to true, disables all the lights affecting the material.
  49904. */
  49905. protected _disableLighting: boolean;
  49906. /**
  49907. * Number of Simultaneous lights allowed on the material.
  49908. */
  49909. protected _maxSimultaneousLights: number;
  49910. /**
  49911. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49912. */
  49913. protected _invertNormalMapX: boolean;
  49914. /**
  49915. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49916. */
  49917. protected _invertNormalMapY: boolean;
  49918. /**
  49919. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49920. */
  49921. protected _twoSidedLighting: boolean;
  49922. /**
  49923. * Defines the alpha limits in alpha test mode.
  49924. */
  49925. protected _alphaCutOff: number;
  49926. /**
  49927. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49928. */
  49929. protected _forceAlphaTest: boolean;
  49930. /**
  49931. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49932. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49933. */
  49934. protected _useAlphaFresnel: boolean;
  49935. /**
  49936. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49937. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49938. */
  49939. protected _useLinearAlphaFresnel: boolean;
  49940. /**
  49941. * The transparency mode of the material.
  49942. */
  49943. protected _transparencyMode: Nullable<number>;
  49944. /**
  49945. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49946. * from cos thetav and roughness:
  49947. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49948. */
  49949. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49950. /**
  49951. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49952. */
  49953. protected _forceIrradianceInFragment: boolean;
  49954. /**
  49955. * Force normal to face away from face.
  49956. */
  49957. protected _forceNormalForward: boolean;
  49958. /**
  49959. * Enables specular anti aliasing in the PBR shader.
  49960. * It will both interacts on the Geometry for analytical and IBL lighting.
  49961. * It also prefilter the roughness map based on the bump values.
  49962. */
  49963. protected _enableSpecularAntiAliasing: boolean;
  49964. /**
  49965. * Default configuration related to image processing available in the PBR Material.
  49966. */
  49967. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49968. /**
  49969. * Keep track of the image processing observer to allow dispose and replace.
  49970. */
  49971. private _imageProcessingObserver;
  49972. /**
  49973. * Attaches a new image processing configuration to the PBR Material.
  49974. * @param configuration
  49975. */
  49976. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49977. /**
  49978. * Stores the available render targets.
  49979. */
  49980. private _renderTargets;
  49981. /**
  49982. * Sets the global ambient color for the material used in lighting calculations.
  49983. */
  49984. private _globalAmbientColor;
  49985. /**
  49986. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49987. */
  49988. private _useLogarithmicDepth;
  49989. /**
  49990. * If set to true, no lighting calculations will be applied.
  49991. */
  49992. private _unlit;
  49993. private _debugMode;
  49994. /**
  49995. * @hidden
  49996. * This is reserved for the inspector.
  49997. * Defines the material debug mode.
  49998. * It helps seeing only some components of the material while troubleshooting.
  49999. */
  50000. debugMode: number;
  50001. /**
  50002. * @hidden
  50003. * This is reserved for the inspector.
  50004. * Specify from where on screen the debug mode should start.
  50005. * The value goes from -1 (full screen) to 1 (not visible)
  50006. * It helps with side by side comparison against the final render
  50007. * This defaults to -1
  50008. */
  50009. private debugLimit;
  50010. /**
  50011. * @hidden
  50012. * This is reserved for the inspector.
  50013. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50014. * You can use the factor to better multiply the final value.
  50015. */
  50016. private debugFactor;
  50017. /**
  50018. * Defines the clear coat layer parameters for the material.
  50019. */
  50020. readonly clearCoat: PBRClearCoatConfiguration;
  50021. /**
  50022. * Defines the anisotropic parameters for the material.
  50023. */
  50024. readonly anisotropy: PBRAnisotropicConfiguration;
  50025. /**
  50026. * Defines the BRDF parameters for the material.
  50027. */
  50028. readonly brdf: PBRBRDFConfiguration;
  50029. /**
  50030. * Defines the Sheen parameters for the material.
  50031. */
  50032. readonly sheen: PBRSheenConfiguration;
  50033. /**
  50034. * Defines the SubSurface parameters for the material.
  50035. */
  50036. readonly subSurface: PBRSubSurfaceConfiguration;
  50037. /**
  50038. * Custom callback helping to override the default shader used in the material.
  50039. */
  50040. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50041. protected _rebuildInParallel: boolean;
  50042. /**
  50043. * Instantiates a new PBRMaterial instance.
  50044. *
  50045. * @param name The material name
  50046. * @param scene The scene the material will be use in.
  50047. */
  50048. constructor(name: string, scene: Scene);
  50049. /**
  50050. * Gets a boolean indicating that current material needs to register RTT
  50051. */
  50052. readonly hasRenderTargetTextures: boolean;
  50053. /**
  50054. * Gets the name of the material class.
  50055. */
  50056. getClassName(): string;
  50057. /**
  50058. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50059. */
  50060. /**
  50061. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50062. */
  50063. useLogarithmicDepth: boolean;
  50064. /**
  50065. * Gets the current transparency mode.
  50066. */
  50067. /**
  50068. * Sets the transparency mode of the material.
  50069. *
  50070. * | Value | Type | Description |
  50071. * | ----- | ----------------------------------- | ----------- |
  50072. * | 0 | OPAQUE | |
  50073. * | 1 | ALPHATEST | |
  50074. * | 2 | ALPHABLEND | |
  50075. * | 3 | ALPHATESTANDBLEND | |
  50076. *
  50077. */
  50078. transparencyMode: Nullable<number>;
  50079. /**
  50080. * Returns true if alpha blending should be disabled.
  50081. */
  50082. private readonly _disableAlphaBlending;
  50083. /**
  50084. * Specifies whether or not this material should be rendered in alpha blend mode.
  50085. */
  50086. needAlphaBlending(): boolean;
  50087. /**
  50088. * Specifies if the mesh will require alpha blending.
  50089. * @param mesh - BJS mesh.
  50090. */
  50091. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50092. /**
  50093. * Specifies whether or not this material should be rendered in alpha test mode.
  50094. */
  50095. needAlphaTesting(): boolean;
  50096. /**
  50097. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50098. */
  50099. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50100. /**
  50101. * Gets the texture used for the alpha test.
  50102. */
  50103. getAlphaTestTexture(): Nullable<BaseTexture>;
  50104. /**
  50105. * Specifies that the submesh is ready to be used.
  50106. * @param mesh - BJS mesh.
  50107. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50108. * @param useInstances - Specifies that instances should be used.
  50109. * @returns - boolean indicating that the submesh is ready or not.
  50110. */
  50111. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50112. /**
  50113. * Specifies if the material uses metallic roughness workflow.
  50114. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50115. */
  50116. isMetallicWorkflow(): boolean;
  50117. private _prepareEffect;
  50118. private _prepareDefines;
  50119. /**
  50120. * Force shader compilation
  50121. */
  50122. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50123. clipPlane: boolean;
  50124. }>): void;
  50125. /**
  50126. * Initializes the uniform buffer layout for the shader.
  50127. */
  50128. buildUniformLayout(): void;
  50129. /**
  50130. * Unbinds the material from the mesh
  50131. */
  50132. unbind(): void;
  50133. /**
  50134. * Binds the submesh data.
  50135. * @param world - The world matrix.
  50136. * @param mesh - The BJS mesh.
  50137. * @param subMesh - A submesh of the BJS mesh.
  50138. */
  50139. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50140. /**
  50141. * Returns the animatable textures.
  50142. * @returns - Array of animatable textures.
  50143. */
  50144. getAnimatables(): IAnimatable[];
  50145. /**
  50146. * Returns the texture used for reflections.
  50147. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50148. */
  50149. private _getReflectionTexture;
  50150. /**
  50151. * Returns an array of the actively used textures.
  50152. * @returns - Array of BaseTextures
  50153. */
  50154. getActiveTextures(): BaseTexture[];
  50155. /**
  50156. * Checks to see if a texture is used in the material.
  50157. * @param texture - Base texture to use.
  50158. * @returns - Boolean specifying if a texture is used in the material.
  50159. */
  50160. hasTexture(texture: BaseTexture): boolean;
  50161. /**
  50162. * Disposes the resources of the material.
  50163. * @param forceDisposeEffect - Forces the disposal of effects.
  50164. * @param forceDisposeTextures - Forces the disposal of all textures.
  50165. */
  50166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50167. }
  50168. }
  50169. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50170. import { Nullable } from "babylonjs/types";
  50171. import { Scene } from "babylonjs/scene";
  50172. import { Color3 } from "babylonjs/Maths/math.color";
  50173. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50174. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50175. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50176. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50177. /**
  50178. * The Physically based material of BJS.
  50179. *
  50180. * This offers the main features of a standard PBR material.
  50181. * For more information, please refer to the documentation :
  50182. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50183. */
  50184. export class PBRMaterial extends PBRBaseMaterial {
  50185. /**
  50186. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50187. */
  50188. static readonly PBRMATERIAL_OPAQUE: number;
  50189. /**
  50190. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50191. */
  50192. static readonly PBRMATERIAL_ALPHATEST: number;
  50193. /**
  50194. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50195. */
  50196. static readonly PBRMATERIAL_ALPHABLEND: number;
  50197. /**
  50198. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50199. * They are also discarded below the alpha cutoff threshold to improve performances.
  50200. */
  50201. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50202. /**
  50203. * Defines the default value of how much AO map is occluding the analytical lights
  50204. * (point spot...).
  50205. */
  50206. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50207. /**
  50208. * Intensity of the direct lights e.g. the four lights available in your scene.
  50209. * This impacts both the direct diffuse and specular highlights.
  50210. */
  50211. directIntensity: number;
  50212. /**
  50213. * Intensity of the emissive part of the material.
  50214. * This helps controlling the emissive effect without modifying the emissive color.
  50215. */
  50216. emissiveIntensity: number;
  50217. /**
  50218. * Intensity of the environment e.g. how much the environment will light the object
  50219. * either through harmonics for rough material or through the refelction for shiny ones.
  50220. */
  50221. environmentIntensity: number;
  50222. /**
  50223. * This is a special control allowing the reduction of the specular highlights coming from the
  50224. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50225. */
  50226. specularIntensity: number;
  50227. /**
  50228. * Debug Control allowing disabling the bump map on this material.
  50229. */
  50230. disableBumpMap: boolean;
  50231. /**
  50232. * AKA Diffuse Texture in standard nomenclature.
  50233. */
  50234. albedoTexture: BaseTexture;
  50235. /**
  50236. * AKA Occlusion Texture in other nomenclature.
  50237. */
  50238. ambientTexture: BaseTexture;
  50239. /**
  50240. * AKA Occlusion Texture Intensity in other nomenclature.
  50241. */
  50242. ambientTextureStrength: number;
  50243. /**
  50244. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50245. * 1 means it completely occludes it
  50246. * 0 mean it has no impact
  50247. */
  50248. ambientTextureImpactOnAnalyticalLights: number;
  50249. /**
  50250. * Stores the alpha values in a texture.
  50251. */
  50252. opacityTexture: BaseTexture;
  50253. /**
  50254. * Stores the reflection values in a texture.
  50255. */
  50256. reflectionTexture: Nullable<BaseTexture>;
  50257. /**
  50258. * Stores the emissive values in a texture.
  50259. */
  50260. emissiveTexture: BaseTexture;
  50261. /**
  50262. * AKA Specular texture in other nomenclature.
  50263. */
  50264. reflectivityTexture: BaseTexture;
  50265. /**
  50266. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50267. */
  50268. metallicTexture: BaseTexture;
  50269. /**
  50270. * Specifies the metallic scalar of the metallic/roughness workflow.
  50271. * Can also be used to scale the metalness values of the metallic texture.
  50272. */
  50273. metallic: Nullable<number>;
  50274. /**
  50275. * Specifies the roughness scalar of the metallic/roughness workflow.
  50276. * Can also be used to scale the roughness values of the metallic texture.
  50277. */
  50278. roughness: Nullable<number>;
  50279. /**
  50280. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50281. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50282. */
  50283. microSurfaceTexture: BaseTexture;
  50284. /**
  50285. * Stores surface normal data used to displace a mesh in a texture.
  50286. */
  50287. bumpTexture: BaseTexture;
  50288. /**
  50289. * Stores the pre-calculated light information of a mesh in a texture.
  50290. */
  50291. lightmapTexture: BaseTexture;
  50292. /**
  50293. * Stores the refracted light information in a texture.
  50294. */
  50295. refractionTexture: Nullable<BaseTexture>;
  50296. /**
  50297. * The color of a material in ambient lighting.
  50298. */
  50299. ambientColor: Color3;
  50300. /**
  50301. * AKA Diffuse Color in other nomenclature.
  50302. */
  50303. albedoColor: Color3;
  50304. /**
  50305. * AKA Specular Color in other nomenclature.
  50306. */
  50307. reflectivityColor: Color3;
  50308. /**
  50309. * The color reflected from the material.
  50310. */
  50311. reflectionColor: Color3;
  50312. /**
  50313. * The color emitted from the material.
  50314. */
  50315. emissiveColor: Color3;
  50316. /**
  50317. * AKA Glossiness in other nomenclature.
  50318. */
  50319. microSurface: number;
  50320. /**
  50321. * source material index of refraction (IOR)' / 'destination material IOR.
  50322. */
  50323. indexOfRefraction: number;
  50324. /**
  50325. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50326. */
  50327. invertRefractionY: boolean;
  50328. /**
  50329. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50330. * Materials half opaque for instance using refraction could benefit from this control.
  50331. */
  50332. linkRefractionWithTransparency: boolean;
  50333. /**
  50334. * If true, the light map contains occlusion information instead of lighting info.
  50335. */
  50336. useLightmapAsShadowmap: boolean;
  50337. /**
  50338. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50339. */
  50340. useAlphaFromAlbedoTexture: boolean;
  50341. /**
  50342. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50343. */
  50344. forceAlphaTest: boolean;
  50345. /**
  50346. * Defines the alpha limits in alpha test mode.
  50347. */
  50348. alphaCutOff: number;
  50349. /**
  50350. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50351. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50352. */
  50353. useSpecularOverAlpha: boolean;
  50354. /**
  50355. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50356. */
  50357. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50358. /**
  50359. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50360. */
  50361. useRoughnessFromMetallicTextureAlpha: boolean;
  50362. /**
  50363. * Specifies if the metallic texture contains the roughness information in its green channel.
  50364. */
  50365. useRoughnessFromMetallicTextureGreen: boolean;
  50366. /**
  50367. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50368. */
  50369. useMetallnessFromMetallicTextureBlue: boolean;
  50370. /**
  50371. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50372. */
  50373. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50374. /**
  50375. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50376. */
  50377. useAmbientInGrayScale: boolean;
  50378. /**
  50379. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50380. * The material will try to infer what glossiness each pixel should be.
  50381. */
  50382. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50383. /**
  50384. * BJS is using an harcoded light falloff based on a manually sets up range.
  50385. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50386. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50387. */
  50388. /**
  50389. * BJS is using an harcoded light falloff based on a manually sets up range.
  50390. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50391. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50392. */
  50393. usePhysicalLightFalloff: boolean;
  50394. /**
  50395. * In order to support the falloff compatibility with gltf, a special mode has been added
  50396. * to reproduce the gltf light falloff.
  50397. */
  50398. /**
  50399. * In order to support the falloff compatibility with gltf, a special mode has been added
  50400. * to reproduce the gltf light falloff.
  50401. */
  50402. useGLTFLightFalloff: boolean;
  50403. /**
  50404. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50405. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50406. */
  50407. useRadianceOverAlpha: boolean;
  50408. /**
  50409. * Allows using an object space normal map (instead of tangent space).
  50410. */
  50411. useObjectSpaceNormalMap: boolean;
  50412. /**
  50413. * Allows using the bump map in parallax mode.
  50414. */
  50415. useParallax: boolean;
  50416. /**
  50417. * Allows using the bump map in parallax occlusion mode.
  50418. */
  50419. useParallaxOcclusion: boolean;
  50420. /**
  50421. * Controls the scale bias of the parallax mode.
  50422. */
  50423. parallaxScaleBias: number;
  50424. /**
  50425. * If sets to true, disables all the lights affecting the material.
  50426. */
  50427. disableLighting: boolean;
  50428. /**
  50429. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50430. */
  50431. forceIrradianceInFragment: boolean;
  50432. /**
  50433. * Number of Simultaneous lights allowed on the material.
  50434. */
  50435. maxSimultaneousLights: number;
  50436. /**
  50437. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50438. */
  50439. invertNormalMapX: boolean;
  50440. /**
  50441. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50442. */
  50443. invertNormalMapY: boolean;
  50444. /**
  50445. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50446. */
  50447. twoSidedLighting: boolean;
  50448. /**
  50449. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50450. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50451. */
  50452. useAlphaFresnel: boolean;
  50453. /**
  50454. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50455. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50456. */
  50457. useLinearAlphaFresnel: boolean;
  50458. /**
  50459. * Let user defines the brdf lookup texture used for IBL.
  50460. * A default 8bit version is embedded but you could point at :
  50461. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50462. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50463. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50464. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50465. */
  50466. environmentBRDFTexture: Nullable<BaseTexture>;
  50467. /**
  50468. * Force normal to face away from face.
  50469. */
  50470. forceNormalForward: boolean;
  50471. /**
  50472. * Enables specular anti aliasing in the PBR shader.
  50473. * It will both interacts on the Geometry for analytical and IBL lighting.
  50474. * It also prefilter the roughness map based on the bump values.
  50475. */
  50476. enableSpecularAntiAliasing: boolean;
  50477. /**
  50478. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50479. * makes the reflect vector face the model (under horizon).
  50480. */
  50481. useHorizonOcclusion: boolean;
  50482. /**
  50483. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50484. * too much the area relying on ambient texture to define their ambient occlusion.
  50485. */
  50486. useRadianceOcclusion: boolean;
  50487. /**
  50488. * If set to true, no lighting calculations will be applied.
  50489. */
  50490. unlit: boolean;
  50491. /**
  50492. * Gets the image processing configuration used either in this material.
  50493. */
  50494. /**
  50495. * Sets the Default image processing configuration used either in the this material.
  50496. *
  50497. * If sets to null, the scene one is in use.
  50498. */
  50499. imageProcessingConfiguration: ImageProcessingConfiguration;
  50500. /**
  50501. * Gets wether the color curves effect is enabled.
  50502. */
  50503. /**
  50504. * Sets wether the color curves effect is enabled.
  50505. */
  50506. cameraColorCurvesEnabled: boolean;
  50507. /**
  50508. * Gets wether the color grading effect is enabled.
  50509. */
  50510. /**
  50511. * Gets wether the color grading effect is enabled.
  50512. */
  50513. cameraColorGradingEnabled: boolean;
  50514. /**
  50515. * Gets wether tonemapping is enabled or not.
  50516. */
  50517. /**
  50518. * Sets wether tonemapping is enabled or not
  50519. */
  50520. cameraToneMappingEnabled: boolean;
  50521. /**
  50522. * The camera exposure used on this material.
  50523. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50524. * This corresponds to a photographic exposure.
  50525. */
  50526. /**
  50527. * The camera exposure used on this material.
  50528. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50529. * This corresponds to a photographic exposure.
  50530. */
  50531. cameraExposure: number;
  50532. /**
  50533. * Gets The camera contrast used on this material.
  50534. */
  50535. /**
  50536. * Sets The camera contrast used on this material.
  50537. */
  50538. cameraContrast: number;
  50539. /**
  50540. * Gets the Color Grading 2D Lookup Texture.
  50541. */
  50542. /**
  50543. * Sets the Color Grading 2D Lookup Texture.
  50544. */
  50545. cameraColorGradingTexture: Nullable<BaseTexture>;
  50546. /**
  50547. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50548. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50549. * 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;
  50550. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50551. */
  50552. /**
  50553. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50554. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50555. * 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;
  50556. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50557. */
  50558. cameraColorCurves: Nullable<ColorCurves>;
  50559. /**
  50560. * Instantiates a new PBRMaterial instance.
  50561. *
  50562. * @param name The material name
  50563. * @param scene The scene the material will be use in.
  50564. */
  50565. constructor(name: string, scene: Scene);
  50566. /**
  50567. * Returns the name of this material class.
  50568. */
  50569. getClassName(): string;
  50570. /**
  50571. * Makes a duplicate of the current material.
  50572. * @param name - name to use for the new material.
  50573. */
  50574. clone(name: string): PBRMaterial;
  50575. /**
  50576. * Serializes this PBR Material.
  50577. * @returns - An object with the serialized material.
  50578. */
  50579. serialize(): any;
  50580. /**
  50581. * Parses a PBR Material from a serialized object.
  50582. * @param source - Serialized object.
  50583. * @param scene - BJS scene instance.
  50584. * @param rootUrl - url for the scene object
  50585. * @returns - PBRMaterial
  50586. */
  50587. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50588. }
  50589. }
  50590. declare module "babylonjs/Misc/dds" {
  50591. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50592. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50593. import { Nullable } from "babylonjs/types";
  50594. import { Scene } from "babylonjs/scene";
  50595. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50597. /**
  50598. * Direct draw surface info
  50599. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50600. */
  50601. export interface DDSInfo {
  50602. /**
  50603. * Width of the texture
  50604. */
  50605. width: number;
  50606. /**
  50607. * Width of the texture
  50608. */
  50609. height: number;
  50610. /**
  50611. * Number of Mipmaps for the texture
  50612. * @see https://en.wikipedia.org/wiki/Mipmap
  50613. */
  50614. mipmapCount: number;
  50615. /**
  50616. * If the textures format is a known fourCC format
  50617. * @see https://www.fourcc.org/
  50618. */
  50619. isFourCC: boolean;
  50620. /**
  50621. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50622. */
  50623. isRGB: boolean;
  50624. /**
  50625. * If the texture is a lumincance format
  50626. */
  50627. isLuminance: boolean;
  50628. /**
  50629. * If this is a cube texture
  50630. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50631. */
  50632. isCube: boolean;
  50633. /**
  50634. * If the texture is a compressed format eg. FOURCC_DXT1
  50635. */
  50636. isCompressed: boolean;
  50637. /**
  50638. * The dxgiFormat of the texture
  50639. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50640. */
  50641. dxgiFormat: number;
  50642. /**
  50643. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50644. */
  50645. textureType: number;
  50646. /**
  50647. * Sphericle polynomial created for the dds texture
  50648. */
  50649. sphericalPolynomial?: SphericalPolynomial;
  50650. }
  50651. /**
  50652. * Class used to provide DDS decompression tools
  50653. */
  50654. export class DDSTools {
  50655. /**
  50656. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50657. */
  50658. static StoreLODInAlphaChannel: boolean;
  50659. /**
  50660. * Gets DDS information from an array buffer
  50661. * @param arrayBuffer defines the array buffer to read data from
  50662. * @returns the DDS information
  50663. */
  50664. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50665. private static _FloatView;
  50666. private static _Int32View;
  50667. private static _ToHalfFloat;
  50668. private static _FromHalfFloat;
  50669. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50670. private static _GetHalfFloatRGBAArrayBuffer;
  50671. private static _GetFloatRGBAArrayBuffer;
  50672. private static _GetFloatAsUIntRGBAArrayBuffer;
  50673. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50674. private static _GetRGBAArrayBuffer;
  50675. private static _ExtractLongWordOrder;
  50676. private static _GetRGBArrayBuffer;
  50677. private static _GetLuminanceArrayBuffer;
  50678. /**
  50679. * Uploads DDS Levels to a Babylon Texture
  50680. * @hidden
  50681. */
  50682. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50683. }
  50684. module "babylonjs/Engines/thinEngine" {
  50685. interface ThinEngine {
  50686. /**
  50687. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50688. * @param rootUrl defines the url where the file to load is located
  50689. * @param scene defines the current scene
  50690. * @param lodScale defines scale to apply to the mip map selection
  50691. * @param lodOffset defines offset to apply to the mip map selection
  50692. * @param onLoad defines an optional callback raised when the texture is loaded
  50693. * @param onError defines an optional callback raised if there is an issue to load the texture
  50694. * @param format defines the format of the data
  50695. * @param forcedExtension defines the extension to use to pick the right loader
  50696. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50697. * @returns the cube texture as an InternalTexture
  50698. */
  50699. 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;
  50700. }
  50701. }
  50702. }
  50703. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50704. import { Nullable } from "babylonjs/types";
  50705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50706. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50707. /**
  50708. * Implementation of the DDS Texture Loader.
  50709. * @hidden
  50710. */
  50711. export class _DDSTextureLoader implements IInternalTextureLoader {
  50712. /**
  50713. * Defines wether the loader supports cascade loading the different faces.
  50714. */
  50715. readonly supportCascades: boolean;
  50716. /**
  50717. * This returns if the loader support the current file information.
  50718. * @param extension defines the file extension of the file being loaded
  50719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50720. * @param fallback defines the fallback internal texture if any
  50721. * @param isBase64 defines whether the texture is encoded as a base64
  50722. * @param isBuffer defines whether the texture data are stored as a buffer
  50723. * @returns true if the loader can load the specified file
  50724. */
  50725. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50726. /**
  50727. * Transform the url before loading if required.
  50728. * @param rootUrl the url of the texture
  50729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50730. * @returns the transformed texture
  50731. */
  50732. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50733. /**
  50734. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50735. * @param rootUrl the url of the texture
  50736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50737. * @returns the fallback texture
  50738. */
  50739. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50740. /**
  50741. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50742. * @param data contains the texture data
  50743. * @param texture defines the BabylonJS internal texture
  50744. * @param createPolynomials will be true if polynomials have been requested
  50745. * @param onLoad defines the callback to trigger once the texture is ready
  50746. * @param onError defines the callback to trigger in case of error
  50747. */
  50748. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50749. /**
  50750. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50751. * @param data contains the texture data
  50752. * @param texture defines the BabylonJS internal texture
  50753. * @param callback defines the method to call once ready to upload
  50754. */
  50755. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50756. }
  50757. }
  50758. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50759. import { Nullable } from "babylonjs/types";
  50760. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50761. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50762. /**
  50763. * Implementation of the ENV Texture Loader.
  50764. * @hidden
  50765. */
  50766. export class _ENVTextureLoader implements IInternalTextureLoader {
  50767. /**
  50768. * Defines wether the loader supports cascade loading the different faces.
  50769. */
  50770. readonly supportCascades: boolean;
  50771. /**
  50772. * This returns if the loader support the current file information.
  50773. * @param extension defines the file extension of the file being loaded
  50774. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50775. * @param fallback defines the fallback internal texture if any
  50776. * @param isBase64 defines whether the texture is encoded as a base64
  50777. * @param isBuffer defines whether the texture data are stored as a buffer
  50778. * @returns true if the loader can load the specified file
  50779. */
  50780. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50781. /**
  50782. * Transform the url before loading if required.
  50783. * @param rootUrl the url of the texture
  50784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50785. * @returns the transformed texture
  50786. */
  50787. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50788. /**
  50789. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50790. * @param rootUrl the url of the texture
  50791. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50792. * @returns the fallback texture
  50793. */
  50794. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50795. /**
  50796. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50797. * @param data contains the texture data
  50798. * @param texture defines the BabylonJS internal texture
  50799. * @param createPolynomials will be true if polynomials have been requested
  50800. * @param onLoad defines the callback to trigger once the texture is ready
  50801. * @param onError defines the callback to trigger in case of error
  50802. */
  50803. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50804. /**
  50805. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50806. * @param data contains the texture data
  50807. * @param texture defines the BabylonJS internal texture
  50808. * @param callback defines the method to call once ready to upload
  50809. */
  50810. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50811. }
  50812. }
  50813. declare module "babylonjs/Misc/khronosTextureContainer" {
  50814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50815. /**
  50816. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50817. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50818. */
  50819. export class KhronosTextureContainer {
  50820. /** contents of the KTX container file */
  50821. arrayBuffer: any;
  50822. private static HEADER_LEN;
  50823. private static COMPRESSED_2D;
  50824. private static COMPRESSED_3D;
  50825. private static TEX_2D;
  50826. private static TEX_3D;
  50827. /**
  50828. * Gets the openGL type
  50829. */
  50830. glType: number;
  50831. /**
  50832. * Gets the openGL type size
  50833. */
  50834. glTypeSize: number;
  50835. /**
  50836. * Gets the openGL format
  50837. */
  50838. glFormat: number;
  50839. /**
  50840. * Gets the openGL internal format
  50841. */
  50842. glInternalFormat: number;
  50843. /**
  50844. * Gets the base internal format
  50845. */
  50846. glBaseInternalFormat: number;
  50847. /**
  50848. * Gets image width in pixel
  50849. */
  50850. pixelWidth: number;
  50851. /**
  50852. * Gets image height in pixel
  50853. */
  50854. pixelHeight: number;
  50855. /**
  50856. * Gets image depth in pixels
  50857. */
  50858. pixelDepth: number;
  50859. /**
  50860. * Gets the number of array elements
  50861. */
  50862. numberOfArrayElements: number;
  50863. /**
  50864. * Gets the number of faces
  50865. */
  50866. numberOfFaces: number;
  50867. /**
  50868. * Gets the number of mipmap levels
  50869. */
  50870. numberOfMipmapLevels: number;
  50871. /**
  50872. * Gets the bytes of key value data
  50873. */
  50874. bytesOfKeyValueData: number;
  50875. /**
  50876. * Gets the load type
  50877. */
  50878. loadType: number;
  50879. /**
  50880. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50881. */
  50882. isInvalid: boolean;
  50883. /**
  50884. * Creates a new KhronosTextureContainer
  50885. * @param arrayBuffer contents of the KTX container file
  50886. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50887. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50888. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50889. */
  50890. constructor(
  50891. /** contents of the KTX container file */
  50892. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50893. /**
  50894. * Uploads KTX content to a Babylon Texture.
  50895. * It is assumed that the texture has already been created & is currently bound
  50896. * @hidden
  50897. */
  50898. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50899. private _upload2DCompressedLevels;
  50900. }
  50901. }
  50902. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50903. import { Nullable } from "babylonjs/types";
  50904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50905. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50906. /**
  50907. * Implementation of the KTX Texture Loader.
  50908. * @hidden
  50909. */
  50910. export class _KTXTextureLoader implements IInternalTextureLoader {
  50911. /**
  50912. * Defines wether the loader supports cascade loading the different faces.
  50913. */
  50914. readonly supportCascades: boolean;
  50915. /**
  50916. * This returns if the loader support the current file information.
  50917. * @param extension defines the file extension of the file being loaded
  50918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50919. * @param fallback defines the fallback internal texture if any
  50920. * @param isBase64 defines whether the texture is encoded as a base64
  50921. * @param isBuffer defines whether the texture data are stored as a buffer
  50922. * @returns true if the loader can load the specified file
  50923. */
  50924. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50925. /**
  50926. * Transform the url before loading if required.
  50927. * @param rootUrl the url of the texture
  50928. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50929. * @returns the transformed texture
  50930. */
  50931. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50932. /**
  50933. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50934. * @param rootUrl the url of the texture
  50935. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50936. * @returns the fallback texture
  50937. */
  50938. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50939. /**
  50940. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50941. * @param data contains the texture data
  50942. * @param texture defines the BabylonJS internal texture
  50943. * @param createPolynomials will be true if polynomials have been requested
  50944. * @param onLoad defines the callback to trigger once the texture is ready
  50945. * @param onError defines the callback to trigger in case of error
  50946. */
  50947. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50948. /**
  50949. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50950. * @param data contains the texture data
  50951. * @param texture defines the BabylonJS internal texture
  50952. * @param callback defines the method to call once ready to upload
  50953. */
  50954. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50955. }
  50956. }
  50957. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50958. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50959. import { Scene } from "babylonjs/scene";
  50960. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50961. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50962. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50963. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50964. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50965. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50967. /**
  50968. * Options for the default xr helper
  50969. */
  50970. export class WebXRDefaultExperienceOptions {
  50971. /**
  50972. * Floor meshes that should be used for teleporting
  50973. */
  50974. floorMeshes: Array<AbstractMesh>;
  50975. }
  50976. /**
  50977. * Default experience which provides a similar setup to the previous webVRExperience
  50978. */
  50979. export class WebXRDefaultExperience {
  50980. /**
  50981. * Base experience
  50982. */
  50983. baseExperience: WebXRExperienceHelper;
  50984. /**
  50985. * Input experience extension
  50986. */
  50987. input: WebXRInput;
  50988. /**
  50989. * Loads the controller models
  50990. */
  50991. controllerModelLoader: WebXRControllerModelLoader;
  50992. /**
  50993. * Enables laser pointer and selection
  50994. */
  50995. pointerSelection: WebXRControllerPointerSelection;
  50996. /**
  50997. * Enables teleportation
  50998. */
  50999. teleportation: WebXRControllerTeleportation;
  51000. /**
  51001. * Enables ui for enetering/exiting xr
  51002. */
  51003. enterExitUI: WebXREnterExitUI;
  51004. /**
  51005. * Default output canvas xr should render to
  51006. */
  51007. outputCanvas: WebXRManagedOutputCanvas;
  51008. /**
  51009. * Creates the default xr experience
  51010. * @param scene scene
  51011. * @param options options for basic configuration
  51012. * @returns resulting WebXRDefaultExperience
  51013. */
  51014. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51015. private constructor();
  51016. /**
  51017. * DIsposes of the experience helper
  51018. */
  51019. dispose(): void;
  51020. }
  51021. }
  51022. declare module "babylonjs/Helpers/sceneHelpers" {
  51023. import { Nullable } from "babylonjs/types";
  51024. import { Mesh } from "babylonjs/Meshes/mesh";
  51025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51026. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51027. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51028. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51029. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51030. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51031. import "babylonjs/Meshes/Builders/boxBuilder";
  51032. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51033. /** @hidden */
  51034. export var _forceSceneHelpersToBundle: boolean;
  51035. module "babylonjs/scene" {
  51036. interface Scene {
  51037. /**
  51038. * Creates a default light for the scene.
  51039. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51040. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51041. */
  51042. createDefaultLight(replace?: boolean): void;
  51043. /**
  51044. * Creates a default camera for the scene.
  51045. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51046. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51047. * @param replace has default false, when true replaces the active camera in the scene
  51048. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51049. */
  51050. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51051. /**
  51052. * Creates a default camera and a default light.
  51053. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51054. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51055. * @param replace has the default false, when true replaces the active camera/light in the scene
  51056. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51057. */
  51058. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51059. /**
  51060. * Creates a new sky box
  51061. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51062. * @param environmentTexture defines the texture to use as environment texture
  51063. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51064. * @param scale defines the overall scale of the skybox
  51065. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51066. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51067. * @returns a new mesh holding the sky box
  51068. */
  51069. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51070. /**
  51071. * Creates a new environment
  51072. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51073. * @param options defines the options you can use to configure the environment
  51074. * @returns the new EnvironmentHelper
  51075. */
  51076. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51077. /**
  51078. * Creates a new VREXperienceHelper
  51079. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51080. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51081. * @returns a new VREXperienceHelper
  51082. */
  51083. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51084. /**
  51085. * Creates a new WebXRDefaultExperience
  51086. * @see http://doc.babylonjs.com/how_to/webxr
  51087. * @param options experience options
  51088. * @returns a promise for a new WebXRDefaultExperience
  51089. */
  51090. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51091. }
  51092. }
  51093. }
  51094. declare module "babylonjs/Helpers/videoDome" {
  51095. import { Scene } from "babylonjs/scene";
  51096. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51097. import { Mesh } from "babylonjs/Meshes/mesh";
  51098. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51099. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51100. import "babylonjs/Meshes/Builders/sphereBuilder";
  51101. /**
  51102. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51103. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51104. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51105. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51106. */
  51107. export class VideoDome extends TransformNode {
  51108. /**
  51109. * Define the video source as a Monoscopic panoramic 360 video.
  51110. */
  51111. static readonly MODE_MONOSCOPIC: number;
  51112. /**
  51113. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51114. */
  51115. static readonly MODE_TOPBOTTOM: number;
  51116. /**
  51117. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51118. */
  51119. static readonly MODE_SIDEBYSIDE: number;
  51120. private _halfDome;
  51121. private _useDirectMapping;
  51122. /**
  51123. * The video texture being displayed on the sphere
  51124. */
  51125. protected _videoTexture: VideoTexture;
  51126. /**
  51127. * Gets the video texture being displayed on the sphere
  51128. */
  51129. readonly videoTexture: VideoTexture;
  51130. /**
  51131. * The skybox material
  51132. */
  51133. protected _material: BackgroundMaterial;
  51134. /**
  51135. * The surface used for the skybox
  51136. */
  51137. protected _mesh: Mesh;
  51138. /**
  51139. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51140. */
  51141. private _halfDomeMask;
  51142. /**
  51143. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51144. * Also see the options.resolution property.
  51145. */
  51146. fovMultiplier: number;
  51147. private _videoMode;
  51148. /**
  51149. * Gets or set the current video mode for the video. It can be:
  51150. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51151. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51152. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51153. */
  51154. videoMode: number;
  51155. /**
  51156. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51157. *
  51158. */
  51159. /**
  51160. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51161. */
  51162. halfDome: boolean;
  51163. /**
  51164. * Oberserver used in Stereoscopic VR Mode.
  51165. */
  51166. private _onBeforeCameraRenderObserver;
  51167. /**
  51168. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51169. * @param name Element's name, child elements will append suffixes for their own names.
  51170. * @param urlsOrVideo defines the url(s) or the video element to use
  51171. * @param options An object containing optional or exposed sub element properties
  51172. */
  51173. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51174. resolution?: number;
  51175. clickToPlay?: boolean;
  51176. autoPlay?: boolean;
  51177. loop?: boolean;
  51178. size?: number;
  51179. poster?: string;
  51180. faceForward?: boolean;
  51181. useDirectMapping?: boolean;
  51182. halfDomeMode?: boolean;
  51183. }, scene: Scene);
  51184. private _changeVideoMode;
  51185. /**
  51186. * Releases resources associated with this node.
  51187. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51188. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51189. */
  51190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51191. }
  51192. }
  51193. declare module "babylonjs/Helpers/index" {
  51194. export * from "babylonjs/Helpers/environmentHelper";
  51195. export * from "babylonjs/Helpers/photoDome";
  51196. export * from "babylonjs/Helpers/sceneHelpers";
  51197. export * from "babylonjs/Helpers/videoDome";
  51198. }
  51199. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51200. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51201. import { IDisposable } from "babylonjs/scene";
  51202. import { Engine } from "babylonjs/Engines/engine";
  51203. /**
  51204. * This class can be used to get instrumentation data from a Babylon engine
  51205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51206. */
  51207. export class EngineInstrumentation implements IDisposable {
  51208. /**
  51209. * Define the instrumented engine.
  51210. */
  51211. engine: Engine;
  51212. private _captureGPUFrameTime;
  51213. private _gpuFrameTimeToken;
  51214. private _gpuFrameTime;
  51215. private _captureShaderCompilationTime;
  51216. private _shaderCompilationTime;
  51217. private _onBeginFrameObserver;
  51218. private _onEndFrameObserver;
  51219. private _onBeforeShaderCompilationObserver;
  51220. private _onAfterShaderCompilationObserver;
  51221. /**
  51222. * Gets the perf counter used for GPU frame time
  51223. */
  51224. readonly gpuFrameTimeCounter: PerfCounter;
  51225. /**
  51226. * Gets the GPU frame time capture status
  51227. */
  51228. /**
  51229. * Enable or disable the GPU frame time capture
  51230. */
  51231. captureGPUFrameTime: boolean;
  51232. /**
  51233. * Gets the perf counter used for shader compilation time
  51234. */
  51235. readonly shaderCompilationTimeCounter: PerfCounter;
  51236. /**
  51237. * Gets the shader compilation time capture status
  51238. */
  51239. /**
  51240. * Enable or disable the shader compilation time capture
  51241. */
  51242. captureShaderCompilationTime: boolean;
  51243. /**
  51244. * Instantiates a new engine instrumentation.
  51245. * This class can be used to get instrumentation data from a Babylon engine
  51246. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51247. * @param engine Defines the engine to instrument
  51248. */
  51249. constructor(
  51250. /**
  51251. * Define the instrumented engine.
  51252. */
  51253. engine: Engine);
  51254. /**
  51255. * Dispose and release associated resources.
  51256. */
  51257. dispose(): void;
  51258. }
  51259. }
  51260. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51261. import { Scene, IDisposable } from "babylonjs/scene";
  51262. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51263. /**
  51264. * This class can be used to get instrumentation data from a Babylon engine
  51265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51266. */
  51267. export class SceneInstrumentation implements IDisposable {
  51268. /**
  51269. * Defines the scene to instrument
  51270. */
  51271. scene: Scene;
  51272. private _captureActiveMeshesEvaluationTime;
  51273. private _activeMeshesEvaluationTime;
  51274. private _captureRenderTargetsRenderTime;
  51275. private _renderTargetsRenderTime;
  51276. private _captureFrameTime;
  51277. private _frameTime;
  51278. private _captureRenderTime;
  51279. private _renderTime;
  51280. private _captureInterFrameTime;
  51281. private _interFrameTime;
  51282. private _captureParticlesRenderTime;
  51283. private _particlesRenderTime;
  51284. private _captureSpritesRenderTime;
  51285. private _spritesRenderTime;
  51286. private _capturePhysicsTime;
  51287. private _physicsTime;
  51288. private _captureAnimationsTime;
  51289. private _animationsTime;
  51290. private _captureCameraRenderTime;
  51291. private _cameraRenderTime;
  51292. private _onBeforeActiveMeshesEvaluationObserver;
  51293. private _onAfterActiveMeshesEvaluationObserver;
  51294. private _onBeforeRenderTargetsRenderObserver;
  51295. private _onAfterRenderTargetsRenderObserver;
  51296. private _onAfterRenderObserver;
  51297. private _onBeforeDrawPhaseObserver;
  51298. private _onAfterDrawPhaseObserver;
  51299. private _onBeforeAnimationsObserver;
  51300. private _onBeforeParticlesRenderingObserver;
  51301. private _onAfterParticlesRenderingObserver;
  51302. private _onBeforeSpritesRenderingObserver;
  51303. private _onAfterSpritesRenderingObserver;
  51304. private _onBeforePhysicsObserver;
  51305. private _onAfterPhysicsObserver;
  51306. private _onAfterAnimationsObserver;
  51307. private _onBeforeCameraRenderObserver;
  51308. private _onAfterCameraRenderObserver;
  51309. /**
  51310. * Gets the perf counter used for active meshes evaluation time
  51311. */
  51312. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51313. /**
  51314. * Gets the active meshes evaluation time capture status
  51315. */
  51316. /**
  51317. * Enable or disable the active meshes evaluation time capture
  51318. */
  51319. captureActiveMeshesEvaluationTime: boolean;
  51320. /**
  51321. * Gets the perf counter used for render targets render time
  51322. */
  51323. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51324. /**
  51325. * Gets the render targets render time capture status
  51326. */
  51327. /**
  51328. * Enable or disable the render targets render time capture
  51329. */
  51330. captureRenderTargetsRenderTime: boolean;
  51331. /**
  51332. * Gets the perf counter used for particles render time
  51333. */
  51334. readonly particlesRenderTimeCounter: PerfCounter;
  51335. /**
  51336. * Gets the particles render time capture status
  51337. */
  51338. /**
  51339. * Enable or disable the particles render time capture
  51340. */
  51341. captureParticlesRenderTime: boolean;
  51342. /**
  51343. * Gets the perf counter used for sprites render time
  51344. */
  51345. readonly spritesRenderTimeCounter: PerfCounter;
  51346. /**
  51347. * Gets the sprites render time capture status
  51348. */
  51349. /**
  51350. * Enable or disable the sprites render time capture
  51351. */
  51352. captureSpritesRenderTime: boolean;
  51353. /**
  51354. * Gets the perf counter used for physics time
  51355. */
  51356. readonly physicsTimeCounter: PerfCounter;
  51357. /**
  51358. * Gets the physics time capture status
  51359. */
  51360. /**
  51361. * Enable or disable the physics time capture
  51362. */
  51363. capturePhysicsTime: boolean;
  51364. /**
  51365. * Gets the perf counter used for animations time
  51366. */
  51367. readonly animationsTimeCounter: PerfCounter;
  51368. /**
  51369. * Gets the animations time capture status
  51370. */
  51371. /**
  51372. * Enable or disable the animations time capture
  51373. */
  51374. captureAnimationsTime: boolean;
  51375. /**
  51376. * Gets the perf counter used for frame time capture
  51377. */
  51378. readonly frameTimeCounter: PerfCounter;
  51379. /**
  51380. * Gets the frame time capture status
  51381. */
  51382. /**
  51383. * Enable or disable the frame time capture
  51384. */
  51385. captureFrameTime: boolean;
  51386. /**
  51387. * Gets the perf counter used for inter-frames time capture
  51388. */
  51389. readonly interFrameTimeCounter: PerfCounter;
  51390. /**
  51391. * Gets the inter-frames time capture status
  51392. */
  51393. /**
  51394. * Enable or disable the inter-frames time capture
  51395. */
  51396. captureInterFrameTime: boolean;
  51397. /**
  51398. * Gets the perf counter used for render time capture
  51399. */
  51400. readonly renderTimeCounter: PerfCounter;
  51401. /**
  51402. * Gets the render time capture status
  51403. */
  51404. /**
  51405. * Enable or disable the render time capture
  51406. */
  51407. captureRenderTime: boolean;
  51408. /**
  51409. * Gets the perf counter used for camera render time capture
  51410. */
  51411. readonly cameraRenderTimeCounter: PerfCounter;
  51412. /**
  51413. * Gets the camera render time capture status
  51414. */
  51415. /**
  51416. * Enable or disable the camera render time capture
  51417. */
  51418. captureCameraRenderTime: boolean;
  51419. /**
  51420. * Gets the perf counter used for draw calls
  51421. */
  51422. readonly drawCallsCounter: PerfCounter;
  51423. /**
  51424. * Instantiates a new scene instrumentation.
  51425. * This class can be used to get instrumentation data from a Babylon engine
  51426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51427. * @param scene Defines the scene to instrument
  51428. */
  51429. constructor(
  51430. /**
  51431. * Defines the scene to instrument
  51432. */
  51433. scene: Scene);
  51434. /**
  51435. * Dispose and release associated resources.
  51436. */
  51437. dispose(): void;
  51438. }
  51439. }
  51440. declare module "babylonjs/Instrumentation/index" {
  51441. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51442. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51443. export * from "babylonjs/Instrumentation/timeToken";
  51444. }
  51445. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51446. /** @hidden */
  51447. export var glowMapGenerationPixelShader: {
  51448. name: string;
  51449. shader: string;
  51450. };
  51451. }
  51452. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51455. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51458. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51459. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51460. /** @hidden */
  51461. export var glowMapGenerationVertexShader: {
  51462. name: string;
  51463. shader: string;
  51464. };
  51465. }
  51466. declare module "babylonjs/Layers/effectLayer" {
  51467. import { Observable } from "babylonjs/Misc/observable";
  51468. import { Nullable } from "babylonjs/types";
  51469. import { Camera } from "babylonjs/Cameras/camera";
  51470. import { Scene } from "babylonjs/scene";
  51471. import { ISize } from "babylonjs/Maths/math.size";
  51472. import { Color4 } from "babylonjs/Maths/math.color";
  51473. import { Engine } from "babylonjs/Engines/engine";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51478. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51479. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51480. import { Effect } from "babylonjs/Materials/effect";
  51481. import { Material } from "babylonjs/Materials/material";
  51482. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51483. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51484. /**
  51485. * Effect layer options. This helps customizing the behaviour
  51486. * of the effect layer.
  51487. */
  51488. export interface IEffectLayerOptions {
  51489. /**
  51490. * Multiplication factor apply to the canvas size to compute the render target size
  51491. * used to generated the objects (the smaller the faster).
  51492. */
  51493. mainTextureRatio: number;
  51494. /**
  51495. * Enforces a fixed size texture to ensure effect stability across devices.
  51496. */
  51497. mainTextureFixedSize?: number;
  51498. /**
  51499. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51500. */
  51501. alphaBlendingMode: number;
  51502. /**
  51503. * The camera attached to the layer.
  51504. */
  51505. camera: Nullable<Camera>;
  51506. /**
  51507. * The rendering group to draw the layer in.
  51508. */
  51509. renderingGroupId: number;
  51510. }
  51511. /**
  51512. * The effect layer Helps adding post process effect blended with the main pass.
  51513. *
  51514. * This can be for instance use to generate glow or higlight effects on the scene.
  51515. *
  51516. * The effect layer class can not be used directly and is intented to inherited from to be
  51517. * customized per effects.
  51518. */
  51519. export abstract class EffectLayer {
  51520. private _vertexBuffers;
  51521. private _indexBuffer;
  51522. private _cachedDefines;
  51523. private _effectLayerMapGenerationEffect;
  51524. private _effectLayerOptions;
  51525. private _mergeEffect;
  51526. protected _scene: Scene;
  51527. protected _engine: Engine;
  51528. protected _maxSize: number;
  51529. protected _mainTextureDesiredSize: ISize;
  51530. protected _mainTexture: RenderTargetTexture;
  51531. protected _shouldRender: boolean;
  51532. protected _postProcesses: PostProcess[];
  51533. protected _textures: BaseTexture[];
  51534. protected _emissiveTextureAndColor: {
  51535. texture: Nullable<BaseTexture>;
  51536. color: Color4;
  51537. };
  51538. /**
  51539. * The name of the layer
  51540. */
  51541. name: string;
  51542. /**
  51543. * The clear color of the texture used to generate the glow map.
  51544. */
  51545. neutralColor: Color4;
  51546. /**
  51547. * Specifies wether the highlight layer is enabled or not.
  51548. */
  51549. isEnabled: boolean;
  51550. /**
  51551. * Gets the camera attached to the layer.
  51552. */
  51553. readonly camera: Nullable<Camera>;
  51554. /**
  51555. * Gets the rendering group id the layer should render in.
  51556. */
  51557. renderingGroupId: number;
  51558. /**
  51559. * An event triggered when the effect layer has been disposed.
  51560. */
  51561. onDisposeObservable: Observable<EffectLayer>;
  51562. /**
  51563. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51564. */
  51565. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51566. /**
  51567. * An event triggered when the generated texture is being merged in the scene.
  51568. */
  51569. onBeforeComposeObservable: Observable<EffectLayer>;
  51570. /**
  51571. * An event triggered when the generated texture has been merged in the scene.
  51572. */
  51573. onAfterComposeObservable: Observable<EffectLayer>;
  51574. /**
  51575. * An event triggered when the efffect layer changes its size.
  51576. */
  51577. onSizeChangedObservable: Observable<EffectLayer>;
  51578. /** @hidden */
  51579. static _SceneComponentInitialization: (scene: Scene) => void;
  51580. /**
  51581. * Instantiates a new effect Layer and references it in the scene.
  51582. * @param name The name of the layer
  51583. * @param scene The scene to use the layer in
  51584. */
  51585. constructor(
  51586. /** The Friendly of the effect in the scene */
  51587. name: string, scene: Scene);
  51588. /**
  51589. * Get the effect name of the layer.
  51590. * @return The effect name
  51591. */
  51592. abstract getEffectName(): string;
  51593. /**
  51594. * Checks for the readiness of the element composing the layer.
  51595. * @param subMesh the mesh to check for
  51596. * @param useInstances specify wether or not to use instances to render the mesh
  51597. * @return true if ready otherwise, false
  51598. */
  51599. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51600. /**
  51601. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51602. * @returns true if the effect requires stencil during the main canvas render pass.
  51603. */
  51604. abstract needStencil(): boolean;
  51605. /**
  51606. * Create the merge effect. This is the shader use to blit the information back
  51607. * to the main canvas at the end of the scene rendering.
  51608. * @returns The effect containing the shader used to merge the effect on the main canvas
  51609. */
  51610. protected abstract _createMergeEffect(): Effect;
  51611. /**
  51612. * Creates the render target textures and post processes used in the effect layer.
  51613. */
  51614. protected abstract _createTextureAndPostProcesses(): void;
  51615. /**
  51616. * Implementation specific of rendering the generating effect on the main canvas.
  51617. * @param effect The effect used to render through
  51618. */
  51619. protected abstract _internalRender(effect: Effect): void;
  51620. /**
  51621. * Sets the required values for both the emissive texture and and the main color.
  51622. */
  51623. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51624. /**
  51625. * Free any resources and references associated to a mesh.
  51626. * Internal use
  51627. * @param mesh The mesh to free.
  51628. */
  51629. abstract _disposeMesh(mesh: Mesh): void;
  51630. /**
  51631. * Serializes this layer (Glow or Highlight for example)
  51632. * @returns a serialized layer object
  51633. */
  51634. abstract serialize?(): any;
  51635. /**
  51636. * Initializes the effect layer with the required options.
  51637. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51638. */
  51639. protected _init(options: Partial<IEffectLayerOptions>): void;
  51640. /**
  51641. * Generates the index buffer of the full screen quad blending to the main canvas.
  51642. */
  51643. private _generateIndexBuffer;
  51644. /**
  51645. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51646. */
  51647. private _generateVertexBuffer;
  51648. /**
  51649. * Sets the main texture desired size which is the closest power of two
  51650. * of the engine canvas size.
  51651. */
  51652. private _setMainTextureSize;
  51653. /**
  51654. * Creates the main texture for the effect layer.
  51655. */
  51656. protected _createMainTexture(): void;
  51657. /**
  51658. * Adds specific effects defines.
  51659. * @param defines The defines to add specifics to.
  51660. */
  51661. protected _addCustomEffectDefines(defines: string[]): void;
  51662. /**
  51663. * Checks for the readiness of the element composing the layer.
  51664. * @param subMesh the mesh to check for
  51665. * @param useInstances specify wether or not to use instances to render the mesh
  51666. * @param emissiveTexture the associated emissive texture used to generate the glow
  51667. * @return true if ready otherwise, false
  51668. */
  51669. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51670. /**
  51671. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51672. */
  51673. render(): void;
  51674. /**
  51675. * Determine if a given mesh will be used in the current effect.
  51676. * @param mesh mesh to test
  51677. * @returns true if the mesh will be used
  51678. */
  51679. hasMesh(mesh: AbstractMesh): boolean;
  51680. /**
  51681. * Returns true if the layer contains information to display, otherwise false.
  51682. * @returns true if the glow layer should be rendered
  51683. */
  51684. shouldRender(): boolean;
  51685. /**
  51686. * Returns true if the mesh should render, otherwise false.
  51687. * @param mesh The mesh to render
  51688. * @returns true if it should render otherwise false
  51689. */
  51690. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51691. /**
  51692. * Returns true if the mesh can be rendered, otherwise false.
  51693. * @param mesh The mesh to render
  51694. * @param material The material used on the mesh
  51695. * @returns true if it can be rendered otherwise false
  51696. */
  51697. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51698. /**
  51699. * Returns true if the mesh should render, otherwise false.
  51700. * @param mesh The mesh to render
  51701. * @returns true if it should render otherwise false
  51702. */
  51703. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51704. /**
  51705. * Renders the submesh passed in parameter to the generation map.
  51706. */
  51707. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51708. /**
  51709. * Rebuild the required buffers.
  51710. * @hidden Internal use only.
  51711. */
  51712. _rebuild(): void;
  51713. /**
  51714. * Dispose only the render target textures and post process.
  51715. */
  51716. private _disposeTextureAndPostProcesses;
  51717. /**
  51718. * Dispose the highlight layer and free resources.
  51719. */
  51720. dispose(): void;
  51721. /**
  51722. * Gets the class name of the effect layer
  51723. * @returns the string with the class name of the effect layer
  51724. */
  51725. getClassName(): string;
  51726. /**
  51727. * Creates an effect layer from parsed effect layer data
  51728. * @param parsedEffectLayer defines effect layer data
  51729. * @param scene defines the current scene
  51730. * @param rootUrl defines the root URL containing the effect layer information
  51731. * @returns a parsed effect Layer
  51732. */
  51733. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51734. }
  51735. }
  51736. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51737. import { Scene } from "babylonjs/scene";
  51738. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51739. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51740. import { AbstractScene } from "babylonjs/abstractScene";
  51741. module "babylonjs/abstractScene" {
  51742. interface AbstractScene {
  51743. /**
  51744. * The list of effect layers (highlights/glow) added to the scene
  51745. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51746. * @see http://doc.babylonjs.com/how_to/glow_layer
  51747. */
  51748. effectLayers: Array<EffectLayer>;
  51749. /**
  51750. * Removes the given effect layer from this scene.
  51751. * @param toRemove defines the effect layer to remove
  51752. * @returns the index of the removed effect layer
  51753. */
  51754. removeEffectLayer(toRemove: EffectLayer): number;
  51755. /**
  51756. * Adds the given effect layer to this scene
  51757. * @param newEffectLayer defines the effect layer to add
  51758. */
  51759. addEffectLayer(newEffectLayer: EffectLayer): void;
  51760. }
  51761. }
  51762. /**
  51763. * Defines the layer scene component responsible to manage any effect layers
  51764. * in a given scene.
  51765. */
  51766. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51767. /**
  51768. * The component name helpfull to identify the component in the list of scene components.
  51769. */
  51770. readonly name: string;
  51771. /**
  51772. * The scene the component belongs to.
  51773. */
  51774. scene: Scene;
  51775. private _engine;
  51776. private _renderEffects;
  51777. private _needStencil;
  51778. private _previousStencilState;
  51779. /**
  51780. * Creates a new instance of the component for the given scene
  51781. * @param scene Defines the scene to register the component in
  51782. */
  51783. constructor(scene: Scene);
  51784. /**
  51785. * Registers the component in a given scene
  51786. */
  51787. register(): void;
  51788. /**
  51789. * Rebuilds the elements related to this component in case of
  51790. * context lost for instance.
  51791. */
  51792. rebuild(): void;
  51793. /**
  51794. * Serializes the component data to the specified json object
  51795. * @param serializationObject The object to serialize to
  51796. */
  51797. serialize(serializationObject: any): void;
  51798. /**
  51799. * Adds all the elements from the container to the scene
  51800. * @param container the container holding the elements
  51801. */
  51802. addFromContainer(container: AbstractScene): void;
  51803. /**
  51804. * Removes all the elements in the container from the scene
  51805. * @param container contains the elements to remove
  51806. * @param dispose if the removed element should be disposed (default: false)
  51807. */
  51808. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51809. /**
  51810. * Disposes the component and the associated ressources.
  51811. */
  51812. dispose(): void;
  51813. private _isReadyForMesh;
  51814. private _renderMainTexture;
  51815. private _setStencil;
  51816. private _setStencilBack;
  51817. private _draw;
  51818. private _drawCamera;
  51819. private _drawRenderingGroup;
  51820. }
  51821. }
  51822. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51823. /** @hidden */
  51824. export var glowMapMergePixelShader: {
  51825. name: string;
  51826. shader: string;
  51827. };
  51828. }
  51829. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51830. /** @hidden */
  51831. export var glowMapMergeVertexShader: {
  51832. name: string;
  51833. shader: string;
  51834. };
  51835. }
  51836. declare module "babylonjs/Layers/glowLayer" {
  51837. import { Nullable } from "babylonjs/types";
  51838. import { Camera } from "babylonjs/Cameras/camera";
  51839. import { Scene } from "babylonjs/scene";
  51840. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51842. import { Mesh } from "babylonjs/Meshes/mesh";
  51843. import { Texture } from "babylonjs/Materials/Textures/texture";
  51844. import { Effect } from "babylonjs/Materials/effect";
  51845. import { Material } from "babylonjs/Materials/material";
  51846. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51847. import { Color4 } from "babylonjs/Maths/math.color";
  51848. import "babylonjs/Shaders/glowMapMerge.fragment";
  51849. import "babylonjs/Shaders/glowMapMerge.vertex";
  51850. import "babylonjs/Layers/effectLayerSceneComponent";
  51851. module "babylonjs/abstractScene" {
  51852. interface AbstractScene {
  51853. /**
  51854. * Return a the first highlight layer of the scene with a given name.
  51855. * @param name The name of the highlight layer to look for.
  51856. * @return The highlight layer if found otherwise null.
  51857. */
  51858. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51859. }
  51860. }
  51861. /**
  51862. * Glow layer options. This helps customizing the behaviour
  51863. * of the glow layer.
  51864. */
  51865. export interface IGlowLayerOptions {
  51866. /**
  51867. * Multiplication factor apply to the canvas size to compute the render target size
  51868. * used to generated the glowing objects (the smaller the faster).
  51869. */
  51870. mainTextureRatio: number;
  51871. /**
  51872. * Enforces a fixed size texture to ensure resize independant blur.
  51873. */
  51874. mainTextureFixedSize?: number;
  51875. /**
  51876. * How big is the kernel of the blur texture.
  51877. */
  51878. blurKernelSize: number;
  51879. /**
  51880. * The camera attached to the layer.
  51881. */
  51882. camera: Nullable<Camera>;
  51883. /**
  51884. * Enable MSAA by chosing the number of samples.
  51885. */
  51886. mainTextureSamples?: number;
  51887. /**
  51888. * The rendering group to draw the layer in.
  51889. */
  51890. renderingGroupId: number;
  51891. }
  51892. /**
  51893. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51894. *
  51895. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51896. * glowy meshes to your scene.
  51897. *
  51898. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51899. */
  51900. export class GlowLayer extends EffectLayer {
  51901. /**
  51902. * Effect Name of the layer.
  51903. */
  51904. static readonly EffectName: string;
  51905. /**
  51906. * The default blur kernel size used for the glow.
  51907. */
  51908. static DefaultBlurKernelSize: number;
  51909. /**
  51910. * The default texture size ratio used for the glow.
  51911. */
  51912. static DefaultTextureRatio: number;
  51913. /**
  51914. * Sets the kernel size of the blur.
  51915. */
  51916. /**
  51917. * Gets the kernel size of the blur.
  51918. */
  51919. blurKernelSize: number;
  51920. /**
  51921. * Sets the glow intensity.
  51922. */
  51923. /**
  51924. * Gets the glow intensity.
  51925. */
  51926. intensity: number;
  51927. private _options;
  51928. private _intensity;
  51929. private _horizontalBlurPostprocess1;
  51930. private _verticalBlurPostprocess1;
  51931. private _horizontalBlurPostprocess2;
  51932. private _verticalBlurPostprocess2;
  51933. private _blurTexture1;
  51934. private _blurTexture2;
  51935. private _postProcesses1;
  51936. private _postProcesses2;
  51937. private _includedOnlyMeshes;
  51938. private _excludedMeshes;
  51939. /**
  51940. * Callback used to let the user override the color selection on a per mesh basis
  51941. */
  51942. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51943. /**
  51944. * Callback used to let the user override the texture selection on a per mesh basis
  51945. */
  51946. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51947. /**
  51948. * Instantiates a new glow Layer and references it to the scene.
  51949. * @param name The name of the layer
  51950. * @param scene The scene to use the layer in
  51951. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51952. */
  51953. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51954. /**
  51955. * Get the effect name of the layer.
  51956. * @return The effect name
  51957. */
  51958. getEffectName(): string;
  51959. /**
  51960. * Create the merge effect. This is the shader use to blit the information back
  51961. * to the main canvas at the end of the scene rendering.
  51962. */
  51963. protected _createMergeEffect(): Effect;
  51964. /**
  51965. * Creates the render target textures and post processes used in the glow layer.
  51966. */
  51967. protected _createTextureAndPostProcesses(): void;
  51968. /**
  51969. * Checks for the readiness of the element composing the layer.
  51970. * @param subMesh the mesh to check for
  51971. * @param useInstances specify wether or not to use instances to render the mesh
  51972. * @param emissiveTexture the associated emissive texture used to generate the glow
  51973. * @return true if ready otherwise, false
  51974. */
  51975. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51976. /**
  51977. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51978. */
  51979. needStencil(): boolean;
  51980. /**
  51981. * Returns true if the mesh can be rendered, otherwise false.
  51982. * @param mesh The mesh to render
  51983. * @param material The material used on the mesh
  51984. * @returns true if it can be rendered otherwise false
  51985. */
  51986. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51987. /**
  51988. * Implementation specific of rendering the generating effect on the main canvas.
  51989. * @param effect The effect used to render through
  51990. */
  51991. protected _internalRender(effect: Effect): void;
  51992. /**
  51993. * Sets the required values for both the emissive texture and and the main color.
  51994. */
  51995. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51996. /**
  51997. * Returns true if the mesh should render, otherwise false.
  51998. * @param mesh The mesh to render
  51999. * @returns true if it should render otherwise false
  52000. */
  52001. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52002. /**
  52003. * Adds specific effects defines.
  52004. * @param defines The defines to add specifics to.
  52005. */
  52006. protected _addCustomEffectDefines(defines: string[]): void;
  52007. /**
  52008. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52009. * @param mesh The mesh to exclude from the glow layer
  52010. */
  52011. addExcludedMesh(mesh: Mesh): void;
  52012. /**
  52013. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52014. * @param mesh The mesh to remove
  52015. */
  52016. removeExcludedMesh(mesh: Mesh): void;
  52017. /**
  52018. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52019. * @param mesh The mesh to include in the glow layer
  52020. */
  52021. addIncludedOnlyMesh(mesh: Mesh): void;
  52022. /**
  52023. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52024. * @param mesh The mesh to remove
  52025. */
  52026. removeIncludedOnlyMesh(mesh: Mesh): void;
  52027. /**
  52028. * Determine if a given mesh will be used in the glow layer
  52029. * @param mesh The mesh to test
  52030. * @returns true if the mesh will be highlighted by the current glow layer
  52031. */
  52032. hasMesh(mesh: AbstractMesh): boolean;
  52033. /**
  52034. * Free any resources and references associated to a mesh.
  52035. * Internal use
  52036. * @param mesh The mesh to free.
  52037. * @hidden
  52038. */
  52039. _disposeMesh(mesh: Mesh): void;
  52040. /**
  52041. * Gets the class name of the effect layer
  52042. * @returns the string with the class name of the effect layer
  52043. */
  52044. getClassName(): string;
  52045. /**
  52046. * Serializes this glow layer
  52047. * @returns a serialized glow layer object
  52048. */
  52049. serialize(): any;
  52050. /**
  52051. * Creates a Glow Layer from parsed glow layer data
  52052. * @param parsedGlowLayer defines glow layer data
  52053. * @param scene defines the current scene
  52054. * @param rootUrl defines the root URL containing the glow layer information
  52055. * @returns a parsed Glow Layer
  52056. */
  52057. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52058. }
  52059. }
  52060. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52061. /** @hidden */
  52062. export var glowBlurPostProcessPixelShader: {
  52063. name: string;
  52064. shader: string;
  52065. };
  52066. }
  52067. declare module "babylonjs/Layers/highlightLayer" {
  52068. import { Observable } from "babylonjs/Misc/observable";
  52069. import { Nullable } from "babylonjs/types";
  52070. import { Camera } from "babylonjs/Cameras/camera";
  52071. import { Scene } from "babylonjs/scene";
  52072. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52074. import { Mesh } from "babylonjs/Meshes/mesh";
  52075. import { Effect } from "babylonjs/Materials/effect";
  52076. import { Material } from "babylonjs/Materials/material";
  52077. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52078. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52079. import "babylonjs/Shaders/glowMapMerge.fragment";
  52080. import "babylonjs/Shaders/glowMapMerge.vertex";
  52081. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52082. module "babylonjs/abstractScene" {
  52083. interface AbstractScene {
  52084. /**
  52085. * Return a the first highlight layer of the scene with a given name.
  52086. * @param name The name of the highlight layer to look for.
  52087. * @return The highlight layer if found otherwise null.
  52088. */
  52089. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52090. }
  52091. }
  52092. /**
  52093. * Highlight layer options. This helps customizing the behaviour
  52094. * of the highlight layer.
  52095. */
  52096. export interface IHighlightLayerOptions {
  52097. /**
  52098. * Multiplication factor apply to the canvas size to compute the render target size
  52099. * used to generated the glowing objects (the smaller the faster).
  52100. */
  52101. mainTextureRatio: number;
  52102. /**
  52103. * Enforces a fixed size texture to ensure resize independant blur.
  52104. */
  52105. mainTextureFixedSize?: number;
  52106. /**
  52107. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52108. * of the picture to blur (the smaller the faster).
  52109. */
  52110. blurTextureSizeRatio: number;
  52111. /**
  52112. * How big in texel of the blur texture is the vertical blur.
  52113. */
  52114. blurVerticalSize: number;
  52115. /**
  52116. * How big in texel of the blur texture is the horizontal blur.
  52117. */
  52118. blurHorizontalSize: number;
  52119. /**
  52120. * Alpha blending mode used to apply the blur. Default is combine.
  52121. */
  52122. alphaBlendingMode: number;
  52123. /**
  52124. * The camera attached to the layer.
  52125. */
  52126. camera: Nullable<Camera>;
  52127. /**
  52128. * Should we display highlight as a solid stroke?
  52129. */
  52130. isStroke?: boolean;
  52131. /**
  52132. * The rendering group to draw the layer in.
  52133. */
  52134. renderingGroupId: number;
  52135. }
  52136. /**
  52137. * The highlight layer Helps adding a glow effect around a mesh.
  52138. *
  52139. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52140. * glowy meshes to your scene.
  52141. *
  52142. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52143. */
  52144. export class HighlightLayer extends EffectLayer {
  52145. name: string;
  52146. /**
  52147. * Effect Name of the highlight layer.
  52148. */
  52149. static readonly EffectName: string;
  52150. /**
  52151. * The neutral color used during the preparation of the glow effect.
  52152. * This is black by default as the blend operation is a blend operation.
  52153. */
  52154. static NeutralColor: Color4;
  52155. /**
  52156. * Stencil value used for glowing meshes.
  52157. */
  52158. static GlowingMeshStencilReference: number;
  52159. /**
  52160. * Stencil value used for the other meshes in the scene.
  52161. */
  52162. static NormalMeshStencilReference: number;
  52163. /**
  52164. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52165. */
  52166. innerGlow: boolean;
  52167. /**
  52168. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52169. */
  52170. outerGlow: boolean;
  52171. /**
  52172. * Specifies the horizontal size of the blur.
  52173. */
  52174. /**
  52175. * Gets the horizontal size of the blur.
  52176. */
  52177. blurHorizontalSize: number;
  52178. /**
  52179. * Specifies the vertical size of the blur.
  52180. */
  52181. /**
  52182. * Gets the vertical size of the blur.
  52183. */
  52184. blurVerticalSize: number;
  52185. /**
  52186. * An event triggered when the highlight layer is being blurred.
  52187. */
  52188. onBeforeBlurObservable: Observable<HighlightLayer>;
  52189. /**
  52190. * An event triggered when the highlight layer has been blurred.
  52191. */
  52192. onAfterBlurObservable: Observable<HighlightLayer>;
  52193. private _instanceGlowingMeshStencilReference;
  52194. private _options;
  52195. private _downSamplePostprocess;
  52196. private _horizontalBlurPostprocess;
  52197. private _verticalBlurPostprocess;
  52198. private _blurTexture;
  52199. private _meshes;
  52200. private _excludedMeshes;
  52201. /**
  52202. * Instantiates a new highlight Layer and references it to the scene..
  52203. * @param name The name of the layer
  52204. * @param scene The scene to use the layer in
  52205. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52206. */
  52207. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52208. /**
  52209. * Get the effect name of the layer.
  52210. * @return The effect name
  52211. */
  52212. getEffectName(): string;
  52213. /**
  52214. * Create the merge effect. This is the shader use to blit the information back
  52215. * to the main canvas at the end of the scene rendering.
  52216. */
  52217. protected _createMergeEffect(): Effect;
  52218. /**
  52219. * Creates the render target textures and post processes used in the highlight layer.
  52220. */
  52221. protected _createTextureAndPostProcesses(): void;
  52222. /**
  52223. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52224. */
  52225. needStencil(): boolean;
  52226. /**
  52227. * Checks for the readiness of the element composing the layer.
  52228. * @param subMesh the mesh to check for
  52229. * @param useInstances specify wether or not to use instances to render the mesh
  52230. * @param emissiveTexture the associated emissive texture used to generate the glow
  52231. * @return true if ready otherwise, false
  52232. */
  52233. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52234. /**
  52235. * Implementation specific of rendering the generating effect on the main canvas.
  52236. * @param effect The effect used to render through
  52237. */
  52238. protected _internalRender(effect: Effect): void;
  52239. /**
  52240. * Returns true if the layer contains information to display, otherwise false.
  52241. */
  52242. shouldRender(): boolean;
  52243. /**
  52244. * Returns true if the mesh should render, otherwise false.
  52245. * @param mesh The mesh to render
  52246. * @returns true if it should render otherwise false
  52247. */
  52248. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52249. /**
  52250. * Sets the required values for both the emissive texture and and the main color.
  52251. */
  52252. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52253. /**
  52254. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52255. * @param mesh The mesh to exclude from the highlight layer
  52256. */
  52257. addExcludedMesh(mesh: Mesh): void;
  52258. /**
  52259. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52260. * @param mesh The mesh to highlight
  52261. */
  52262. removeExcludedMesh(mesh: Mesh): void;
  52263. /**
  52264. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52265. * @param mesh mesh to test
  52266. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52267. */
  52268. hasMesh(mesh: AbstractMesh): boolean;
  52269. /**
  52270. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52271. * @param mesh The mesh to highlight
  52272. * @param color The color of the highlight
  52273. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52274. */
  52275. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52276. /**
  52277. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52278. * @param mesh The mesh to highlight
  52279. */
  52280. removeMesh(mesh: Mesh): void;
  52281. /**
  52282. * Force the stencil to the normal expected value for none glowing parts
  52283. */
  52284. private _defaultStencilReference;
  52285. /**
  52286. * Free any resources and references associated to a mesh.
  52287. * Internal use
  52288. * @param mesh The mesh to free.
  52289. * @hidden
  52290. */
  52291. _disposeMesh(mesh: Mesh): void;
  52292. /**
  52293. * Dispose the highlight layer and free resources.
  52294. */
  52295. dispose(): void;
  52296. /**
  52297. * Gets the class name of the effect layer
  52298. * @returns the string with the class name of the effect layer
  52299. */
  52300. getClassName(): string;
  52301. /**
  52302. * Serializes this Highlight layer
  52303. * @returns a serialized Highlight layer object
  52304. */
  52305. serialize(): any;
  52306. /**
  52307. * Creates a Highlight layer from parsed Highlight layer data
  52308. * @param parsedHightlightLayer defines the Highlight layer data
  52309. * @param scene defines the current scene
  52310. * @param rootUrl defines the root URL containing the Highlight layer information
  52311. * @returns a parsed Highlight layer
  52312. */
  52313. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52314. }
  52315. }
  52316. declare module "babylonjs/Layers/layerSceneComponent" {
  52317. import { Scene } from "babylonjs/scene";
  52318. import { ISceneComponent } from "babylonjs/sceneComponent";
  52319. import { Layer } from "babylonjs/Layers/layer";
  52320. import { AbstractScene } from "babylonjs/abstractScene";
  52321. module "babylonjs/abstractScene" {
  52322. interface AbstractScene {
  52323. /**
  52324. * The list of layers (background and foreground) of the scene
  52325. */
  52326. layers: Array<Layer>;
  52327. }
  52328. }
  52329. /**
  52330. * Defines the layer scene component responsible to manage any layers
  52331. * in a given scene.
  52332. */
  52333. export class LayerSceneComponent implements ISceneComponent {
  52334. /**
  52335. * The component name helpfull to identify the component in the list of scene components.
  52336. */
  52337. readonly name: string;
  52338. /**
  52339. * The scene the component belongs to.
  52340. */
  52341. scene: Scene;
  52342. private _engine;
  52343. /**
  52344. * Creates a new instance of the component for the given scene
  52345. * @param scene Defines the scene to register the component in
  52346. */
  52347. constructor(scene: Scene);
  52348. /**
  52349. * Registers the component in a given scene
  52350. */
  52351. register(): void;
  52352. /**
  52353. * Rebuilds the elements related to this component in case of
  52354. * context lost for instance.
  52355. */
  52356. rebuild(): void;
  52357. /**
  52358. * Disposes the component and the associated ressources.
  52359. */
  52360. dispose(): void;
  52361. private _draw;
  52362. private _drawCameraPredicate;
  52363. private _drawCameraBackground;
  52364. private _drawCameraForeground;
  52365. private _drawRenderTargetPredicate;
  52366. private _drawRenderTargetBackground;
  52367. private _drawRenderTargetForeground;
  52368. /**
  52369. * Adds all the elements from the container to the scene
  52370. * @param container the container holding the elements
  52371. */
  52372. addFromContainer(container: AbstractScene): void;
  52373. /**
  52374. * Removes all the elements in the container from the scene
  52375. * @param container contains the elements to remove
  52376. * @param dispose if the removed element should be disposed (default: false)
  52377. */
  52378. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52379. }
  52380. }
  52381. declare module "babylonjs/Shaders/layer.fragment" {
  52382. /** @hidden */
  52383. export var layerPixelShader: {
  52384. name: string;
  52385. shader: string;
  52386. };
  52387. }
  52388. declare module "babylonjs/Shaders/layer.vertex" {
  52389. /** @hidden */
  52390. export var layerVertexShader: {
  52391. name: string;
  52392. shader: string;
  52393. };
  52394. }
  52395. declare module "babylonjs/Layers/layer" {
  52396. import { Observable } from "babylonjs/Misc/observable";
  52397. import { Nullable } from "babylonjs/types";
  52398. import { Scene } from "babylonjs/scene";
  52399. import { Vector2 } from "babylonjs/Maths/math.vector";
  52400. import { Color4 } from "babylonjs/Maths/math.color";
  52401. import { Texture } from "babylonjs/Materials/Textures/texture";
  52402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52403. import "babylonjs/Shaders/layer.fragment";
  52404. import "babylonjs/Shaders/layer.vertex";
  52405. /**
  52406. * This represents a full screen 2d layer.
  52407. * This can be useful to display a picture in the background of your scene for instance.
  52408. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52409. */
  52410. export class Layer {
  52411. /**
  52412. * Define the name of the layer.
  52413. */
  52414. name: string;
  52415. /**
  52416. * Define the texture the layer should display.
  52417. */
  52418. texture: Nullable<Texture>;
  52419. /**
  52420. * Is the layer in background or foreground.
  52421. */
  52422. isBackground: boolean;
  52423. /**
  52424. * Define the color of the layer (instead of texture).
  52425. */
  52426. color: Color4;
  52427. /**
  52428. * Define the scale of the layer in order to zoom in out of the texture.
  52429. */
  52430. scale: Vector2;
  52431. /**
  52432. * Define an offset for the layer in order to shift the texture.
  52433. */
  52434. offset: Vector2;
  52435. /**
  52436. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52437. */
  52438. alphaBlendingMode: number;
  52439. /**
  52440. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52441. * Alpha test will not mix with the background color in case of transparency.
  52442. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52443. */
  52444. alphaTest: boolean;
  52445. /**
  52446. * Define a mask to restrict the layer to only some of the scene cameras.
  52447. */
  52448. layerMask: number;
  52449. /**
  52450. * Define the list of render target the layer is visible into.
  52451. */
  52452. renderTargetTextures: RenderTargetTexture[];
  52453. /**
  52454. * Define if the layer is only used in renderTarget or if it also
  52455. * renders in the main frame buffer of the canvas.
  52456. */
  52457. renderOnlyInRenderTargetTextures: boolean;
  52458. private _scene;
  52459. private _vertexBuffers;
  52460. private _indexBuffer;
  52461. private _effect;
  52462. private _alphaTestEffect;
  52463. /**
  52464. * An event triggered when the layer is disposed.
  52465. */
  52466. onDisposeObservable: Observable<Layer>;
  52467. private _onDisposeObserver;
  52468. /**
  52469. * Back compatibility with callback before the onDisposeObservable existed.
  52470. * The set callback will be triggered when the layer has been disposed.
  52471. */
  52472. onDispose: () => void;
  52473. /**
  52474. * An event triggered before rendering the scene
  52475. */
  52476. onBeforeRenderObservable: Observable<Layer>;
  52477. private _onBeforeRenderObserver;
  52478. /**
  52479. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52480. * The set callback will be triggered just before rendering the layer.
  52481. */
  52482. onBeforeRender: () => void;
  52483. /**
  52484. * An event triggered after rendering the scene
  52485. */
  52486. onAfterRenderObservable: Observable<Layer>;
  52487. private _onAfterRenderObserver;
  52488. /**
  52489. * Back compatibility with callback before the onAfterRenderObservable existed.
  52490. * The set callback will be triggered just after rendering the layer.
  52491. */
  52492. onAfterRender: () => void;
  52493. /**
  52494. * Instantiates a new layer.
  52495. * This represents a full screen 2d layer.
  52496. * This can be useful to display a picture in the background of your scene for instance.
  52497. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52498. * @param name Define the name of the layer in the scene
  52499. * @param imgUrl Define the url of the texture to display in the layer
  52500. * @param scene Define the scene the layer belongs to
  52501. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52502. * @param color Defines a color for the layer
  52503. */
  52504. constructor(
  52505. /**
  52506. * Define the name of the layer.
  52507. */
  52508. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52509. private _createIndexBuffer;
  52510. /** @hidden */
  52511. _rebuild(): void;
  52512. /**
  52513. * Renders the layer in the scene.
  52514. */
  52515. render(): void;
  52516. /**
  52517. * Disposes and releases the associated ressources.
  52518. */
  52519. dispose(): void;
  52520. }
  52521. }
  52522. declare module "babylonjs/Layers/index" {
  52523. export * from "babylonjs/Layers/effectLayer";
  52524. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52525. export * from "babylonjs/Layers/glowLayer";
  52526. export * from "babylonjs/Layers/highlightLayer";
  52527. export * from "babylonjs/Layers/layer";
  52528. export * from "babylonjs/Layers/layerSceneComponent";
  52529. }
  52530. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52531. /** @hidden */
  52532. export var lensFlarePixelShader: {
  52533. name: string;
  52534. shader: string;
  52535. };
  52536. }
  52537. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52538. /** @hidden */
  52539. export var lensFlareVertexShader: {
  52540. name: string;
  52541. shader: string;
  52542. };
  52543. }
  52544. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52545. import { Scene } from "babylonjs/scene";
  52546. import { Vector3 } from "babylonjs/Maths/math.vector";
  52547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52548. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52549. import "babylonjs/Shaders/lensFlare.fragment";
  52550. import "babylonjs/Shaders/lensFlare.vertex";
  52551. import { Viewport } from "babylonjs/Maths/math.viewport";
  52552. /**
  52553. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52554. * It is usually composed of several `lensFlare`.
  52555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52556. */
  52557. export class LensFlareSystem {
  52558. /**
  52559. * Define the name of the lens flare system
  52560. */
  52561. name: string;
  52562. /**
  52563. * List of lens flares used in this system.
  52564. */
  52565. lensFlares: LensFlare[];
  52566. /**
  52567. * Define a limit from the border the lens flare can be visible.
  52568. */
  52569. borderLimit: number;
  52570. /**
  52571. * Define a viewport border we do not want to see the lens flare in.
  52572. */
  52573. viewportBorder: number;
  52574. /**
  52575. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52576. */
  52577. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52578. /**
  52579. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52580. */
  52581. layerMask: number;
  52582. /**
  52583. * Define the id of the lens flare system in the scene.
  52584. * (equal to name by default)
  52585. */
  52586. id: string;
  52587. private _scene;
  52588. private _emitter;
  52589. private _vertexBuffers;
  52590. private _indexBuffer;
  52591. private _effect;
  52592. private _positionX;
  52593. private _positionY;
  52594. private _isEnabled;
  52595. /** @hidden */
  52596. static _SceneComponentInitialization: (scene: Scene) => void;
  52597. /**
  52598. * Instantiates a lens flare system.
  52599. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52600. * It is usually composed of several `lensFlare`.
  52601. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52602. * @param name Define the name of the lens flare system in the scene
  52603. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52604. * @param scene Define the scene the lens flare system belongs to
  52605. */
  52606. constructor(
  52607. /**
  52608. * Define the name of the lens flare system
  52609. */
  52610. name: string, emitter: any, scene: Scene);
  52611. /**
  52612. * Define if the lens flare system is enabled.
  52613. */
  52614. isEnabled: boolean;
  52615. /**
  52616. * Get the scene the effects belongs to.
  52617. * @returns the scene holding the lens flare system
  52618. */
  52619. getScene(): Scene;
  52620. /**
  52621. * Get the emitter of the lens flare system.
  52622. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52623. * @returns the emitter of the lens flare system
  52624. */
  52625. getEmitter(): any;
  52626. /**
  52627. * Set the emitter of the lens flare system.
  52628. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52629. * @param newEmitter Define the new emitter of the system
  52630. */
  52631. setEmitter(newEmitter: any): void;
  52632. /**
  52633. * Get the lens flare system emitter position.
  52634. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52635. * @returns the position
  52636. */
  52637. getEmitterPosition(): Vector3;
  52638. /**
  52639. * @hidden
  52640. */
  52641. computeEffectivePosition(globalViewport: Viewport): boolean;
  52642. /** @hidden */
  52643. _isVisible(): boolean;
  52644. /**
  52645. * @hidden
  52646. */
  52647. render(): boolean;
  52648. /**
  52649. * Dispose and release the lens flare with its associated resources.
  52650. */
  52651. dispose(): void;
  52652. /**
  52653. * Parse a lens flare system from a JSON repressentation
  52654. * @param parsedLensFlareSystem Define the JSON to parse
  52655. * @param scene Define the scene the parsed system should be instantiated in
  52656. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52657. * @returns the parsed system
  52658. */
  52659. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52660. /**
  52661. * Serialize the current Lens Flare System into a JSON representation.
  52662. * @returns the serialized JSON
  52663. */
  52664. serialize(): any;
  52665. }
  52666. }
  52667. declare module "babylonjs/LensFlares/lensFlare" {
  52668. import { Nullable } from "babylonjs/types";
  52669. import { Color3 } from "babylonjs/Maths/math.color";
  52670. import { Texture } from "babylonjs/Materials/Textures/texture";
  52671. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52672. /**
  52673. * This represents one of the lens effect in a `lensFlareSystem`.
  52674. * It controls one of the indiviual texture used in the effect.
  52675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52676. */
  52677. export class LensFlare {
  52678. /**
  52679. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52680. */
  52681. size: number;
  52682. /**
  52683. * 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.
  52684. */
  52685. position: number;
  52686. /**
  52687. * Define the lens color.
  52688. */
  52689. color: Color3;
  52690. /**
  52691. * Define the lens texture.
  52692. */
  52693. texture: Nullable<Texture>;
  52694. /**
  52695. * Define the alpha mode to render this particular lens.
  52696. */
  52697. alphaMode: number;
  52698. private _system;
  52699. /**
  52700. * Creates a new Lens Flare.
  52701. * This represents one of the lens effect in a `lensFlareSystem`.
  52702. * It controls one of the indiviual texture used in the effect.
  52703. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52704. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52705. * @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.
  52706. * @param color Define the lens color
  52707. * @param imgUrl Define the lens texture url
  52708. * @param system Define the `lensFlareSystem` this flare is part of
  52709. * @returns The newly created Lens Flare
  52710. */
  52711. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52712. /**
  52713. * Instantiates a new Lens Flare.
  52714. * This represents one of the lens effect in a `lensFlareSystem`.
  52715. * It controls one of the indiviual texture used in the effect.
  52716. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52717. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52718. * @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.
  52719. * @param color Define the lens color
  52720. * @param imgUrl Define the lens texture url
  52721. * @param system Define the `lensFlareSystem` this flare is part of
  52722. */
  52723. constructor(
  52724. /**
  52725. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52726. */
  52727. size: number,
  52728. /**
  52729. * 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.
  52730. */
  52731. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52732. /**
  52733. * Dispose and release the lens flare with its associated resources.
  52734. */
  52735. dispose(): void;
  52736. }
  52737. }
  52738. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52739. import { Nullable } from "babylonjs/types";
  52740. import { Scene } from "babylonjs/scene";
  52741. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52742. import { AbstractScene } from "babylonjs/abstractScene";
  52743. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52744. module "babylonjs/abstractScene" {
  52745. interface AbstractScene {
  52746. /**
  52747. * The list of lens flare system added to the scene
  52748. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52749. */
  52750. lensFlareSystems: Array<LensFlareSystem>;
  52751. /**
  52752. * Removes the given lens flare system from this scene.
  52753. * @param toRemove The lens flare system to remove
  52754. * @returns The index of the removed lens flare system
  52755. */
  52756. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52757. /**
  52758. * Adds the given lens flare system to this scene
  52759. * @param newLensFlareSystem The lens flare system to add
  52760. */
  52761. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52762. /**
  52763. * Gets a lens flare system using its name
  52764. * @param name defines the name to look for
  52765. * @returns the lens flare system or null if not found
  52766. */
  52767. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52768. /**
  52769. * Gets a lens flare system using its id
  52770. * @param id defines the id to look for
  52771. * @returns the lens flare system or null if not found
  52772. */
  52773. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52774. }
  52775. }
  52776. /**
  52777. * Defines the lens flare scene component responsible to manage any lens flares
  52778. * in a given scene.
  52779. */
  52780. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52781. /**
  52782. * The component name helpfull to identify the component in the list of scene components.
  52783. */
  52784. readonly name: string;
  52785. /**
  52786. * The scene the component belongs to.
  52787. */
  52788. scene: Scene;
  52789. /**
  52790. * Creates a new instance of the component for the given scene
  52791. * @param scene Defines the scene to register the component in
  52792. */
  52793. constructor(scene: Scene);
  52794. /**
  52795. * Registers the component in a given scene
  52796. */
  52797. register(): void;
  52798. /**
  52799. * Rebuilds the elements related to this component in case of
  52800. * context lost for instance.
  52801. */
  52802. rebuild(): void;
  52803. /**
  52804. * Adds all the elements from the container to the scene
  52805. * @param container the container holding the elements
  52806. */
  52807. addFromContainer(container: AbstractScene): void;
  52808. /**
  52809. * Removes all the elements in the container from the scene
  52810. * @param container contains the elements to remove
  52811. * @param dispose if the removed element should be disposed (default: false)
  52812. */
  52813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52814. /**
  52815. * Serializes the component data to the specified json object
  52816. * @param serializationObject The object to serialize to
  52817. */
  52818. serialize(serializationObject: any): void;
  52819. /**
  52820. * Disposes the component and the associated ressources.
  52821. */
  52822. dispose(): void;
  52823. private _draw;
  52824. }
  52825. }
  52826. declare module "babylonjs/LensFlares/index" {
  52827. export * from "babylonjs/LensFlares/lensFlare";
  52828. export * from "babylonjs/LensFlares/lensFlareSystem";
  52829. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52830. }
  52831. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52832. import { Scene } from "babylonjs/scene";
  52833. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52834. import { AbstractScene } from "babylonjs/abstractScene";
  52835. /**
  52836. * Defines the shadow generator component responsible to manage any shadow generators
  52837. * in a given scene.
  52838. */
  52839. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52840. /**
  52841. * The component name helpfull to identify the component in the list of scene components.
  52842. */
  52843. readonly name: string;
  52844. /**
  52845. * The scene the component belongs to.
  52846. */
  52847. scene: Scene;
  52848. /**
  52849. * Creates a new instance of the component for the given scene
  52850. * @param scene Defines the scene to register the component in
  52851. */
  52852. constructor(scene: Scene);
  52853. /**
  52854. * Registers the component in a given scene
  52855. */
  52856. register(): void;
  52857. /**
  52858. * Rebuilds the elements related to this component in case of
  52859. * context lost for instance.
  52860. */
  52861. rebuild(): void;
  52862. /**
  52863. * Serializes the component data to the specified json object
  52864. * @param serializationObject The object to serialize to
  52865. */
  52866. serialize(serializationObject: any): void;
  52867. /**
  52868. * Adds all the elements from the container to the scene
  52869. * @param container the container holding the elements
  52870. */
  52871. addFromContainer(container: AbstractScene): void;
  52872. /**
  52873. * Removes all the elements in the container from the scene
  52874. * @param container contains the elements to remove
  52875. * @param dispose if the removed element should be disposed (default: false)
  52876. */
  52877. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52878. /**
  52879. * Rebuilds the elements related to this component in case of
  52880. * context lost for instance.
  52881. */
  52882. dispose(): void;
  52883. private _gatherRenderTargets;
  52884. }
  52885. }
  52886. declare module "babylonjs/Lights/Shadows/index" {
  52887. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52888. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52889. }
  52890. declare module "babylonjs/Lights/pointLight" {
  52891. import { Scene } from "babylonjs/scene";
  52892. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52894. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52895. import { Effect } from "babylonjs/Materials/effect";
  52896. /**
  52897. * A point light is a light defined by an unique point in world space.
  52898. * The light is emitted in every direction from this point.
  52899. * A good example of a point light is a standard light bulb.
  52900. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52901. */
  52902. export class PointLight extends ShadowLight {
  52903. private _shadowAngle;
  52904. /**
  52905. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52906. * This specifies what angle the shadow will use to be created.
  52907. *
  52908. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52909. */
  52910. /**
  52911. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52912. * This specifies what angle the shadow will use to be created.
  52913. *
  52914. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52915. */
  52916. shadowAngle: number;
  52917. /**
  52918. * Gets the direction if it has been set.
  52919. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52920. */
  52921. /**
  52922. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52923. */
  52924. direction: Vector3;
  52925. /**
  52926. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52927. * A PointLight emits the light in every direction.
  52928. * It can cast shadows.
  52929. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52930. * ```javascript
  52931. * var pointLight = new PointLight("pl", camera.position, scene);
  52932. * ```
  52933. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52934. * @param name The light friendly name
  52935. * @param position The position of the point light in the scene
  52936. * @param scene The scene the lights belongs to
  52937. */
  52938. constructor(name: string, position: Vector3, scene: Scene);
  52939. /**
  52940. * Returns the string "PointLight"
  52941. * @returns the class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Returns the integer 0.
  52946. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52947. */
  52948. getTypeID(): number;
  52949. /**
  52950. * Specifies wether or not the shadowmap should be a cube texture.
  52951. * @returns true if the shadowmap needs to be a cube texture.
  52952. */
  52953. needCube(): boolean;
  52954. /**
  52955. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52956. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52957. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52958. */
  52959. getShadowDirection(faceIndex?: number): Vector3;
  52960. /**
  52961. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52962. * - fov = PI / 2
  52963. * - aspect ratio : 1.0
  52964. * - z-near and far equal to the active camera minZ and maxZ.
  52965. * Returns the PointLight.
  52966. */
  52967. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52968. protected _buildUniformLayout(): void;
  52969. /**
  52970. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52971. * @param effect The effect to update
  52972. * @param lightIndex The index of the light in the effect to update
  52973. * @returns The point light
  52974. */
  52975. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52976. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52977. /**
  52978. * Prepares the list of defines specific to the light type.
  52979. * @param defines the list of defines
  52980. * @param lightIndex defines the index of the light for the effect
  52981. */
  52982. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52983. }
  52984. }
  52985. declare module "babylonjs/Lights/index" {
  52986. export * from "babylonjs/Lights/light";
  52987. export * from "babylonjs/Lights/shadowLight";
  52988. export * from "babylonjs/Lights/Shadows/index";
  52989. export * from "babylonjs/Lights/directionalLight";
  52990. export * from "babylonjs/Lights/hemisphericLight";
  52991. export * from "babylonjs/Lights/pointLight";
  52992. export * from "babylonjs/Lights/spotLight";
  52993. }
  52994. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52996. /**
  52997. * Header information of HDR texture files.
  52998. */
  52999. export interface HDRInfo {
  53000. /**
  53001. * The height of the texture in pixels.
  53002. */
  53003. height: number;
  53004. /**
  53005. * The width of the texture in pixels.
  53006. */
  53007. width: number;
  53008. /**
  53009. * The index of the beginning of the data in the binary file.
  53010. */
  53011. dataPosition: number;
  53012. }
  53013. /**
  53014. * This groups tools to convert HDR texture to native colors array.
  53015. */
  53016. export class HDRTools {
  53017. private static Ldexp;
  53018. private static Rgbe2float;
  53019. private static readStringLine;
  53020. /**
  53021. * Reads header information from an RGBE texture stored in a native array.
  53022. * More information on this format are available here:
  53023. * https://en.wikipedia.org/wiki/RGBE_image_format
  53024. *
  53025. * @param uint8array The binary file stored in native array.
  53026. * @return The header information.
  53027. */
  53028. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53029. /**
  53030. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53031. * This RGBE texture needs to store the information as a panorama.
  53032. *
  53033. * More information on this format are available here:
  53034. * https://en.wikipedia.org/wiki/RGBE_image_format
  53035. *
  53036. * @param buffer The binary file stored in an array buffer.
  53037. * @param size The expected size of the extracted cubemap.
  53038. * @return The Cube Map information.
  53039. */
  53040. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53041. /**
  53042. * Returns the pixels data extracted from an RGBE texture.
  53043. * This pixels will be stored left to right up to down in the R G B order in one array.
  53044. *
  53045. * More information on this format are available here:
  53046. * https://en.wikipedia.org/wiki/RGBE_image_format
  53047. *
  53048. * @param uint8array The binary file stored in an array buffer.
  53049. * @param hdrInfo The header information of the file.
  53050. * @return The pixels data in RGB right to left up to down order.
  53051. */
  53052. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53053. private static RGBE_ReadPixels_RLE;
  53054. }
  53055. }
  53056. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53057. import { Nullable } from "babylonjs/types";
  53058. import { Scene } from "babylonjs/scene";
  53059. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53061. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53062. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53063. /**
  53064. * This represents a texture coming from an HDR input.
  53065. *
  53066. * The only supported format is currently panorama picture stored in RGBE format.
  53067. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53068. */
  53069. export class HDRCubeTexture extends BaseTexture {
  53070. private static _facesMapping;
  53071. private _generateHarmonics;
  53072. private _noMipmap;
  53073. private _textureMatrix;
  53074. private _size;
  53075. private _onLoad;
  53076. private _onError;
  53077. /**
  53078. * The texture URL.
  53079. */
  53080. url: string;
  53081. /**
  53082. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53083. */
  53084. coordinatesMode: number;
  53085. protected _isBlocking: boolean;
  53086. /**
  53087. * Sets wether or not the texture is blocking during loading.
  53088. */
  53089. /**
  53090. * Gets wether or not the texture is blocking during loading.
  53091. */
  53092. isBlocking: boolean;
  53093. protected _rotationY: number;
  53094. /**
  53095. * Sets texture matrix rotation angle around Y axis in radians.
  53096. */
  53097. /**
  53098. * Gets texture matrix rotation angle around Y axis radians.
  53099. */
  53100. rotationY: number;
  53101. /**
  53102. * Gets or sets the center of the bounding box associated with the cube texture
  53103. * It must define where the camera used to render the texture was set
  53104. */
  53105. boundingBoxPosition: Vector3;
  53106. private _boundingBoxSize;
  53107. /**
  53108. * Gets or sets the size of the bounding box associated with the cube texture
  53109. * When defined, the cubemap will switch to local mode
  53110. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53111. * @example https://www.babylonjs-playground.com/#RNASML
  53112. */
  53113. boundingBoxSize: Vector3;
  53114. /**
  53115. * Instantiates an HDRTexture from the following parameters.
  53116. *
  53117. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53118. * @param scene The scene the texture will be used in
  53119. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53120. * @param noMipmap Forces to not generate the mipmap if true
  53121. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53122. * @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)
  53123. * @param reserved Reserved flag for internal use.
  53124. */
  53125. 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>);
  53126. /**
  53127. * Get the current class name of the texture useful for serialization or dynamic coding.
  53128. * @returns "HDRCubeTexture"
  53129. */
  53130. getClassName(): string;
  53131. /**
  53132. * Occurs when the file is raw .hdr file.
  53133. */
  53134. private loadTexture;
  53135. clone(): HDRCubeTexture;
  53136. delayLoad(): void;
  53137. /**
  53138. * Get the texture reflection matrix used to rotate/transform the reflection.
  53139. * @returns the reflection matrix
  53140. */
  53141. getReflectionTextureMatrix(): Matrix;
  53142. /**
  53143. * Set the texture reflection matrix used to rotate/transform the reflection.
  53144. * @param value Define the reflection matrix to set
  53145. */
  53146. setReflectionTextureMatrix(value: Matrix): void;
  53147. /**
  53148. * Parses a JSON representation of an HDR Texture in order to create the texture
  53149. * @param parsedTexture Define the JSON representation
  53150. * @param scene Define the scene the texture should be created in
  53151. * @param rootUrl Define the root url in case we need to load relative dependencies
  53152. * @returns the newly created texture after parsing
  53153. */
  53154. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53155. serialize(): any;
  53156. }
  53157. }
  53158. declare module "babylonjs/Physics/physicsEngine" {
  53159. import { Nullable } from "babylonjs/types";
  53160. import { Vector3 } from "babylonjs/Maths/math.vector";
  53161. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53162. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53163. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53164. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53165. /**
  53166. * Class used to control physics engine
  53167. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53168. */
  53169. export class PhysicsEngine implements IPhysicsEngine {
  53170. private _physicsPlugin;
  53171. /**
  53172. * Global value used to control the smallest number supported by the simulation
  53173. */
  53174. static Epsilon: number;
  53175. private _impostors;
  53176. private _joints;
  53177. /**
  53178. * Gets the gravity vector used by the simulation
  53179. */
  53180. gravity: Vector3;
  53181. /**
  53182. * Factory used to create the default physics plugin.
  53183. * @returns The default physics plugin
  53184. */
  53185. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53186. /**
  53187. * Creates a new Physics Engine
  53188. * @param gravity defines the gravity vector used by the simulation
  53189. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53190. */
  53191. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53192. /**
  53193. * Sets the gravity vector used by the simulation
  53194. * @param gravity defines the gravity vector to use
  53195. */
  53196. setGravity(gravity: Vector3): void;
  53197. /**
  53198. * Set the time step of the physics engine.
  53199. * Default is 1/60.
  53200. * To slow it down, enter 1/600 for example.
  53201. * To speed it up, 1/30
  53202. * @param newTimeStep defines the new timestep to apply to this world.
  53203. */
  53204. setTimeStep(newTimeStep?: number): void;
  53205. /**
  53206. * Get the time step of the physics engine.
  53207. * @returns the current time step
  53208. */
  53209. getTimeStep(): number;
  53210. /**
  53211. * Release all resources
  53212. */
  53213. dispose(): void;
  53214. /**
  53215. * Gets the name of the current physics plugin
  53216. * @returns the name of the plugin
  53217. */
  53218. getPhysicsPluginName(): string;
  53219. /**
  53220. * Adding a new impostor for the impostor tracking.
  53221. * This will be done by the impostor itself.
  53222. * @param impostor the impostor to add
  53223. */
  53224. addImpostor(impostor: PhysicsImpostor): void;
  53225. /**
  53226. * Remove an impostor from the engine.
  53227. * This impostor and its mesh will not longer be updated by the physics engine.
  53228. * @param impostor the impostor to remove
  53229. */
  53230. removeImpostor(impostor: PhysicsImpostor): void;
  53231. /**
  53232. * Add a joint to the physics engine
  53233. * @param mainImpostor defines the main impostor to which the joint is added.
  53234. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53235. * @param joint defines the joint that will connect both impostors.
  53236. */
  53237. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53238. /**
  53239. * Removes a joint from the simulation
  53240. * @param mainImpostor defines the impostor used with the joint
  53241. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53242. * @param joint defines the joint to remove
  53243. */
  53244. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53245. /**
  53246. * Called by the scene. No need to call it.
  53247. * @param delta defines the timespam between frames
  53248. */
  53249. _step(delta: number): void;
  53250. /**
  53251. * Gets the current plugin used to run the simulation
  53252. * @returns current plugin
  53253. */
  53254. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53255. /**
  53256. * Gets the list of physic impostors
  53257. * @returns an array of PhysicsImpostor
  53258. */
  53259. getImpostors(): Array<PhysicsImpostor>;
  53260. /**
  53261. * Gets the impostor for a physics enabled object
  53262. * @param object defines the object impersonated by the impostor
  53263. * @returns the PhysicsImpostor or null if not found
  53264. */
  53265. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53266. /**
  53267. * Gets the impostor for a physics body object
  53268. * @param body defines physics body used by the impostor
  53269. * @returns the PhysicsImpostor or null if not found
  53270. */
  53271. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53272. /**
  53273. * Does a raycast in the physics world
  53274. * @param from when should the ray start?
  53275. * @param to when should the ray end?
  53276. * @returns PhysicsRaycastResult
  53277. */
  53278. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53279. }
  53280. }
  53281. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53282. import { Nullable } from "babylonjs/types";
  53283. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53285. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53286. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53287. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53288. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53289. /** @hidden */
  53290. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53291. private _useDeltaForWorldStep;
  53292. world: any;
  53293. name: string;
  53294. private _physicsMaterials;
  53295. private _fixedTimeStep;
  53296. private _cannonRaycastResult;
  53297. private _raycastResult;
  53298. private _physicsBodysToRemoveAfterStep;
  53299. BJSCANNON: any;
  53300. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53301. setGravity(gravity: Vector3): void;
  53302. setTimeStep(timeStep: number): void;
  53303. getTimeStep(): number;
  53304. executeStep(delta: number): void;
  53305. private _removeMarkedPhysicsBodiesFromWorld;
  53306. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53307. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53308. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53309. private _processChildMeshes;
  53310. removePhysicsBody(impostor: PhysicsImpostor): void;
  53311. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53312. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53313. private _addMaterial;
  53314. private _checkWithEpsilon;
  53315. private _createShape;
  53316. private _createHeightmap;
  53317. private _minus90X;
  53318. private _plus90X;
  53319. private _tmpPosition;
  53320. private _tmpDeltaPosition;
  53321. private _tmpUnityRotation;
  53322. private _updatePhysicsBodyTransformation;
  53323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53324. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53325. isSupported(): boolean;
  53326. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53327. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53328. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53331. getBodyMass(impostor: PhysicsImpostor): number;
  53332. getBodyFriction(impostor: PhysicsImpostor): number;
  53333. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53334. getBodyRestitution(impostor: PhysicsImpostor): number;
  53335. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53336. sleepBody(impostor: PhysicsImpostor): void;
  53337. wakeUpBody(impostor: PhysicsImpostor): void;
  53338. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53339. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53340. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53341. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53342. getRadius(impostor: PhysicsImpostor): number;
  53343. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53344. dispose(): void;
  53345. private _extendNamespace;
  53346. /**
  53347. * Does a raycast in the physics world
  53348. * @param from when should the ray start?
  53349. * @param to when should the ray end?
  53350. * @returns PhysicsRaycastResult
  53351. */
  53352. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53353. }
  53354. }
  53355. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53356. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53357. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53358. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53360. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53361. import { Nullable } from "babylonjs/types";
  53362. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53363. /** @hidden */
  53364. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53365. world: any;
  53366. name: string;
  53367. BJSOIMO: any;
  53368. private _raycastResult;
  53369. constructor(iterations?: number, oimoInjection?: any);
  53370. setGravity(gravity: Vector3): void;
  53371. setTimeStep(timeStep: number): void;
  53372. getTimeStep(): number;
  53373. private _tmpImpostorsArray;
  53374. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53375. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53376. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53377. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53378. private _tmpPositionVector;
  53379. removePhysicsBody(impostor: PhysicsImpostor): void;
  53380. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53381. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53382. isSupported(): boolean;
  53383. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53384. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53385. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53386. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53387. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53388. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53389. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53390. getBodyMass(impostor: PhysicsImpostor): number;
  53391. getBodyFriction(impostor: PhysicsImpostor): number;
  53392. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53393. getBodyRestitution(impostor: PhysicsImpostor): number;
  53394. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53395. sleepBody(impostor: PhysicsImpostor): void;
  53396. wakeUpBody(impostor: PhysicsImpostor): void;
  53397. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53398. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53399. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53400. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53401. getRadius(impostor: PhysicsImpostor): number;
  53402. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53403. dispose(): void;
  53404. /**
  53405. * Does a raycast in the physics world
  53406. * @param from when should the ray start?
  53407. * @param to when should the ray end?
  53408. * @returns PhysicsRaycastResult
  53409. */
  53410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53411. }
  53412. }
  53413. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53414. import { Nullable } from "babylonjs/types";
  53415. import { Scene } from "babylonjs/scene";
  53416. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53417. import { Color4 } from "babylonjs/Maths/math.color";
  53418. import { Mesh } from "babylonjs/Meshes/mesh";
  53419. /**
  53420. * Class containing static functions to help procedurally build meshes
  53421. */
  53422. export class RibbonBuilder {
  53423. /**
  53424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53428. * * 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
  53429. * * 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
  53430. * * 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
  53431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53434. * * 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
  53435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53436. * * 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
  53437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53439. * @param name defines the name of the mesh
  53440. * @param options defines the options used to create the mesh
  53441. * @param scene defines the hosting scene
  53442. * @returns the ribbon mesh
  53443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53445. */
  53446. static CreateRibbon(name: string, options: {
  53447. pathArray: Vector3[][];
  53448. closeArray?: boolean;
  53449. closePath?: boolean;
  53450. offset?: number;
  53451. updatable?: boolean;
  53452. sideOrientation?: number;
  53453. frontUVs?: Vector4;
  53454. backUVs?: Vector4;
  53455. instance?: Mesh;
  53456. invertUV?: boolean;
  53457. uvs?: Vector2[];
  53458. colors?: Color4[];
  53459. }, scene?: Nullable<Scene>): Mesh;
  53460. }
  53461. }
  53462. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53463. import { Nullable } from "babylonjs/types";
  53464. import { Scene } from "babylonjs/scene";
  53465. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53466. import { Mesh } from "babylonjs/Meshes/mesh";
  53467. /**
  53468. * Class containing static functions to help procedurally build meshes
  53469. */
  53470. export class ShapeBuilder {
  53471. /**
  53472. * 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.
  53473. * * 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.
  53474. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53475. * * 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.
  53476. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53477. * * 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
  53478. * * 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
  53479. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53482. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53484. * @param name defines the name of the mesh
  53485. * @param options defines the options used to create the mesh
  53486. * @param scene defines the hosting scene
  53487. * @returns the extruded shape mesh
  53488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53490. */
  53491. static ExtrudeShape(name: string, options: {
  53492. shape: Vector3[];
  53493. path: Vector3[];
  53494. scale?: number;
  53495. rotation?: number;
  53496. cap?: number;
  53497. updatable?: boolean;
  53498. sideOrientation?: number;
  53499. frontUVs?: Vector4;
  53500. backUVs?: Vector4;
  53501. instance?: Mesh;
  53502. invertUV?: boolean;
  53503. }, scene?: Nullable<Scene>): Mesh;
  53504. /**
  53505. * Creates an custom extruded shape mesh.
  53506. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53507. * * 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.
  53508. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53509. * * 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
  53510. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53511. * * 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
  53512. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53513. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53514. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53515. * * 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
  53516. * * 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
  53517. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53520. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53522. * @param name defines the name of the mesh
  53523. * @param options defines the options used to create the mesh
  53524. * @param scene defines the hosting scene
  53525. * @returns the custom extruded shape mesh
  53526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53527. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53529. */
  53530. static ExtrudeShapeCustom(name: string, options: {
  53531. shape: Vector3[];
  53532. path: Vector3[];
  53533. scaleFunction?: any;
  53534. rotationFunction?: any;
  53535. ribbonCloseArray?: boolean;
  53536. ribbonClosePath?: boolean;
  53537. cap?: number;
  53538. updatable?: boolean;
  53539. sideOrientation?: number;
  53540. frontUVs?: Vector4;
  53541. backUVs?: Vector4;
  53542. instance?: Mesh;
  53543. invertUV?: boolean;
  53544. }, scene?: Nullable<Scene>): Mesh;
  53545. private static _ExtrudeShapeGeneric;
  53546. }
  53547. }
  53548. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53549. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53550. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53551. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53552. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53553. import { Nullable } from "babylonjs/types";
  53554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53555. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53556. /**
  53557. * AmmoJS Physics plugin
  53558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53559. * @see https://github.com/kripken/ammo.js/
  53560. */
  53561. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53562. private _useDeltaForWorldStep;
  53563. /**
  53564. * Reference to the Ammo library
  53565. */
  53566. bjsAMMO: any;
  53567. /**
  53568. * Created ammoJS world which physics bodies are added to
  53569. */
  53570. world: any;
  53571. /**
  53572. * Name of the plugin
  53573. */
  53574. name: string;
  53575. private _timeStep;
  53576. private _fixedTimeStep;
  53577. private _maxSteps;
  53578. private _tmpQuaternion;
  53579. private _tmpAmmoTransform;
  53580. private _tmpAmmoQuaternion;
  53581. private _tmpAmmoConcreteContactResultCallback;
  53582. private _collisionConfiguration;
  53583. private _dispatcher;
  53584. private _overlappingPairCache;
  53585. private _solver;
  53586. private _softBodySolver;
  53587. private _tmpAmmoVectorA;
  53588. private _tmpAmmoVectorB;
  53589. private _tmpAmmoVectorC;
  53590. private _tmpAmmoVectorD;
  53591. private _tmpContactCallbackResult;
  53592. private _tmpAmmoVectorRCA;
  53593. private _tmpAmmoVectorRCB;
  53594. private _raycastResult;
  53595. private static readonly DISABLE_COLLISION_FLAG;
  53596. private static readonly KINEMATIC_FLAG;
  53597. private static readonly DISABLE_DEACTIVATION_FLAG;
  53598. /**
  53599. * Initializes the ammoJS plugin
  53600. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53601. * @param ammoInjection can be used to inject your own ammo reference
  53602. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53603. */
  53604. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53605. /**
  53606. * Sets the gravity of the physics world (m/(s^2))
  53607. * @param gravity Gravity to set
  53608. */
  53609. setGravity(gravity: Vector3): void;
  53610. /**
  53611. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53612. * @param timeStep timestep to use in seconds
  53613. */
  53614. setTimeStep(timeStep: number): void;
  53615. /**
  53616. * 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)
  53617. * @param fixedTimeStep fixedTimeStep to use in seconds
  53618. */
  53619. setFixedTimeStep(fixedTimeStep: number): void;
  53620. /**
  53621. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53622. * @param maxSteps the maximum number of steps by the physics engine per frame
  53623. */
  53624. setMaxSteps(maxSteps: number): void;
  53625. /**
  53626. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53627. * @returns the current timestep in seconds
  53628. */
  53629. getTimeStep(): number;
  53630. private _isImpostorInContact;
  53631. private _isImpostorPairInContact;
  53632. private _stepSimulation;
  53633. /**
  53634. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53635. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53636. * After the step the babylon meshes are set to the position of the physics imposters
  53637. * @param delta amount of time to step forward
  53638. * @param impostors array of imposters to update before/after the step
  53639. */
  53640. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53641. /**
  53642. * Update babylon mesh to match physics world object
  53643. * @param impostor imposter to match
  53644. */
  53645. private _afterSoftStep;
  53646. /**
  53647. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53648. * @param impostor imposter to match
  53649. */
  53650. private _ropeStep;
  53651. /**
  53652. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53653. * @param impostor imposter to match
  53654. */
  53655. private _softbodyOrClothStep;
  53656. private _tmpVector;
  53657. private _tmpMatrix;
  53658. /**
  53659. * Applies an impulse on the imposter
  53660. * @param impostor imposter to apply impulse to
  53661. * @param force amount of force to be applied to the imposter
  53662. * @param contactPoint the location to apply the impulse on the imposter
  53663. */
  53664. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53665. /**
  53666. * Applies a force on the imposter
  53667. * @param impostor imposter to apply force
  53668. * @param force amount of force to be applied to the imposter
  53669. * @param contactPoint the location to apply the force on the imposter
  53670. */
  53671. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53672. /**
  53673. * Creates a physics body using the plugin
  53674. * @param impostor the imposter to create the physics body on
  53675. */
  53676. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53677. /**
  53678. * Removes the physics body from the imposter and disposes of the body's memory
  53679. * @param impostor imposter to remove the physics body from
  53680. */
  53681. removePhysicsBody(impostor: PhysicsImpostor): void;
  53682. /**
  53683. * Generates a joint
  53684. * @param impostorJoint the imposter joint to create the joint with
  53685. */
  53686. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53687. /**
  53688. * Removes a joint
  53689. * @param impostorJoint the imposter joint to remove the joint from
  53690. */
  53691. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53692. private _addMeshVerts;
  53693. /**
  53694. * Initialise the soft body vertices to match its object's (mesh) vertices
  53695. * Softbody vertices (nodes) are in world space and to match this
  53696. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53697. * @param impostor to create the softbody for
  53698. */
  53699. private _softVertexData;
  53700. /**
  53701. * Create an impostor's soft body
  53702. * @param impostor to create the softbody for
  53703. */
  53704. private _createSoftbody;
  53705. /**
  53706. * Create cloth for an impostor
  53707. * @param impostor to create the softbody for
  53708. */
  53709. private _createCloth;
  53710. /**
  53711. * Create rope for an impostor
  53712. * @param impostor to create the softbody for
  53713. */
  53714. private _createRope;
  53715. private _addHullVerts;
  53716. private _createShape;
  53717. /**
  53718. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53719. * @param impostor imposter containing the physics body and babylon object
  53720. */
  53721. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53722. /**
  53723. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53724. * @param impostor imposter containing the physics body and babylon object
  53725. * @param newPosition new position
  53726. * @param newRotation new rotation
  53727. */
  53728. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53729. /**
  53730. * If this plugin is supported
  53731. * @returns true if its supported
  53732. */
  53733. isSupported(): boolean;
  53734. /**
  53735. * Sets the linear velocity of the physics body
  53736. * @param impostor imposter to set the velocity on
  53737. * @param velocity velocity to set
  53738. */
  53739. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53740. /**
  53741. * Sets the angular velocity of the physics body
  53742. * @param impostor imposter to set the velocity on
  53743. * @param velocity velocity to set
  53744. */
  53745. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53746. /**
  53747. * gets the linear velocity
  53748. * @param impostor imposter to get linear velocity from
  53749. * @returns linear velocity
  53750. */
  53751. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53752. /**
  53753. * gets the angular velocity
  53754. * @param impostor imposter to get angular velocity from
  53755. * @returns angular velocity
  53756. */
  53757. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53758. /**
  53759. * Sets the mass of physics body
  53760. * @param impostor imposter to set the mass on
  53761. * @param mass mass to set
  53762. */
  53763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53764. /**
  53765. * Gets the mass of the physics body
  53766. * @param impostor imposter to get the mass from
  53767. * @returns mass
  53768. */
  53769. getBodyMass(impostor: PhysicsImpostor): number;
  53770. /**
  53771. * Gets friction of the impostor
  53772. * @param impostor impostor to get friction from
  53773. * @returns friction value
  53774. */
  53775. getBodyFriction(impostor: PhysicsImpostor): number;
  53776. /**
  53777. * Sets friction of the impostor
  53778. * @param impostor impostor to set friction on
  53779. * @param friction friction value
  53780. */
  53781. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53782. /**
  53783. * Gets restitution of the impostor
  53784. * @param impostor impostor to get restitution from
  53785. * @returns restitution value
  53786. */
  53787. getBodyRestitution(impostor: PhysicsImpostor): number;
  53788. /**
  53789. * Sets resitution of the impostor
  53790. * @param impostor impostor to set resitution on
  53791. * @param restitution resitution value
  53792. */
  53793. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53794. /**
  53795. * Gets pressure inside the impostor
  53796. * @param impostor impostor to get pressure from
  53797. * @returns pressure value
  53798. */
  53799. getBodyPressure(impostor: PhysicsImpostor): number;
  53800. /**
  53801. * Sets pressure inside a soft body impostor
  53802. * Cloth and rope must remain 0 pressure
  53803. * @param impostor impostor to set pressure on
  53804. * @param pressure pressure value
  53805. */
  53806. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53807. /**
  53808. * Gets stiffness of the impostor
  53809. * @param impostor impostor to get stiffness from
  53810. * @returns pressure value
  53811. */
  53812. getBodyStiffness(impostor: PhysicsImpostor): number;
  53813. /**
  53814. * Sets stiffness of the impostor
  53815. * @param impostor impostor to set stiffness on
  53816. * @param stiffness stiffness value from 0 to 1
  53817. */
  53818. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53819. /**
  53820. * Gets velocityIterations of the impostor
  53821. * @param impostor impostor to get velocity iterations from
  53822. * @returns velocityIterations value
  53823. */
  53824. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53825. /**
  53826. * Sets velocityIterations of the impostor
  53827. * @param impostor impostor to set velocity iterations on
  53828. * @param velocityIterations velocityIterations value
  53829. */
  53830. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53831. /**
  53832. * Gets positionIterations of the impostor
  53833. * @param impostor impostor to get position iterations from
  53834. * @returns positionIterations value
  53835. */
  53836. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53837. /**
  53838. * Sets positionIterations of the impostor
  53839. * @param impostor impostor to set position on
  53840. * @param positionIterations positionIterations value
  53841. */
  53842. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53843. /**
  53844. * Append an anchor to a cloth object
  53845. * @param impostor is the cloth impostor to add anchor to
  53846. * @param otherImpostor is the rigid impostor to anchor to
  53847. * @param width ratio across width from 0 to 1
  53848. * @param height ratio up height from 0 to 1
  53849. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53850. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53851. */
  53852. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53853. /**
  53854. * Append an hook to a rope object
  53855. * @param impostor is the rope impostor to add hook to
  53856. * @param otherImpostor is the rigid impostor to hook to
  53857. * @param length ratio along the rope from 0 to 1
  53858. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53859. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53860. */
  53861. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53862. /**
  53863. * Sleeps the physics body and stops it from being active
  53864. * @param impostor impostor to sleep
  53865. */
  53866. sleepBody(impostor: PhysicsImpostor): void;
  53867. /**
  53868. * Activates the physics body
  53869. * @param impostor impostor to activate
  53870. */
  53871. wakeUpBody(impostor: PhysicsImpostor): void;
  53872. /**
  53873. * Updates the distance parameters of the joint
  53874. * @param joint joint to update
  53875. * @param maxDistance maximum distance of the joint
  53876. * @param minDistance minimum distance of the joint
  53877. */
  53878. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53879. /**
  53880. * Sets a motor on the joint
  53881. * @param joint joint to set motor on
  53882. * @param speed speed of the motor
  53883. * @param maxForce maximum force of the motor
  53884. * @param motorIndex index of the motor
  53885. */
  53886. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53887. /**
  53888. * Sets the motors limit
  53889. * @param joint joint to set limit on
  53890. * @param upperLimit upper limit
  53891. * @param lowerLimit lower limit
  53892. */
  53893. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53894. /**
  53895. * Syncs the position and rotation of a mesh with the impostor
  53896. * @param mesh mesh to sync
  53897. * @param impostor impostor to update the mesh with
  53898. */
  53899. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53900. /**
  53901. * Gets the radius of the impostor
  53902. * @param impostor impostor to get radius from
  53903. * @returns the radius
  53904. */
  53905. getRadius(impostor: PhysicsImpostor): number;
  53906. /**
  53907. * Gets the box size of the impostor
  53908. * @param impostor impostor to get box size from
  53909. * @param result the resulting box size
  53910. */
  53911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53912. /**
  53913. * Disposes of the impostor
  53914. */
  53915. dispose(): void;
  53916. /**
  53917. * Does a raycast in the physics world
  53918. * @param from when should the ray start?
  53919. * @param to when should the ray end?
  53920. * @returns PhysicsRaycastResult
  53921. */
  53922. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53923. }
  53924. }
  53925. declare module "babylonjs/Probes/reflectionProbe" {
  53926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53927. import { Vector3 } from "babylonjs/Maths/math.vector";
  53928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53929. import { Nullable } from "babylonjs/types";
  53930. import { Scene } from "babylonjs/scene";
  53931. module "babylonjs/abstractScene" {
  53932. interface AbstractScene {
  53933. /**
  53934. * The list of reflection probes added to the scene
  53935. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53936. */
  53937. reflectionProbes: Array<ReflectionProbe>;
  53938. /**
  53939. * Removes the given reflection probe from this scene.
  53940. * @param toRemove The reflection probe to remove
  53941. * @returns The index of the removed reflection probe
  53942. */
  53943. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53944. /**
  53945. * Adds the given reflection probe to this scene.
  53946. * @param newReflectionProbe The reflection probe to add
  53947. */
  53948. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53949. }
  53950. }
  53951. /**
  53952. * Class used to generate realtime reflection / refraction cube textures
  53953. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53954. */
  53955. export class ReflectionProbe {
  53956. /** defines the name of the probe */
  53957. name: string;
  53958. private _scene;
  53959. private _renderTargetTexture;
  53960. private _projectionMatrix;
  53961. private _viewMatrix;
  53962. private _target;
  53963. private _add;
  53964. private _attachedMesh;
  53965. private _invertYAxis;
  53966. /** Gets or sets probe position (center of the cube map) */
  53967. position: Vector3;
  53968. /**
  53969. * Creates a new reflection probe
  53970. * @param name defines the name of the probe
  53971. * @param size defines the texture resolution (for each face)
  53972. * @param scene defines the hosting scene
  53973. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53974. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53975. */
  53976. constructor(
  53977. /** defines the name of the probe */
  53978. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53979. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53980. samples: number;
  53981. /** Gets or sets the refresh rate to use (on every frame by default) */
  53982. refreshRate: number;
  53983. /**
  53984. * Gets the hosting scene
  53985. * @returns a Scene
  53986. */
  53987. getScene(): Scene;
  53988. /** Gets the internal CubeTexture used to render to */
  53989. readonly cubeTexture: RenderTargetTexture;
  53990. /** Gets the list of meshes to render */
  53991. readonly renderList: Nullable<AbstractMesh[]>;
  53992. /**
  53993. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53994. * @param mesh defines the mesh to attach to
  53995. */
  53996. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53997. /**
  53998. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53999. * @param renderingGroupId The rendering group id corresponding to its index
  54000. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54001. */
  54002. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54003. /**
  54004. * Clean all associated resources
  54005. */
  54006. dispose(): void;
  54007. /**
  54008. * Converts the reflection probe information to a readable string for debug purpose.
  54009. * @param fullDetails Supports for multiple levels of logging within scene loading
  54010. * @returns the human readable reflection probe info
  54011. */
  54012. toString(fullDetails?: boolean): string;
  54013. /**
  54014. * Get the class name of the relfection probe.
  54015. * @returns "ReflectionProbe"
  54016. */
  54017. getClassName(): string;
  54018. /**
  54019. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54020. * @returns The JSON representation of the texture
  54021. */
  54022. serialize(): any;
  54023. /**
  54024. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54025. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54026. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54027. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54028. * @returns The parsed reflection probe if successful
  54029. */
  54030. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54031. }
  54032. }
  54033. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54034. /** @hidden */
  54035. export var _BabylonLoaderRegistered: boolean;
  54036. }
  54037. declare module "babylonjs/Loading/Plugins/index" {
  54038. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54039. }
  54040. declare module "babylonjs/Loading/index" {
  54041. export * from "babylonjs/Loading/loadingScreen";
  54042. export * from "babylonjs/Loading/Plugins/index";
  54043. export * from "babylonjs/Loading/sceneLoader";
  54044. export * from "babylonjs/Loading/sceneLoaderFlags";
  54045. }
  54046. declare module "babylonjs/Materials/Background/index" {
  54047. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54048. }
  54049. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54050. import { Scene } from "babylonjs/scene";
  54051. import { Color3 } from "babylonjs/Maths/math.color";
  54052. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54053. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54054. /**
  54055. * The Physically based simple base material of BJS.
  54056. *
  54057. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54058. * It is used as the base class for both the specGloss and metalRough conventions.
  54059. */
  54060. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54061. /**
  54062. * Number of Simultaneous lights allowed on the material.
  54063. */
  54064. maxSimultaneousLights: number;
  54065. /**
  54066. * If sets to true, disables all the lights affecting the material.
  54067. */
  54068. disableLighting: boolean;
  54069. /**
  54070. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54071. */
  54072. environmentTexture: BaseTexture;
  54073. /**
  54074. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54075. */
  54076. invertNormalMapX: boolean;
  54077. /**
  54078. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54079. */
  54080. invertNormalMapY: boolean;
  54081. /**
  54082. * Normal map used in the model.
  54083. */
  54084. normalTexture: BaseTexture;
  54085. /**
  54086. * Emissivie color used to self-illuminate the model.
  54087. */
  54088. emissiveColor: Color3;
  54089. /**
  54090. * Emissivie texture used to self-illuminate the model.
  54091. */
  54092. emissiveTexture: BaseTexture;
  54093. /**
  54094. * Occlusion Channel Strenght.
  54095. */
  54096. occlusionStrength: number;
  54097. /**
  54098. * Occlusion Texture of the material (adding extra occlusion effects).
  54099. */
  54100. occlusionTexture: BaseTexture;
  54101. /**
  54102. * Defines the alpha limits in alpha test mode.
  54103. */
  54104. alphaCutOff: number;
  54105. /**
  54106. * Gets the current double sided mode.
  54107. */
  54108. /**
  54109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54110. */
  54111. doubleSided: boolean;
  54112. /**
  54113. * Stores the pre-calculated light information of a mesh in a texture.
  54114. */
  54115. lightmapTexture: BaseTexture;
  54116. /**
  54117. * If true, the light map contains occlusion information instead of lighting info.
  54118. */
  54119. useLightmapAsShadowmap: boolean;
  54120. /**
  54121. * Instantiates a new PBRMaterial instance.
  54122. *
  54123. * @param name The material name
  54124. * @param scene The scene the material will be use in.
  54125. */
  54126. constructor(name: string, scene: Scene);
  54127. getClassName(): string;
  54128. }
  54129. }
  54130. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54131. import { Scene } from "babylonjs/scene";
  54132. import { Color3 } from "babylonjs/Maths/math.color";
  54133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54134. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54135. /**
  54136. * The PBR material of BJS following the metal roughness convention.
  54137. *
  54138. * This fits to the PBR convention in the GLTF definition:
  54139. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54140. */
  54141. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54142. /**
  54143. * The base color has two different interpretations depending on the value of metalness.
  54144. * When the material is a metal, the base color is the specific measured reflectance value
  54145. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54146. * of the material.
  54147. */
  54148. baseColor: Color3;
  54149. /**
  54150. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54151. * well as opacity information in the alpha channel.
  54152. */
  54153. baseTexture: BaseTexture;
  54154. /**
  54155. * Specifies the metallic scalar value of the material.
  54156. * Can also be used to scale the metalness values of the metallic texture.
  54157. */
  54158. metallic: number;
  54159. /**
  54160. * Specifies the roughness scalar value of the material.
  54161. * Can also be used to scale the roughness values of the metallic texture.
  54162. */
  54163. roughness: number;
  54164. /**
  54165. * Texture containing both the metallic value in the B channel and the
  54166. * roughness value in the G channel to keep better precision.
  54167. */
  54168. metallicRoughnessTexture: BaseTexture;
  54169. /**
  54170. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54171. *
  54172. * @param name The material name
  54173. * @param scene The scene the material will be use in.
  54174. */
  54175. constructor(name: string, scene: Scene);
  54176. /**
  54177. * Return the currrent class name of the material.
  54178. */
  54179. getClassName(): string;
  54180. /**
  54181. * Makes a duplicate of the current material.
  54182. * @param name - name to use for the new material.
  54183. */
  54184. clone(name: string): PBRMetallicRoughnessMaterial;
  54185. /**
  54186. * Serialize the material to a parsable JSON object.
  54187. */
  54188. serialize(): any;
  54189. /**
  54190. * Parses a JSON object correponding to the serialize function.
  54191. */
  54192. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54193. }
  54194. }
  54195. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54196. import { Scene } from "babylonjs/scene";
  54197. import { Color3 } from "babylonjs/Maths/math.color";
  54198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54199. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54200. /**
  54201. * The PBR material of BJS following the specular glossiness convention.
  54202. *
  54203. * This fits to the PBR convention in the GLTF definition:
  54204. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54205. */
  54206. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54207. /**
  54208. * Specifies the diffuse color of the material.
  54209. */
  54210. diffuseColor: Color3;
  54211. /**
  54212. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54213. * channel.
  54214. */
  54215. diffuseTexture: BaseTexture;
  54216. /**
  54217. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54218. */
  54219. specularColor: Color3;
  54220. /**
  54221. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54222. */
  54223. glossiness: number;
  54224. /**
  54225. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54226. */
  54227. specularGlossinessTexture: BaseTexture;
  54228. /**
  54229. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54230. *
  54231. * @param name The material name
  54232. * @param scene The scene the material will be use in.
  54233. */
  54234. constructor(name: string, scene: Scene);
  54235. /**
  54236. * Return the currrent class name of the material.
  54237. */
  54238. getClassName(): string;
  54239. /**
  54240. * Makes a duplicate of the current material.
  54241. * @param name - name to use for the new material.
  54242. */
  54243. clone(name: string): PBRSpecularGlossinessMaterial;
  54244. /**
  54245. * Serialize the material to a parsable JSON object.
  54246. */
  54247. serialize(): any;
  54248. /**
  54249. * Parses a JSON object correponding to the serialize function.
  54250. */
  54251. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54252. }
  54253. }
  54254. declare module "babylonjs/Materials/PBR/index" {
  54255. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54256. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54257. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54258. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54259. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54260. }
  54261. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54262. import { Nullable } from "babylonjs/types";
  54263. import { Scene } from "babylonjs/scene";
  54264. import { Matrix } from "babylonjs/Maths/math.vector";
  54265. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54266. /**
  54267. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54268. * It can help converting any input color in a desired output one. This can then be used to create effects
  54269. * from sepia, black and white to sixties or futuristic rendering...
  54270. *
  54271. * The only supported format is currently 3dl.
  54272. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54273. */
  54274. export class ColorGradingTexture extends BaseTexture {
  54275. /**
  54276. * The current texture matrix. (will always be identity in color grading texture)
  54277. */
  54278. private _textureMatrix;
  54279. /**
  54280. * The texture URL.
  54281. */
  54282. url: string;
  54283. /**
  54284. * Empty line regex stored for GC.
  54285. */
  54286. private static _noneEmptyLineRegex;
  54287. private _engine;
  54288. /**
  54289. * Instantiates a ColorGradingTexture from the following parameters.
  54290. *
  54291. * @param url The location of the color gradind data (currently only supporting 3dl)
  54292. * @param scene The scene the texture will be used in
  54293. */
  54294. constructor(url: string, scene: Scene);
  54295. /**
  54296. * Returns the texture matrix used in most of the material.
  54297. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54298. */
  54299. getTextureMatrix(): Matrix;
  54300. /**
  54301. * Occurs when the file being loaded is a .3dl LUT file.
  54302. */
  54303. private load3dlTexture;
  54304. /**
  54305. * Starts the loading process of the texture.
  54306. */
  54307. private loadTexture;
  54308. /**
  54309. * Clones the color gradind texture.
  54310. */
  54311. clone(): ColorGradingTexture;
  54312. /**
  54313. * Called during delayed load for textures.
  54314. */
  54315. delayLoad(): void;
  54316. /**
  54317. * Parses a color grading texture serialized by Babylon.
  54318. * @param parsedTexture The texture information being parsedTexture
  54319. * @param scene The scene to load the texture in
  54320. * @param rootUrl The root url of the data assets to load
  54321. * @return A color gradind texture
  54322. */
  54323. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54324. /**
  54325. * Serializes the LUT texture to json format.
  54326. */
  54327. serialize(): any;
  54328. }
  54329. }
  54330. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54332. import { Scene } from "babylonjs/scene";
  54333. import { Nullable } from "babylonjs/types";
  54334. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54335. /**
  54336. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54337. */
  54338. export class EquiRectangularCubeTexture extends BaseTexture {
  54339. /** The six faces of the cube. */
  54340. private static _FacesMapping;
  54341. private _noMipmap;
  54342. private _onLoad;
  54343. private _onError;
  54344. /** The size of the cubemap. */
  54345. private _size;
  54346. /** The buffer of the image. */
  54347. private _buffer;
  54348. /** The width of the input image. */
  54349. private _width;
  54350. /** The height of the input image. */
  54351. private _height;
  54352. /** The URL to the image. */
  54353. url: string;
  54354. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54355. coordinatesMode: number;
  54356. /**
  54357. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54358. * @param url The location of the image
  54359. * @param scene The scene the texture will be used in
  54360. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54361. * @param noMipmap Forces to not generate the mipmap if true
  54362. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54363. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54364. * @param onLoad — defines a callback called when texture is loaded
  54365. * @param onError — defines a callback called if there is an error
  54366. */
  54367. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54368. /**
  54369. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54370. */
  54371. private loadImage;
  54372. /**
  54373. * Convert the image buffer into a cubemap and create a CubeTexture.
  54374. */
  54375. private loadTexture;
  54376. /**
  54377. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54378. * @param buffer The ArrayBuffer that should be converted.
  54379. * @returns The buffer as Float32Array.
  54380. */
  54381. private getFloat32ArrayFromArrayBuffer;
  54382. /**
  54383. * Get the current class name of the texture useful for serialization or dynamic coding.
  54384. * @returns "EquiRectangularCubeTexture"
  54385. */
  54386. getClassName(): string;
  54387. /**
  54388. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54389. * @returns A clone of the current EquiRectangularCubeTexture.
  54390. */
  54391. clone(): EquiRectangularCubeTexture;
  54392. }
  54393. }
  54394. declare module "babylonjs/Misc/tga" {
  54395. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54396. /**
  54397. * Based on jsTGALoader - Javascript loader for TGA file
  54398. * By Vincent Thibault
  54399. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54400. */
  54401. export class TGATools {
  54402. private static _TYPE_INDEXED;
  54403. private static _TYPE_RGB;
  54404. private static _TYPE_GREY;
  54405. private static _TYPE_RLE_INDEXED;
  54406. private static _TYPE_RLE_RGB;
  54407. private static _TYPE_RLE_GREY;
  54408. private static _ORIGIN_MASK;
  54409. private static _ORIGIN_SHIFT;
  54410. private static _ORIGIN_BL;
  54411. private static _ORIGIN_BR;
  54412. private static _ORIGIN_UL;
  54413. private static _ORIGIN_UR;
  54414. /**
  54415. * Gets the header of a TGA file
  54416. * @param data defines the TGA data
  54417. * @returns the header
  54418. */
  54419. static GetTGAHeader(data: Uint8Array): any;
  54420. /**
  54421. * Uploads TGA content to a Babylon Texture
  54422. * @hidden
  54423. */
  54424. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54425. /** @hidden */
  54426. 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;
  54427. /** @hidden */
  54428. 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;
  54429. /** @hidden */
  54430. 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;
  54431. /** @hidden */
  54432. 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;
  54433. /** @hidden */
  54434. 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;
  54435. /** @hidden */
  54436. 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;
  54437. }
  54438. }
  54439. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54440. import { Nullable } from "babylonjs/types";
  54441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54442. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54443. /**
  54444. * Implementation of the TGA Texture Loader.
  54445. * @hidden
  54446. */
  54447. export class _TGATextureLoader implements IInternalTextureLoader {
  54448. /**
  54449. * Defines wether the loader supports cascade loading the different faces.
  54450. */
  54451. readonly supportCascades: boolean;
  54452. /**
  54453. * This returns if the loader support the current file information.
  54454. * @param extension defines the file extension of the file being loaded
  54455. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54456. * @param fallback defines the fallback internal texture if any
  54457. * @param isBase64 defines whether the texture is encoded as a base64
  54458. * @param isBuffer defines whether the texture data are stored as a buffer
  54459. * @returns true if the loader can load the specified file
  54460. */
  54461. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54462. /**
  54463. * Transform the url before loading if required.
  54464. * @param rootUrl the url of the texture
  54465. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54466. * @returns the transformed texture
  54467. */
  54468. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54469. /**
  54470. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54471. * @param rootUrl the url of the texture
  54472. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54473. * @returns the fallback texture
  54474. */
  54475. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54476. /**
  54477. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54478. * @param data contains the texture data
  54479. * @param texture defines the BabylonJS internal texture
  54480. * @param createPolynomials will be true if polynomials have been requested
  54481. * @param onLoad defines the callback to trigger once the texture is ready
  54482. * @param onError defines the callback to trigger in case of error
  54483. */
  54484. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54485. /**
  54486. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54487. * @param data contains the texture data
  54488. * @param texture defines the BabylonJS internal texture
  54489. * @param callback defines the method to call once ready to upload
  54490. */
  54491. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54492. }
  54493. }
  54494. declare module "babylonjs/Misc/basis" {
  54495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54496. /**
  54497. * Info about the .basis files
  54498. */
  54499. class BasisFileInfo {
  54500. /**
  54501. * If the file has alpha
  54502. */
  54503. hasAlpha: boolean;
  54504. /**
  54505. * Info about each image of the basis file
  54506. */
  54507. images: Array<{
  54508. levels: Array<{
  54509. width: number;
  54510. height: number;
  54511. transcodedPixels: ArrayBufferView;
  54512. }>;
  54513. }>;
  54514. }
  54515. /**
  54516. * Result of transcoding a basis file
  54517. */
  54518. class TranscodeResult {
  54519. /**
  54520. * Info about the .basis file
  54521. */
  54522. fileInfo: BasisFileInfo;
  54523. /**
  54524. * Format to use when loading the file
  54525. */
  54526. format: number;
  54527. }
  54528. /**
  54529. * Configuration options for the Basis transcoder
  54530. */
  54531. export class BasisTranscodeConfiguration {
  54532. /**
  54533. * Supported compression formats used to determine the supported output format of the transcoder
  54534. */
  54535. supportedCompressionFormats?: {
  54536. /**
  54537. * etc1 compression format
  54538. */
  54539. etc1?: boolean;
  54540. /**
  54541. * s3tc compression format
  54542. */
  54543. s3tc?: boolean;
  54544. /**
  54545. * pvrtc compression format
  54546. */
  54547. pvrtc?: boolean;
  54548. /**
  54549. * etc2 compression format
  54550. */
  54551. etc2?: boolean;
  54552. };
  54553. /**
  54554. * If mipmap levels should be loaded for transcoded images (Default: true)
  54555. */
  54556. loadMipmapLevels?: boolean;
  54557. /**
  54558. * Index of a single image to load (Default: all images)
  54559. */
  54560. loadSingleImage?: number;
  54561. }
  54562. /**
  54563. * Used to load .Basis files
  54564. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54565. */
  54566. export class BasisTools {
  54567. private static _IgnoreSupportedFormats;
  54568. /**
  54569. * URL to use when loading the basis transcoder
  54570. */
  54571. static JSModuleURL: string;
  54572. /**
  54573. * URL to use when loading the wasm module for the transcoder
  54574. */
  54575. static WasmModuleURL: string;
  54576. /**
  54577. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54578. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54579. * @returns internal format corresponding to the Basis format
  54580. */
  54581. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54582. private static _WorkerPromise;
  54583. private static _Worker;
  54584. private static _actionId;
  54585. private static _CreateWorkerAsync;
  54586. /**
  54587. * Transcodes a loaded image file to compressed pixel data
  54588. * @param imageData image data to transcode
  54589. * @param config configuration options for the transcoding
  54590. * @returns a promise resulting in the transcoded image
  54591. */
  54592. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54593. /**
  54594. * Loads a texture from the transcode result
  54595. * @param texture texture load to
  54596. * @param transcodeResult the result of transcoding the basis file to load from
  54597. */
  54598. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54599. }
  54600. }
  54601. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54602. import { Nullable } from "babylonjs/types";
  54603. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54605. /**
  54606. * Loader for .basis file format
  54607. */
  54608. export class _BasisTextureLoader implements IInternalTextureLoader {
  54609. /**
  54610. * Defines whether the loader supports cascade loading the different faces.
  54611. */
  54612. readonly supportCascades: boolean;
  54613. /**
  54614. * This returns if the loader support the current file information.
  54615. * @param extension defines the file extension of the file being loaded
  54616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54617. * @param fallback defines the fallback internal texture if any
  54618. * @param isBase64 defines whether the texture is encoded as a base64
  54619. * @param isBuffer defines whether the texture data are stored as a buffer
  54620. * @returns true if the loader can load the specified file
  54621. */
  54622. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54623. /**
  54624. * Transform the url before loading if required.
  54625. * @param rootUrl the url of the texture
  54626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54627. * @returns the transformed texture
  54628. */
  54629. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54630. /**
  54631. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54632. * @param rootUrl the url of the texture
  54633. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54634. * @returns the fallback texture
  54635. */
  54636. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54637. /**
  54638. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54639. * @param data contains the texture data
  54640. * @param texture defines the BabylonJS internal texture
  54641. * @param createPolynomials will be true if polynomials have been requested
  54642. * @param onLoad defines the callback to trigger once the texture is ready
  54643. * @param onError defines the callback to trigger in case of error
  54644. */
  54645. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54646. /**
  54647. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54648. * @param data contains the texture data
  54649. * @param texture defines the BabylonJS internal texture
  54650. * @param callback defines the method to call once ready to upload
  54651. */
  54652. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54653. }
  54654. }
  54655. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54656. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54657. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54658. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54659. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54660. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54661. }
  54662. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54663. import { Scene } from "babylonjs/scene";
  54664. import { Texture } from "babylonjs/Materials/Textures/texture";
  54665. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54666. /**
  54667. * 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.
  54668. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54669. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54670. */
  54671. export class CustomProceduralTexture extends ProceduralTexture {
  54672. private _animate;
  54673. private _time;
  54674. private _config;
  54675. private _texturePath;
  54676. /**
  54677. * Instantiates a new Custom Procedural Texture.
  54678. * 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.
  54679. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54680. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54681. * @param name Define the name of the texture
  54682. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54683. * @param size Define the size of the texture to create
  54684. * @param scene Define the scene the texture belongs to
  54685. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54686. * @param generateMipMaps Define if the texture should creates mip maps or not
  54687. */
  54688. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54689. private _loadJson;
  54690. /**
  54691. * Is the texture ready to be used ? (rendered at least once)
  54692. * @returns true if ready, otherwise, false.
  54693. */
  54694. isReady(): boolean;
  54695. /**
  54696. * Render the texture to its associated render target.
  54697. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54698. */
  54699. render(useCameraPostProcess?: boolean): void;
  54700. /**
  54701. * Update the list of dependant textures samplers in the shader.
  54702. */
  54703. updateTextures(): void;
  54704. /**
  54705. * Update the uniform values of the procedural texture in the shader.
  54706. */
  54707. updateShaderUniforms(): void;
  54708. /**
  54709. * Define if the texture animates or not.
  54710. */
  54711. animate: boolean;
  54712. }
  54713. }
  54714. declare module "babylonjs/Shaders/noise.fragment" {
  54715. /** @hidden */
  54716. export var noisePixelShader: {
  54717. name: string;
  54718. shader: string;
  54719. };
  54720. }
  54721. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54722. import { Nullable } from "babylonjs/types";
  54723. import { Scene } from "babylonjs/scene";
  54724. import { Texture } from "babylonjs/Materials/Textures/texture";
  54725. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54726. import "babylonjs/Shaders/noise.fragment";
  54727. /**
  54728. * Class used to generate noise procedural textures
  54729. */
  54730. export class NoiseProceduralTexture extends ProceduralTexture {
  54731. private _time;
  54732. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54733. brightness: number;
  54734. /** Defines the number of octaves to process */
  54735. octaves: number;
  54736. /** Defines the level of persistence (0.8 by default) */
  54737. persistence: number;
  54738. /** Gets or sets animation speed factor (default is 1) */
  54739. animationSpeedFactor: number;
  54740. /**
  54741. * Creates a new NoiseProceduralTexture
  54742. * @param name defines the name fo the texture
  54743. * @param size defines the size of the texture (default is 256)
  54744. * @param scene defines the hosting scene
  54745. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54746. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54747. */
  54748. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54749. private _updateShaderUniforms;
  54750. protected _getDefines(): string;
  54751. /** Generate the current state of the procedural texture */
  54752. render(useCameraPostProcess?: boolean): void;
  54753. /**
  54754. * Serializes this noise procedural texture
  54755. * @returns a serialized noise procedural texture object
  54756. */
  54757. serialize(): any;
  54758. /**
  54759. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54760. * @param parsedTexture defines parsed texture data
  54761. * @param scene defines the current scene
  54762. * @param rootUrl defines the root URL containing noise procedural texture information
  54763. * @returns a parsed NoiseProceduralTexture
  54764. */
  54765. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54766. }
  54767. }
  54768. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54769. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54770. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54771. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54772. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54773. }
  54774. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54775. import { Nullable } from "babylonjs/types";
  54776. import { Scene } from "babylonjs/scene";
  54777. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54778. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54779. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54780. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54781. /**
  54782. * Raw cube texture where the raw buffers are passed in
  54783. */
  54784. export class RawCubeTexture extends CubeTexture {
  54785. /**
  54786. * Creates a cube texture where the raw buffers are passed in.
  54787. * @param scene defines the scene the texture is attached to
  54788. * @param data defines the array of data to use to create each face
  54789. * @param size defines the size of the textures
  54790. * @param format defines the format of the data
  54791. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54792. * @param generateMipMaps defines if the engine should generate the mip levels
  54793. * @param invertY defines if data must be stored with Y axis inverted
  54794. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54795. * @param compression defines the compression used (null by default)
  54796. */
  54797. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54798. /**
  54799. * Updates the raw cube texture.
  54800. * @param data defines the data to store
  54801. * @param format defines the data format
  54802. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54803. * @param invertY defines if data must be stored with Y axis inverted
  54804. * @param compression defines the compression used (null by default)
  54805. * @param level defines which level of the texture to update
  54806. */
  54807. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54808. /**
  54809. * Updates a raw cube texture with RGBD encoded data.
  54810. * @param data defines the array of data [mipmap][face] to use to create each face
  54811. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54812. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54813. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54814. * @returns a promsie that resolves when the operation is complete
  54815. */
  54816. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54817. /**
  54818. * Clones the raw cube texture.
  54819. * @return a new cube texture
  54820. */
  54821. clone(): CubeTexture;
  54822. /** @hidden */
  54823. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54824. }
  54825. }
  54826. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54827. import { Scene } from "babylonjs/scene";
  54828. import { Texture } from "babylonjs/Materials/Textures/texture";
  54829. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54830. /**
  54831. * Class used to store 3D textures containing user data
  54832. */
  54833. export class RawTexture3D extends Texture {
  54834. /** Gets or sets the texture format to use */
  54835. format: number;
  54836. private _engine;
  54837. /**
  54838. * Create a new RawTexture3D
  54839. * @param data defines the data of the texture
  54840. * @param width defines the width of the texture
  54841. * @param height defines the height of the texture
  54842. * @param depth defines the depth of the texture
  54843. * @param format defines the texture format to use
  54844. * @param scene defines the hosting scene
  54845. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54846. * @param invertY defines if texture must be stored with Y axis inverted
  54847. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54848. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54849. */
  54850. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54851. /** Gets or sets the texture format to use */
  54852. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54853. /**
  54854. * Update the texture with new data
  54855. * @param data defines the data to store in the texture
  54856. */
  54857. update(data: ArrayBufferView): void;
  54858. }
  54859. }
  54860. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54861. import { Scene } from "babylonjs/scene";
  54862. import { Plane } from "babylonjs/Maths/math.plane";
  54863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54864. /**
  54865. * Creates a refraction texture used by refraction channel of the standard material.
  54866. * It is like a mirror but to see through a material.
  54867. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54868. */
  54869. export class RefractionTexture extends RenderTargetTexture {
  54870. /**
  54871. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54872. * 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.
  54873. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54874. */
  54875. refractionPlane: Plane;
  54876. /**
  54877. * Define how deep under the surface we should see.
  54878. */
  54879. depth: number;
  54880. /**
  54881. * Creates a refraction texture used by refraction channel of the standard material.
  54882. * It is like a mirror but to see through a material.
  54883. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54884. * @param name Define the texture name
  54885. * @param size Define the size of the underlying texture
  54886. * @param scene Define the scene the refraction belongs to
  54887. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54888. */
  54889. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54890. /**
  54891. * Clone the refraction texture.
  54892. * @returns the cloned texture
  54893. */
  54894. clone(): RefractionTexture;
  54895. /**
  54896. * Serialize the texture to a JSON representation you could use in Parse later on
  54897. * @returns the serialized JSON representation
  54898. */
  54899. serialize(): any;
  54900. }
  54901. }
  54902. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54903. import { Nullable } from "babylonjs/types";
  54904. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54905. import { Matrix } from "babylonjs/Maths/math.vector";
  54906. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54907. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54908. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54909. import { Scene } from "babylonjs/scene";
  54910. /**
  54911. * Defines the options related to the creation of an HtmlElementTexture
  54912. */
  54913. export interface IHtmlElementTextureOptions {
  54914. /**
  54915. * Defines wether mip maps should be created or not.
  54916. */
  54917. generateMipMaps?: boolean;
  54918. /**
  54919. * Defines the sampling mode of the texture.
  54920. */
  54921. samplingMode?: number;
  54922. /**
  54923. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54924. */
  54925. engine: Nullable<ThinEngine>;
  54926. /**
  54927. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54928. */
  54929. scene: Nullable<Scene>;
  54930. }
  54931. /**
  54932. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54933. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54934. * is automatically managed.
  54935. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54936. * in your application.
  54937. *
  54938. * As the update is not automatic, you need to call them manually.
  54939. */
  54940. export class HtmlElementTexture extends BaseTexture {
  54941. /**
  54942. * The texture URL.
  54943. */
  54944. element: HTMLVideoElement | HTMLCanvasElement;
  54945. private static readonly DefaultOptions;
  54946. private _textureMatrix;
  54947. private _engine;
  54948. private _isVideo;
  54949. private _generateMipMaps;
  54950. private _samplingMode;
  54951. /**
  54952. * Instantiates a HtmlElementTexture from the following parameters.
  54953. *
  54954. * @param name Defines the name of the texture
  54955. * @param element Defines the video or canvas the texture is filled with
  54956. * @param options Defines the other none mandatory texture creation options
  54957. */
  54958. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54959. private _createInternalTexture;
  54960. /**
  54961. * Returns the texture matrix used in most of the material.
  54962. */
  54963. getTextureMatrix(): Matrix;
  54964. /**
  54965. * Updates the content of the texture.
  54966. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54967. */
  54968. update(invertY?: Nullable<boolean>): void;
  54969. }
  54970. }
  54971. declare module "babylonjs/Materials/Textures/index" {
  54972. export * from "babylonjs/Materials/Textures/baseTexture";
  54973. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54974. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54975. export * from "babylonjs/Materials/Textures/cubeTexture";
  54976. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54977. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54978. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54979. export * from "babylonjs/Materials/Textures/internalTexture";
  54980. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54981. export * from "babylonjs/Materials/Textures/Loaders/index";
  54982. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54983. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54984. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54985. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54986. export * from "babylonjs/Materials/Textures/rawTexture";
  54987. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54988. export * from "babylonjs/Materials/Textures/refractionTexture";
  54989. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54990. export * from "babylonjs/Materials/Textures/texture";
  54991. export * from "babylonjs/Materials/Textures/videoTexture";
  54992. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54993. }
  54994. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54995. /**
  54996. * Enum used to define the target of a block
  54997. */
  54998. export enum NodeMaterialBlockTargets {
  54999. /** Vertex shader */
  55000. Vertex = 1,
  55001. /** Fragment shader */
  55002. Fragment = 2,
  55003. /** Neutral */
  55004. Neutral = 4,
  55005. /** Vertex and Fragment */
  55006. VertexAndFragment = 3
  55007. }
  55008. }
  55009. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55010. /**
  55011. * Defines the kind of connection point for node based material
  55012. */
  55013. export enum NodeMaterialBlockConnectionPointTypes {
  55014. /** Float */
  55015. Float = 1,
  55016. /** Int */
  55017. Int = 2,
  55018. /** Vector2 */
  55019. Vector2 = 4,
  55020. /** Vector3 */
  55021. Vector3 = 8,
  55022. /** Vector4 */
  55023. Vector4 = 16,
  55024. /** Color3 */
  55025. Color3 = 32,
  55026. /** Color4 */
  55027. Color4 = 64,
  55028. /** Matrix */
  55029. Matrix = 128,
  55030. /** Detect type based on connection */
  55031. AutoDetect = 1024,
  55032. /** Output type that will be defined by input type */
  55033. BasedOnInput = 2048
  55034. }
  55035. }
  55036. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55037. /**
  55038. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55039. */
  55040. export enum NodeMaterialBlockConnectionPointMode {
  55041. /** Value is an uniform */
  55042. Uniform = 0,
  55043. /** Value is a mesh attribute */
  55044. Attribute = 1,
  55045. /** Value is a varying between vertex and fragment shaders */
  55046. Varying = 2,
  55047. /** Mode is undefined */
  55048. Undefined = 3
  55049. }
  55050. }
  55051. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55052. /**
  55053. * Enum used to define system values e.g. values automatically provided by the system
  55054. */
  55055. export enum NodeMaterialSystemValues {
  55056. /** World */
  55057. World = 1,
  55058. /** View */
  55059. View = 2,
  55060. /** Projection */
  55061. Projection = 3,
  55062. /** ViewProjection */
  55063. ViewProjection = 4,
  55064. /** WorldView */
  55065. WorldView = 5,
  55066. /** WorldViewProjection */
  55067. WorldViewProjection = 6,
  55068. /** CameraPosition */
  55069. CameraPosition = 7,
  55070. /** Fog Color */
  55071. FogColor = 8,
  55072. /** Delta time */
  55073. DeltaTime = 9
  55074. }
  55075. }
  55076. declare module "babylonjs/Materials/Node/Enums/index" {
  55077. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55078. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55079. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55080. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55081. }
  55082. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55083. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55084. /**
  55085. * Root class for all node material optimizers
  55086. */
  55087. export class NodeMaterialOptimizer {
  55088. /**
  55089. * Function used to optimize a NodeMaterial graph
  55090. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55091. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55092. */
  55093. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55094. }
  55095. }
  55096. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55100. import { Scene } from "babylonjs/scene";
  55101. /**
  55102. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55103. */
  55104. export class TransformBlock extends NodeMaterialBlock {
  55105. /**
  55106. * Defines the value to use to complement W value to transform it to a Vector4
  55107. */
  55108. complementW: number;
  55109. /**
  55110. * Defines the value to use to complement z value to transform it to a Vector4
  55111. */
  55112. complementZ: number;
  55113. /**
  55114. * Creates a new TransformBlock
  55115. * @param name defines the block name
  55116. */
  55117. constructor(name: string);
  55118. /**
  55119. * Gets the current class name
  55120. * @returns the class name
  55121. */
  55122. getClassName(): string;
  55123. /**
  55124. * Gets the vector input
  55125. */
  55126. readonly vector: NodeMaterialConnectionPoint;
  55127. /**
  55128. * Gets the output component
  55129. */
  55130. readonly output: NodeMaterialConnectionPoint;
  55131. /**
  55132. * Gets the matrix transform input
  55133. */
  55134. readonly transform: NodeMaterialConnectionPoint;
  55135. protected _buildBlock(state: NodeMaterialBuildState): this;
  55136. serialize(): any;
  55137. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55138. protected _dumpPropertiesCode(): string;
  55139. }
  55140. }
  55141. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55145. /**
  55146. * Block used to output the vertex position
  55147. */
  55148. export class VertexOutputBlock extends NodeMaterialBlock {
  55149. /**
  55150. * Creates a new VertexOutputBlock
  55151. * @param name defines the block name
  55152. */
  55153. constructor(name: string);
  55154. /**
  55155. * Gets the current class name
  55156. * @returns the class name
  55157. */
  55158. getClassName(): string;
  55159. /**
  55160. * Gets the vector input component
  55161. */
  55162. readonly vector: NodeMaterialConnectionPoint;
  55163. protected _buildBlock(state: NodeMaterialBuildState): this;
  55164. }
  55165. }
  55166. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55170. /**
  55171. * Block used to output the final color
  55172. */
  55173. export class FragmentOutputBlock extends NodeMaterialBlock {
  55174. /**
  55175. * Create a new FragmentOutputBlock
  55176. * @param name defines the block name
  55177. */
  55178. constructor(name: string);
  55179. /**
  55180. * Gets the current class name
  55181. * @returns the class name
  55182. */
  55183. getClassName(): string;
  55184. /**
  55185. * Gets the rgba input component
  55186. */
  55187. readonly rgba: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the rgb input component
  55190. */
  55191. readonly rgb: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the a input component
  55194. */
  55195. readonly a: NodeMaterialConnectionPoint;
  55196. protected _buildBlock(state: NodeMaterialBuildState): this;
  55197. }
  55198. }
  55199. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55205. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55206. import { Effect } from "babylonjs/Materials/effect";
  55207. import { Mesh } from "babylonjs/Meshes/mesh";
  55208. import { Nullable } from "babylonjs/types";
  55209. import { Scene } from "babylonjs/scene";
  55210. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55211. /**
  55212. * Block used to read a reflection texture from a sampler
  55213. */
  55214. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55215. private _define3DName;
  55216. private _defineCubicName;
  55217. private _defineExplicitName;
  55218. private _defineProjectionName;
  55219. private _defineLocalCubicName;
  55220. private _defineSphericalName;
  55221. private _definePlanarName;
  55222. private _defineEquirectangularName;
  55223. private _defineMirroredEquirectangularFixedName;
  55224. private _defineEquirectangularFixedName;
  55225. private _defineSkyboxName;
  55226. private _cubeSamplerName;
  55227. private _2DSamplerName;
  55228. private _positionUVWName;
  55229. private _directionWName;
  55230. private _reflectionCoordsName;
  55231. private _reflection2DCoordsName;
  55232. private _reflectionColorName;
  55233. private _reflectionMatrixName;
  55234. /**
  55235. * Gets or sets the texture associated with the node
  55236. */
  55237. texture: Nullable<BaseTexture>;
  55238. /**
  55239. * Create a new TextureBlock
  55240. * @param name defines the block name
  55241. */
  55242. constructor(name: string);
  55243. /**
  55244. * Gets the current class name
  55245. * @returns the class name
  55246. */
  55247. getClassName(): string;
  55248. /**
  55249. * Gets the world position input component
  55250. */
  55251. readonly position: NodeMaterialConnectionPoint;
  55252. /**
  55253. * Gets the world position input component
  55254. */
  55255. readonly worldPosition: NodeMaterialConnectionPoint;
  55256. /**
  55257. * Gets the world normal input component
  55258. */
  55259. readonly worldNormal: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the world input component
  55262. */
  55263. readonly world: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the camera (or eye) position component
  55266. */
  55267. readonly cameraPosition: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the view input component
  55270. */
  55271. readonly view: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the rgb output component
  55274. */
  55275. readonly rgb: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the r output component
  55278. */
  55279. readonly r: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the g output component
  55282. */
  55283. readonly g: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the b output component
  55286. */
  55287. readonly b: NodeMaterialConnectionPoint;
  55288. autoConfigure(material: NodeMaterial): void;
  55289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55290. isReady(): boolean;
  55291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55292. private _injectVertexCode;
  55293. private _writeOutput;
  55294. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55295. serialize(): any;
  55296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55297. }
  55298. }
  55299. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55301. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55302. import { Scene } from "babylonjs/scene";
  55303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55304. import { Matrix } from "babylonjs/Maths/math.vector";
  55305. import { Mesh } from "babylonjs/Meshes/mesh";
  55306. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55307. import { Observable } from "babylonjs/Misc/observable";
  55308. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55309. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55310. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55311. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55312. import { Nullable } from "babylonjs/types";
  55313. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55314. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55315. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55316. /**
  55317. * Interface used to configure the node material editor
  55318. */
  55319. export interface INodeMaterialEditorOptions {
  55320. /** Define the URl to load node editor script */
  55321. editorURL?: string;
  55322. }
  55323. /** @hidden */
  55324. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55325. /** BONES */
  55326. NUM_BONE_INFLUENCERS: number;
  55327. BonesPerMesh: number;
  55328. BONETEXTURE: boolean;
  55329. /** MORPH TARGETS */
  55330. MORPHTARGETS: boolean;
  55331. MORPHTARGETS_NORMAL: boolean;
  55332. MORPHTARGETS_TANGENT: boolean;
  55333. MORPHTARGETS_UV: boolean;
  55334. NUM_MORPH_INFLUENCERS: number;
  55335. /** IMAGE PROCESSING */
  55336. IMAGEPROCESSING: boolean;
  55337. VIGNETTE: boolean;
  55338. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55339. VIGNETTEBLENDMODEOPAQUE: boolean;
  55340. TONEMAPPING: boolean;
  55341. TONEMAPPING_ACES: boolean;
  55342. CONTRAST: boolean;
  55343. EXPOSURE: boolean;
  55344. COLORCURVES: boolean;
  55345. COLORGRADING: boolean;
  55346. COLORGRADING3D: boolean;
  55347. SAMPLER3DGREENDEPTH: boolean;
  55348. SAMPLER3DBGRMAP: boolean;
  55349. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55350. /** MISC. */
  55351. BUMPDIRECTUV: number;
  55352. constructor();
  55353. setValue(name: string, value: boolean): void;
  55354. }
  55355. /**
  55356. * Class used to configure NodeMaterial
  55357. */
  55358. export interface INodeMaterialOptions {
  55359. /**
  55360. * Defines if blocks should emit comments
  55361. */
  55362. emitComments: boolean;
  55363. }
  55364. /**
  55365. * Class used to create a node based material built by assembling shader blocks
  55366. */
  55367. export class NodeMaterial extends PushMaterial {
  55368. private static _BuildIdGenerator;
  55369. private _options;
  55370. private _vertexCompilationState;
  55371. private _fragmentCompilationState;
  55372. private _sharedData;
  55373. private _buildId;
  55374. private _buildWasSuccessful;
  55375. private _cachedWorldViewMatrix;
  55376. private _cachedWorldViewProjectionMatrix;
  55377. private _optimizers;
  55378. private _animationFrame;
  55379. /** Define the URl to load node editor script */
  55380. static EditorURL: string;
  55381. private BJSNODEMATERIALEDITOR;
  55382. /** Get the inspector from bundle or global */
  55383. private _getGlobalNodeMaterialEditor;
  55384. /**
  55385. * 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)
  55386. */
  55387. ignoreAlpha: boolean;
  55388. /**
  55389. * Defines the maximum number of lights that can be used in the material
  55390. */
  55391. maxSimultaneousLights: number;
  55392. /**
  55393. * Observable raised when the material is built
  55394. */
  55395. onBuildObservable: Observable<NodeMaterial>;
  55396. /**
  55397. * Gets or sets the root nodes of the material vertex shader
  55398. */
  55399. _vertexOutputNodes: NodeMaterialBlock[];
  55400. /**
  55401. * Gets or sets the root nodes of the material fragment (pixel) shader
  55402. */
  55403. _fragmentOutputNodes: NodeMaterialBlock[];
  55404. /** Gets or sets options to control the node material overall behavior */
  55405. options: INodeMaterialOptions;
  55406. /**
  55407. * Default configuration related to image processing available in the standard Material.
  55408. */
  55409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55410. /**
  55411. * Gets the image processing configuration used either in this material.
  55412. */
  55413. /**
  55414. * Sets the Default image processing configuration used either in the this material.
  55415. *
  55416. * If sets to null, the scene one is in use.
  55417. */
  55418. imageProcessingConfiguration: ImageProcessingConfiguration;
  55419. /**
  55420. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55421. */
  55422. attachedBlocks: NodeMaterialBlock[];
  55423. /**
  55424. * Create a new node based material
  55425. * @param name defines the material name
  55426. * @param scene defines the hosting scene
  55427. * @param options defines creation option
  55428. */
  55429. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55430. /**
  55431. * Gets the current class name of the material e.g. "NodeMaterial"
  55432. * @returns the class name
  55433. */
  55434. getClassName(): string;
  55435. /**
  55436. * Keep track of the image processing observer to allow dispose and replace.
  55437. */
  55438. private _imageProcessingObserver;
  55439. /**
  55440. * Attaches a new image processing configuration to the Standard Material.
  55441. * @param configuration
  55442. */
  55443. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55444. /**
  55445. * Get a block by its name
  55446. * @param name defines the name of the block to retrieve
  55447. * @returns the required block or null if not found
  55448. */
  55449. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55450. /**
  55451. * Get a block by its name
  55452. * @param predicate defines the predicate used to find the good candidate
  55453. * @returns the required block or null if not found
  55454. */
  55455. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55456. /**
  55457. * Get an input block by its name
  55458. * @param predicate defines the predicate used to find the good candidate
  55459. * @returns the required input block or null if not found
  55460. */
  55461. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55462. /**
  55463. * Gets the list of input blocks attached to this material
  55464. * @returns an array of InputBlocks
  55465. */
  55466. getInputBlocks(): InputBlock[];
  55467. /**
  55468. * Adds a new optimizer to the list of optimizers
  55469. * @param optimizer defines the optimizers to add
  55470. * @returns the current material
  55471. */
  55472. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55473. /**
  55474. * Remove an optimizer from the list of optimizers
  55475. * @param optimizer defines the optimizers to remove
  55476. * @returns the current material
  55477. */
  55478. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55479. /**
  55480. * Add a new block to the list of output nodes
  55481. * @param node defines the node to add
  55482. * @returns the current material
  55483. */
  55484. addOutputNode(node: NodeMaterialBlock): this;
  55485. /**
  55486. * Remove a block from the list of root nodes
  55487. * @param node defines the node to remove
  55488. * @returns the current material
  55489. */
  55490. removeOutputNode(node: NodeMaterialBlock): this;
  55491. private _addVertexOutputNode;
  55492. private _removeVertexOutputNode;
  55493. private _addFragmentOutputNode;
  55494. private _removeFragmentOutputNode;
  55495. /**
  55496. * Specifies if the material will require alpha blending
  55497. * @returns a boolean specifying if alpha blending is needed
  55498. */
  55499. needAlphaBlending(): boolean;
  55500. /**
  55501. * Specifies if this material should be rendered in alpha test mode
  55502. * @returns a boolean specifying if an alpha test is needed.
  55503. */
  55504. needAlphaTesting(): boolean;
  55505. private _initializeBlock;
  55506. private _resetDualBlocks;
  55507. /**
  55508. * Build the material and generates the inner effect
  55509. * @param verbose defines if the build should log activity
  55510. */
  55511. build(verbose?: boolean): void;
  55512. /**
  55513. * Runs an otpimization phase to try to improve the shader code
  55514. */
  55515. optimize(): void;
  55516. private _prepareDefinesForAttributes;
  55517. /**
  55518. * Get if the submesh is ready to be used and all its information available.
  55519. * Child classes can use it to update shaders
  55520. * @param mesh defines the mesh to check
  55521. * @param subMesh defines which submesh to check
  55522. * @param useInstances specifies that instances should be used
  55523. * @returns a boolean indicating that the submesh is ready or not
  55524. */
  55525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55526. /**
  55527. * Get a string representing the shaders built by the current node graph
  55528. */
  55529. readonly compiledShaders: string;
  55530. /**
  55531. * Binds the world matrix to the material
  55532. * @param world defines the world transformation matrix
  55533. */
  55534. bindOnlyWorldMatrix(world: Matrix): void;
  55535. /**
  55536. * Binds the submesh to this material by preparing the effect and shader to draw
  55537. * @param world defines the world transformation matrix
  55538. * @param mesh defines the mesh containing the submesh
  55539. * @param subMesh defines the submesh to bind the material to
  55540. */
  55541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55542. /**
  55543. * Gets the active textures from the material
  55544. * @returns an array of textures
  55545. */
  55546. getActiveTextures(): BaseTexture[];
  55547. /**
  55548. * Gets the list of texture blocks
  55549. * @returns an array of texture blocks
  55550. */
  55551. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55552. /**
  55553. * Specifies if the material uses a texture
  55554. * @param texture defines the texture to check against the material
  55555. * @returns a boolean specifying if the material uses the texture
  55556. */
  55557. hasTexture(texture: BaseTexture): boolean;
  55558. /**
  55559. * Disposes the material
  55560. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55561. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55562. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55563. */
  55564. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55565. /** Creates the node editor window. */
  55566. private _createNodeEditor;
  55567. /**
  55568. * Launch the node material editor
  55569. * @param config Define the configuration of the editor
  55570. * @return a promise fulfilled when the node editor is visible
  55571. */
  55572. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55573. /**
  55574. * Clear the current material
  55575. */
  55576. clear(): void;
  55577. /**
  55578. * Clear the current material and set it to a default state
  55579. */
  55580. setToDefault(): void;
  55581. /**
  55582. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55583. * @param url defines the url to load from
  55584. * @returns a promise that will fullfil when the material is fully loaded
  55585. */
  55586. loadAsync(url: string): Promise<unknown>;
  55587. private _gatherBlocks;
  55588. /**
  55589. * Generate a string containing the code declaration required to create an equivalent of this material
  55590. * @returns a string
  55591. */
  55592. generateCode(): string;
  55593. /**
  55594. * Serializes this material in a JSON representation
  55595. * @returns the serialized material object
  55596. */
  55597. serialize(): any;
  55598. private _restoreConnections;
  55599. /**
  55600. * Clear the current graph and load a new one from a serialization object
  55601. * @param source defines the JSON representation of the material
  55602. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55603. */
  55604. loadFromSerialization(source: any, rootUrl?: string): void;
  55605. /**
  55606. * Creates a node material from parsed material data
  55607. * @param source defines the JSON representation of the material
  55608. * @param scene defines the hosting scene
  55609. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55610. * @returns a new node material
  55611. */
  55612. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55613. /**
  55614. * Creates a new node material set to default basic configuration
  55615. * @param name defines the name of the material
  55616. * @param scene defines the hosting scene
  55617. * @returns a new NodeMaterial
  55618. */
  55619. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55620. }
  55621. }
  55622. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55625. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55628. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55629. import { Effect } from "babylonjs/Materials/effect";
  55630. import { Mesh } from "babylonjs/Meshes/mesh";
  55631. import { Nullable } from "babylonjs/types";
  55632. import { Texture } from "babylonjs/Materials/Textures/texture";
  55633. import { Scene } from "babylonjs/scene";
  55634. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55635. /**
  55636. * Block used to read a texture from a sampler
  55637. */
  55638. export class TextureBlock extends NodeMaterialBlock {
  55639. private _defineName;
  55640. private _linearDefineName;
  55641. private _samplerName;
  55642. private _transformedUVName;
  55643. private _textureTransformName;
  55644. private _textureInfoName;
  55645. private _mainUVName;
  55646. private _mainUVDefineName;
  55647. /**
  55648. * Gets or sets the texture associated with the node
  55649. */
  55650. texture: Nullable<Texture>;
  55651. /**
  55652. * Create a new TextureBlock
  55653. * @param name defines the block name
  55654. */
  55655. constructor(name: string);
  55656. /**
  55657. * Gets the current class name
  55658. * @returns the class name
  55659. */
  55660. getClassName(): string;
  55661. /**
  55662. * Gets the uv input component
  55663. */
  55664. readonly uv: NodeMaterialConnectionPoint;
  55665. /**
  55666. * Gets the rgba output component
  55667. */
  55668. readonly rgba: NodeMaterialConnectionPoint;
  55669. /**
  55670. * Gets the rgb output component
  55671. */
  55672. readonly rgb: NodeMaterialConnectionPoint;
  55673. /**
  55674. * Gets the r output component
  55675. */
  55676. readonly r: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the g output component
  55679. */
  55680. readonly g: NodeMaterialConnectionPoint;
  55681. /**
  55682. * Gets the b output component
  55683. */
  55684. readonly b: NodeMaterialConnectionPoint;
  55685. /**
  55686. * Gets the a output component
  55687. */
  55688. readonly a: NodeMaterialConnectionPoint;
  55689. readonly target: NodeMaterialBlockTargets;
  55690. autoConfigure(material: NodeMaterial): void;
  55691. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55693. isReady(): boolean;
  55694. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55695. private readonly _isMixed;
  55696. private _injectVertexCode;
  55697. private _writeOutput;
  55698. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55699. protected _dumpPropertiesCode(): string;
  55700. serialize(): any;
  55701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55702. }
  55703. }
  55704. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55707. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55708. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55709. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55710. import { Scene } from "babylonjs/scene";
  55711. /**
  55712. * Class used to store shared data between 2 NodeMaterialBuildState
  55713. */
  55714. export class NodeMaterialBuildStateSharedData {
  55715. /**
  55716. * Gets the list of emitted varyings
  55717. */
  55718. temps: string[];
  55719. /**
  55720. * Gets the list of emitted varyings
  55721. */
  55722. varyings: string[];
  55723. /**
  55724. * Gets the varying declaration string
  55725. */
  55726. varyingDeclaration: string;
  55727. /**
  55728. * Input blocks
  55729. */
  55730. inputBlocks: InputBlock[];
  55731. /**
  55732. * Input blocks
  55733. */
  55734. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55735. /**
  55736. * Bindable blocks (Blocks that need to set data to the effect)
  55737. */
  55738. bindableBlocks: NodeMaterialBlock[];
  55739. /**
  55740. * List of blocks that can provide a compilation fallback
  55741. */
  55742. blocksWithFallbacks: NodeMaterialBlock[];
  55743. /**
  55744. * List of blocks that can provide a define update
  55745. */
  55746. blocksWithDefines: NodeMaterialBlock[];
  55747. /**
  55748. * List of blocks that can provide a repeatable content
  55749. */
  55750. repeatableContentBlocks: NodeMaterialBlock[];
  55751. /**
  55752. * List of blocks that can provide a dynamic list of uniforms
  55753. */
  55754. dynamicUniformBlocks: NodeMaterialBlock[];
  55755. /**
  55756. * List of blocks that can block the isReady function for the material
  55757. */
  55758. blockingBlocks: NodeMaterialBlock[];
  55759. /**
  55760. * Gets the list of animated inputs
  55761. */
  55762. animatedInputs: InputBlock[];
  55763. /**
  55764. * Build Id used to avoid multiple recompilations
  55765. */
  55766. buildId: number;
  55767. /** List of emitted variables */
  55768. variableNames: {
  55769. [key: string]: number;
  55770. };
  55771. /** List of emitted defines */
  55772. defineNames: {
  55773. [key: string]: number;
  55774. };
  55775. /** Should emit comments? */
  55776. emitComments: boolean;
  55777. /** Emit build activity */
  55778. verbose: boolean;
  55779. /** Gets or sets the hosting scene */
  55780. scene: Scene;
  55781. /**
  55782. * Gets the compilation hints emitted at compilation time
  55783. */
  55784. hints: {
  55785. needWorldViewMatrix: boolean;
  55786. needWorldViewProjectionMatrix: boolean;
  55787. needAlphaBlending: boolean;
  55788. needAlphaTesting: boolean;
  55789. };
  55790. /**
  55791. * List of compilation checks
  55792. */
  55793. checks: {
  55794. emitVertex: boolean;
  55795. emitFragment: boolean;
  55796. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55797. };
  55798. /** Creates a new shared data */
  55799. constructor();
  55800. /**
  55801. * Emits console errors and exceptions if there is a failing check
  55802. */
  55803. emitErrors(): void;
  55804. }
  55805. }
  55806. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55807. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55808. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55809. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55810. /**
  55811. * Class used to store node based material build state
  55812. */
  55813. export class NodeMaterialBuildState {
  55814. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55815. supportUniformBuffers: boolean;
  55816. /**
  55817. * Gets the list of emitted attributes
  55818. */
  55819. attributes: string[];
  55820. /**
  55821. * Gets the list of emitted uniforms
  55822. */
  55823. uniforms: string[];
  55824. /**
  55825. * Gets the list of emitted constants
  55826. */
  55827. constants: string[];
  55828. /**
  55829. * Gets the list of emitted uniform buffers
  55830. */
  55831. uniformBuffers: string[];
  55832. /**
  55833. * Gets the list of emitted samplers
  55834. */
  55835. samplers: string[];
  55836. /**
  55837. * Gets the list of emitted functions
  55838. */
  55839. functions: {
  55840. [key: string]: string;
  55841. };
  55842. /**
  55843. * Gets the list of emitted extensions
  55844. */
  55845. extensions: {
  55846. [key: string]: string;
  55847. };
  55848. /**
  55849. * Gets the target of the compilation state
  55850. */
  55851. target: NodeMaterialBlockTargets;
  55852. /**
  55853. * Gets the list of emitted counters
  55854. */
  55855. counters: {
  55856. [key: string]: number;
  55857. };
  55858. /**
  55859. * Shared data between multiple NodeMaterialBuildState instances
  55860. */
  55861. sharedData: NodeMaterialBuildStateSharedData;
  55862. /** @hidden */
  55863. _vertexState: NodeMaterialBuildState;
  55864. /** @hidden */
  55865. _attributeDeclaration: string;
  55866. /** @hidden */
  55867. _uniformDeclaration: string;
  55868. /** @hidden */
  55869. _constantDeclaration: string;
  55870. /** @hidden */
  55871. _samplerDeclaration: string;
  55872. /** @hidden */
  55873. _varyingTransfer: string;
  55874. private _repeatableContentAnchorIndex;
  55875. /** @hidden */
  55876. _builtCompilationString: string;
  55877. /**
  55878. * Gets the emitted compilation strings
  55879. */
  55880. compilationString: string;
  55881. /**
  55882. * Finalize the compilation strings
  55883. * @param state defines the current compilation state
  55884. */
  55885. finalize(state: NodeMaterialBuildState): void;
  55886. /** @hidden */
  55887. readonly _repeatableContentAnchor: string;
  55888. /** @hidden */
  55889. _getFreeVariableName(prefix: string): string;
  55890. /** @hidden */
  55891. _getFreeDefineName(prefix: string): string;
  55892. /** @hidden */
  55893. _excludeVariableName(name: string): void;
  55894. /** @hidden */
  55895. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55896. /** @hidden */
  55897. _emitExtension(name: string, extension: string): void;
  55898. /** @hidden */
  55899. _emitFunction(name: string, code: string, comments: string): void;
  55900. /** @hidden */
  55901. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55902. replaceStrings?: {
  55903. search: RegExp;
  55904. replace: string;
  55905. }[];
  55906. repeatKey?: string;
  55907. }): string;
  55908. /** @hidden */
  55909. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55910. repeatKey?: string;
  55911. removeAttributes?: boolean;
  55912. removeUniforms?: boolean;
  55913. removeVaryings?: boolean;
  55914. removeIfDef?: boolean;
  55915. replaceStrings?: {
  55916. search: RegExp;
  55917. replace: string;
  55918. }[];
  55919. }, storeKey?: string): void;
  55920. /** @hidden */
  55921. _registerTempVariable(name: string): boolean;
  55922. /** @hidden */
  55923. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55924. /** @hidden */
  55925. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55926. /** @hidden */
  55927. _emitFloat(value: number): string;
  55928. }
  55929. }
  55930. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55931. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55933. import { Nullable } from "babylonjs/types";
  55934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55935. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55936. import { Effect } from "babylonjs/Materials/effect";
  55937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55938. import { Mesh } from "babylonjs/Meshes/mesh";
  55939. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55940. import { Scene } from "babylonjs/scene";
  55941. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55942. /**
  55943. * Defines a block that can be used inside a node based material
  55944. */
  55945. export class NodeMaterialBlock {
  55946. private _buildId;
  55947. private _buildTarget;
  55948. private _target;
  55949. private _isFinalMerger;
  55950. private _isInput;
  55951. /** @hidden */
  55952. _codeVariableName: string;
  55953. /** @hidden */
  55954. _inputs: NodeMaterialConnectionPoint[];
  55955. /** @hidden */
  55956. _outputs: NodeMaterialConnectionPoint[];
  55957. /** @hidden */
  55958. _preparationId: number;
  55959. /**
  55960. * Gets or sets the name of the block
  55961. */
  55962. name: string;
  55963. /**
  55964. * Gets or sets the unique id of the node
  55965. */
  55966. uniqueId: number;
  55967. /**
  55968. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55969. */
  55970. readonly isFinalMerger: boolean;
  55971. /**
  55972. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55973. */
  55974. readonly isInput: boolean;
  55975. /**
  55976. * Gets or sets the build Id
  55977. */
  55978. buildId: number;
  55979. /**
  55980. * Gets or sets the target of the block
  55981. */
  55982. target: NodeMaterialBlockTargets;
  55983. /**
  55984. * Gets the list of input points
  55985. */
  55986. readonly inputs: NodeMaterialConnectionPoint[];
  55987. /** Gets the list of output points */
  55988. readonly outputs: NodeMaterialConnectionPoint[];
  55989. /**
  55990. * Find an input by its name
  55991. * @param name defines the name of the input to look for
  55992. * @returns the input or null if not found
  55993. */
  55994. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55995. /**
  55996. * Find an output by its name
  55997. * @param name defines the name of the outputto look for
  55998. * @returns the output or null if not found
  55999. */
  56000. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56001. /**
  56002. * Creates a new NodeMaterialBlock
  56003. * @param name defines the block name
  56004. * @param target defines the target of that block (Vertex by default)
  56005. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56006. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56007. */
  56008. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56009. /**
  56010. * Initialize the block and prepare the context for build
  56011. * @param state defines the state that will be used for the build
  56012. */
  56013. initialize(state: NodeMaterialBuildState): void;
  56014. /**
  56015. * Bind data to effect. Will only be called for blocks with isBindable === true
  56016. * @param effect defines the effect to bind data to
  56017. * @param nodeMaterial defines the hosting NodeMaterial
  56018. * @param mesh defines the mesh that will be rendered
  56019. */
  56020. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56021. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56022. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56023. protected _writeFloat(value: number): string;
  56024. /**
  56025. * Gets the current class name e.g. "NodeMaterialBlock"
  56026. * @returns the class name
  56027. */
  56028. getClassName(): string;
  56029. /**
  56030. * Register a new input. Must be called inside a block constructor
  56031. * @param name defines the connection point name
  56032. * @param type defines the connection point type
  56033. * @param isOptional defines a boolean indicating that this input can be omitted
  56034. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56035. * @returns the current block
  56036. */
  56037. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56038. /**
  56039. * Register a new output. Must be called inside a block constructor
  56040. * @param name defines the connection point name
  56041. * @param type defines the connection point type
  56042. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56043. * @returns the current block
  56044. */
  56045. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56046. /**
  56047. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56048. * @param forOutput defines an optional connection point to check compatibility with
  56049. * @returns the first available input or null
  56050. */
  56051. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56052. /**
  56053. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56054. * @param forBlock defines an optional block to check compatibility with
  56055. * @returns the first available input or null
  56056. */
  56057. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56058. /**
  56059. * Gets the sibling of the given output
  56060. * @param current defines the current output
  56061. * @returns the next output in the list or null
  56062. */
  56063. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56064. /**
  56065. * Connect current block with another block
  56066. * @param other defines the block to connect with
  56067. * @param options define the various options to help pick the right connections
  56068. * @returns the current block
  56069. */
  56070. connectTo(other: NodeMaterialBlock, options?: {
  56071. input?: string;
  56072. output?: string;
  56073. outputSwizzle?: string;
  56074. }): this | undefined;
  56075. protected _buildBlock(state: NodeMaterialBuildState): void;
  56076. /**
  56077. * Add uniforms, samplers and uniform buffers at compilation time
  56078. * @param state defines the state to update
  56079. * @param nodeMaterial defines the node material requesting the update
  56080. * @param defines defines the material defines to update
  56081. */
  56082. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56083. /**
  56084. * Add potential fallbacks if shader compilation fails
  56085. * @param mesh defines the mesh to be rendered
  56086. * @param fallbacks defines the current prioritized list of fallbacks
  56087. */
  56088. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56089. /**
  56090. * Initialize defines for shader compilation
  56091. * @param mesh defines the mesh to be rendered
  56092. * @param nodeMaterial defines the node material requesting the update
  56093. * @param defines defines the material defines to update
  56094. * @param useInstances specifies that instances should be used
  56095. */
  56096. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56097. /**
  56098. * Update defines for shader compilation
  56099. * @param mesh defines the mesh to be rendered
  56100. * @param nodeMaterial defines the node material requesting the update
  56101. * @param defines defines the material defines to update
  56102. * @param useInstances specifies that instances should be used
  56103. */
  56104. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56105. /**
  56106. * Lets the block try to connect some inputs automatically
  56107. * @param material defines the hosting NodeMaterial
  56108. */
  56109. autoConfigure(material: NodeMaterial): void;
  56110. /**
  56111. * Function called when a block is declared as repeatable content generator
  56112. * @param vertexShaderState defines the current compilation state for the vertex shader
  56113. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56114. * @param mesh defines the mesh to be rendered
  56115. * @param defines defines the material defines to update
  56116. */
  56117. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56118. /**
  56119. * Checks if the block is ready
  56120. * @param mesh defines the mesh to be rendered
  56121. * @param nodeMaterial defines the node material requesting the update
  56122. * @param defines defines the material defines to update
  56123. * @param useInstances specifies that instances should be used
  56124. * @returns true if the block is ready
  56125. */
  56126. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56127. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56128. private _processBuild;
  56129. /**
  56130. * Compile the current node and generate the shader code
  56131. * @param state defines the current compilation state (uniforms, samplers, current string)
  56132. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56133. * @returns true if already built
  56134. */
  56135. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56136. protected _inputRename(name: string): string;
  56137. protected _outputRename(name: string): string;
  56138. protected _dumpPropertiesCode(): string;
  56139. /** @hidden */
  56140. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56141. /**
  56142. * Clone the current block to a new identical block
  56143. * @param scene defines the hosting scene
  56144. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56145. * @returns a copy of the current block
  56146. */
  56147. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56148. /**
  56149. * Serializes this block in a JSON representation
  56150. * @returns the serialized block object
  56151. */
  56152. serialize(): any;
  56153. /** @hidden */
  56154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56155. }
  56156. }
  56157. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56158. /**
  56159. * Enum defining the type of animations supported by InputBlock
  56160. */
  56161. export enum AnimatedInputBlockTypes {
  56162. /** No animation */
  56163. None = 0,
  56164. /** Time based animation. Will only work for floats */
  56165. Time = 1
  56166. }
  56167. }
  56168. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56170. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56171. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56172. import { Nullable } from "babylonjs/types";
  56173. import { Effect } from "babylonjs/Materials/effect";
  56174. import { Matrix } from "babylonjs/Maths/math.vector";
  56175. import { Scene } from "babylonjs/scene";
  56176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56177. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56178. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56179. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56180. /**
  56181. * Block used to expose an input value
  56182. */
  56183. export class InputBlock extends NodeMaterialBlock {
  56184. private _mode;
  56185. private _associatedVariableName;
  56186. private _storedValue;
  56187. private _valueCallback;
  56188. private _type;
  56189. private _animationType;
  56190. /** Gets or set a value used to limit the range of float values */
  56191. min: number;
  56192. /** Gets or set a value used to limit the range of float values */
  56193. max: number;
  56194. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56195. matrixMode: number;
  56196. /** @hidden */
  56197. _systemValue: Nullable<NodeMaterialSystemValues>;
  56198. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56199. visibleInInspector: boolean;
  56200. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56201. isConstant: boolean;
  56202. /**
  56203. * Gets or sets the connection point type (default is float)
  56204. */
  56205. readonly type: NodeMaterialBlockConnectionPointTypes;
  56206. /**
  56207. * Creates a new InputBlock
  56208. * @param name defines the block name
  56209. * @param target defines the target of that block (Vertex by default)
  56210. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56211. */
  56212. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56213. /**
  56214. * Gets the output component
  56215. */
  56216. readonly output: NodeMaterialConnectionPoint;
  56217. /**
  56218. * Set the source of this connection point to a vertex attribute
  56219. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56220. * @returns the current connection point
  56221. */
  56222. setAsAttribute(attributeName?: string): InputBlock;
  56223. /**
  56224. * Set the source of this connection point to a system value
  56225. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56226. * @returns the current connection point
  56227. */
  56228. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56229. /**
  56230. * Gets or sets the value of that point.
  56231. * Please note that this value will be ignored if valueCallback is defined
  56232. */
  56233. value: any;
  56234. /**
  56235. * Gets or sets a callback used to get the value of that point.
  56236. * Please note that setting this value will force the connection point to ignore the value property
  56237. */
  56238. valueCallback: () => any;
  56239. /**
  56240. * Gets or sets the associated variable name in the shader
  56241. */
  56242. associatedVariableName: string;
  56243. /** Gets or sets the type of animation applied to the input */
  56244. animationType: AnimatedInputBlockTypes;
  56245. /**
  56246. * Gets a boolean indicating that this connection point not defined yet
  56247. */
  56248. readonly isUndefined: boolean;
  56249. /**
  56250. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56251. * In this case the connection point name must be the name of the uniform to use.
  56252. * Can only be set on inputs
  56253. */
  56254. isUniform: boolean;
  56255. /**
  56256. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56257. * In this case the connection point name must be the name of the attribute to use
  56258. * Can only be set on inputs
  56259. */
  56260. isAttribute: boolean;
  56261. /**
  56262. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56263. * Can only be set on exit points
  56264. */
  56265. isVarying: boolean;
  56266. /**
  56267. * Gets a boolean indicating that the current connection point is a system value
  56268. */
  56269. readonly isSystemValue: boolean;
  56270. /**
  56271. * Gets or sets the current well known value or null if not defined as a system value
  56272. */
  56273. systemValue: Nullable<NodeMaterialSystemValues>;
  56274. /**
  56275. * Gets the current class name
  56276. * @returns the class name
  56277. */
  56278. getClassName(): string;
  56279. /**
  56280. * Animate the input if animationType !== None
  56281. * @param scene defines the rendering scene
  56282. */
  56283. animate(scene: Scene): void;
  56284. private _emitDefine;
  56285. initialize(state: NodeMaterialBuildState): void;
  56286. /**
  56287. * Set the input block to its default value (based on its type)
  56288. */
  56289. setDefaultValue(): void;
  56290. private _emitConstant;
  56291. private _emit;
  56292. /** @hidden */
  56293. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56294. /** @hidden */
  56295. _transmit(effect: Effect, scene: Scene): void;
  56296. protected _buildBlock(state: NodeMaterialBuildState): void;
  56297. protected _dumpPropertiesCode(): string;
  56298. serialize(): any;
  56299. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56300. }
  56301. }
  56302. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56303. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56304. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56305. import { Nullable } from "babylonjs/types";
  56306. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56308. /**
  56309. * Defines a connection point for a block
  56310. */
  56311. export class NodeMaterialConnectionPoint {
  56312. /** @hidden */
  56313. _ownerBlock: NodeMaterialBlock;
  56314. /** @hidden */
  56315. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56316. private _endpoints;
  56317. private _associatedVariableName;
  56318. /** @hidden */
  56319. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56320. /** @hidden */
  56321. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56322. private _type;
  56323. /** @hidden */
  56324. _enforceAssociatedVariableName: boolean;
  56325. /**
  56326. * Gets or sets the additional types supported by this connection point
  56327. */
  56328. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56329. /**
  56330. * Gets or sets the additional types excluded by this connection point
  56331. */
  56332. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56333. /**
  56334. * Gets or sets the associated variable name in the shader
  56335. */
  56336. associatedVariableName: string;
  56337. /**
  56338. * Gets or sets the connection point type (default is float)
  56339. */
  56340. type: NodeMaterialBlockConnectionPointTypes;
  56341. /**
  56342. * Gets or sets the connection point name
  56343. */
  56344. name: string;
  56345. /**
  56346. * Gets or sets a boolean indicating that this connection point can be omitted
  56347. */
  56348. isOptional: boolean;
  56349. /**
  56350. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56351. */
  56352. define: string;
  56353. /** Gets or sets the target of that connection point */
  56354. target: NodeMaterialBlockTargets;
  56355. /**
  56356. * Gets a boolean indicating that the current point is connected
  56357. */
  56358. readonly isConnected: boolean;
  56359. /**
  56360. * Gets a boolean indicating that the current point is connected to an input block
  56361. */
  56362. readonly isConnectedToInputBlock: boolean;
  56363. /**
  56364. * Gets a the connected input block (if any)
  56365. */
  56366. readonly connectInputBlock: Nullable<InputBlock>;
  56367. /** Get the other side of the connection (if any) */
  56368. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56369. /** Get the block that owns this connection point */
  56370. readonly ownerBlock: NodeMaterialBlock;
  56371. /** Get the block connected on the other side of this connection (if any) */
  56372. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56373. /** Get the block connected on the endpoints of this connection (if any) */
  56374. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56375. /** Gets the list of connected endpoints */
  56376. readonly endpoints: NodeMaterialConnectionPoint[];
  56377. /** Gets a boolean indicating if that output point is connected to at least one input */
  56378. readonly hasEndpoints: boolean;
  56379. /**
  56380. * Creates a new connection point
  56381. * @param name defines the connection point name
  56382. * @param ownerBlock defines the block hosting this connection point
  56383. */
  56384. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56385. /**
  56386. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56387. * @returns the class name
  56388. */
  56389. getClassName(): string;
  56390. /**
  56391. * Gets an boolean indicating if the current point can be connected to another point
  56392. * @param connectionPoint defines the other connection point
  56393. * @returns true if the connection is possible
  56394. */
  56395. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56396. /**
  56397. * Connect this point to another connection point
  56398. * @param connectionPoint defines the other connection point
  56399. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56400. * @returns the current connection point
  56401. */
  56402. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56403. /**
  56404. * Disconnect this point from one of his endpoint
  56405. * @param endpoint defines the other connection point
  56406. * @returns the current connection point
  56407. */
  56408. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56409. /**
  56410. * Serializes this point in a JSON representation
  56411. * @returns the serialized point object
  56412. */
  56413. serialize(): any;
  56414. }
  56415. }
  56416. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56420. import { Mesh } from "babylonjs/Meshes/mesh";
  56421. import { Effect } from "babylonjs/Materials/effect";
  56422. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56425. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56426. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56427. /**
  56428. * Block used to add support for vertex skinning (bones)
  56429. */
  56430. export class BonesBlock extends NodeMaterialBlock {
  56431. /**
  56432. * Creates a new BonesBlock
  56433. * @param name defines the block name
  56434. */
  56435. constructor(name: string);
  56436. /**
  56437. * Initialize the block and prepare the context for build
  56438. * @param state defines the state that will be used for the build
  56439. */
  56440. initialize(state: NodeMaterialBuildState): void;
  56441. /**
  56442. * Gets the current class name
  56443. * @returns the class name
  56444. */
  56445. getClassName(): string;
  56446. /**
  56447. * Gets the matrix indices input component
  56448. */
  56449. readonly matricesIndices: NodeMaterialConnectionPoint;
  56450. /**
  56451. * Gets the matrix weights input component
  56452. */
  56453. readonly matricesWeights: NodeMaterialConnectionPoint;
  56454. /**
  56455. * Gets the extra matrix indices input component
  56456. */
  56457. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56458. /**
  56459. * Gets the extra matrix weights input component
  56460. */
  56461. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56462. /**
  56463. * Gets the world input component
  56464. */
  56465. readonly world: NodeMaterialConnectionPoint;
  56466. /**
  56467. * Gets the output component
  56468. */
  56469. readonly output: NodeMaterialConnectionPoint;
  56470. autoConfigure(material: NodeMaterial): void;
  56471. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56472. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56474. protected _buildBlock(state: NodeMaterialBuildState): this;
  56475. }
  56476. }
  56477. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56479. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56482. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56483. /**
  56484. * Block used to add support for instances
  56485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56486. */
  56487. export class InstancesBlock extends NodeMaterialBlock {
  56488. /**
  56489. * Creates a new InstancesBlock
  56490. * @param name defines the block name
  56491. */
  56492. constructor(name: string);
  56493. /**
  56494. * Gets the current class name
  56495. * @returns the class name
  56496. */
  56497. getClassName(): string;
  56498. /**
  56499. * Gets the first world row input component
  56500. */
  56501. readonly world0: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the second world row input component
  56504. */
  56505. readonly world1: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the third world row input component
  56508. */
  56509. readonly world2: NodeMaterialConnectionPoint;
  56510. /**
  56511. * Gets the forth world row input component
  56512. */
  56513. readonly world3: NodeMaterialConnectionPoint;
  56514. /**
  56515. * Gets the world input component
  56516. */
  56517. readonly world: NodeMaterialConnectionPoint;
  56518. /**
  56519. * Gets the output component
  56520. */
  56521. readonly output: NodeMaterialConnectionPoint;
  56522. autoConfigure(material: NodeMaterial): void;
  56523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56524. protected _buildBlock(state: NodeMaterialBuildState): this;
  56525. }
  56526. }
  56527. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56532. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56533. import { Effect } from "babylonjs/Materials/effect";
  56534. import { Mesh } from "babylonjs/Meshes/mesh";
  56535. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56536. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56537. /**
  56538. * Block used to add morph targets support to vertex shader
  56539. */
  56540. export class MorphTargetsBlock extends NodeMaterialBlock {
  56541. private _repeatableContentAnchor;
  56542. private _repeatebleContentGenerated;
  56543. /**
  56544. * Create a new MorphTargetsBlock
  56545. * @param name defines the block name
  56546. */
  56547. constructor(name: string);
  56548. /**
  56549. * Gets the current class name
  56550. * @returns the class name
  56551. */
  56552. getClassName(): string;
  56553. /**
  56554. * Gets the position input component
  56555. */
  56556. readonly position: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the normal input component
  56559. */
  56560. readonly normal: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the tangent input component
  56563. */
  56564. readonly tangent: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the tangent input component
  56567. */
  56568. readonly uv: NodeMaterialConnectionPoint;
  56569. /**
  56570. * Gets the position output component
  56571. */
  56572. readonly positionOutput: NodeMaterialConnectionPoint;
  56573. /**
  56574. * Gets the normal output component
  56575. */
  56576. readonly normalOutput: NodeMaterialConnectionPoint;
  56577. /**
  56578. * Gets the tangent output component
  56579. */
  56580. readonly tangentOutput: NodeMaterialConnectionPoint;
  56581. /**
  56582. * Gets the tangent output component
  56583. */
  56584. readonly uvOutput: NodeMaterialConnectionPoint;
  56585. initialize(state: NodeMaterialBuildState): void;
  56586. autoConfigure(material: NodeMaterial): void;
  56587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56589. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56590. protected _buildBlock(state: NodeMaterialBuildState): this;
  56591. }
  56592. }
  56593. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56597. import { Nullable } from "babylonjs/types";
  56598. import { Scene } from "babylonjs/scene";
  56599. import { Effect } from "babylonjs/Materials/effect";
  56600. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56601. import { Mesh } from "babylonjs/Meshes/mesh";
  56602. import { Light } from "babylonjs/Lights/light";
  56603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56604. /**
  56605. * Block used to get data information from a light
  56606. */
  56607. export class LightInformationBlock extends NodeMaterialBlock {
  56608. private _lightDataUniformName;
  56609. private _lightColorUniformName;
  56610. private _lightTypeDefineName;
  56611. /**
  56612. * Gets or sets the light associated with this block
  56613. */
  56614. light: Nullable<Light>;
  56615. /**
  56616. * Creates a new LightInformationBlock
  56617. * @param name defines the block name
  56618. */
  56619. constructor(name: string);
  56620. /**
  56621. * Gets the current class name
  56622. * @returns the class name
  56623. */
  56624. getClassName(): string;
  56625. /**
  56626. * Gets the world position input component
  56627. */
  56628. readonly worldPosition: NodeMaterialConnectionPoint;
  56629. /**
  56630. * Gets the direction output component
  56631. */
  56632. readonly direction: NodeMaterialConnectionPoint;
  56633. /**
  56634. * Gets the direction output component
  56635. */
  56636. readonly color: NodeMaterialConnectionPoint;
  56637. /**
  56638. * Gets the direction output component
  56639. */
  56640. readonly intensity: NodeMaterialConnectionPoint;
  56641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56643. protected _buildBlock(state: NodeMaterialBuildState): this;
  56644. serialize(): any;
  56645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56646. }
  56647. }
  56648. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56649. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56650. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56651. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56652. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56653. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56654. }
  56655. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56660. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56661. import { Effect } from "babylonjs/Materials/effect";
  56662. import { Mesh } from "babylonjs/Meshes/mesh";
  56663. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56664. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56665. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56666. /**
  56667. * Block used to add image processing support to fragment shader
  56668. */
  56669. export class ImageProcessingBlock extends NodeMaterialBlock {
  56670. /**
  56671. * Create a new ImageProcessingBlock
  56672. * @param name defines the block name
  56673. */
  56674. constructor(name: string);
  56675. /**
  56676. * Gets the current class name
  56677. * @returns the class name
  56678. */
  56679. getClassName(): string;
  56680. /**
  56681. * Gets the color input component
  56682. */
  56683. readonly color: NodeMaterialConnectionPoint;
  56684. /**
  56685. * Gets the output component
  56686. */
  56687. readonly output: NodeMaterialConnectionPoint;
  56688. /**
  56689. * Initialize the block and prepare the context for build
  56690. * @param state defines the state that will be used for the build
  56691. */
  56692. initialize(state: NodeMaterialBuildState): void;
  56693. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56696. protected _buildBlock(state: NodeMaterialBuildState): this;
  56697. }
  56698. }
  56699. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56703. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56705. import { Effect } from "babylonjs/Materials/effect";
  56706. import { Mesh } from "babylonjs/Meshes/mesh";
  56707. import { Scene } from "babylonjs/scene";
  56708. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56709. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56710. /**
  56711. * Block used to pertub normals based on a normal map
  56712. */
  56713. export class PerturbNormalBlock extends NodeMaterialBlock {
  56714. private _tangentSpaceParameterName;
  56715. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56716. invertX: boolean;
  56717. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56718. invertY: boolean;
  56719. /**
  56720. * Create a new PerturbNormalBlock
  56721. * @param name defines the block name
  56722. */
  56723. constructor(name: string);
  56724. /**
  56725. * Gets the current class name
  56726. * @returns the class name
  56727. */
  56728. getClassName(): string;
  56729. /**
  56730. * Gets the world position input component
  56731. */
  56732. readonly worldPosition: NodeMaterialConnectionPoint;
  56733. /**
  56734. * Gets the world normal input component
  56735. */
  56736. readonly worldNormal: NodeMaterialConnectionPoint;
  56737. /**
  56738. * Gets the uv input component
  56739. */
  56740. readonly uv: NodeMaterialConnectionPoint;
  56741. /**
  56742. * Gets the normal map color input component
  56743. */
  56744. readonly normalMapColor: NodeMaterialConnectionPoint;
  56745. /**
  56746. * Gets the strength input component
  56747. */
  56748. readonly strength: NodeMaterialConnectionPoint;
  56749. /**
  56750. * Gets the output component
  56751. */
  56752. readonly output: NodeMaterialConnectionPoint;
  56753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56755. autoConfigure(material: NodeMaterial): void;
  56756. protected _buildBlock(state: NodeMaterialBuildState): this;
  56757. protected _dumpPropertiesCode(): string;
  56758. serialize(): any;
  56759. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56760. }
  56761. }
  56762. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56766. /**
  56767. * Block used to discard a pixel if a value is smaller than a cutoff
  56768. */
  56769. export class DiscardBlock extends NodeMaterialBlock {
  56770. /**
  56771. * Create a new DiscardBlock
  56772. * @param name defines the block name
  56773. */
  56774. constructor(name: string);
  56775. /**
  56776. * Gets the current class name
  56777. * @returns the class name
  56778. */
  56779. getClassName(): string;
  56780. /**
  56781. * Gets the color input component
  56782. */
  56783. readonly value: NodeMaterialConnectionPoint;
  56784. /**
  56785. * Gets the cutoff input component
  56786. */
  56787. readonly cutoff: NodeMaterialConnectionPoint;
  56788. protected _buildBlock(state: NodeMaterialBuildState): this;
  56789. }
  56790. }
  56791. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56792. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56793. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56794. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56795. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56796. }
  56797. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56800. import { Mesh } from "babylonjs/Meshes/mesh";
  56801. import { Effect } from "babylonjs/Materials/effect";
  56802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56804. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56805. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56806. /**
  56807. * Block used to add support for scene fog
  56808. */
  56809. export class FogBlock extends NodeMaterialBlock {
  56810. private _fogDistanceName;
  56811. private _fogParameters;
  56812. /**
  56813. * Create a new FogBlock
  56814. * @param name defines the block name
  56815. */
  56816. constructor(name: string);
  56817. /**
  56818. * Gets the current class name
  56819. * @returns the class name
  56820. */
  56821. getClassName(): string;
  56822. /**
  56823. * Gets the world position input component
  56824. */
  56825. readonly worldPosition: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the view input component
  56828. */
  56829. readonly view: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the color input component
  56832. */
  56833. readonly input: NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the fog color input component
  56836. */
  56837. readonly fogColor: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the output component
  56840. */
  56841. readonly output: NodeMaterialConnectionPoint;
  56842. autoConfigure(material: NodeMaterial): void;
  56843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56845. protected _buildBlock(state: NodeMaterialBuildState): this;
  56846. }
  56847. }
  56848. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56851. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56854. import { Effect } from "babylonjs/Materials/effect";
  56855. import { Mesh } from "babylonjs/Meshes/mesh";
  56856. import { Light } from "babylonjs/Lights/light";
  56857. import { Nullable } from "babylonjs/types";
  56858. import { Scene } from "babylonjs/scene";
  56859. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56860. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56861. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56862. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56863. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56864. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56865. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56866. /**
  56867. * Block used to add light in the fragment shader
  56868. */
  56869. export class LightBlock extends NodeMaterialBlock {
  56870. private _lightId;
  56871. /**
  56872. * Gets or sets the light associated with this block
  56873. */
  56874. light: Nullable<Light>;
  56875. /**
  56876. * Create a new LightBlock
  56877. * @param name defines the block name
  56878. */
  56879. constructor(name: string);
  56880. /**
  56881. * Gets the current class name
  56882. * @returns the class name
  56883. */
  56884. getClassName(): string;
  56885. /**
  56886. * Gets the world position input component
  56887. */
  56888. readonly worldPosition: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the world normal input component
  56891. */
  56892. readonly worldNormal: NodeMaterialConnectionPoint;
  56893. /**
  56894. * Gets the camera (or eye) position component
  56895. */
  56896. readonly cameraPosition: NodeMaterialConnectionPoint;
  56897. /**
  56898. * Gets the glossiness component
  56899. */
  56900. readonly glossiness: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the glossinness power component
  56903. */
  56904. readonly glossPower: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the diffuse color component
  56907. */
  56908. readonly diffuseColor: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the specular color component
  56911. */
  56912. readonly specularColor: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the diffuse output component
  56915. */
  56916. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the specular output component
  56919. */
  56920. readonly specularOutput: NodeMaterialConnectionPoint;
  56921. autoConfigure(material: NodeMaterial): void;
  56922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56923. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56925. private _injectVertexCode;
  56926. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56927. serialize(): any;
  56928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56929. }
  56930. }
  56931. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56932. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56933. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56934. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56935. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56936. }
  56937. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56938. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56939. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56940. }
  56941. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56945. /**
  56946. * Block used to multiply 2 values
  56947. */
  56948. export class MultiplyBlock extends NodeMaterialBlock {
  56949. /**
  56950. * Creates a new MultiplyBlock
  56951. * @param name defines the block name
  56952. */
  56953. constructor(name: string);
  56954. /**
  56955. * Gets the current class name
  56956. * @returns the class name
  56957. */
  56958. getClassName(): string;
  56959. /**
  56960. * Gets the left operand input component
  56961. */
  56962. readonly left: NodeMaterialConnectionPoint;
  56963. /**
  56964. * Gets the right operand input component
  56965. */
  56966. readonly right: NodeMaterialConnectionPoint;
  56967. /**
  56968. * Gets the output component
  56969. */
  56970. readonly output: NodeMaterialConnectionPoint;
  56971. protected _buildBlock(state: NodeMaterialBuildState): this;
  56972. }
  56973. }
  56974. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56978. /**
  56979. * Block used to add 2 vectors
  56980. */
  56981. export class AddBlock extends NodeMaterialBlock {
  56982. /**
  56983. * Creates a new AddBlock
  56984. * @param name defines the block name
  56985. */
  56986. constructor(name: string);
  56987. /**
  56988. * Gets the current class name
  56989. * @returns the class name
  56990. */
  56991. getClassName(): string;
  56992. /**
  56993. * Gets the left operand input component
  56994. */
  56995. readonly left: NodeMaterialConnectionPoint;
  56996. /**
  56997. * Gets the right operand input component
  56998. */
  56999. readonly right: NodeMaterialConnectionPoint;
  57000. /**
  57001. * Gets the output component
  57002. */
  57003. readonly output: NodeMaterialConnectionPoint;
  57004. protected _buildBlock(state: NodeMaterialBuildState): this;
  57005. }
  57006. }
  57007. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57011. /**
  57012. * Block used to scale a vector by a float
  57013. */
  57014. export class ScaleBlock extends NodeMaterialBlock {
  57015. /**
  57016. * Creates a new ScaleBlock
  57017. * @param name defines the block name
  57018. */
  57019. constructor(name: string);
  57020. /**
  57021. * Gets the current class name
  57022. * @returns the class name
  57023. */
  57024. getClassName(): string;
  57025. /**
  57026. * Gets the input component
  57027. */
  57028. readonly input: NodeMaterialConnectionPoint;
  57029. /**
  57030. * Gets the factor input component
  57031. */
  57032. readonly factor: NodeMaterialConnectionPoint;
  57033. /**
  57034. * Gets the output component
  57035. */
  57036. readonly output: NodeMaterialConnectionPoint;
  57037. protected _buildBlock(state: NodeMaterialBuildState): this;
  57038. }
  57039. }
  57040. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57044. import { Scene } from "babylonjs/scene";
  57045. /**
  57046. * Block used to clamp a float
  57047. */
  57048. export class ClampBlock extends NodeMaterialBlock {
  57049. /** Gets or sets the minimum range */
  57050. minimum: number;
  57051. /** Gets or sets the maximum range */
  57052. maximum: number;
  57053. /**
  57054. * Creates a new ClampBlock
  57055. * @param name defines the block name
  57056. */
  57057. constructor(name: string);
  57058. /**
  57059. * Gets the current class name
  57060. * @returns the class name
  57061. */
  57062. getClassName(): string;
  57063. /**
  57064. * Gets the value input component
  57065. */
  57066. readonly value: NodeMaterialConnectionPoint;
  57067. /**
  57068. * Gets the output component
  57069. */
  57070. readonly output: NodeMaterialConnectionPoint;
  57071. protected _buildBlock(state: NodeMaterialBuildState): this;
  57072. protected _dumpPropertiesCode(): string;
  57073. serialize(): any;
  57074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57075. }
  57076. }
  57077. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57079. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57080. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57081. /**
  57082. * Block used to apply a cross product between 2 vectors
  57083. */
  57084. export class CrossBlock extends NodeMaterialBlock {
  57085. /**
  57086. * Creates a new CrossBlock
  57087. * @param name defines the block name
  57088. */
  57089. constructor(name: string);
  57090. /**
  57091. * Gets the current class name
  57092. * @returns the class name
  57093. */
  57094. getClassName(): string;
  57095. /**
  57096. * Gets the left operand input component
  57097. */
  57098. readonly left: NodeMaterialConnectionPoint;
  57099. /**
  57100. * Gets the right operand input component
  57101. */
  57102. readonly right: NodeMaterialConnectionPoint;
  57103. /**
  57104. * Gets the output component
  57105. */
  57106. readonly output: NodeMaterialConnectionPoint;
  57107. protected _buildBlock(state: NodeMaterialBuildState): this;
  57108. }
  57109. }
  57110. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57114. /**
  57115. * Block used to apply a dot product between 2 vectors
  57116. */
  57117. export class DotBlock extends NodeMaterialBlock {
  57118. /**
  57119. * Creates a new DotBlock
  57120. * @param name defines the block name
  57121. */
  57122. constructor(name: string);
  57123. /**
  57124. * Gets the current class name
  57125. * @returns the class name
  57126. */
  57127. getClassName(): string;
  57128. /**
  57129. * Gets the left operand input component
  57130. */
  57131. readonly left: NodeMaterialConnectionPoint;
  57132. /**
  57133. * Gets the right operand input component
  57134. */
  57135. readonly right: NodeMaterialConnectionPoint;
  57136. /**
  57137. * Gets the output component
  57138. */
  57139. readonly output: NodeMaterialConnectionPoint;
  57140. protected _buildBlock(state: NodeMaterialBuildState): this;
  57141. }
  57142. }
  57143. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57147. import { Vector2 } from "babylonjs/Maths/math.vector";
  57148. import { Scene } from "babylonjs/scene";
  57149. /**
  57150. * Block used to remap a float from a range to a new one
  57151. */
  57152. export class RemapBlock extends NodeMaterialBlock {
  57153. /**
  57154. * Gets or sets the source range
  57155. */
  57156. sourceRange: Vector2;
  57157. /**
  57158. * Gets or sets the target range
  57159. */
  57160. targetRange: Vector2;
  57161. /**
  57162. * Creates a new RemapBlock
  57163. * @param name defines the block name
  57164. */
  57165. constructor(name: string);
  57166. /**
  57167. * Gets the current class name
  57168. * @returns the class name
  57169. */
  57170. getClassName(): string;
  57171. /**
  57172. * Gets the input component
  57173. */
  57174. readonly input: NodeMaterialConnectionPoint;
  57175. /**
  57176. * Gets the source min input component
  57177. */
  57178. readonly sourceMin: NodeMaterialConnectionPoint;
  57179. /**
  57180. * Gets the source max input component
  57181. */
  57182. readonly sourceMax: NodeMaterialConnectionPoint;
  57183. /**
  57184. * Gets the target min input component
  57185. */
  57186. readonly targetMin: NodeMaterialConnectionPoint;
  57187. /**
  57188. * Gets the target max input component
  57189. */
  57190. readonly targetMax: NodeMaterialConnectionPoint;
  57191. /**
  57192. * Gets the output component
  57193. */
  57194. readonly output: NodeMaterialConnectionPoint;
  57195. protected _buildBlock(state: NodeMaterialBuildState): this;
  57196. protected _dumpPropertiesCode(): string;
  57197. serialize(): any;
  57198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57199. }
  57200. }
  57201. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57205. /**
  57206. * Block used to normalize a vector
  57207. */
  57208. export class NormalizeBlock extends NodeMaterialBlock {
  57209. /**
  57210. * Creates a new NormalizeBlock
  57211. * @param name defines the block name
  57212. */
  57213. constructor(name: string);
  57214. /**
  57215. * Gets the current class name
  57216. * @returns the class name
  57217. */
  57218. getClassName(): string;
  57219. /**
  57220. * Gets the input component
  57221. */
  57222. readonly input: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the output component
  57225. */
  57226. readonly output: NodeMaterialConnectionPoint;
  57227. protected _buildBlock(state: NodeMaterialBuildState): this;
  57228. }
  57229. }
  57230. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57234. import { Scene } from "babylonjs/scene";
  57235. /**
  57236. * Operations supported by the Trigonometry block
  57237. */
  57238. export enum TrigonometryBlockOperations {
  57239. /** Cos */
  57240. Cos = 0,
  57241. /** Sin */
  57242. Sin = 1,
  57243. /** Abs */
  57244. Abs = 2,
  57245. /** Exp */
  57246. Exp = 3,
  57247. /** Exp2 */
  57248. Exp2 = 4,
  57249. /** Round */
  57250. Round = 5,
  57251. /** Floor */
  57252. Floor = 6,
  57253. /** Ceiling */
  57254. Ceiling = 7,
  57255. /** Square root */
  57256. Sqrt = 8,
  57257. /** Log */
  57258. Log = 9,
  57259. /** Tangent */
  57260. Tan = 10,
  57261. /** Arc tangent */
  57262. ArcTan = 11,
  57263. /** Arc cosinus */
  57264. ArcCos = 12,
  57265. /** Arc sinus */
  57266. ArcSin = 13,
  57267. /** Fraction */
  57268. Fract = 14,
  57269. /** Sign */
  57270. Sign = 15,
  57271. /** To radians (from degrees) */
  57272. Radians = 16,
  57273. /** To degrees (from radians) */
  57274. Degrees = 17
  57275. }
  57276. /**
  57277. * Block used to apply trigonometry operation to floats
  57278. */
  57279. export class TrigonometryBlock extends NodeMaterialBlock {
  57280. /**
  57281. * Gets or sets the operation applied by the block
  57282. */
  57283. operation: TrigonometryBlockOperations;
  57284. /**
  57285. * Creates a new TrigonometryBlock
  57286. * @param name defines the block name
  57287. */
  57288. constructor(name: string);
  57289. /**
  57290. * Gets the current class name
  57291. * @returns the class name
  57292. */
  57293. getClassName(): string;
  57294. /**
  57295. * Gets the input component
  57296. */
  57297. readonly input: NodeMaterialConnectionPoint;
  57298. /**
  57299. * Gets the output component
  57300. */
  57301. readonly output: NodeMaterialConnectionPoint;
  57302. protected _buildBlock(state: NodeMaterialBuildState): this;
  57303. serialize(): any;
  57304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57305. }
  57306. }
  57307. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57311. /**
  57312. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57313. */
  57314. export class ColorMergerBlock extends NodeMaterialBlock {
  57315. /**
  57316. * Create a new ColorMergerBlock
  57317. * @param name defines the block name
  57318. */
  57319. constructor(name: string);
  57320. /**
  57321. * Gets the current class name
  57322. * @returns the class name
  57323. */
  57324. getClassName(): string;
  57325. /**
  57326. * Gets the r component (input)
  57327. */
  57328. readonly r: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the g component (input)
  57331. */
  57332. readonly g: NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the b component (input)
  57335. */
  57336. readonly b: NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the a component (input)
  57339. */
  57340. readonly a: NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the rgba component (output)
  57343. */
  57344. readonly rgba: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the rgb component (output)
  57347. */
  57348. readonly rgb: NodeMaterialConnectionPoint;
  57349. protected _buildBlock(state: NodeMaterialBuildState): this;
  57350. }
  57351. }
  57352. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57356. /**
  57357. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57358. */
  57359. export class VectorMergerBlock extends NodeMaterialBlock {
  57360. /**
  57361. * Create a new VectorMergerBlock
  57362. * @param name defines the block name
  57363. */
  57364. constructor(name: string);
  57365. /**
  57366. * Gets the current class name
  57367. * @returns the class name
  57368. */
  57369. getClassName(): string;
  57370. /**
  57371. * Gets the x component (input)
  57372. */
  57373. readonly x: NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the y component (input)
  57376. */
  57377. readonly y: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the z component (input)
  57380. */
  57381. readonly z: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the w component (input)
  57384. */
  57385. readonly w: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the xyzw component (output)
  57388. */
  57389. readonly xyzw: NodeMaterialConnectionPoint;
  57390. /**
  57391. * Gets the xyz component (output)
  57392. */
  57393. readonly xyz: NodeMaterialConnectionPoint;
  57394. /**
  57395. * Gets the xy component (output)
  57396. */
  57397. readonly xy: NodeMaterialConnectionPoint;
  57398. protected _buildBlock(state: NodeMaterialBuildState): this;
  57399. }
  57400. }
  57401. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57405. /**
  57406. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57407. */
  57408. export class ColorSplitterBlock extends NodeMaterialBlock {
  57409. /**
  57410. * Create a new ColorSplitterBlock
  57411. * @param name defines the block name
  57412. */
  57413. constructor(name: string);
  57414. /**
  57415. * Gets the current class name
  57416. * @returns the class name
  57417. */
  57418. getClassName(): string;
  57419. /**
  57420. * Gets the rgba component (input)
  57421. */
  57422. readonly rgba: NodeMaterialConnectionPoint;
  57423. /**
  57424. * Gets the rgb component (input)
  57425. */
  57426. readonly rgbIn: NodeMaterialConnectionPoint;
  57427. /**
  57428. * Gets the rgb component (output)
  57429. */
  57430. readonly rgbOut: NodeMaterialConnectionPoint;
  57431. /**
  57432. * Gets the r component (output)
  57433. */
  57434. readonly r: NodeMaterialConnectionPoint;
  57435. /**
  57436. * Gets the g component (output)
  57437. */
  57438. readonly g: NodeMaterialConnectionPoint;
  57439. /**
  57440. * Gets the b component (output)
  57441. */
  57442. readonly b: NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the a component (output)
  57445. */
  57446. readonly a: NodeMaterialConnectionPoint;
  57447. protected _inputRename(name: string): string;
  57448. protected _outputRename(name: string): string;
  57449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57450. }
  57451. }
  57452. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57456. /**
  57457. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57458. */
  57459. export class VectorSplitterBlock extends NodeMaterialBlock {
  57460. /**
  57461. * Create a new VectorSplitterBlock
  57462. * @param name defines the block name
  57463. */
  57464. constructor(name: string);
  57465. /**
  57466. * Gets the current class name
  57467. * @returns the class name
  57468. */
  57469. getClassName(): string;
  57470. /**
  57471. * Gets the xyzw component (input)
  57472. */
  57473. readonly xyzw: NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the xyz component (input)
  57476. */
  57477. readonly xyzIn: NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the xy component (input)
  57480. */
  57481. readonly xyIn: NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the xyz component (output)
  57484. */
  57485. readonly xyzOut: NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the xy component (output)
  57488. */
  57489. readonly xyOut: NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the x component (output)
  57492. */
  57493. readonly x: NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the y component (output)
  57496. */
  57497. readonly y: NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the z component (output)
  57500. */
  57501. readonly z: NodeMaterialConnectionPoint;
  57502. /**
  57503. * Gets the w component (output)
  57504. */
  57505. readonly w: NodeMaterialConnectionPoint;
  57506. protected _inputRename(name: string): string;
  57507. protected _outputRename(name: string): string;
  57508. protected _buildBlock(state: NodeMaterialBuildState): this;
  57509. }
  57510. }
  57511. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57515. /**
  57516. * Block used to lerp between 2 values
  57517. */
  57518. export class LerpBlock extends NodeMaterialBlock {
  57519. /**
  57520. * Creates a new LerpBlock
  57521. * @param name defines the block name
  57522. */
  57523. constructor(name: string);
  57524. /**
  57525. * Gets the current class name
  57526. * @returns the class name
  57527. */
  57528. getClassName(): string;
  57529. /**
  57530. * Gets the left operand input component
  57531. */
  57532. readonly left: NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the right operand input component
  57535. */
  57536. readonly right: NodeMaterialConnectionPoint;
  57537. /**
  57538. * Gets the gradient operand input component
  57539. */
  57540. readonly gradient: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the output component
  57543. */
  57544. readonly output: NodeMaterialConnectionPoint;
  57545. protected _buildBlock(state: NodeMaterialBuildState): this;
  57546. }
  57547. }
  57548. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57552. /**
  57553. * Block used to divide 2 vectors
  57554. */
  57555. export class DivideBlock extends NodeMaterialBlock {
  57556. /**
  57557. * Creates a new DivideBlock
  57558. * @param name defines the block name
  57559. */
  57560. constructor(name: string);
  57561. /**
  57562. * Gets the current class name
  57563. * @returns the class name
  57564. */
  57565. getClassName(): string;
  57566. /**
  57567. * Gets the left operand input component
  57568. */
  57569. readonly left: NodeMaterialConnectionPoint;
  57570. /**
  57571. * Gets the right operand input component
  57572. */
  57573. readonly right: NodeMaterialConnectionPoint;
  57574. /**
  57575. * Gets the output component
  57576. */
  57577. readonly output: NodeMaterialConnectionPoint;
  57578. protected _buildBlock(state: NodeMaterialBuildState): this;
  57579. }
  57580. }
  57581. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57585. /**
  57586. * Block used to subtract 2 vectors
  57587. */
  57588. export class SubtractBlock extends NodeMaterialBlock {
  57589. /**
  57590. * Creates a new SubtractBlock
  57591. * @param name defines the block name
  57592. */
  57593. constructor(name: string);
  57594. /**
  57595. * Gets the current class name
  57596. * @returns the class name
  57597. */
  57598. getClassName(): string;
  57599. /**
  57600. * Gets the left operand input component
  57601. */
  57602. readonly left: NodeMaterialConnectionPoint;
  57603. /**
  57604. * Gets the right operand input component
  57605. */
  57606. readonly right: NodeMaterialConnectionPoint;
  57607. /**
  57608. * Gets the output component
  57609. */
  57610. readonly output: NodeMaterialConnectionPoint;
  57611. protected _buildBlock(state: NodeMaterialBuildState): this;
  57612. }
  57613. }
  57614. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57618. /**
  57619. * Block used to step a value
  57620. */
  57621. export class StepBlock extends NodeMaterialBlock {
  57622. /**
  57623. * Creates a new StepBlock
  57624. * @param name defines the block name
  57625. */
  57626. constructor(name: string);
  57627. /**
  57628. * Gets the current class name
  57629. * @returns the class name
  57630. */
  57631. getClassName(): string;
  57632. /**
  57633. * Gets the value operand input component
  57634. */
  57635. readonly value: NodeMaterialConnectionPoint;
  57636. /**
  57637. * Gets the edge operand input component
  57638. */
  57639. readonly edge: NodeMaterialConnectionPoint;
  57640. /**
  57641. * Gets the output component
  57642. */
  57643. readonly output: NodeMaterialConnectionPoint;
  57644. protected _buildBlock(state: NodeMaterialBuildState): this;
  57645. }
  57646. }
  57647. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57651. /**
  57652. * Block used to get the opposite (1 - x) of a value
  57653. */
  57654. export class OneMinusBlock extends NodeMaterialBlock {
  57655. /**
  57656. * Creates a new OneMinusBlock
  57657. * @param name defines the block name
  57658. */
  57659. constructor(name: string);
  57660. /**
  57661. * Gets the current class name
  57662. * @returns the class name
  57663. */
  57664. getClassName(): string;
  57665. /**
  57666. * Gets the input component
  57667. */
  57668. readonly input: NodeMaterialConnectionPoint;
  57669. /**
  57670. * Gets the output component
  57671. */
  57672. readonly output: NodeMaterialConnectionPoint;
  57673. protected _buildBlock(state: NodeMaterialBuildState): this;
  57674. }
  57675. }
  57676. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57680. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57681. /**
  57682. * Block used to get the view direction
  57683. */
  57684. export class ViewDirectionBlock extends NodeMaterialBlock {
  57685. /**
  57686. * Creates a new ViewDirectionBlock
  57687. * @param name defines the block name
  57688. */
  57689. constructor(name: string);
  57690. /**
  57691. * Gets the current class name
  57692. * @returns the class name
  57693. */
  57694. getClassName(): string;
  57695. /**
  57696. * Gets the world position component
  57697. */
  57698. readonly worldPosition: NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the camera position component
  57701. */
  57702. readonly cameraPosition: NodeMaterialConnectionPoint;
  57703. /**
  57704. * Gets the output component
  57705. */
  57706. readonly output: NodeMaterialConnectionPoint;
  57707. autoConfigure(material: NodeMaterial): void;
  57708. protected _buildBlock(state: NodeMaterialBuildState): this;
  57709. }
  57710. }
  57711. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57715. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57716. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57717. /**
  57718. * Block used to compute fresnel value
  57719. */
  57720. export class FresnelBlock extends NodeMaterialBlock {
  57721. /**
  57722. * Create a new FresnelBlock
  57723. * @param name defines the block name
  57724. */
  57725. constructor(name: string);
  57726. /**
  57727. * Gets the current class name
  57728. * @returns the class name
  57729. */
  57730. getClassName(): string;
  57731. /**
  57732. * Gets the world normal input component
  57733. */
  57734. readonly worldNormal: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the view direction input component
  57737. */
  57738. readonly viewDirection: NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the bias input component
  57741. */
  57742. readonly bias: NodeMaterialConnectionPoint;
  57743. /**
  57744. * Gets the camera (or eye) position component
  57745. */
  57746. readonly power: NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the fresnel output component
  57749. */
  57750. readonly fresnel: NodeMaterialConnectionPoint;
  57751. autoConfigure(material: NodeMaterial): void;
  57752. protected _buildBlock(state: NodeMaterialBuildState): this;
  57753. }
  57754. }
  57755. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57759. /**
  57760. * Block used to get the max of 2 values
  57761. */
  57762. export class MaxBlock extends NodeMaterialBlock {
  57763. /**
  57764. * Creates a new MaxBlock
  57765. * @param name defines the block name
  57766. */
  57767. constructor(name: string);
  57768. /**
  57769. * Gets the current class name
  57770. * @returns the class name
  57771. */
  57772. getClassName(): string;
  57773. /**
  57774. * Gets the left operand input component
  57775. */
  57776. readonly left: NodeMaterialConnectionPoint;
  57777. /**
  57778. * Gets the right operand input component
  57779. */
  57780. readonly right: NodeMaterialConnectionPoint;
  57781. /**
  57782. * Gets the output component
  57783. */
  57784. readonly output: NodeMaterialConnectionPoint;
  57785. protected _buildBlock(state: NodeMaterialBuildState): this;
  57786. }
  57787. }
  57788. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57791. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57792. /**
  57793. * Block used to get the min of 2 values
  57794. */
  57795. export class MinBlock extends NodeMaterialBlock {
  57796. /**
  57797. * Creates a new MinBlock
  57798. * @param name defines the block name
  57799. */
  57800. constructor(name: string);
  57801. /**
  57802. * Gets the current class name
  57803. * @returns the class name
  57804. */
  57805. getClassName(): string;
  57806. /**
  57807. * Gets the left operand input component
  57808. */
  57809. readonly left: NodeMaterialConnectionPoint;
  57810. /**
  57811. * Gets the right operand input component
  57812. */
  57813. readonly right: NodeMaterialConnectionPoint;
  57814. /**
  57815. * Gets the output component
  57816. */
  57817. readonly output: NodeMaterialConnectionPoint;
  57818. protected _buildBlock(state: NodeMaterialBuildState): this;
  57819. }
  57820. }
  57821. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57825. /**
  57826. * Block used to get the distance between 2 values
  57827. */
  57828. export class DistanceBlock extends NodeMaterialBlock {
  57829. /**
  57830. * Creates a new DistanceBlock
  57831. * @param name defines the block name
  57832. */
  57833. constructor(name: string);
  57834. /**
  57835. * Gets the current class name
  57836. * @returns the class name
  57837. */
  57838. getClassName(): string;
  57839. /**
  57840. * Gets the left operand input component
  57841. */
  57842. readonly left: NodeMaterialConnectionPoint;
  57843. /**
  57844. * Gets the right operand input component
  57845. */
  57846. readonly right: NodeMaterialConnectionPoint;
  57847. /**
  57848. * Gets the output component
  57849. */
  57850. readonly output: NodeMaterialConnectionPoint;
  57851. protected _buildBlock(state: NodeMaterialBuildState): this;
  57852. }
  57853. }
  57854. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57858. /**
  57859. * Block used to get the length of a vector
  57860. */
  57861. export class LengthBlock extends NodeMaterialBlock {
  57862. /**
  57863. * Creates a new LengthBlock
  57864. * @param name defines the block name
  57865. */
  57866. constructor(name: string);
  57867. /**
  57868. * Gets the current class name
  57869. * @returns the class name
  57870. */
  57871. getClassName(): string;
  57872. /**
  57873. * Gets the value input component
  57874. */
  57875. readonly value: NodeMaterialConnectionPoint;
  57876. /**
  57877. * Gets the output component
  57878. */
  57879. readonly output: NodeMaterialConnectionPoint;
  57880. protected _buildBlock(state: NodeMaterialBuildState): this;
  57881. }
  57882. }
  57883. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57887. /**
  57888. * Block used to get negative version of a value (i.e. x * -1)
  57889. */
  57890. export class NegateBlock extends NodeMaterialBlock {
  57891. /**
  57892. * Creates a new NegateBlock
  57893. * @param name defines the block name
  57894. */
  57895. constructor(name: string);
  57896. /**
  57897. * Gets the current class name
  57898. * @returns the class name
  57899. */
  57900. getClassName(): string;
  57901. /**
  57902. * Gets the value input component
  57903. */
  57904. readonly value: NodeMaterialConnectionPoint;
  57905. /**
  57906. * Gets the output component
  57907. */
  57908. readonly output: NodeMaterialConnectionPoint;
  57909. protected _buildBlock(state: NodeMaterialBuildState): this;
  57910. }
  57911. }
  57912. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57913. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57914. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57915. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57916. /**
  57917. * Block used to get the value of the first parameter raised to the power of the second
  57918. */
  57919. export class PowBlock extends NodeMaterialBlock {
  57920. /**
  57921. * Creates a new PowBlock
  57922. * @param name defines the block name
  57923. */
  57924. constructor(name: string);
  57925. /**
  57926. * Gets the current class name
  57927. * @returns the class name
  57928. */
  57929. getClassName(): string;
  57930. /**
  57931. * Gets the value operand input component
  57932. */
  57933. readonly value: NodeMaterialConnectionPoint;
  57934. /**
  57935. * Gets the power operand input component
  57936. */
  57937. readonly power: NodeMaterialConnectionPoint;
  57938. /**
  57939. * Gets the output component
  57940. */
  57941. readonly output: NodeMaterialConnectionPoint;
  57942. protected _buildBlock(state: NodeMaterialBuildState): this;
  57943. }
  57944. }
  57945. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57950. /**
  57951. * Block used to get a random number
  57952. */
  57953. export class RandomNumberBlock extends NodeMaterialBlock {
  57954. /**
  57955. * Creates a new RandomNumberBlock
  57956. * @param name defines the block name
  57957. */
  57958. constructor(name: string);
  57959. /**
  57960. * Gets the current class name
  57961. * @returns the class name
  57962. */
  57963. getClassName(): string;
  57964. /**
  57965. * Gets the seed input component
  57966. */
  57967. readonly seed: NodeMaterialConnectionPoint;
  57968. /**
  57969. * Gets the output component
  57970. */
  57971. readonly output: NodeMaterialConnectionPoint;
  57972. protected _buildBlock(state: NodeMaterialBuildState): this;
  57973. }
  57974. }
  57975. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57979. /**
  57980. * Block used to compute arc tangent of 2 values
  57981. */
  57982. export class ArcTan2Block extends NodeMaterialBlock {
  57983. /**
  57984. * Creates a new ArcTan2Block
  57985. * @param name defines the block name
  57986. */
  57987. constructor(name: string);
  57988. /**
  57989. * Gets the current class name
  57990. * @returns the class name
  57991. */
  57992. getClassName(): string;
  57993. /**
  57994. * Gets the x operand input component
  57995. */
  57996. readonly x: NodeMaterialConnectionPoint;
  57997. /**
  57998. * Gets the y operand input component
  57999. */
  58000. readonly y: NodeMaterialConnectionPoint;
  58001. /**
  58002. * Gets the output component
  58003. */
  58004. readonly output: NodeMaterialConnectionPoint;
  58005. protected _buildBlock(state: NodeMaterialBuildState): this;
  58006. }
  58007. }
  58008. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58009. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58011. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58012. /**
  58013. * Block used to smooth step a value
  58014. */
  58015. export class SmoothStepBlock extends NodeMaterialBlock {
  58016. /**
  58017. * Creates a new SmoothStepBlock
  58018. * @param name defines the block name
  58019. */
  58020. constructor(name: string);
  58021. /**
  58022. * Gets the current class name
  58023. * @returns the class name
  58024. */
  58025. getClassName(): string;
  58026. /**
  58027. * Gets the value operand input component
  58028. */
  58029. readonly value: NodeMaterialConnectionPoint;
  58030. /**
  58031. * Gets the first edge operand input component
  58032. */
  58033. readonly edge0: NodeMaterialConnectionPoint;
  58034. /**
  58035. * Gets the second edge operand input component
  58036. */
  58037. readonly edge1: NodeMaterialConnectionPoint;
  58038. /**
  58039. * Gets the output component
  58040. */
  58041. readonly output: NodeMaterialConnectionPoint;
  58042. protected _buildBlock(state: NodeMaterialBuildState): this;
  58043. }
  58044. }
  58045. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58046. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58047. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58048. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58049. /**
  58050. * Block used to get the reciprocal (1 / x) of a value
  58051. */
  58052. export class ReciprocalBlock extends NodeMaterialBlock {
  58053. /**
  58054. * Creates a new ReciprocalBlock
  58055. * @param name defines the block name
  58056. */
  58057. constructor(name: string);
  58058. /**
  58059. * Gets the current class name
  58060. * @returns the class name
  58061. */
  58062. getClassName(): string;
  58063. /**
  58064. * Gets the input component
  58065. */
  58066. readonly input: NodeMaterialConnectionPoint;
  58067. /**
  58068. * Gets the output component
  58069. */
  58070. readonly output: NodeMaterialConnectionPoint;
  58071. protected _buildBlock(state: NodeMaterialBuildState): this;
  58072. }
  58073. }
  58074. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58078. /**
  58079. * Block used to replace a color by another one
  58080. */
  58081. export class ReplaceColorBlock extends NodeMaterialBlock {
  58082. /**
  58083. * Creates a new ReplaceColorBlock
  58084. * @param name defines the block name
  58085. */
  58086. constructor(name: string);
  58087. /**
  58088. * Gets the current class name
  58089. * @returns the class name
  58090. */
  58091. getClassName(): string;
  58092. /**
  58093. * Gets the value input component
  58094. */
  58095. readonly value: NodeMaterialConnectionPoint;
  58096. /**
  58097. * Gets the reference input component
  58098. */
  58099. readonly reference: NodeMaterialConnectionPoint;
  58100. /**
  58101. * Gets the distance input component
  58102. */
  58103. readonly distance: NodeMaterialConnectionPoint;
  58104. /**
  58105. * Gets the replacement input component
  58106. */
  58107. readonly replacement: NodeMaterialConnectionPoint;
  58108. /**
  58109. * Gets the output component
  58110. */
  58111. readonly output: NodeMaterialConnectionPoint;
  58112. protected _buildBlock(state: NodeMaterialBuildState): this;
  58113. }
  58114. }
  58115. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58116. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58119. /**
  58120. * Block used to posterize a value
  58121. * @see https://en.wikipedia.org/wiki/Posterization
  58122. */
  58123. export class PosterizeBlock extends NodeMaterialBlock {
  58124. /**
  58125. * Creates a new PosterizeBlock
  58126. * @param name defines the block name
  58127. */
  58128. constructor(name: string);
  58129. /**
  58130. * Gets the current class name
  58131. * @returns the class name
  58132. */
  58133. getClassName(): string;
  58134. /**
  58135. * Gets the value input component
  58136. */
  58137. readonly value: NodeMaterialConnectionPoint;
  58138. /**
  58139. * Gets the steps input component
  58140. */
  58141. readonly steps: NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the output component
  58144. */
  58145. readonly output: NodeMaterialConnectionPoint;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. }
  58148. }
  58149. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58153. import { Scene } from "babylonjs/scene";
  58154. /**
  58155. * Operations supported by the Wave block
  58156. */
  58157. export enum WaveBlockKind {
  58158. /** SawTooth */
  58159. SawTooth = 0,
  58160. /** Square */
  58161. Square = 1,
  58162. /** Triangle */
  58163. Triangle = 2
  58164. }
  58165. /**
  58166. * Block used to apply wave operation to floats
  58167. */
  58168. export class WaveBlock extends NodeMaterialBlock {
  58169. /**
  58170. * Gets or sets the kibnd of wave to be applied by the block
  58171. */
  58172. kind: WaveBlockKind;
  58173. /**
  58174. * Creates a new WaveBlock
  58175. * @param name defines the block name
  58176. */
  58177. constructor(name: string);
  58178. /**
  58179. * Gets the current class name
  58180. * @returns the class name
  58181. */
  58182. getClassName(): string;
  58183. /**
  58184. * Gets the input component
  58185. */
  58186. readonly input: NodeMaterialConnectionPoint;
  58187. /**
  58188. * Gets the output component
  58189. */
  58190. readonly output: NodeMaterialConnectionPoint;
  58191. protected _buildBlock(state: NodeMaterialBuildState): this;
  58192. serialize(): any;
  58193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58194. }
  58195. }
  58196. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58200. import { Color3 } from "babylonjs/Maths/math.color";
  58201. import { Scene } from "babylonjs/scene";
  58202. /**
  58203. * Class used to store a color step for the GradientBlock
  58204. */
  58205. export class GradientBlockColorStep {
  58206. /**
  58207. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58208. */
  58209. step: number;
  58210. /**
  58211. * Gets or sets the color associated with this step
  58212. */
  58213. color: Color3;
  58214. /**
  58215. * Creates a new GradientBlockColorStep
  58216. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58217. * @param color defines the color associated with this step
  58218. */
  58219. constructor(
  58220. /**
  58221. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58222. */
  58223. step: number,
  58224. /**
  58225. * Gets or sets the color associated with this step
  58226. */
  58227. color: Color3);
  58228. }
  58229. /**
  58230. * Block used to return a color from a gradient based on an input value between 0 and 1
  58231. */
  58232. export class GradientBlock extends NodeMaterialBlock {
  58233. /**
  58234. * Gets or sets the list of color steps
  58235. */
  58236. colorSteps: GradientBlockColorStep[];
  58237. /**
  58238. * Creates a new GradientBlock
  58239. * @param name defines the block name
  58240. */
  58241. constructor(name: string);
  58242. /**
  58243. * Gets the current class name
  58244. * @returns the class name
  58245. */
  58246. getClassName(): string;
  58247. /**
  58248. * Gets the gradient input component
  58249. */
  58250. readonly gradient: NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the output component
  58253. */
  58254. readonly output: NodeMaterialConnectionPoint;
  58255. private _writeColorConstant;
  58256. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58257. serialize(): any;
  58258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58259. protected _dumpPropertiesCode(): string;
  58260. }
  58261. }
  58262. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58263. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58264. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58266. /**
  58267. * Block used to normalize lerp between 2 values
  58268. */
  58269. export class NLerpBlock extends NodeMaterialBlock {
  58270. /**
  58271. * Creates a new NLerpBlock
  58272. * @param name defines the block name
  58273. */
  58274. constructor(name: string);
  58275. /**
  58276. * Gets the current class name
  58277. * @returns the class name
  58278. */
  58279. getClassName(): string;
  58280. /**
  58281. * Gets the left operand input component
  58282. */
  58283. readonly left: NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the right operand input component
  58286. */
  58287. readonly right: NodeMaterialConnectionPoint;
  58288. /**
  58289. * Gets the gradient operand input component
  58290. */
  58291. readonly gradient: NodeMaterialConnectionPoint;
  58292. /**
  58293. * Gets the output component
  58294. */
  58295. readonly output: NodeMaterialConnectionPoint;
  58296. protected _buildBlock(state: NodeMaterialBuildState): this;
  58297. }
  58298. }
  58299. declare module "babylonjs/Materials/Node/Blocks/index" {
  58300. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58301. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58302. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58303. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58304. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58305. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58306. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58307. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58308. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58309. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58310. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58311. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58315. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58333. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58335. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58336. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58340. }
  58341. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58342. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58343. }
  58344. declare module "babylonjs/Materials/Node/index" {
  58345. export * from "babylonjs/Materials/Node/Enums/index";
  58346. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58347. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58348. export * from "babylonjs/Materials/Node/nodeMaterial";
  58349. export * from "babylonjs/Materials/Node/Blocks/index";
  58350. export * from "babylonjs/Materials/Node/Optimizers/index";
  58351. }
  58352. declare module "babylonjs/Materials/effectRenderer" {
  58353. import { Nullable } from "babylonjs/types";
  58354. import { Texture } from "babylonjs/Materials/Textures/texture";
  58355. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58356. import { Viewport } from "babylonjs/Maths/math.viewport";
  58357. import { Observable } from "babylonjs/Misc/observable";
  58358. import { Effect } from "babylonjs/Materials/effect";
  58359. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58360. import "babylonjs/Shaders/postprocess.vertex";
  58361. /**
  58362. * Effect Render Options
  58363. */
  58364. export interface IEffectRendererOptions {
  58365. /**
  58366. * Defines the vertices positions.
  58367. */
  58368. positions?: number[];
  58369. /**
  58370. * Defines the indices.
  58371. */
  58372. indices?: number[];
  58373. }
  58374. /**
  58375. * Helper class to render one or more effects
  58376. */
  58377. export class EffectRenderer {
  58378. private engine;
  58379. private static _DefaultOptions;
  58380. private _vertexBuffers;
  58381. private _indexBuffer;
  58382. private _ringBufferIndex;
  58383. private _ringScreenBuffer;
  58384. private _fullscreenViewport;
  58385. private _getNextFrameBuffer;
  58386. /**
  58387. * Creates an effect renderer
  58388. * @param engine the engine to use for rendering
  58389. * @param options defines the options of the effect renderer
  58390. */
  58391. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58392. /**
  58393. * Sets the current viewport in normalized coordinates 0-1
  58394. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58395. */
  58396. setViewport(viewport?: Viewport): void;
  58397. /**
  58398. * Binds the embedded attributes buffer to the effect.
  58399. * @param effect Defines the effect to bind the attributes for
  58400. */
  58401. bindBuffers(effect: Effect): void;
  58402. /**
  58403. * Sets the current effect wrapper to use during draw.
  58404. * The effect needs to be ready before calling this api.
  58405. * This also sets the default full screen position attribute.
  58406. * @param effectWrapper Defines the effect to draw with
  58407. */
  58408. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58409. /**
  58410. * Draws a full screen quad.
  58411. */
  58412. draw(): void;
  58413. /**
  58414. * renders one or more effects to a specified texture
  58415. * @param effectWrappers list of effects to renderer
  58416. * @param outputTexture texture to draw to, if null it will render to the screen
  58417. */
  58418. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58419. /**
  58420. * Disposes of the effect renderer
  58421. */
  58422. dispose(): void;
  58423. }
  58424. /**
  58425. * Options to create an EffectWrapper
  58426. */
  58427. interface EffectWrapperCreationOptions {
  58428. /**
  58429. * Engine to use to create the effect
  58430. */
  58431. engine: ThinEngine;
  58432. /**
  58433. * Fragment shader for the effect
  58434. */
  58435. fragmentShader: string;
  58436. /**
  58437. * Vertex shader for the effect
  58438. */
  58439. vertexShader?: string;
  58440. /**
  58441. * Attributes to use in the shader
  58442. */
  58443. attributeNames?: Array<string>;
  58444. /**
  58445. * Uniforms to use in the shader
  58446. */
  58447. uniformNames?: Array<string>;
  58448. /**
  58449. * Texture sampler names to use in the shader
  58450. */
  58451. samplerNames?: Array<string>;
  58452. /**
  58453. * The friendly name of the effect displayed in Spector.
  58454. */
  58455. name?: string;
  58456. }
  58457. /**
  58458. * Wraps an effect to be used for rendering
  58459. */
  58460. export class EffectWrapper {
  58461. /**
  58462. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58463. */
  58464. onApplyObservable: Observable<{}>;
  58465. /**
  58466. * The underlying effect
  58467. */
  58468. effect: Effect;
  58469. /**
  58470. * Creates an effect to be renderer
  58471. * @param creationOptions options to create the effect
  58472. */
  58473. constructor(creationOptions: EffectWrapperCreationOptions);
  58474. /**
  58475. * Disposes of the effect wrapper
  58476. */
  58477. dispose(): void;
  58478. }
  58479. }
  58480. declare module "babylonjs/Materials/index" {
  58481. export * from "babylonjs/Materials/Background/index";
  58482. export * from "babylonjs/Materials/colorCurves";
  58483. export * from "babylonjs/Materials/iEffectFallbacks";
  58484. export * from "babylonjs/Materials/effectFallbacks";
  58485. export * from "babylonjs/Materials/effect";
  58486. export * from "babylonjs/Materials/fresnelParameters";
  58487. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58488. export * from "babylonjs/Materials/material";
  58489. export * from "babylonjs/Materials/materialDefines";
  58490. export * from "babylonjs/Materials/materialHelper";
  58491. export * from "babylonjs/Materials/multiMaterial";
  58492. export * from "babylonjs/Materials/PBR/index";
  58493. export * from "babylonjs/Materials/pushMaterial";
  58494. export * from "babylonjs/Materials/shaderMaterial";
  58495. export * from "babylonjs/Materials/standardMaterial";
  58496. export * from "babylonjs/Materials/Textures/index";
  58497. export * from "babylonjs/Materials/uniformBuffer";
  58498. export * from "babylonjs/Materials/materialFlags";
  58499. export * from "babylonjs/Materials/Node/index";
  58500. export * from "babylonjs/Materials/effectRenderer";
  58501. }
  58502. declare module "babylonjs/Maths/index" {
  58503. export * from "babylonjs/Maths/math.scalar";
  58504. export * from "babylonjs/Maths/math";
  58505. export * from "babylonjs/Maths/sphericalPolynomial";
  58506. }
  58507. declare module "babylonjs/Misc/workerPool" {
  58508. import { IDisposable } from "babylonjs/scene";
  58509. /**
  58510. * Helper class to push actions to a pool of workers.
  58511. */
  58512. export class WorkerPool implements IDisposable {
  58513. private _workerInfos;
  58514. private _pendingActions;
  58515. /**
  58516. * Constructor
  58517. * @param workers Array of workers to use for actions
  58518. */
  58519. constructor(workers: Array<Worker>);
  58520. /**
  58521. * Terminates all workers and clears any pending actions.
  58522. */
  58523. dispose(): void;
  58524. /**
  58525. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58526. * pended until a worker has completed its action.
  58527. * @param action The action to perform. Call onComplete when the action is complete.
  58528. */
  58529. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58530. private _execute;
  58531. }
  58532. }
  58533. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58534. import { IDisposable } from "babylonjs/scene";
  58535. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58536. /**
  58537. * Configuration for Draco compression
  58538. */
  58539. export interface IDracoCompressionConfiguration {
  58540. /**
  58541. * Configuration for the decoder.
  58542. */
  58543. decoder: {
  58544. /**
  58545. * The url to the WebAssembly module.
  58546. */
  58547. wasmUrl?: string;
  58548. /**
  58549. * The url to the WebAssembly binary.
  58550. */
  58551. wasmBinaryUrl?: string;
  58552. /**
  58553. * The url to the fallback JavaScript module.
  58554. */
  58555. fallbackUrl?: string;
  58556. };
  58557. }
  58558. /**
  58559. * Draco compression (https://google.github.io/draco/)
  58560. *
  58561. * This class wraps the Draco module.
  58562. *
  58563. * **Encoder**
  58564. *
  58565. * The encoder is not currently implemented.
  58566. *
  58567. * **Decoder**
  58568. *
  58569. * 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.
  58570. *
  58571. * To update the configuration, use the following code:
  58572. * ```javascript
  58573. * DracoCompression.Configuration = {
  58574. * decoder: {
  58575. * wasmUrl: "<url to the WebAssembly library>",
  58576. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58577. * fallbackUrl: "<url to the fallback JavaScript library>",
  58578. * }
  58579. * };
  58580. * ```
  58581. *
  58582. * 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.
  58583. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58584. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58585. *
  58586. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58587. * ```javascript
  58588. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58589. * ```
  58590. *
  58591. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58592. */
  58593. export class DracoCompression implements IDisposable {
  58594. private _workerPoolPromise?;
  58595. private _decoderModulePromise?;
  58596. /**
  58597. * The configuration. Defaults to the following urls:
  58598. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58599. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58600. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58601. */
  58602. static Configuration: IDracoCompressionConfiguration;
  58603. /**
  58604. * Returns true if the decoder configuration is available.
  58605. */
  58606. static readonly DecoderAvailable: boolean;
  58607. /**
  58608. * Default number of workers to create when creating the draco compression object.
  58609. */
  58610. static DefaultNumWorkers: number;
  58611. private static GetDefaultNumWorkers;
  58612. private static _Default;
  58613. /**
  58614. * Default instance for the draco compression object.
  58615. */
  58616. static readonly Default: DracoCompression;
  58617. /**
  58618. * Constructor
  58619. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58620. */
  58621. constructor(numWorkers?: number);
  58622. /**
  58623. * Stop all async operations and release resources.
  58624. */
  58625. dispose(): void;
  58626. /**
  58627. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58628. * @returns a promise that resolves when ready
  58629. */
  58630. whenReadyAsync(): Promise<void>;
  58631. /**
  58632. * Decode Draco compressed mesh data to vertex data.
  58633. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58634. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58635. * @returns A promise that resolves with the decoded vertex data
  58636. */
  58637. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58638. [kind: string]: number;
  58639. }): Promise<VertexData>;
  58640. }
  58641. }
  58642. declare module "babylonjs/Meshes/Compression/index" {
  58643. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58644. }
  58645. declare module "babylonjs/Meshes/csg" {
  58646. import { Nullable } from "babylonjs/types";
  58647. import { Scene } from "babylonjs/scene";
  58648. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58649. import { Mesh } from "babylonjs/Meshes/mesh";
  58650. import { Material } from "babylonjs/Materials/material";
  58651. /**
  58652. * Class for building Constructive Solid Geometry
  58653. */
  58654. export class CSG {
  58655. private polygons;
  58656. /**
  58657. * The world matrix
  58658. */
  58659. matrix: Matrix;
  58660. /**
  58661. * Stores the position
  58662. */
  58663. position: Vector3;
  58664. /**
  58665. * Stores the rotation
  58666. */
  58667. rotation: Vector3;
  58668. /**
  58669. * Stores the rotation quaternion
  58670. */
  58671. rotationQuaternion: Nullable<Quaternion>;
  58672. /**
  58673. * Stores the scaling vector
  58674. */
  58675. scaling: Vector3;
  58676. /**
  58677. * Convert the Mesh to CSG
  58678. * @param mesh The Mesh to convert to CSG
  58679. * @returns A new CSG from the Mesh
  58680. */
  58681. static FromMesh(mesh: Mesh): CSG;
  58682. /**
  58683. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58684. * @param polygons Polygons used to construct a CSG solid
  58685. */
  58686. private static FromPolygons;
  58687. /**
  58688. * Clones, or makes a deep copy, of the CSG
  58689. * @returns A new CSG
  58690. */
  58691. clone(): CSG;
  58692. /**
  58693. * Unions this CSG with another CSG
  58694. * @param csg The CSG to union against this CSG
  58695. * @returns The unioned CSG
  58696. */
  58697. union(csg: CSG): CSG;
  58698. /**
  58699. * Unions this CSG with another CSG in place
  58700. * @param csg The CSG to union against this CSG
  58701. */
  58702. unionInPlace(csg: CSG): void;
  58703. /**
  58704. * Subtracts this CSG with another CSG
  58705. * @param csg The CSG to subtract against this CSG
  58706. * @returns A new CSG
  58707. */
  58708. subtract(csg: CSG): CSG;
  58709. /**
  58710. * Subtracts this CSG with another CSG in place
  58711. * @param csg The CSG to subtact against this CSG
  58712. */
  58713. subtractInPlace(csg: CSG): void;
  58714. /**
  58715. * Intersect this CSG with another CSG
  58716. * @param csg The CSG to intersect against this CSG
  58717. * @returns A new CSG
  58718. */
  58719. intersect(csg: CSG): CSG;
  58720. /**
  58721. * Intersects this CSG with another CSG in place
  58722. * @param csg The CSG to intersect against this CSG
  58723. */
  58724. intersectInPlace(csg: CSG): void;
  58725. /**
  58726. * Return a new CSG solid with solid and empty space switched. This solid is
  58727. * not modified.
  58728. * @returns A new CSG solid with solid and empty space switched
  58729. */
  58730. inverse(): CSG;
  58731. /**
  58732. * Inverses the CSG in place
  58733. */
  58734. inverseInPlace(): void;
  58735. /**
  58736. * This is used to keep meshes transformations so they can be restored
  58737. * when we build back a Babylon Mesh
  58738. * NB : All CSG operations are performed in world coordinates
  58739. * @param csg The CSG to copy the transform attributes from
  58740. * @returns This CSG
  58741. */
  58742. copyTransformAttributes(csg: CSG): CSG;
  58743. /**
  58744. * Build Raw mesh from CSG
  58745. * Coordinates here are in world space
  58746. * @param name The name of the mesh geometry
  58747. * @param scene The Scene
  58748. * @param keepSubMeshes Specifies if the submeshes should be kept
  58749. * @returns A new Mesh
  58750. */
  58751. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58752. /**
  58753. * Build Mesh from CSG taking material and transforms into account
  58754. * @param name The name of the Mesh
  58755. * @param material The material of the Mesh
  58756. * @param scene The Scene
  58757. * @param keepSubMeshes Specifies if submeshes should be kept
  58758. * @returns The new Mesh
  58759. */
  58760. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58761. }
  58762. }
  58763. declare module "babylonjs/Meshes/trailMesh" {
  58764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58765. import { Mesh } from "babylonjs/Meshes/mesh";
  58766. import { Scene } from "babylonjs/scene";
  58767. /**
  58768. * Class used to create a trail following a mesh
  58769. */
  58770. export class TrailMesh extends Mesh {
  58771. private _generator;
  58772. private _autoStart;
  58773. private _running;
  58774. private _diameter;
  58775. private _length;
  58776. private _sectionPolygonPointsCount;
  58777. private _sectionVectors;
  58778. private _sectionNormalVectors;
  58779. private _beforeRenderObserver;
  58780. /**
  58781. * @constructor
  58782. * @param name The value used by scene.getMeshByName() to do a lookup.
  58783. * @param generator The mesh to generate a trail.
  58784. * @param scene The scene to add this mesh to.
  58785. * @param diameter Diameter of trailing mesh. Default is 1.
  58786. * @param length Length of trailing mesh. Default is 60.
  58787. * @param autoStart Automatically start trailing mesh. Default true.
  58788. */
  58789. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58790. /**
  58791. * "TrailMesh"
  58792. * @returns "TrailMesh"
  58793. */
  58794. getClassName(): string;
  58795. private _createMesh;
  58796. /**
  58797. * Start trailing mesh.
  58798. */
  58799. start(): void;
  58800. /**
  58801. * Stop trailing mesh.
  58802. */
  58803. stop(): void;
  58804. /**
  58805. * Update trailing mesh geometry.
  58806. */
  58807. update(): void;
  58808. /**
  58809. * Returns a new TrailMesh object.
  58810. * @param name is a string, the name given to the new mesh
  58811. * @param newGenerator use new generator object for cloned trail mesh
  58812. * @returns a new mesh
  58813. */
  58814. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58815. /**
  58816. * Serializes this trail mesh
  58817. * @param serializationObject object to write serialization to
  58818. */
  58819. serialize(serializationObject: any): void;
  58820. /**
  58821. * Parses a serialized trail mesh
  58822. * @param parsedMesh the serialized mesh
  58823. * @param scene the scene to create the trail mesh in
  58824. * @returns the created trail mesh
  58825. */
  58826. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58827. }
  58828. }
  58829. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58830. import { Nullable } from "babylonjs/types";
  58831. import { Scene } from "babylonjs/scene";
  58832. import { Vector4 } from "babylonjs/Maths/math.vector";
  58833. import { Color4 } from "babylonjs/Maths/math.color";
  58834. import { Mesh } from "babylonjs/Meshes/mesh";
  58835. /**
  58836. * Class containing static functions to help procedurally build meshes
  58837. */
  58838. export class TiledBoxBuilder {
  58839. /**
  58840. * Creates a box mesh
  58841. * 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)
  58842. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58846. * @param name defines the name of the mesh
  58847. * @param options defines the options used to create the mesh
  58848. * @param scene defines the hosting scene
  58849. * @returns the box mesh
  58850. */
  58851. static CreateTiledBox(name: string, options: {
  58852. pattern?: number;
  58853. width?: number;
  58854. height?: number;
  58855. depth?: number;
  58856. tileSize?: number;
  58857. tileWidth?: number;
  58858. tileHeight?: number;
  58859. alignHorizontal?: number;
  58860. alignVertical?: number;
  58861. faceUV?: Vector4[];
  58862. faceColors?: Color4[];
  58863. sideOrientation?: number;
  58864. updatable?: boolean;
  58865. }, scene?: Nullable<Scene>): Mesh;
  58866. }
  58867. }
  58868. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58869. import { Vector4 } from "babylonjs/Maths/math.vector";
  58870. import { Mesh } from "babylonjs/Meshes/mesh";
  58871. /**
  58872. * Class containing static functions to help procedurally build meshes
  58873. */
  58874. export class TorusKnotBuilder {
  58875. /**
  58876. * Creates a torus knot mesh
  58877. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58878. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58879. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58880. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58884. * @param name defines the name of the mesh
  58885. * @param options defines the options used to create the mesh
  58886. * @param scene defines the hosting scene
  58887. * @returns the torus knot mesh
  58888. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58889. */
  58890. static CreateTorusKnot(name: string, options: {
  58891. radius?: number;
  58892. tube?: number;
  58893. radialSegments?: number;
  58894. tubularSegments?: number;
  58895. p?: number;
  58896. q?: number;
  58897. updatable?: boolean;
  58898. sideOrientation?: number;
  58899. frontUVs?: Vector4;
  58900. backUVs?: Vector4;
  58901. }, scene: any): Mesh;
  58902. }
  58903. }
  58904. declare module "babylonjs/Meshes/polygonMesh" {
  58905. import { Scene } from "babylonjs/scene";
  58906. import { Vector2 } from "babylonjs/Maths/math.vector";
  58907. import { Mesh } from "babylonjs/Meshes/mesh";
  58908. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58909. import { Path2 } from "babylonjs/Maths/math.path";
  58910. /**
  58911. * Polygon
  58912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58913. */
  58914. export class Polygon {
  58915. /**
  58916. * Creates a rectangle
  58917. * @param xmin bottom X coord
  58918. * @param ymin bottom Y coord
  58919. * @param xmax top X coord
  58920. * @param ymax top Y coord
  58921. * @returns points that make the resulting rectation
  58922. */
  58923. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58924. /**
  58925. * Creates a circle
  58926. * @param radius radius of circle
  58927. * @param cx scale in x
  58928. * @param cy scale in y
  58929. * @param numberOfSides number of sides that make up the circle
  58930. * @returns points that make the resulting circle
  58931. */
  58932. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58933. /**
  58934. * Creates a polygon from input string
  58935. * @param input Input polygon data
  58936. * @returns the parsed points
  58937. */
  58938. static Parse(input: string): Vector2[];
  58939. /**
  58940. * Starts building a polygon from x and y coordinates
  58941. * @param x x coordinate
  58942. * @param y y coordinate
  58943. * @returns the started path2
  58944. */
  58945. static StartingAt(x: number, y: number): Path2;
  58946. }
  58947. /**
  58948. * Builds a polygon
  58949. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58950. */
  58951. export class PolygonMeshBuilder {
  58952. private _points;
  58953. private _outlinepoints;
  58954. private _holes;
  58955. private _name;
  58956. private _scene;
  58957. private _epoints;
  58958. private _eholes;
  58959. private _addToepoint;
  58960. /**
  58961. * Babylon reference to the earcut plugin.
  58962. */
  58963. bjsEarcut: any;
  58964. /**
  58965. * Creates a PolygonMeshBuilder
  58966. * @param name name of the builder
  58967. * @param contours Path of the polygon
  58968. * @param scene scene to add to when creating the mesh
  58969. * @param earcutInjection can be used to inject your own earcut reference
  58970. */
  58971. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58972. /**
  58973. * Adds a whole within the polygon
  58974. * @param hole Array of points defining the hole
  58975. * @returns this
  58976. */
  58977. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58978. /**
  58979. * Creates the polygon
  58980. * @param updatable If the mesh should be updatable
  58981. * @param depth The depth of the mesh created
  58982. * @returns the created mesh
  58983. */
  58984. build(updatable?: boolean, depth?: number): Mesh;
  58985. /**
  58986. * Creates the polygon
  58987. * @param depth The depth of the mesh created
  58988. * @returns the created VertexData
  58989. */
  58990. buildVertexData(depth?: number): VertexData;
  58991. /**
  58992. * Adds a side to the polygon
  58993. * @param positions points that make the polygon
  58994. * @param normals normals of the polygon
  58995. * @param uvs uvs of the polygon
  58996. * @param indices indices of the polygon
  58997. * @param bounds bounds of the polygon
  58998. * @param points points of the polygon
  58999. * @param depth depth of the polygon
  59000. * @param flip flip of the polygon
  59001. */
  59002. private addSide;
  59003. }
  59004. }
  59005. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59006. import { Scene } from "babylonjs/scene";
  59007. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59008. import { Color4 } from "babylonjs/Maths/math.color";
  59009. import { Mesh } from "babylonjs/Meshes/mesh";
  59010. import { Nullable } from "babylonjs/types";
  59011. /**
  59012. * Class containing static functions to help procedurally build meshes
  59013. */
  59014. export class PolygonBuilder {
  59015. /**
  59016. * Creates a polygon mesh
  59017. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59018. * * 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
  59019. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59022. * * Remember you can only change the shape positions, not their number when updating a polygon
  59023. * @param name defines the name of the mesh
  59024. * @param options defines the options used to create the mesh
  59025. * @param scene defines the hosting scene
  59026. * @param earcutInjection can be used to inject your own earcut reference
  59027. * @returns the polygon mesh
  59028. */
  59029. static CreatePolygon(name: string, options: {
  59030. shape: Vector3[];
  59031. holes?: Vector3[][];
  59032. depth?: number;
  59033. faceUV?: Vector4[];
  59034. faceColors?: Color4[];
  59035. updatable?: boolean;
  59036. sideOrientation?: number;
  59037. frontUVs?: Vector4;
  59038. backUVs?: Vector4;
  59039. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59040. /**
  59041. * Creates an extruded polygon mesh, with depth in the Y direction.
  59042. * * 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)
  59043. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59044. * @param name defines the name of the mesh
  59045. * @param options defines the options used to create the mesh
  59046. * @param scene defines the hosting scene
  59047. * @param earcutInjection can be used to inject your own earcut reference
  59048. * @returns the polygon mesh
  59049. */
  59050. static ExtrudePolygon(name: string, options: {
  59051. shape: Vector3[];
  59052. holes?: Vector3[][];
  59053. depth?: number;
  59054. faceUV?: Vector4[];
  59055. faceColors?: Color4[];
  59056. updatable?: boolean;
  59057. sideOrientation?: number;
  59058. frontUVs?: Vector4;
  59059. backUVs?: Vector4;
  59060. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59061. }
  59062. }
  59063. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59064. import { Scene } from "babylonjs/scene";
  59065. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59066. import { Mesh } from "babylonjs/Meshes/mesh";
  59067. import { Nullable } from "babylonjs/types";
  59068. /**
  59069. * Class containing static functions to help procedurally build meshes
  59070. */
  59071. export class LatheBuilder {
  59072. /**
  59073. * Creates lathe mesh.
  59074. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59075. * * 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
  59076. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59077. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59078. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59079. * * 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
  59080. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59081. * * 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
  59082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59086. * @param name defines the name of the mesh
  59087. * @param options defines the options used to create the mesh
  59088. * @param scene defines the hosting scene
  59089. * @returns the lathe mesh
  59090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59091. */
  59092. static CreateLathe(name: string, options: {
  59093. shape: Vector3[];
  59094. radius?: number;
  59095. tessellation?: number;
  59096. clip?: number;
  59097. arc?: number;
  59098. closed?: boolean;
  59099. updatable?: boolean;
  59100. sideOrientation?: number;
  59101. frontUVs?: Vector4;
  59102. backUVs?: Vector4;
  59103. cap?: number;
  59104. invertUV?: boolean;
  59105. }, scene?: Nullable<Scene>): Mesh;
  59106. }
  59107. }
  59108. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59109. import { Nullable } from "babylonjs/types";
  59110. import { Scene } from "babylonjs/scene";
  59111. import { Vector4 } from "babylonjs/Maths/math.vector";
  59112. import { Mesh } from "babylonjs/Meshes/mesh";
  59113. /**
  59114. * Class containing static functions to help procedurally build meshes
  59115. */
  59116. export class TiledPlaneBuilder {
  59117. /**
  59118. * Creates a tiled plane mesh
  59119. * * The parameter `pattern` will, depending on value, do nothing or
  59120. * * * flip (reflect about central vertical) alternate tiles across and up
  59121. * * * flip every tile on alternate rows
  59122. * * * rotate (180 degs) alternate tiles across and up
  59123. * * * rotate every tile on alternate rows
  59124. * * * flip and rotate alternate tiles across and up
  59125. * * * flip and rotate every tile on alternate rows
  59126. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59127. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59129. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59130. * * 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)
  59131. * * 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)
  59132. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59133. * @param name defines the name of the mesh
  59134. * @param options defines the options used to create the mesh
  59135. * @param scene defines the hosting scene
  59136. * @returns the box mesh
  59137. */
  59138. static CreateTiledPlane(name: string, options: {
  59139. pattern?: number;
  59140. tileSize?: number;
  59141. tileWidth?: number;
  59142. tileHeight?: number;
  59143. size?: number;
  59144. width?: number;
  59145. height?: number;
  59146. alignHorizontal?: number;
  59147. alignVertical?: number;
  59148. sideOrientation?: number;
  59149. frontUVs?: Vector4;
  59150. backUVs?: Vector4;
  59151. updatable?: boolean;
  59152. }, scene?: Nullable<Scene>): Mesh;
  59153. }
  59154. }
  59155. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59156. import { Nullable } from "babylonjs/types";
  59157. import { Scene } from "babylonjs/scene";
  59158. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59159. import { Mesh } from "babylonjs/Meshes/mesh";
  59160. /**
  59161. * Class containing static functions to help procedurally build meshes
  59162. */
  59163. export class TubeBuilder {
  59164. /**
  59165. * Creates a tube mesh.
  59166. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59167. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59168. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59169. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59170. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59171. * * 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)
  59172. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59173. * * 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
  59174. * * 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
  59175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59177. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59179. * @param name defines the name of the mesh
  59180. * @param options defines the options used to create the mesh
  59181. * @param scene defines the hosting scene
  59182. * @returns the tube mesh
  59183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59184. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59185. */
  59186. static CreateTube(name: string, options: {
  59187. path: Vector3[];
  59188. radius?: number;
  59189. tessellation?: number;
  59190. radiusFunction?: {
  59191. (i: number, distance: number): number;
  59192. };
  59193. cap?: number;
  59194. arc?: number;
  59195. updatable?: boolean;
  59196. sideOrientation?: number;
  59197. frontUVs?: Vector4;
  59198. backUVs?: Vector4;
  59199. instance?: Mesh;
  59200. invertUV?: boolean;
  59201. }, scene?: Nullable<Scene>): Mesh;
  59202. }
  59203. }
  59204. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59205. import { Scene } from "babylonjs/scene";
  59206. import { Vector4 } from "babylonjs/Maths/math.vector";
  59207. import { Mesh } from "babylonjs/Meshes/mesh";
  59208. import { Nullable } from "babylonjs/types";
  59209. /**
  59210. * Class containing static functions to help procedurally build meshes
  59211. */
  59212. export class IcoSphereBuilder {
  59213. /**
  59214. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59215. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59216. * * 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`)
  59217. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59218. * * 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
  59219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59222. * @param name defines the name of the mesh
  59223. * @param options defines the options used to create the mesh
  59224. * @param scene defines the hosting scene
  59225. * @returns the icosahedron mesh
  59226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59227. */
  59228. static CreateIcoSphere(name: string, options: {
  59229. radius?: number;
  59230. radiusX?: number;
  59231. radiusY?: number;
  59232. radiusZ?: number;
  59233. flat?: boolean;
  59234. subdivisions?: number;
  59235. sideOrientation?: number;
  59236. frontUVs?: Vector4;
  59237. backUVs?: Vector4;
  59238. updatable?: boolean;
  59239. }, scene?: Nullable<Scene>): Mesh;
  59240. }
  59241. }
  59242. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59243. import { Vector3 } from "babylonjs/Maths/math.vector";
  59244. import { Mesh } from "babylonjs/Meshes/mesh";
  59245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59246. /**
  59247. * Class containing static functions to help procedurally build meshes
  59248. */
  59249. export class DecalBuilder {
  59250. /**
  59251. * Creates a decal mesh.
  59252. * 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
  59253. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59254. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59255. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59256. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59257. * @param name defines the name of the mesh
  59258. * @param sourceMesh defines the mesh where the decal must be applied
  59259. * @param options defines the options used to create the mesh
  59260. * @param scene defines the hosting scene
  59261. * @returns the decal mesh
  59262. * @see https://doc.babylonjs.com/how_to/decals
  59263. */
  59264. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59265. position?: Vector3;
  59266. normal?: Vector3;
  59267. size?: Vector3;
  59268. angle?: number;
  59269. }): Mesh;
  59270. }
  59271. }
  59272. declare module "babylonjs/Meshes/meshBuilder" {
  59273. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59274. import { Nullable } from "babylonjs/types";
  59275. import { Scene } from "babylonjs/scene";
  59276. import { Mesh } from "babylonjs/Meshes/mesh";
  59277. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59278. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59280. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59281. import { Plane } from "babylonjs/Maths/math.plane";
  59282. /**
  59283. * Class containing static functions to help procedurally build meshes
  59284. */
  59285. export class MeshBuilder {
  59286. /**
  59287. * Creates a box mesh
  59288. * * The parameter `size` sets the size (float) of each box side (default 1)
  59289. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59290. * * 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)
  59291. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59295. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59296. * @param name defines the name of the mesh
  59297. * @param options defines the options used to create the mesh
  59298. * @param scene defines the hosting scene
  59299. * @returns the box mesh
  59300. */
  59301. static CreateBox(name: string, options: {
  59302. size?: number;
  59303. width?: number;
  59304. height?: number;
  59305. depth?: number;
  59306. faceUV?: Vector4[];
  59307. faceColors?: Color4[];
  59308. sideOrientation?: number;
  59309. frontUVs?: Vector4;
  59310. backUVs?: Vector4;
  59311. updatable?: boolean;
  59312. }, scene?: Nullable<Scene>): Mesh;
  59313. /**
  59314. * Creates a tiled box mesh
  59315. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59317. * @param name defines the name of the mesh
  59318. * @param options defines the options used to create the mesh
  59319. * @param scene defines the hosting scene
  59320. * @returns the tiled box mesh
  59321. */
  59322. static CreateTiledBox(name: string, options: {
  59323. pattern?: number;
  59324. size?: number;
  59325. width?: number;
  59326. height?: number;
  59327. depth: number;
  59328. tileSize?: number;
  59329. tileWidth?: number;
  59330. tileHeight?: number;
  59331. faceUV?: Vector4[];
  59332. faceColors?: Color4[];
  59333. alignHorizontal?: number;
  59334. alignVertical?: number;
  59335. sideOrientation?: number;
  59336. updatable?: boolean;
  59337. }, scene?: Nullable<Scene>): Mesh;
  59338. /**
  59339. * Creates a sphere mesh
  59340. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59341. * * 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`)
  59342. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59343. * * 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
  59344. * * 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)
  59345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59346. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59348. * @param name defines the name of the mesh
  59349. * @param options defines the options used to create the mesh
  59350. * @param scene defines the hosting scene
  59351. * @returns the sphere mesh
  59352. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59353. */
  59354. static CreateSphere(name: string, options: {
  59355. segments?: number;
  59356. diameter?: number;
  59357. diameterX?: number;
  59358. diameterY?: number;
  59359. diameterZ?: number;
  59360. arc?: number;
  59361. slice?: number;
  59362. sideOrientation?: number;
  59363. frontUVs?: Vector4;
  59364. backUVs?: Vector4;
  59365. updatable?: boolean;
  59366. }, scene?: Nullable<Scene>): Mesh;
  59367. /**
  59368. * Creates a plane polygonal mesh. By default, this is a disc
  59369. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59370. * * 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
  59371. * * 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
  59372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59375. * @param name defines the name of the mesh
  59376. * @param options defines the options used to create the mesh
  59377. * @param scene defines the hosting scene
  59378. * @returns the plane polygonal mesh
  59379. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59380. */
  59381. static CreateDisc(name: string, options: {
  59382. radius?: number;
  59383. tessellation?: number;
  59384. arc?: number;
  59385. updatable?: boolean;
  59386. sideOrientation?: number;
  59387. frontUVs?: Vector4;
  59388. backUVs?: Vector4;
  59389. }, scene?: Nullable<Scene>): Mesh;
  59390. /**
  59391. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59392. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59393. * * 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`)
  59394. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59395. * * 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
  59396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59399. * @param name defines the name of the mesh
  59400. * @param options defines the options used to create the mesh
  59401. * @param scene defines the hosting scene
  59402. * @returns the icosahedron mesh
  59403. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59404. */
  59405. static CreateIcoSphere(name: string, options: {
  59406. radius?: number;
  59407. radiusX?: number;
  59408. radiusY?: number;
  59409. radiusZ?: number;
  59410. flat?: boolean;
  59411. subdivisions?: number;
  59412. sideOrientation?: number;
  59413. frontUVs?: Vector4;
  59414. backUVs?: Vector4;
  59415. updatable?: boolean;
  59416. }, scene?: Nullable<Scene>): Mesh;
  59417. /**
  59418. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59419. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59420. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59421. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59422. * * 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
  59423. * * 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
  59424. * * 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
  59425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59428. * * 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
  59429. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59430. * * 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
  59431. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59433. * @param name defines the name of the mesh
  59434. * @param options defines the options used to create the mesh
  59435. * @param scene defines the hosting scene
  59436. * @returns the ribbon mesh
  59437. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59439. */
  59440. static CreateRibbon(name: string, options: {
  59441. pathArray: Vector3[][];
  59442. closeArray?: boolean;
  59443. closePath?: boolean;
  59444. offset?: number;
  59445. updatable?: boolean;
  59446. sideOrientation?: number;
  59447. frontUVs?: Vector4;
  59448. backUVs?: Vector4;
  59449. instance?: Mesh;
  59450. invertUV?: boolean;
  59451. uvs?: Vector2[];
  59452. colors?: Color4[];
  59453. }, scene?: Nullable<Scene>): Mesh;
  59454. /**
  59455. * Creates a cylinder or a cone mesh
  59456. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59457. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59458. * * 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.
  59459. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59460. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59461. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59462. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59463. * * 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).
  59464. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59465. * * 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).
  59466. * * 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
  59467. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59468. * * 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
  59469. * * 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.
  59470. * * If `enclose` is false, a ring surface is one element.
  59471. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59472. * * 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
  59473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59474. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59476. * @param name defines the name of the mesh
  59477. * @param options defines the options used to create the mesh
  59478. * @param scene defines the hosting scene
  59479. * @returns the cylinder mesh
  59480. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59481. */
  59482. static CreateCylinder(name: string, options: {
  59483. height?: number;
  59484. diameterTop?: number;
  59485. diameterBottom?: number;
  59486. diameter?: number;
  59487. tessellation?: number;
  59488. subdivisions?: number;
  59489. arc?: number;
  59490. faceColors?: Color4[];
  59491. faceUV?: Vector4[];
  59492. updatable?: boolean;
  59493. hasRings?: boolean;
  59494. enclose?: boolean;
  59495. cap?: number;
  59496. sideOrientation?: number;
  59497. frontUVs?: Vector4;
  59498. backUVs?: Vector4;
  59499. }, scene?: Nullable<Scene>): Mesh;
  59500. /**
  59501. * Creates a torus mesh
  59502. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59503. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59504. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59508. * @param name defines the name of the mesh
  59509. * @param options defines the options used to create the mesh
  59510. * @param scene defines the hosting scene
  59511. * @returns the torus mesh
  59512. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59513. */
  59514. static CreateTorus(name: string, options: {
  59515. diameter?: number;
  59516. thickness?: number;
  59517. tessellation?: number;
  59518. updatable?: boolean;
  59519. sideOrientation?: number;
  59520. frontUVs?: Vector4;
  59521. backUVs?: Vector4;
  59522. }, scene?: Nullable<Scene>): Mesh;
  59523. /**
  59524. * Creates a torus knot mesh
  59525. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59526. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59527. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59528. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59532. * @param name defines the name of the mesh
  59533. * @param options defines the options used to create the mesh
  59534. * @param scene defines the hosting scene
  59535. * @returns the torus knot mesh
  59536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59537. */
  59538. static CreateTorusKnot(name: string, options: {
  59539. radius?: number;
  59540. tube?: number;
  59541. radialSegments?: number;
  59542. tubularSegments?: number;
  59543. p?: number;
  59544. q?: number;
  59545. updatable?: boolean;
  59546. sideOrientation?: number;
  59547. frontUVs?: Vector4;
  59548. backUVs?: Vector4;
  59549. }, scene?: Nullable<Scene>): Mesh;
  59550. /**
  59551. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59552. * * 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
  59553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59554. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59555. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59556. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59558. * * 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
  59559. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59562. * @param name defines the name of the new line system
  59563. * @param options defines the options used to create the line system
  59564. * @param scene defines the hosting scene
  59565. * @returns a new line system mesh
  59566. */
  59567. static CreateLineSystem(name: string, options: {
  59568. lines: Vector3[][];
  59569. updatable?: boolean;
  59570. instance?: Nullable<LinesMesh>;
  59571. colors?: Nullable<Color4[][]>;
  59572. useVertexAlpha?: boolean;
  59573. }, scene: Nullable<Scene>): LinesMesh;
  59574. /**
  59575. * Creates a line mesh
  59576. * 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
  59577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59578. * * The parameter `points` is an array successive Vector3
  59579. * * 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
  59580. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59582. * * When updating an instance, remember that only point positions can change, not the number of points
  59583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59585. * @param name defines the name of the new line system
  59586. * @param options defines the options used to create the line system
  59587. * @param scene defines the hosting scene
  59588. * @returns a new line mesh
  59589. */
  59590. static CreateLines(name: string, options: {
  59591. points: Vector3[];
  59592. updatable?: boolean;
  59593. instance?: Nullable<LinesMesh>;
  59594. colors?: Color4[];
  59595. useVertexAlpha?: boolean;
  59596. }, scene?: Nullable<Scene>): LinesMesh;
  59597. /**
  59598. * Creates a dashed line mesh
  59599. * * 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
  59600. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59601. * * The parameter `points` is an array successive Vector3
  59602. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59603. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59604. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59605. * * 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
  59606. * * When updating an instance, remember that only point positions can change, not the number of points
  59607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59608. * @param name defines the name of the mesh
  59609. * @param options defines the options used to create the mesh
  59610. * @param scene defines the hosting scene
  59611. * @returns the dashed line mesh
  59612. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59613. */
  59614. static CreateDashedLines(name: string, options: {
  59615. points: Vector3[];
  59616. dashSize?: number;
  59617. gapSize?: number;
  59618. dashNb?: number;
  59619. updatable?: boolean;
  59620. instance?: LinesMesh;
  59621. }, scene?: Nullable<Scene>): LinesMesh;
  59622. /**
  59623. * 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.
  59624. * * 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.
  59625. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59626. * * 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.
  59627. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59628. * * 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
  59629. * * 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
  59630. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59633. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59635. * @param name defines the name of the mesh
  59636. * @param options defines the options used to create the mesh
  59637. * @param scene defines the hosting scene
  59638. * @returns the extruded shape mesh
  59639. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59641. */
  59642. static ExtrudeShape(name: string, options: {
  59643. shape: Vector3[];
  59644. path: Vector3[];
  59645. scale?: number;
  59646. rotation?: number;
  59647. cap?: number;
  59648. updatable?: boolean;
  59649. sideOrientation?: number;
  59650. frontUVs?: Vector4;
  59651. backUVs?: Vector4;
  59652. instance?: Mesh;
  59653. invertUV?: boolean;
  59654. }, scene?: Nullable<Scene>): Mesh;
  59655. /**
  59656. * Creates an custom extruded shape mesh.
  59657. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59658. * * 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.
  59659. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59660. * * 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
  59661. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59662. * * 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
  59663. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59664. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59665. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59666. * * 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
  59667. * * 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
  59668. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59673. * @param name defines the name of the mesh
  59674. * @param options defines the options used to create the mesh
  59675. * @param scene defines the hosting scene
  59676. * @returns the custom extruded shape mesh
  59677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59679. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59680. */
  59681. static ExtrudeShapeCustom(name: string, options: {
  59682. shape: Vector3[];
  59683. path: Vector3[];
  59684. scaleFunction?: any;
  59685. rotationFunction?: any;
  59686. ribbonCloseArray?: boolean;
  59687. ribbonClosePath?: boolean;
  59688. cap?: number;
  59689. updatable?: boolean;
  59690. sideOrientation?: number;
  59691. frontUVs?: Vector4;
  59692. backUVs?: Vector4;
  59693. instance?: Mesh;
  59694. invertUV?: boolean;
  59695. }, scene?: Nullable<Scene>): Mesh;
  59696. /**
  59697. * Creates lathe mesh.
  59698. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59699. * * 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
  59700. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59701. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59702. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59703. * * 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
  59704. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59705. * * 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
  59706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59710. * @param name defines the name of the mesh
  59711. * @param options defines the options used to create the mesh
  59712. * @param scene defines the hosting scene
  59713. * @returns the lathe mesh
  59714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59715. */
  59716. static CreateLathe(name: string, options: {
  59717. shape: Vector3[];
  59718. radius?: number;
  59719. tessellation?: number;
  59720. clip?: number;
  59721. arc?: number;
  59722. closed?: boolean;
  59723. updatable?: boolean;
  59724. sideOrientation?: number;
  59725. frontUVs?: Vector4;
  59726. backUVs?: Vector4;
  59727. cap?: number;
  59728. invertUV?: boolean;
  59729. }, scene?: Nullable<Scene>): Mesh;
  59730. /**
  59731. * Creates a tiled plane mesh
  59732. * * You can set a limited pattern arrangement with the tiles
  59733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59736. * @param name defines the name of the mesh
  59737. * @param options defines the options used to create the mesh
  59738. * @param scene defines the hosting scene
  59739. * @returns the plane mesh
  59740. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59741. */
  59742. static CreateTiledPlane(name: string, options: {
  59743. pattern?: number;
  59744. tileSize?: number;
  59745. tileWidth?: number;
  59746. tileHeight?: number;
  59747. size?: number;
  59748. width?: number;
  59749. height?: number;
  59750. alignHorizontal?: number;
  59751. alignVertical?: number;
  59752. sideOrientation?: number;
  59753. frontUVs?: Vector4;
  59754. backUVs?: Vector4;
  59755. updatable?: boolean;
  59756. }, scene?: Nullable<Scene>): Mesh;
  59757. /**
  59758. * Creates a plane mesh
  59759. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59760. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59761. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59765. * @param name defines the name of the mesh
  59766. * @param options defines the options used to create the mesh
  59767. * @param scene defines the hosting scene
  59768. * @returns the plane mesh
  59769. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59770. */
  59771. static CreatePlane(name: string, options: {
  59772. size?: number;
  59773. width?: number;
  59774. height?: number;
  59775. sideOrientation?: number;
  59776. frontUVs?: Vector4;
  59777. backUVs?: Vector4;
  59778. updatable?: boolean;
  59779. sourcePlane?: Plane;
  59780. }, scene?: Nullable<Scene>): Mesh;
  59781. /**
  59782. * Creates a ground mesh
  59783. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59784. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59786. * @param name defines the name of the mesh
  59787. * @param options defines the options used to create the mesh
  59788. * @param scene defines the hosting scene
  59789. * @returns the ground mesh
  59790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59791. */
  59792. static CreateGround(name: string, options: {
  59793. width?: number;
  59794. height?: number;
  59795. subdivisions?: number;
  59796. subdivisionsX?: number;
  59797. subdivisionsY?: number;
  59798. updatable?: boolean;
  59799. }, scene?: Nullable<Scene>): Mesh;
  59800. /**
  59801. * Creates a tiled ground mesh
  59802. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59803. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59804. * * 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
  59805. * * 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
  59806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59807. * @param name defines the name of the mesh
  59808. * @param options defines the options used to create the mesh
  59809. * @param scene defines the hosting scene
  59810. * @returns the tiled ground mesh
  59811. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59812. */
  59813. static CreateTiledGround(name: string, options: {
  59814. xmin: number;
  59815. zmin: number;
  59816. xmax: number;
  59817. zmax: number;
  59818. subdivisions?: {
  59819. w: number;
  59820. h: number;
  59821. };
  59822. precision?: {
  59823. w: number;
  59824. h: number;
  59825. };
  59826. updatable?: boolean;
  59827. }, scene?: Nullable<Scene>): Mesh;
  59828. /**
  59829. * Creates a ground mesh from a height map
  59830. * * The parameter `url` sets the URL of the height map image resource.
  59831. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59832. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59833. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59834. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59835. * * 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.
  59836. * * 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).
  59837. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59839. * @param name defines the name of the mesh
  59840. * @param url defines the url to the height map
  59841. * @param options defines the options used to create the mesh
  59842. * @param scene defines the hosting scene
  59843. * @returns the ground mesh
  59844. * @see https://doc.babylonjs.com/babylon101/height_map
  59845. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59846. */
  59847. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59848. width?: number;
  59849. height?: number;
  59850. subdivisions?: number;
  59851. minHeight?: number;
  59852. maxHeight?: number;
  59853. colorFilter?: Color3;
  59854. alphaFilter?: number;
  59855. updatable?: boolean;
  59856. onReady?: (mesh: GroundMesh) => void;
  59857. }, scene?: Nullable<Scene>): GroundMesh;
  59858. /**
  59859. * Creates a polygon mesh
  59860. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59861. * * 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
  59862. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59865. * * Remember you can only change the shape positions, not their number when updating a polygon
  59866. * @param name defines the name of the mesh
  59867. * @param options defines the options used to create the mesh
  59868. * @param scene defines the hosting scene
  59869. * @param earcutInjection can be used to inject your own earcut reference
  59870. * @returns the polygon mesh
  59871. */
  59872. static CreatePolygon(name: string, options: {
  59873. shape: Vector3[];
  59874. holes?: Vector3[][];
  59875. depth?: number;
  59876. faceUV?: Vector4[];
  59877. faceColors?: Color4[];
  59878. updatable?: boolean;
  59879. sideOrientation?: number;
  59880. frontUVs?: Vector4;
  59881. backUVs?: Vector4;
  59882. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59883. /**
  59884. * Creates an extruded polygon mesh, with depth in the Y direction.
  59885. * * 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)
  59886. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59887. * @param name defines the name of the mesh
  59888. * @param options defines the options used to create the mesh
  59889. * @param scene defines the hosting scene
  59890. * @param earcutInjection can be used to inject your own earcut reference
  59891. * @returns the polygon mesh
  59892. */
  59893. static ExtrudePolygon(name: string, options: {
  59894. shape: Vector3[];
  59895. holes?: Vector3[][];
  59896. depth?: number;
  59897. faceUV?: Vector4[];
  59898. faceColors?: Color4[];
  59899. updatable?: boolean;
  59900. sideOrientation?: number;
  59901. frontUVs?: Vector4;
  59902. backUVs?: Vector4;
  59903. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59904. /**
  59905. * Creates a tube mesh.
  59906. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59907. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59908. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59909. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59910. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59911. * * 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)
  59912. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59913. * * 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
  59914. * * 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
  59915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59919. * @param name defines the name of the mesh
  59920. * @param options defines the options used to create the mesh
  59921. * @param scene defines the hosting scene
  59922. * @returns the tube mesh
  59923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59924. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59925. */
  59926. static CreateTube(name: string, options: {
  59927. path: Vector3[];
  59928. radius?: number;
  59929. tessellation?: number;
  59930. radiusFunction?: {
  59931. (i: number, distance: number): number;
  59932. };
  59933. cap?: number;
  59934. arc?: number;
  59935. updatable?: boolean;
  59936. sideOrientation?: number;
  59937. frontUVs?: Vector4;
  59938. backUVs?: Vector4;
  59939. instance?: Mesh;
  59940. invertUV?: boolean;
  59941. }, scene?: Nullable<Scene>): Mesh;
  59942. /**
  59943. * Creates a polyhedron mesh
  59944. * * 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
  59945. * * The parameter `size` (positive float, default 1) sets the polygon size
  59946. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59947. * * 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`
  59948. * * 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
  59949. * * 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)`)
  59950. * * 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
  59951. * * 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
  59952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59953. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59955. * @param name defines the name of the mesh
  59956. * @param options defines the options used to create the mesh
  59957. * @param scene defines the hosting scene
  59958. * @returns the polyhedron mesh
  59959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59960. */
  59961. static CreatePolyhedron(name: string, options: {
  59962. type?: number;
  59963. size?: number;
  59964. sizeX?: number;
  59965. sizeY?: number;
  59966. sizeZ?: number;
  59967. custom?: any;
  59968. faceUV?: Vector4[];
  59969. faceColors?: Color4[];
  59970. flat?: boolean;
  59971. updatable?: boolean;
  59972. sideOrientation?: number;
  59973. frontUVs?: Vector4;
  59974. backUVs?: Vector4;
  59975. }, scene?: Nullable<Scene>): Mesh;
  59976. /**
  59977. * Creates a decal mesh.
  59978. * 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
  59979. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59980. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59981. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59982. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59983. * @param name defines the name of the mesh
  59984. * @param sourceMesh defines the mesh where the decal must be applied
  59985. * @param options defines the options used to create the mesh
  59986. * @param scene defines the hosting scene
  59987. * @returns the decal mesh
  59988. * @see https://doc.babylonjs.com/how_to/decals
  59989. */
  59990. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59991. position?: Vector3;
  59992. normal?: Vector3;
  59993. size?: Vector3;
  59994. angle?: number;
  59995. }): Mesh;
  59996. }
  59997. }
  59998. declare module "babylonjs/Meshes/meshSimplification" {
  59999. import { Mesh } from "babylonjs/Meshes/mesh";
  60000. /**
  60001. * A simplifier interface for future simplification implementations
  60002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60003. */
  60004. export interface ISimplifier {
  60005. /**
  60006. * Simplification of a given mesh according to the given settings.
  60007. * Since this requires computation, it is assumed that the function runs async.
  60008. * @param settings The settings of the simplification, including quality and distance
  60009. * @param successCallback A callback that will be called after the mesh was simplified.
  60010. * @param errorCallback in case of an error, this callback will be called. optional.
  60011. */
  60012. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60013. }
  60014. /**
  60015. * Expected simplification settings.
  60016. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60017. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60018. */
  60019. export interface ISimplificationSettings {
  60020. /**
  60021. * Gets or sets the expected quality
  60022. */
  60023. quality: number;
  60024. /**
  60025. * Gets or sets the distance when this optimized version should be used
  60026. */
  60027. distance: number;
  60028. /**
  60029. * Gets an already optimized mesh
  60030. */
  60031. optimizeMesh?: boolean;
  60032. }
  60033. /**
  60034. * Class used to specify simplification options
  60035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60036. */
  60037. export class SimplificationSettings implements ISimplificationSettings {
  60038. /** expected quality */
  60039. quality: number;
  60040. /** distance when this optimized version should be used */
  60041. distance: number;
  60042. /** already optimized mesh */
  60043. optimizeMesh?: boolean | undefined;
  60044. /**
  60045. * Creates a SimplificationSettings
  60046. * @param quality expected quality
  60047. * @param distance distance when this optimized version should be used
  60048. * @param optimizeMesh already optimized mesh
  60049. */
  60050. constructor(
  60051. /** expected quality */
  60052. quality: number,
  60053. /** distance when this optimized version should be used */
  60054. distance: number,
  60055. /** already optimized mesh */
  60056. optimizeMesh?: boolean | undefined);
  60057. }
  60058. /**
  60059. * Interface used to define a simplification task
  60060. */
  60061. export interface ISimplificationTask {
  60062. /**
  60063. * Array of settings
  60064. */
  60065. settings: Array<ISimplificationSettings>;
  60066. /**
  60067. * Simplification type
  60068. */
  60069. simplificationType: SimplificationType;
  60070. /**
  60071. * Mesh to simplify
  60072. */
  60073. mesh: Mesh;
  60074. /**
  60075. * Callback called on success
  60076. */
  60077. successCallback?: () => void;
  60078. /**
  60079. * Defines if parallel processing can be used
  60080. */
  60081. parallelProcessing: boolean;
  60082. }
  60083. /**
  60084. * Queue used to order the simplification tasks
  60085. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60086. */
  60087. export class SimplificationQueue {
  60088. private _simplificationArray;
  60089. /**
  60090. * Gets a boolean indicating that the process is still running
  60091. */
  60092. running: boolean;
  60093. /**
  60094. * Creates a new queue
  60095. */
  60096. constructor();
  60097. /**
  60098. * Adds a new simplification task
  60099. * @param task defines a task to add
  60100. */
  60101. addTask(task: ISimplificationTask): void;
  60102. /**
  60103. * Execute next task
  60104. */
  60105. executeNext(): void;
  60106. /**
  60107. * Execute a simplification task
  60108. * @param task defines the task to run
  60109. */
  60110. runSimplification(task: ISimplificationTask): void;
  60111. private getSimplifier;
  60112. }
  60113. /**
  60114. * The implemented types of simplification
  60115. * At the moment only Quadratic Error Decimation is implemented
  60116. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60117. */
  60118. export enum SimplificationType {
  60119. /** Quadratic error decimation */
  60120. QUADRATIC = 0
  60121. }
  60122. }
  60123. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60124. import { Scene } from "babylonjs/scene";
  60125. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60126. import { ISceneComponent } from "babylonjs/sceneComponent";
  60127. module "babylonjs/scene" {
  60128. interface Scene {
  60129. /** @hidden (Backing field) */
  60130. _simplificationQueue: SimplificationQueue;
  60131. /**
  60132. * Gets or sets the simplification queue attached to the scene
  60133. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60134. */
  60135. simplificationQueue: SimplificationQueue;
  60136. }
  60137. }
  60138. module "babylonjs/Meshes/mesh" {
  60139. interface Mesh {
  60140. /**
  60141. * Simplify the mesh according to the given array of settings.
  60142. * Function will return immediately and will simplify async
  60143. * @param settings a collection of simplification settings
  60144. * @param parallelProcessing should all levels calculate parallel or one after the other
  60145. * @param simplificationType the type of simplification to run
  60146. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60147. * @returns the current mesh
  60148. */
  60149. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60150. }
  60151. }
  60152. /**
  60153. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60154. * created in a scene
  60155. */
  60156. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60157. /**
  60158. * The component name helpfull to identify the component in the list of scene components.
  60159. */
  60160. readonly name: string;
  60161. /**
  60162. * The scene the component belongs to.
  60163. */
  60164. scene: Scene;
  60165. /**
  60166. * Creates a new instance of the component for the given scene
  60167. * @param scene Defines the scene to register the component in
  60168. */
  60169. constructor(scene: Scene);
  60170. /**
  60171. * Registers the component in a given scene
  60172. */
  60173. register(): void;
  60174. /**
  60175. * Rebuilds the elements related to this component in case of
  60176. * context lost for instance.
  60177. */
  60178. rebuild(): void;
  60179. /**
  60180. * Disposes the component and the associated ressources
  60181. */
  60182. dispose(): void;
  60183. private _beforeCameraUpdate;
  60184. }
  60185. }
  60186. declare module "babylonjs/Meshes/Builders/index" {
  60187. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60188. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60189. export * from "babylonjs/Meshes/Builders/discBuilder";
  60190. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60191. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60192. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60193. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60194. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60195. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60196. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60197. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60198. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60199. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60200. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60201. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60202. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60203. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60204. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60205. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60206. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60207. }
  60208. declare module "babylonjs/Meshes/index" {
  60209. export * from "babylonjs/Meshes/abstractMesh";
  60210. export * from "babylonjs/Meshes/buffer";
  60211. export * from "babylonjs/Meshes/Compression/index";
  60212. export * from "babylonjs/Meshes/csg";
  60213. export * from "babylonjs/Meshes/geometry";
  60214. export * from "babylonjs/Meshes/groundMesh";
  60215. export * from "babylonjs/Meshes/trailMesh";
  60216. export * from "babylonjs/Meshes/instancedMesh";
  60217. export * from "babylonjs/Meshes/linesMesh";
  60218. export * from "babylonjs/Meshes/mesh";
  60219. export * from "babylonjs/Meshes/mesh.vertexData";
  60220. export * from "babylonjs/Meshes/meshBuilder";
  60221. export * from "babylonjs/Meshes/meshSimplification";
  60222. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60223. export * from "babylonjs/Meshes/polygonMesh";
  60224. export * from "babylonjs/Meshes/subMesh";
  60225. export * from "babylonjs/Meshes/meshLODLevel";
  60226. export * from "babylonjs/Meshes/transformNode";
  60227. export * from "babylonjs/Meshes/Builders/index";
  60228. export * from "babylonjs/Meshes/dataBuffer";
  60229. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60230. }
  60231. declare module "babylonjs/Morph/index" {
  60232. export * from "babylonjs/Morph/morphTarget";
  60233. export * from "babylonjs/Morph/morphTargetManager";
  60234. }
  60235. declare module "babylonjs/Navigation/INavigationEngine" {
  60236. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60237. import { Vector3 } from "babylonjs/Maths/math";
  60238. import { Mesh } from "babylonjs/Meshes/mesh";
  60239. import { Scene } from "babylonjs/scene";
  60240. /**
  60241. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60242. */
  60243. export interface INavigationEnginePlugin {
  60244. /**
  60245. * plugin name
  60246. */
  60247. name: string;
  60248. /**
  60249. * Creates a navigation mesh
  60250. * @param meshes array of all the geometry used to compute the navigatio mesh
  60251. * @param parameters bunch of parameters used to filter geometry
  60252. */
  60253. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60254. /**
  60255. * Create a navigation mesh debug mesh
  60256. * @param scene is where the mesh will be added
  60257. * @returns debug display mesh
  60258. */
  60259. createDebugNavMesh(scene: Scene): Mesh;
  60260. /**
  60261. * Get a navigation mesh constrained position, closest to the parameter position
  60262. * @param position world position
  60263. * @returns the closest point to position constrained by the navigation mesh
  60264. */
  60265. getClosestPoint(position: Vector3): Vector3;
  60266. /**
  60267. * Get a navigation mesh constrained position, within a particular radius
  60268. * @param position world position
  60269. * @param maxRadius the maximum distance to the constrained world position
  60270. * @returns the closest point to position constrained by the navigation mesh
  60271. */
  60272. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60273. /**
  60274. * Compute the final position from a segment made of destination-position
  60275. * @param position world position
  60276. * @param destination world position
  60277. * @returns the resulting point along the navmesh
  60278. */
  60279. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60280. /**
  60281. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60282. * @param start world position
  60283. * @param end world position
  60284. * @returns array containing world position composing the path
  60285. */
  60286. computePath(start: Vector3, end: Vector3): Vector3[];
  60287. /**
  60288. * If this plugin is supported
  60289. * @returns true if plugin is supported
  60290. */
  60291. isSupported(): boolean;
  60292. /**
  60293. * Create a new Crowd so you can add agents
  60294. * @param maxAgents the maximum agent count in the crowd
  60295. * @param maxAgentRadius the maximum radius an agent can have
  60296. * @param scene to attach the crowd to
  60297. * @returns the crowd you can add agents to
  60298. */
  60299. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60300. /**
  60301. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60302. * The queries will try to find a solution within those bounds
  60303. * default is (1,1,1)
  60304. * @param extent x,y,z value that define the extent around the queries point of reference
  60305. */
  60306. setDefaultQueryExtent(extent: Vector3): void;
  60307. /**
  60308. * Get the Bounding box extent specified by setDefaultQueryExtent
  60309. * @returns the box extent values
  60310. */
  60311. getDefaultQueryExtent(): Vector3;
  60312. /**
  60313. * Release all resources
  60314. */
  60315. dispose(): void;
  60316. }
  60317. /**
  60318. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60319. */
  60320. export interface ICrowd {
  60321. /**
  60322. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60323. * You can attach anything to that node. The node position is updated in the scene update tick.
  60324. * @param pos world position that will be constrained by the navigation mesh
  60325. * @param parameters agent parameters
  60326. * @param transform hooked to the agent that will be update by the scene
  60327. * @returns agent index
  60328. */
  60329. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60330. /**
  60331. * Returns the agent position in world space
  60332. * @param index agent index returned by addAgent
  60333. * @returns world space position
  60334. */
  60335. getAgentPosition(index: number): Vector3;
  60336. /**
  60337. * Gets the agent velocity in world space
  60338. * @param index agent index returned by addAgent
  60339. * @returns world space velocity
  60340. */
  60341. getAgentVelocity(index: number): Vector3;
  60342. /**
  60343. * remove a particular agent previously created
  60344. * @param index agent index returned by addAgent
  60345. */
  60346. removeAgent(index: number): void;
  60347. /**
  60348. * get the list of all agents attached to this crowd
  60349. * @returns list of agent indices
  60350. */
  60351. getAgents(): number[];
  60352. /**
  60353. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60354. * @param deltaTime in seconds
  60355. */
  60356. update(deltaTime: number): void;
  60357. /**
  60358. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60359. * @param index agent index returned by addAgent
  60360. * @param destination targeted world position
  60361. */
  60362. agentGoto(index: number, destination: Vector3): void;
  60363. /**
  60364. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60365. * The queries will try to find a solution within those bounds
  60366. * default is (1,1,1)
  60367. * @param extent x,y,z value that define the extent around the queries point of reference
  60368. */
  60369. setDefaultQueryExtent(extent: Vector3): void;
  60370. /**
  60371. * Get the Bounding box extent specified by setDefaultQueryExtent
  60372. * @returns the box extent values
  60373. */
  60374. getDefaultQueryExtent(): Vector3;
  60375. /**
  60376. * Release all resources
  60377. */
  60378. dispose(): void;
  60379. }
  60380. /**
  60381. * Configures an agent
  60382. */
  60383. export interface IAgentParameters {
  60384. /**
  60385. * Agent radius. [Limit: >= 0]
  60386. */
  60387. radius: number;
  60388. /**
  60389. * Agent height. [Limit: > 0]
  60390. */
  60391. height: number;
  60392. /**
  60393. * Maximum allowed acceleration. [Limit: >= 0]
  60394. */
  60395. maxAcceleration: number;
  60396. /**
  60397. * Maximum allowed speed. [Limit: >= 0]
  60398. */
  60399. maxSpeed: number;
  60400. /**
  60401. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60402. */
  60403. collisionQueryRange: number;
  60404. /**
  60405. * The path visibility optimization range. [Limit: > 0]
  60406. */
  60407. pathOptimizationRange: number;
  60408. /**
  60409. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60410. */
  60411. separationWeight: number;
  60412. }
  60413. /**
  60414. * Configures the navigation mesh creation
  60415. */
  60416. export interface INavMeshParameters {
  60417. /**
  60418. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60419. */
  60420. cs: number;
  60421. /**
  60422. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60423. */
  60424. ch: number;
  60425. /**
  60426. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60427. */
  60428. walkableSlopeAngle: number;
  60429. /**
  60430. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60431. * be considered walkable. [Limit: >= 3] [Units: vx]
  60432. */
  60433. walkableHeight: number;
  60434. /**
  60435. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60436. */
  60437. walkableClimb: number;
  60438. /**
  60439. * The distance to erode/shrink the walkable area of the heightfield away from
  60440. * obstructions. [Limit: >=0] [Units: vx]
  60441. */
  60442. walkableRadius: number;
  60443. /**
  60444. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60445. */
  60446. maxEdgeLen: number;
  60447. /**
  60448. * The maximum distance a simplfied contour's border edges should deviate
  60449. * the original raw contour. [Limit: >=0] [Units: vx]
  60450. */
  60451. maxSimplificationError: number;
  60452. /**
  60453. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60454. */
  60455. minRegionArea: number;
  60456. /**
  60457. * Any regions with a span count smaller than this value will, if possible,
  60458. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60459. */
  60460. mergeRegionArea: number;
  60461. /**
  60462. * The maximum number of vertices allowed for polygons generated during the
  60463. * contour to polygon conversion process. [Limit: >= 3]
  60464. */
  60465. maxVertsPerPoly: number;
  60466. /**
  60467. * Sets the sampling distance to use when generating the detail mesh.
  60468. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60469. */
  60470. detailSampleDist: number;
  60471. /**
  60472. * The maximum distance the detail mesh surface should deviate from heightfield
  60473. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60474. */
  60475. detailSampleMaxError: number;
  60476. }
  60477. }
  60478. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60479. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60480. import { Mesh } from "babylonjs/Meshes/mesh";
  60481. import { Scene } from "babylonjs/scene";
  60482. import { Vector3 } from "babylonjs/Maths/math";
  60483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60484. /**
  60485. * RecastJS navigation plugin
  60486. */
  60487. export class RecastJSPlugin implements INavigationEnginePlugin {
  60488. /**
  60489. * Reference to the Recast library
  60490. */
  60491. bjsRECAST: any;
  60492. /**
  60493. * plugin name
  60494. */
  60495. name: string;
  60496. /**
  60497. * the first navmesh created. We might extend this to support multiple navmeshes
  60498. */
  60499. navMesh: any;
  60500. /**
  60501. * Initializes the recastJS plugin
  60502. * @param recastInjection can be used to inject your own recast reference
  60503. */
  60504. constructor(recastInjection?: any);
  60505. /**
  60506. * Creates a navigation mesh
  60507. * @param meshes array of all the geometry used to compute the navigatio mesh
  60508. * @param parameters bunch of parameters used to filter geometry
  60509. */
  60510. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60511. /**
  60512. * Create a navigation mesh debug mesh
  60513. * @param scene is where the mesh will be added
  60514. * @returns debug display mesh
  60515. */
  60516. createDebugNavMesh(scene: Scene): Mesh;
  60517. /**
  60518. * Get a navigation mesh constrained position, closest to the parameter position
  60519. * @param position world position
  60520. * @returns the closest point to position constrained by the navigation mesh
  60521. */
  60522. getClosestPoint(position: Vector3): Vector3;
  60523. /**
  60524. * Get a navigation mesh constrained position, within a particular radius
  60525. * @param position world position
  60526. * @param maxRadius the maximum distance to the constrained world position
  60527. * @returns the closest point to position constrained by the navigation mesh
  60528. */
  60529. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60530. /**
  60531. * Compute the final position from a segment made of destination-position
  60532. * @param position world position
  60533. * @param destination world position
  60534. * @returns the resulting point along the navmesh
  60535. */
  60536. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60537. /**
  60538. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60539. * @param start world position
  60540. * @param end world position
  60541. * @returns array containing world position composing the path
  60542. */
  60543. computePath(start: Vector3, end: Vector3): Vector3[];
  60544. /**
  60545. * Create a new Crowd so you can add agents
  60546. * @param maxAgents the maximum agent count in the crowd
  60547. * @param maxAgentRadius the maximum radius an agent can have
  60548. * @param scene to attach the crowd to
  60549. * @returns the crowd you can add agents to
  60550. */
  60551. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60552. /**
  60553. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60554. * The queries will try to find a solution within those bounds
  60555. * default is (1,1,1)
  60556. * @param extent x,y,z value that define the extent around the queries point of reference
  60557. */
  60558. setDefaultQueryExtent(extent: Vector3): void;
  60559. /**
  60560. * Get the Bounding box extent specified by setDefaultQueryExtent
  60561. * @returns the box extent values
  60562. */
  60563. getDefaultQueryExtent(): Vector3;
  60564. /**
  60565. * Disposes
  60566. */
  60567. dispose(): void;
  60568. /**
  60569. * If this plugin is supported
  60570. * @returns true if plugin is supported
  60571. */
  60572. isSupported(): boolean;
  60573. }
  60574. /**
  60575. * Recast detour crowd implementation
  60576. */
  60577. export class RecastJSCrowd implements ICrowd {
  60578. /**
  60579. * Recast/detour plugin
  60580. */
  60581. bjsRECASTPlugin: RecastJSPlugin;
  60582. /**
  60583. * Link to the detour crowd
  60584. */
  60585. recastCrowd: any;
  60586. /**
  60587. * One transform per agent
  60588. */
  60589. transforms: TransformNode[];
  60590. /**
  60591. * All agents created
  60592. */
  60593. agents: number[];
  60594. /**
  60595. * Link to the scene is kept to unregister the crowd from the scene
  60596. */
  60597. private _scene;
  60598. /**
  60599. * Observer for crowd updates
  60600. */
  60601. private _onBeforeAnimationsObserver;
  60602. /**
  60603. * Constructor
  60604. * @param plugin recastJS plugin
  60605. * @param maxAgents the maximum agent count in the crowd
  60606. * @param maxAgentRadius the maximum radius an agent can have
  60607. * @param scene to attach the crowd to
  60608. * @returns the crowd you can add agents to
  60609. */
  60610. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60611. /**
  60612. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60613. * You can attach anything to that node. The node position is updated in the scene update tick.
  60614. * @param pos world position that will be constrained by the navigation mesh
  60615. * @param parameters agent parameters
  60616. * @param transform hooked to the agent that will be update by the scene
  60617. * @returns agent index
  60618. */
  60619. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60620. /**
  60621. * Returns the agent position in world space
  60622. * @param index agent index returned by addAgent
  60623. * @returns world space position
  60624. */
  60625. getAgentPosition(index: number): Vector3;
  60626. /**
  60627. * Returns the agent velocity in world space
  60628. * @param index agent index returned by addAgent
  60629. * @returns world space velocity
  60630. */
  60631. getAgentVelocity(index: number): Vector3;
  60632. /**
  60633. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60634. * @param index agent index returned by addAgent
  60635. * @param destination targeted world position
  60636. */
  60637. agentGoto(index: number, destination: Vector3): void;
  60638. /**
  60639. * remove a particular agent previously created
  60640. * @param index agent index returned by addAgent
  60641. */
  60642. removeAgent(index: number): void;
  60643. /**
  60644. * get the list of all agents attached to this crowd
  60645. * @returns list of agent indices
  60646. */
  60647. getAgents(): number[];
  60648. /**
  60649. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60650. * @param deltaTime in seconds
  60651. */
  60652. update(deltaTime: number): void;
  60653. /**
  60654. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60655. * The queries will try to find a solution within those bounds
  60656. * default is (1,1,1)
  60657. * @param extent x,y,z value that define the extent around the queries point of reference
  60658. */
  60659. setDefaultQueryExtent(extent: Vector3): void;
  60660. /**
  60661. * Get the Bounding box extent specified by setDefaultQueryExtent
  60662. * @returns the box extent values
  60663. */
  60664. getDefaultQueryExtent(): Vector3;
  60665. /**
  60666. * Release all resources
  60667. */
  60668. dispose(): void;
  60669. }
  60670. }
  60671. declare module "babylonjs/Navigation/Plugins/index" {
  60672. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60673. }
  60674. declare module "babylonjs/Navigation/index" {
  60675. export * from "babylonjs/Navigation/INavigationEngine";
  60676. export * from "babylonjs/Navigation/Plugins/index";
  60677. }
  60678. declare module "babylonjs/Offline/database" {
  60679. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60680. /**
  60681. * Class used to enable access to IndexedDB
  60682. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60683. */
  60684. export class Database implements IOfflineProvider {
  60685. private _callbackManifestChecked;
  60686. private _currentSceneUrl;
  60687. private _db;
  60688. private _enableSceneOffline;
  60689. private _enableTexturesOffline;
  60690. private _manifestVersionFound;
  60691. private _mustUpdateRessources;
  60692. private _hasReachedQuota;
  60693. private _isSupported;
  60694. private _idbFactory;
  60695. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60696. private static IsUASupportingBlobStorage;
  60697. /**
  60698. * Gets a boolean indicating if Database storate is enabled (off by default)
  60699. */
  60700. static IDBStorageEnabled: boolean;
  60701. /**
  60702. * Gets a boolean indicating if scene must be saved in the database
  60703. */
  60704. readonly enableSceneOffline: boolean;
  60705. /**
  60706. * Gets a boolean indicating if textures must be saved in the database
  60707. */
  60708. readonly enableTexturesOffline: boolean;
  60709. /**
  60710. * Creates a new Database
  60711. * @param urlToScene defines the url to load the scene
  60712. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60713. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60714. */
  60715. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60716. private static _ParseURL;
  60717. private static _ReturnFullUrlLocation;
  60718. private _checkManifestFile;
  60719. /**
  60720. * Open the database and make it available
  60721. * @param successCallback defines the callback to call on success
  60722. * @param errorCallback defines the callback to call on error
  60723. */
  60724. open(successCallback: () => void, errorCallback: () => void): void;
  60725. /**
  60726. * Loads an image from the database
  60727. * @param url defines the url to load from
  60728. * @param image defines the target DOM image
  60729. */
  60730. loadImage(url: string, image: HTMLImageElement): void;
  60731. private _loadImageFromDBAsync;
  60732. private _saveImageIntoDBAsync;
  60733. private _checkVersionFromDB;
  60734. private _loadVersionFromDBAsync;
  60735. private _saveVersionIntoDBAsync;
  60736. /**
  60737. * Loads a file from database
  60738. * @param url defines the URL to load from
  60739. * @param sceneLoaded defines a callback to call on success
  60740. * @param progressCallBack defines a callback to call when progress changed
  60741. * @param errorCallback defines a callback to call on error
  60742. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60743. */
  60744. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60745. private _loadFileAsync;
  60746. private _saveFileAsync;
  60747. /**
  60748. * Validates if xhr data is correct
  60749. * @param xhr defines the request to validate
  60750. * @param dataType defines the expected data type
  60751. * @returns true if data is correct
  60752. */
  60753. private static _ValidateXHRData;
  60754. }
  60755. }
  60756. declare module "babylonjs/Offline/index" {
  60757. export * from "babylonjs/Offline/database";
  60758. export * from "babylonjs/Offline/IOfflineProvider";
  60759. }
  60760. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60761. /** @hidden */
  60762. export var gpuUpdateParticlesPixelShader: {
  60763. name: string;
  60764. shader: string;
  60765. };
  60766. }
  60767. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60768. /** @hidden */
  60769. export var gpuUpdateParticlesVertexShader: {
  60770. name: string;
  60771. shader: string;
  60772. };
  60773. }
  60774. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60775. /** @hidden */
  60776. export var clipPlaneFragmentDeclaration2: {
  60777. name: string;
  60778. shader: string;
  60779. };
  60780. }
  60781. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60783. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60785. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60786. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60787. /** @hidden */
  60788. export var gpuRenderParticlesPixelShader: {
  60789. name: string;
  60790. shader: string;
  60791. };
  60792. }
  60793. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60794. /** @hidden */
  60795. export var clipPlaneVertexDeclaration2: {
  60796. name: string;
  60797. shader: string;
  60798. };
  60799. }
  60800. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60802. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60803. /** @hidden */
  60804. export var gpuRenderParticlesVertexShader: {
  60805. name: string;
  60806. shader: string;
  60807. };
  60808. }
  60809. declare module "babylonjs/Particles/gpuParticleSystem" {
  60810. import { Nullable } from "babylonjs/types";
  60811. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60812. import { Observable } from "babylonjs/Misc/observable";
  60813. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60814. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60815. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60816. import { Scene, IDisposable } from "babylonjs/scene";
  60817. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60818. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60819. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60820. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60821. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60822. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60823. /**
  60824. * This represents a GPU particle system in Babylon
  60825. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60826. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60827. */
  60828. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60829. /**
  60830. * The layer mask we are rendering the particles through.
  60831. */
  60832. layerMask: number;
  60833. private _capacity;
  60834. private _activeCount;
  60835. private _currentActiveCount;
  60836. private _accumulatedCount;
  60837. private _renderEffect;
  60838. private _updateEffect;
  60839. private _buffer0;
  60840. private _buffer1;
  60841. private _spriteBuffer;
  60842. private _updateVAO;
  60843. private _renderVAO;
  60844. private _targetIndex;
  60845. private _sourceBuffer;
  60846. private _targetBuffer;
  60847. private _engine;
  60848. private _currentRenderId;
  60849. private _started;
  60850. private _stopped;
  60851. private _timeDelta;
  60852. private _randomTexture;
  60853. private _randomTexture2;
  60854. private _attributesStrideSize;
  60855. private _updateEffectOptions;
  60856. private _randomTextureSize;
  60857. private _actualFrame;
  60858. private readonly _rawTextureWidth;
  60859. /**
  60860. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60861. */
  60862. static readonly IsSupported: boolean;
  60863. /**
  60864. * An event triggered when the system is disposed.
  60865. */
  60866. onDisposeObservable: Observable<GPUParticleSystem>;
  60867. /**
  60868. * Gets the maximum number of particles active at the same time.
  60869. * @returns The max number of active particles.
  60870. */
  60871. getCapacity(): number;
  60872. /**
  60873. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60874. * to override the particles.
  60875. */
  60876. forceDepthWrite: boolean;
  60877. /**
  60878. * Gets or set the number of active particles
  60879. */
  60880. activeParticleCount: number;
  60881. private _preWarmDone;
  60882. /**
  60883. * Is this system ready to be used/rendered
  60884. * @return true if the system is ready
  60885. */
  60886. isReady(): boolean;
  60887. /**
  60888. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60889. * @returns True if it has been started, otherwise false.
  60890. */
  60891. isStarted(): boolean;
  60892. /**
  60893. * Starts the particle system and begins to emit
  60894. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60895. */
  60896. start(delay?: number): void;
  60897. /**
  60898. * Stops the particle system.
  60899. */
  60900. stop(): void;
  60901. /**
  60902. * Remove all active particles
  60903. */
  60904. reset(): void;
  60905. /**
  60906. * Returns the string "GPUParticleSystem"
  60907. * @returns a string containing the class name
  60908. */
  60909. getClassName(): string;
  60910. private _colorGradientsTexture;
  60911. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60912. /**
  60913. * Adds a new color gradient
  60914. * @param gradient defines the gradient to use (between 0 and 1)
  60915. * @param color1 defines the color to affect to the specified gradient
  60916. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60917. * @returns the current particle system
  60918. */
  60919. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60920. /**
  60921. * Remove a specific color gradient
  60922. * @param gradient defines the gradient to remove
  60923. * @returns the current particle system
  60924. */
  60925. removeColorGradient(gradient: number): GPUParticleSystem;
  60926. private _angularSpeedGradientsTexture;
  60927. private _sizeGradientsTexture;
  60928. private _velocityGradientsTexture;
  60929. private _limitVelocityGradientsTexture;
  60930. private _dragGradientsTexture;
  60931. private _addFactorGradient;
  60932. /**
  60933. * Adds a new size gradient
  60934. * @param gradient defines the gradient to use (between 0 and 1)
  60935. * @param factor defines the size factor to affect to the specified gradient
  60936. * @returns the current particle system
  60937. */
  60938. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60939. /**
  60940. * Remove a specific size gradient
  60941. * @param gradient defines the gradient to remove
  60942. * @returns the current particle system
  60943. */
  60944. removeSizeGradient(gradient: number): GPUParticleSystem;
  60945. /**
  60946. * Adds a new angular speed gradient
  60947. * @param gradient defines the gradient to use (between 0 and 1)
  60948. * @param factor defines the angular speed to affect to the specified gradient
  60949. * @returns the current particle system
  60950. */
  60951. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60952. /**
  60953. * Remove a specific angular speed gradient
  60954. * @param gradient defines the gradient to remove
  60955. * @returns the current particle system
  60956. */
  60957. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60958. /**
  60959. * Adds a new velocity gradient
  60960. * @param gradient defines the gradient to use (between 0 and 1)
  60961. * @param factor defines the velocity to affect to the specified gradient
  60962. * @returns the current particle system
  60963. */
  60964. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60965. /**
  60966. * Remove a specific velocity gradient
  60967. * @param gradient defines the gradient to remove
  60968. * @returns the current particle system
  60969. */
  60970. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60971. /**
  60972. * Adds a new limit velocity gradient
  60973. * @param gradient defines the gradient to use (between 0 and 1)
  60974. * @param factor defines the limit velocity value to affect to the specified gradient
  60975. * @returns the current particle system
  60976. */
  60977. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60978. /**
  60979. * Remove a specific limit velocity gradient
  60980. * @param gradient defines the gradient to remove
  60981. * @returns the current particle system
  60982. */
  60983. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60984. /**
  60985. * Adds a new drag gradient
  60986. * @param gradient defines the gradient to use (between 0 and 1)
  60987. * @param factor defines the drag value to affect to the specified gradient
  60988. * @returns the current particle system
  60989. */
  60990. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60991. /**
  60992. * Remove a specific drag gradient
  60993. * @param gradient defines the gradient to remove
  60994. * @returns the current particle system
  60995. */
  60996. removeDragGradient(gradient: number): GPUParticleSystem;
  60997. /**
  60998. * Not supported by GPUParticleSystem
  60999. * @param gradient defines the gradient to use (between 0 and 1)
  61000. * @param factor defines the emit rate value to affect to the specified gradient
  61001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61002. * @returns the current particle system
  61003. */
  61004. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61005. /**
  61006. * Not supported by GPUParticleSystem
  61007. * @param gradient defines the gradient to remove
  61008. * @returns the current particle system
  61009. */
  61010. removeEmitRateGradient(gradient: number): IParticleSystem;
  61011. /**
  61012. * Not supported by GPUParticleSystem
  61013. * @param gradient defines the gradient to use (between 0 and 1)
  61014. * @param factor defines the start size value to affect to the specified gradient
  61015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61016. * @returns the current particle system
  61017. */
  61018. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61019. /**
  61020. * Not supported by GPUParticleSystem
  61021. * @param gradient defines the gradient to remove
  61022. * @returns the current particle system
  61023. */
  61024. removeStartSizeGradient(gradient: number): IParticleSystem;
  61025. /**
  61026. * Not supported by GPUParticleSystem
  61027. * @param gradient defines the gradient to use (between 0 and 1)
  61028. * @param min defines the color remap minimal range
  61029. * @param max defines the color remap maximal range
  61030. * @returns the current particle system
  61031. */
  61032. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61033. /**
  61034. * Not supported by GPUParticleSystem
  61035. * @param gradient defines the gradient to remove
  61036. * @returns the current particle system
  61037. */
  61038. removeColorRemapGradient(): IParticleSystem;
  61039. /**
  61040. * Not supported by GPUParticleSystem
  61041. * @param gradient defines the gradient to use (between 0 and 1)
  61042. * @param min defines the alpha remap minimal range
  61043. * @param max defines the alpha remap maximal range
  61044. * @returns the current particle system
  61045. */
  61046. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61047. /**
  61048. * Not supported by GPUParticleSystem
  61049. * @param gradient defines the gradient to remove
  61050. * @returns the current particle system
  61051. */
  61052. removeAlphaRemapGradient(): IParticleSystem;
  61053. /**
  61054. * Not supported by GPUParticleSystem
  61055. * @param gradient defines the gradient to use (between 0 and 1)
  61056. * @param color defines the color to affect to the specified gradient
  61057. * @returns the current particle system
  61058. */
  61059. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61060. /**
  61061. * Not supported by GPUParticleSystem
  61062. * @param gradient defines the gradient to remove
  61063. * @returns the current particle system
  61064. */
  61065. removeRampGradient(): IParticleSystem;
  61066. /**
  61067. * Not supported by GPUParticleSystem
  61068. * @returns the list of ramp gradients
  61069. */
  61070. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61071. /**
  61072. * Not supported by GPUParticleSystem
  61073. * Gets or sets a boolean indicating that ramp gradients must be used
  61074. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61075. */
  61076. useRampGradients: boolean;
  61077. /**
  61078. * Not supported by GPUParticleSystem
  61079. * @param gradient defines the gradient to use (between 0 and 1)
  61080. * @param factor defines the life time factor to affect to the specified gradient
  61081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61082. * @returns the current particle system
  61083. */
  61084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61085. /**
  61086. * Not supported by GPUParticleSystem
  61087. * @param gradient defines the gradient to remove
  61088. * @returns the current particle system
  61089. */
  61090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61091. /**
  61092. * Instantiates a GPU particle system.
  61093. * 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.
  61094. * @param name The name of the particle system
  61095. * @param options The options used to create the system
  61096. * @param scene The scene the particle system belongs to
  61097. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61098. */
  61099. constructor(name: string, options: Partial<{
  61100. capacity: number;
  61101. randomTextureSize: number;
  61102. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61103. protected _reset(): void;
  61104. private _createUpdateVAO;
  61105. private _createRenderVAO;
  61106. private _initialize;
  61107. /** @hidden */
  61108. _recreateUpdateEffect(): void;
  61109. /** @hidden */
  61110. _recreateRenderEffect(): void;
  61111. /**
  61112. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61113. * @param preWarm defines if we are in the pre-warmimg phase
  61114. */
  61115. animate(preWarm?: boolean): void;
  61116. private _createFactorGradientTexture;
  61117. private _createSizeGradientTexture;
  61118. private _createAngularSpeedGradientTexture;
  61119. private _createVelocityGradientTexture;
  61120. private _createLimitVelocityGradientTexture;
  61121. private _createDragGradientTexture;
  61122. private _createColorGradientTexture;
  61123. /**
  61124. * Renders the particle system in its current state
  61125. * @param preWarm defines if the system should only update the particles but not render them
  61126. * @returns the current number of particles
  61127. */
  61128. render(preWarm?: boolean): number;
  61129. /**
  61130. * Rebuilds the particle system
  61131. */
  61132. rebuild(): void;
  61133. private _releaseBuffers;
  61134. private _releaseVAOs;
  61135. /**
  61136. * Disposes the particle system and free the associated resources
  61137. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61138. */
  61139. dispose(disposeTexture?: boolean): void;
  61140. /**
  61141. * Clones the particle system.
  61142. * @param name The name of the cloned object
  61143. * @param newEmitter The new emitter to use
  61144. * @returns the cloned particle system
  61145. */
  61146. clone(name: string, newEmitter: any): GPUParticleSystem;
  61147. /**
  61148. * Serializes the particle system to a JSON object.
  61149. * @returns the JSON object
  61150. */
  61151. serialize(): any;
  61152. /**
  61153. * Parses a JSON object to create a GPU particle system.
  61154. * @param parsedParticleSystem The JSON object to parse
  61155. * @param scene The scene to create the particle system in
  61156. * @param rootUrl The root url to use to load external dependencies like texture
  61157. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61158. * @returns the parsed GPU particle system
  61159. */
  61160. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61161. }
  61162. }
  61163. declare module "babylonjs/Particles/particleSystemSet" {
  61164. import { Nullable } from "babylonjs/types";
  61165. import { Color3 } from "babylonjs/Maths/math.color";
  61166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61168. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61169. import { Scene, IDisposable } from "babylonjs/scene";
  61170. /**
  61171. * Represents a set of particle systems working together to create a specific effect
  61172. */
  61173. export class ParticleSystemSet implements IDisposable {
  61174. private _emitterCreationOptions;
  61175. private _emitterNode;
  61176. /**
  61177. * Gets the particle system list
  61178. */
  61179. systems: IParticleSystem[];
  61180. /**
  61181. * Gets the emitter node used with this set
  61182. */
  61183. readonly emitterNode: Nullable<TransformNode>;
  61184. /**
  61185. * Creates a new emitter mesh as a sphere
  61186. * @param options defines the options used to create the sphere
  61187. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61188. * @param scene defines the hosting scene
  61189. */
  61190. setEmitterAsSphere(options: {
  61191. diameter: number;
  61192. segments: number;
  61193. color: Color3;
  61194. }, renderingGroupId: number, scene: Scene): void;
  61195. /**
  61196. * Starts all particle systems of the set
  61197. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61198. */
  61199. start(emitter?: AbstractMesh): void;
  61200. /**
  61201. * Release all associated resources
  61202. */
  61203. dispose(): void;
  61204. /**
  61205. * Serialize the set into a JSON compatible object
  61206. * @returns a JSON compatible representation of the set
  61207. */
  61208. serialize(): any;
  61209. /**
  61210. * Parse a new ParticleSystemSet from a serialized source
  61211. * @param data defines a JSON compatible representation of the set
  61212. * @param scene defines the hosting scene
  61213. * @param gpu defines if we want GPU particles or CPU particles
  61214. * @returns a new ParticleSystemSet
  61215. */
  61216. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61217. }
  61218. }
  61219. declare module "babylonjs/Particles/particleHelper" {
  61220. import { Nullable } from "babylonjs/types";
  61221. import { Scene } from "babylonjs/scene";
  61222. import { Vector3 } from "babylonjs/Maths/math.vector";
  61223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61224. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61225. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61226. /**
  61227. * This class is made for on one-liner static method to help creating particle system set.
  61228. */
  61229. export class ParticleHelper {
  61230. /**
  61231. * Gets or sets base Assets URL
  61232. */
  61233. static BaseAssetsUrl: string;
  61234. /**
  61235. * Create a default particle system that you can tweak
  61236. * @param emitter defines the emitter to use
  61237. * @param capacity defines the system capacity (default is 500 particles)
  61238. * @param scene defines the hosting scene
  61239. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61240. * @returns the new Particle system
  61241. */
  61242. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61243. /**
  61244. * This is the main static method (one-liner) of this helper to create different particle systems
  61245. * @param type This string represents the type to the particle system to create
  61246. * @param scene The scene where the particle system should live
  61247. * @param gpu If the system will use gpu
  61248. * @returns the ParticleSystemSet created
  61249. */
  61250. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61251. /**
  61252. * Static function used to export a particle system to a ParticleSystemSet variable.
  61253. * Please note that the emitter shape is not exported
  61254. * @param systems defines the particle systems to export
  61255. * @returns the created particle system set
  61256. */
  61257. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61258. }
  61259. }
  61260. declare module "babylonjs/Particles/particleSystemComponent" {
  61261. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61262. import { Effect } from "babylonjs/Materials/effect";
  61263. import "babylonjs/Shaders/particles.vertex";
  61264. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61265. module "babylonjs/Engines/engine" {
  61266. interface Engine {
  61267. /**
  61268. * Create an effect to use with particle systems.
  61269. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61270. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61271. * @param uniformsNames defines a list of attribute names
  61272. * @param samplers defines an array of string used to represent textures
  61273. * @param defines defines the string containing the defines to use to compile the shaders
  61274. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61275. * @param onCompiled defines a function to call when the effect creation is successful
  61276. * @param onError defines a function to call when the effect creation has failed
  61277. * @returns the new Effect
  61278. */
  61279. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61280. }
  61281. }
  61282. module "babylonjs/Meshes/mesh" {
  61283. interface Mesh {
  61284. /**
  61285. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61286. * @returns an array of IParticleSystem
  61287. */
  61288. getEmittedParticleSystems(): IParticleSystem[];
  61289. /**
  61290. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61291. * @returns an array of IParticleSystem
  61292. */
  61293. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61294. }
  61295. }
  61296. /**
  61297. * @hidden
  61298. */
  61299. export var _IDoNeedToBeInTheBuild: number;
  61300. }
  61301. declare module "babylonjs/Particles/index" {
  61302. export * from "babylonjs/Particles/baseParticleSystem";
  61303. export * from "babylonjs/Particles/EmitterTypes/index";
  61304. export * from "babylonjs/Particles/gpuParticleSystem";
  61305. export * from "babylonjs/Particles/IParticleSystem";
  61306. export * from "babylonjs/Particles/particle";
  61307. export * from "babylonjs/Particles/particleHelper";
  61308. export * from "babylonjs/Particles/particleSystem";
  61309. export * from "babylonjs/Particles/particleSystemComponent";
  61310. export * from "babylonjs/Particles/particleSystemSet";
  61311. export * from "babylonjs/Particles/solidParticle";
  61312. export * from "babylonjs/Particles/solidParticleSystem";
  61313. export * from "babylonjs/Particles/subEmitter";
  61314. }
  61315. declare module "babylonjs/Physics/physicsEngineComponent" {
  61316. import { Nullable } from "babylonjs/types";
  61317. import { Observable, Observer } from "babylonjs/Misc/observable";
  61318. import { Vector3 } from "babylonjs/Maths/math.vector";
  61319. import { Mesh } from "babylonjs/Meshes/mesh";
  61320. import { ISceneComponent } from "babylonjs/sceneComponent";
  61321. import { Scene } from "babylonjs/scene";
  61322. import { Node } from "babylonjs/node";
  61323. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61324. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61325. module "babylonjs/scene" {
  61326. interface Scene {
  61327. /** @hidden (Backing field) */
  61328. _physicsEngine: Nullable<IPhysicsEngine>;
  61329. /**
  61330. * Gets the current physics engine
  61331. * @returns a IPhysicsEngine or null if none attached
  61332. */
  61333. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61334. /**
  61335. * Enables physics to the current scene
  61336. * @param gravity defines the scene's gravity for the physics engine
  61337. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61338. * @return a boolean indicating if the physics engine was initialized
  61339. */
  61340. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61341. /**
  61342. * Disables and disposes the physics engine associated with the scene
  61343. */
  61344. disablePhysicsEngine(): void;
  61345. /**
  61346. * Gets a boolean indicating if there is an active physics engine
  61347. * @returns a boolean indicating if there is an active physics engine
  61348. */
  61349. isPhysicsEnabled(): boolean;
  61350. /**
  61351. * Deletes a physics compound impostor
  61352. * @param compound defines the compound to delete
  61353. */
  61354. deleteCompoundImpostor(compound: any): void;
  61355. /**
  61356. * An event triggered when physic simulation is about to be run
  61357. */
  61358. onBeforePhysicsObservable: Observable<Scene>;
  61359. /**
  61360. * An event triggered when physic simulation has been done
  61361. */
  61362. onAfterPhysicsObservable: Observable<Scene>;
  61363. }
  61364. }
  61365. module "babylonjs/Meshes/abstractMesh" {
  61366. interface AbstractMesh {
  61367. /** @hidden */
  61368. _physicsImpostor: Nullable<PhysicsImpostor>;
  61369. /**
  61370. * Gets or sets impostor used for physic simulation
  61371. * @see http://doc.babylonjs.com/features/physics_engine
  61372. */
  61373. physicsImpostor: Nullable<PhysicsImpostor>;
  61374. /**
  61375. * Gets the current physics impostor
  61376. * @see http://doc.babylonjs.com/features/physics_engine
  61377. * @returns a physics impostor or null
  61378. */
  61379. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61380. /** Apply a physic impulse to the mesh
  61381. * @param force defines the force to apply
  61382. * @param contactPoint defines where to apply the force
  61383. * @returns the current mesh
  61384. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61385. */
  61386. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61387. /**
  61388. * Creates a physic joint between two meshes
  61389. * @param otherMesh defines the other mesh to use
  61390. * @param pivot1 defines the pivot to use on this mesh
  61391. * @param pivot2 defines the pivot to use on the other mesh
  61392. * @param options defines additional options (can be plugin dependent)
  61393. * @returns the current mesh
  61394. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61395. */
  61396. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61397. /** @hidden */
  61398. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61399. }
  61400. }
  61401. /**
  61402. * Defines the physics engine scene component responsible to manage a physics engine
  61403. */
  61404. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61405. /**
  61406. * The component name helpful to identify the component in the list of scene components.
  61407. */
  61408. readonly name: string;
  61409. /**
  61410. * The scene the component belongs to.
  61411. */
  61412. scene: Scene;
  61413. /**
  61414. * Creates a new instance of the component for the given scene
  61415. * @param scene Defines the scene to register the component in
  61416. */
  61417. constructor(scene: Scene);
  61418. /**
  61419. * Registers the component in a given scene
  61420. */
  61421. register(): void;
  61422. /**
  61423. * Rebuilds the elements related to this component in case of
  61424. * context lost for instance.
  61425. */
  61426. rebuild(): void;
  61427. /**
  61428. * Disposes the component and the associated ressources
  61429. */
  61430. dispose(): void;
  61431. }
  61432. }
  61433. declare module "babylonjs/Physics/physicsHelper" {
  61434. import { Nullable } from "babylonjs/types";
  61435. import { Vector3 } from "babylonjs/Maths/math.vector";
  61436. import { Mesh } from "babylonjs/Meshes/mesh";
  61437. import { Scene } from "babylonjs/scene";
  61438. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61439. /**
  61440. * A helper for physics simulations
  61441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61442. */
  61443. export class PhysicsHelper {
  61444. private _scene;
  61445. private _physicsEngine;
  61446. /**
  61447. * Initializes the Physics helper
  61448. * @param scene Babylon.js scene
  61449. */
  61450. constructor(scene: Scene);
  61451. /**
  61452. * Applies a radial explosion impulse
  61453. * @param origin the origin of the explosion
  61454. * @param radiusOrEventOptions the radius or the options of radial explosion
  61455. * @param strength the explosion strength
  61456. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61457. * @returns A physics radial explosion event, or null
  61458. */
  61459. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61460. /**
  61461. * Applies a radial explosion force
  61462. * @param origin the origin of the explosion
  61463. * @param radiusOrEventOptions the radius or the options of radial explosion
  61464. * @param strength the explosion strength
  61465. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61466. * @returns A physics radial explosion event, or null
  61467. */
  61468. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61469. /**
  61470. * Creates a gravitational field
  61471. * @param origin the origin of the explosion
  61472. * @param radiusOrEventOptions the radius or the options of radial explosion
  61473. * @param strength the explosion strength
  61474. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61475. * @returns A physics gravitational field event, or null
  61476. */
  61477. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61478. /**
  61479. * Creates a physics updraft event
  61480. * @param origin the origin of the updraft
  61481. * @param radiusOrEventOptions the radius or the options of the updraft
  61482. * @param strength the strength of the updraft
  61483. * @param height the height of the updraft
  61484. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61485. * @returns A physics updraft event, or null
  61486. */
  61487. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61488. /**
  61489. * Creates a physics vortex event
  61490. * @param origin the of the vortex
  61491. * @param radiusOrEventOptions the radius or the options of the vortex
  61492. * @param strength the strength of the vortex
  61493. * @param height the height of the vortex
  61494. * @returns a Physics vortex event, or null
  61495. * A physics vortex event or null
  61496. */
  61497. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61498. }
  61499. /**
  61500. * Represents a physics radial explosion event
  61501. */
  61502. class PhysicsRadialExplosionEvent {
  61503. private _scene;
  61504. private _options;
  61505. private _sphere;
  61506. private _dataFetched;
  61507. /**
  61508. * Initializes a radial explosioin event
  61509. * @param _scene BabylonJS scene
  61510. * @param _options The options for the vortex event
  61511. */
  61512. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61513. /**
  61514. * Returns the data related to the radial explosion event (sphere).
  61515. * @returns The radial explosion event data
  61516. */
  61517. getData(): PhysicsRadialExplosionEventData;
  61518. /**
  61519. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61520. * @param impostor A physics imposter
  61521. * @param origin the origin of the explosion
  61522. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61523. */
  61524. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61525. /**
  61526. * Triggers affecterd impostors callbacks
  61527. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61528. */
  61529. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61530. /**
  61531. * Disposes the sphere.
  61532. * @param force Specifies if the sphere should be disposed by force
  61533. */
  61534. dispose(force?: boolean): void;
  61535. /*** Helpers ***/
  61536. private _prepareSphere;
  61537. private _intersectsWithSphere;
  61538. }
  61539. /**
  61540. * Represents a gravitational field event
  61541. */
  61542. class PhysicsGravitationalFieldEvent {
  61543. private _physicsHelper;
  61544. private _scene;
  61545. private _origin;
  61546. private _options;
  61547. private _tickCallback;
  61548. private _sphere;
  61549. private _dataFetched;
  61550. /**
  61551. * Initializes the physics gravitational field event
  61552. * @param _physicsHelper A physics helper
  61553. * @param _scene BabylonJS scene
  61554. * @param _origin The origin position of the gravitational field event
  61555. * @param _options The options for the vortex event
  61556. */
  61557. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61558. /**
  61559. * Returns the data related to the gravitational field event (sphere).
  61560. * @returns A gravitational field event
  61561. */
  61562. getData(): PhysicsGravitationalFieldEventData;
  61563. /**
  61564. * Enables the gravitational field.
  61565. */
  61566. enable(): void;
  61567. /**
  61568. * Disables the gravitational field.
  61569. */
  61570. disable(): void;
  61571. /**
  61572. * Disposes the sphere.
  61573. * @param force The force to dispose from the gravitational field event
  61574. */
  61575. dispose(force?: boolean): void;
  61576. private _tick;
  61577. }
  61578. /**
  61579. * Represents a physics updraft event
  61580. */
  61581. class PhysicsUpdraftEvent {
  61582. private _scene;
  61583. private _origin;
  61584. private _options;
  61585. private _physicsEngine;
  61586. private _originTop;
  61587. private _originDirection;
  61588. private _tickCallback;
  61589. private _cylinder;
  61590. private _cylinderPosition;
  61591. private _dataFetched;
  61592. /**
  61593. * Initializes the physics updraft event
  61594. * @param _scene BabylonJS scene
  61595. * @param _origin The origin position of the updraft
  61596. * @param _options The options for the updraft event
  61597. */
  61598. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61599. /**
  61600. * Returns the data related to the updraft event (cylinder).
  61601. * @returns A physics updraft event
  61602. */
  61603. getData(): PhysicsUpdraftEventData;
  61604. /**
  61605. * Enables the updraft.
  61606. */
  61607. enable(): void;
  61608. /**
  61609. * Disables the updraft.
  61610. */
  61611. disable(): void;
  61612. /**
  61613. * Disposes the cylinder.
  61614. * @param force Specifies if the updraft should be disposed by force
  61615. */
  61616. dispose(force?: boolean): void;
  61617. private getImpostorHitData;
  61618. private _tick;
  61619. /*** Helpers ***/
  61620. private _prepareCylinder;
  61621. private _intersectsWithCylinder;
  61622. }
  61623. /**
  61624. * Represents a physics vortex event
  61625. */
  61626. class PhysicsVortexEvent {
  61627. private _scene;
  61628. private _origin;
  61629. private _options;
  61630. private _physicsEngine;
  61631. private _originTop;
  61632. private _tickCallback;
  61633. private _cylinder;
  61634. private _cylinderPosition;
  61635. private _dataFetched;
  61636. /**
  61637. * Initializes the physics vortex event
  61638. * @param _scene The BabylonJS scene
  61639. * @param _origin The origin position of the vortex
  61640. * @param _options The options for the vortex event
  61641. */
  61642. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61643. /**
  61644. * Returns the data related to the vortex event (cylinder).
  61645. * @returns The physics vortex event data
  61646. */
  61647. getData(): PhysicsVortexEventData;
  61648. /**
  61649. * Enables the vortex.
  61650. */
  61651. enable(): void;
  61652. /**
  61653. * Disables the cortex.
  61654. */
  61655. disable(): void;
  61656. /**
  61657. * Disposes the sphere.
  61658. * @param force
  61659. */
  61660. dispose(force?: boolean): void;
  61661. private getImpostorHitData;
  61662. private _tick;
  61663. /*** Helpers ***/
  61664. private _prepareCylinder;
  61665. private _intersectsWithCylinder;
  61666. }
  61667. /**
  61668. * Options fot the radial explosion event
  61669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61670. */
  61671. export class PhysicsRadialExplosionEventOptions {
  61672. /**
  61673. * The radius of the sphere for the radial explosion.
  61674. */
  61675. radius: number;
  61676. /**
  61677. * The strenth of the explosion.
  61678. */
  61679. strength: number;
  61680. /**
  61681. * The strenght of the force in correspondence to the distance of the affected object
  61682. */
  61683. falloff: PhysicsRadialImpulseFalloff;
  61684. /**
  61685. * Sphere options for the radial explosion.
  61686. */
  61687. sphere: {
  61688. segments: number;
  61689. diameter: number;
  61690. };
  61691. /**
  61692. * Sphere options for the radial explosion.
  61693. */
  61694. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61695. }
  61696. /**
  61697. * Options fot the updraft event
  61698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61699. */
  61700. export class PhysicsUpdraftEventOptions {
  61701. /**
  61702. * The radius of the cylinder for the vortex
  61703. */
  61704. radius: number;
  61705. /**
  61706. * The strenth of the updraft.
  61707. */
  61708. strength: number;
  61709. /**
  61710. * The height of the cylinder for the updraft.
  61711. */
  61712. height: number;
  61713. /**
  61714. * The mode for the the updraft.
  61715. */
  61716. updraftMode: PhysicsUpdraftMode;
  61717. }
  61718. /**
  61719. * Options fot the vortex event
  61720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61721. */
  61722. export class PhysicsVortexEventOptions {
  61723. /**
  61724. * The radius of the cylinder for the vortex
  61725. */
  61726. radius: number;
  61727. /**
  61728. * The strenth of the vortex.
  61729. */
  61730. strength: number;
  61731. /**
  61732. * The height of the cylinder for the vortex.
  61733. */
  61734. height: number;
  61735. /**
  61736. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61737. */
  61738. centripetalForceThreshold: number;
  61739. /**
  61740. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61741. */
  61742. centripetalForceMultiplier: number;
  61743. /**
  61744. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61745. */
  61746. centrifugalForceMultiplier: number;
  61747. /**
  61748. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61749. */
  61750. updraftForceMultiplier: number;
  61751. }
  61752. /**
  61753. * The strenght of the force in correspondence to the distance of the affected object
  61754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61755. */
  61756. export enum PhysicsRadialImpulseFalloff {
  61757. /** Defines that impulse is constant in strength across it's whole radius */
  61758. Constant = 0,
  61759. /** Defines that impulse gets weaker if it's further from the origin */
  61760. Linear = 1
  61761. }
  61762. /**
  61763. * The strength of the force in correspondence to the distance of the affected object
  61764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61765. */
  61766. export enum PhysicsUpdraftMode {
  61767. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61768. Center = 0,
  61769. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61770. Perpendicular = 1
  61771. }
  61772. /**
  61773. * Interface for a physics hit data
  61774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61775. */
  61776. export interface PhysicsHitData {
  61777. /**
  61778. * The force applied at the contact point
  61779. */
  61780. force: Vector3;
  61781. /**
  61782. * The contact point
  61783. */
  61784. contactPoint: Vector3;
  61785. /**
  61786. * The distance from the origin to the contact point
  61787. */
  61788. distanceFromOrigin: number;
  61789. }
  61790. /**
  61791. * Interface for radial explosion event data
  61792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61793. */
  61794. export interface PhysicsRadialExplosionEventData {
  61795. /**
  61796. * A sphere used for the radial explosion event
  61797. */
  61798. sphere: Mesh;
  61799. }
  61800. /**
  61801. * Interface for gravitational field event data
  61802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61803. */
  61804. export interface PhysicsGravitationalFieldEventData {
  61805. /**
  61806. * A sphere mesh used for the gravitational field event
  61807. */
  61808. sphere: Mesh;
  61809. }
  61810. /**
  61811. * Interface for updraft event data
  61812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61813. */
  61814. export interface PhysicsUpdraftEventData {
  61815. /**
  61816. * A cylinder used for the updraft event
  61817. */
  61818. cylinder: Mesh;
  61819. }
  61820. /**
  61821. * Interface for vortex event data
  61822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61823. */
  61824. export interface PhysicsVortexEventData {
  61825. /**
  61826. * A cylinder used for the vortex event
  61827. */
  61828. cylinder: Mesh;
  61829. }
  61830. /**
  61831. * Interface for an affected physics impostor
  61832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61833. */
  61834. export interface PhysicsAffectedImpostorWithData {
  61835. /**
  61836. * The impostor affected by the effect
  61837. */
  61838. impostor: PhysicsImpostor;
  61839. /**
  61840. * The data about the hit/horce from the explosion
  61841. */
  61842. hitData: PhysicsHitData;
  61843. }
  61844. }
  61845. declare module "babylonjs/Physics/Plugins/index" {
  61846. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61847. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61848. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61849. }
  61850. declare module "babylonjs/Physics/index" {
  61851. export * from "babylonjs/Physics/IPhysicsEngine";
  61852. export * from "babylonjs/Physics/physicsEngine";
  61853. export * from "babylonjs/Physics/physicsEngineComponent";
  61854. export * from "babylonjs/Physics/physicsHelper";
  61855. export * from "babylonjs/Physics/physicsImpostor";
  61856. export * from "babylonjs/Physics/physicsJoint";
  61857. export * from "babylonjs/Physics/Plugins/index";
  61858. }
  61859. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61860. /** @hidden */
  61861. export var blackAndWhitePixelShader: {
  61862. name: string;
  61863. shader: string;
  61864. };
  61865. }
  61866. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61868. import { Camera } from "babylonjs/Cameras/camera";
  61869. import { Engine } from "babylonjs/Engines/engine";
  61870. import "babylonjs/Shaders/blackAndWhite.fragment";
  61871. /**
  61872. * Post process used to render in black and white
  61873. */
  61874. export class BlackAndWhitePostProcess extends PostProcess {
  61875. /**
  61876. * Linear about to convert he result to black and white (default: 1)
  61877. */
  61878. degree: number;
  61879. /**
  61880. * Creates a black and white post process
  61881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61882. * @param name The name of the effect.
  61883. * @param options The required width/height ratio to downsize to before computing the render pass.
  61884. * @param camera The camera to apply the render pass to.
  61885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61886. * @param engine The engine which the post process will be applied. (default: current engine)
  61887. * @param reusable If the post process can be reused on the same frame. (default: false)
  61888. */
  61889. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61890. }
  61891. }
  61892. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61893. import { Nullable } from "babylonjs/types";
  61894. import { Camera } from "babylonjs/Cameras/camera";
  61895. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61896. import { Engine } from "babylonjs/Engines/engine";
  61897. /**
  61898. * This represents a set of one or more post processes in Babylon.
  61899. * A post process can be used to apply a shader to a texture after it is rendered.
  61900. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61901. */
  61902. export class PostProcessRenderEffect {
  61903. private _postProcesses;
  61904. private _getPostProcesses;
  61905. private _singleInstance;
  61906. private _cameras;
  61907. private _indicesForCamera;
  61908. /**
  61909. * Name of the effect
  61910. * @hidden
  61911. */
  61912. _name: string;
  61913. /**
  61914. * Instantiates a post process render effect.
  61915. * A post process can be used to apply a shader to a texture after it is rendered.
  61916. * @param engine The engine the effect is tied to
  61917. * @param name The name of the effect
  61918. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61919. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61920. */
  61921. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61922. /**
  61923. * Checks if all the post processes in the effect are supported.
  61924. */
  61925. readonly isSupported: boolean;
  61926. /**
  61927. * Updates the current state of the effect
  61928. * @hidden
  61929. */
  61930. _update(): void;
  61931. /**
  61932. * Attaches the effect on cameras
  61933. * @param cameras The camera to attach to.
  61934. * @hidden
  61935. */
  61936. _attachCameras(cameras: Camera): void;
  61937. /**
  61938. * Attaches the effect on cameras
  61939. * @param cameras The camera to attach to.
  61940. * @hidden
  61941. */
  61942. _attachCameras(cameras: Camera[]): void;
  61943. /**
  61944. * Detaches the effect on cameras
  61945. * @param cameras The camera to detatch from.
  61946. * @hidden
  61947. */
  61948. _detachCameras(cameras: Camera): void;
  61949. /**
  61950. * Detatches the effect on cameras
  61951. * @param cameras The camera to detatch from.
  61952. * @hidden
  61953. */
  61954. _detachCameras(cameras: Camera[]): void;
  61955. /**
  61956. * Enables the effect on given cameras
  61957. * @param cameras The camera to enable.
  61958. * @hidden
  61959. */
  61960. _enable(cameras: Camera): void;
  61961. /**
  61962. * Enables the effect on given cameras
  61963. * @param cameras The camera to enable.
  61964. * @hidden
  61965. */
  61966. _enable(cameras: Nullable<Camera[]>): void;
  61967. /**
  61968. * Disables the effect on the given cameras
  61969. * @param cameras The camera to disable.
  61970. * @hidden
  61971. */
  61972. _disable(cameras: Camera): void;
  61973. /**
  61974. * Disables the effect on the given cameras
  61975. * @param cameras The camera to disable.
  61976. * @hidden
  61977. */
  61978. _disable(cameras: Nullable<Camera[]>): void;
  61979. /**
  61980. * Gets a list of the post processes contained in the effect.
  61981. * @param camera The camera to get the post processes on.
  61982. * @returns The list of the post processes in the effect.
  61983. */
  61984. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61985. }
  61986. }
  61987. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61988. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61989. /** @hidden */
  61990. export var extractHighlightsPixelShader: {
  61991. name: string;
  61992. shader: string;
  61993. };
  61994. }
  61995. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61996. import { Nullable } from "babylonjs/types";
  61997. import { Camera } from "babylonjs/Cameras/camera";
  61998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61999. import { Engine } from "babylonjs/Engines/engine";
  62000. import "babylonjs/Shaders/extractHighlights.fragment";
  62001. /**
  62002. * 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.
  62003. */
  62004. export class ExtractHighlightsPostProcess extends PostProcess {
  62005. /**
  62006. * The luminance threshold, pixels below this value will be set to black.
  62007. */
  62008. threshold: number;
  62009. /** @hidden */
  62010. _exposure: number;
  62011. /**
  62012. * Post process which has the input texture to be used when performing highlight extraction
  62013. * @hidden
  62014. */
  62015. _inputPostProcess: Nullable<PostProcess>;
  62016. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62017. }
  62018. }
  62019. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62020. /** @hidden */
  62021. export var bloomMergePixelShader: {
  62022. name: string;
  62023. shader: string;
  62024. };
  62025. }
  62026. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62028. import { Nullable } from "babylonjs/types";
  62029. import { Engine } from "babylonjs/Engines/engine";
  62030. import { Camera } from "babylonjs/Cameras/camera";
  62031. import "babylonjs/Shaders/bloomMerge.fragment";
  62032. /**
  62033. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62034. */
  62035. export class BloomMergePostProcess extends PostProcess {
  62036. /** Weight of the bloom to be added to the original input. */
  62037. weight: number;
  62038. /**
  62039. * Creates a new instance of @see BloomMergePostProcess
  62040. * @param name The name of the effect.
  62041. * @param originalFromInput Post process which's input will be used for the merge.
  62042. * @param blurred Blurred highlights post process which's output will be used.
  62043. * @param weight Weight of the bloom to be added to the original input.
  62044. * @param options The required width/height ratio to downsize to before computing the render pass.
  62045. * @param camera The camera to apply the render pass to.
  62046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62047. * @param engine The engine which the post process will be applied. (default: current engine)
  62048. * @param reusable If the post process can be reused on the same frame. (default: false)
  62049. * @param textureType Type of textures used when performing the post process. (default: 0)
  62050. * @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)
  62051. */
  62052. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62053. /** Weight of the bloom to be added to the original input. */
  62054. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62055. }
  62056. }
  62057. declare module "babylonjs/PostProcesses/bloomEffect" {
  62058. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62060. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62061. import { Camera } from "babylonjs/Cameras/camera";
  62062. import { Scene } from "babylonjs/scene";
  62063. /**
  62064. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62065. */
  62066. export class BloomEffect extends PostProcessRenderEffect {
  62067. private bloomScale;
  62068. /**
  62069. * @hidden Internal
  62070. */
  62071. _effects: Array<PostProcess>;
  62072. /**
  62073. * @hidden Internal
  62074. */
  62075. _downscale: ExtractHighlightsPostProcess;
  62076. private _blurX;
  62077. private _blurY;
  62078. private _merge;
  62079. /**
  62080. * The luminance threshold to find bright areas of the image to bloom.
  62081. */
  62082. threshold: number;
  62083. /**
  62084. * The strength of the bloom.
  62085. */
  62086. weight: number;
  62087. /**
  62088. * Specifies the size of the bloom blur kernel, relative to the final output size
  62089. */
  62090. kernel: number;
  62091. /**
  62092. * Creates a new instance of @see BloomEffect
  62093. * @param scene The scene the effect belongs to.
  62094. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62095. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62096. * @param bloomWeight The the strength of bloom.
  62097. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62098. * @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)
  62099. */
  62100. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62101. /**
  62102. * Disposes each of the internal effects for a given camera.
  62103. * @param camera The camera to dispose the effect on.
  62104. */
  62105. disposeEffects(camera: Camera): void;
  62106. /**
  62107. * @hidden Internal
  62108. */
  62109. _updateEffects(): void;
  62110. /**
  62111. * Internal
  62112. * @returns if all the contained post processes are ready.
  62113. * @hidden
  62114. */
  62115. _isReady(): boolean;
  62116. }
  62117. }
  62118. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62119. /** @hidden */
  62120. export var chromaticAberrationPixelShader: {
  62121. name: string;
  62122. shader: string;
  62123. };
  62124. }
  62125. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62126. import { Vector2 } from "babylonjs/Maths/math.vector";
  62127. import { Nullable } from "babylonjs/types";
  62128. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62129. import { Camera } from "babylonjs/Cameras/camera";
  62130. import { Engine } from "babylonjs/Engines/engine";
  62131. import "babylonjs/Shaders/chromaticAberration.fragment";
  62132. /**
  62133. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62134. */
  62135. export class ChromaticAberrationPostProcess extends PostProcess {
  62136. /**
  62137. * The amount of seperation of rgb channels (default: 30)
  62138. */
  62139. aberrationAmount: number;
  62140. /**
  62141. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62142. */
  62143. radialIntensity: number;
  62144. /**
  62145. * 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))
  62146. */
  62147. direction: Vector2;
  62148. /**
  62149. * 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))
  62150. */
  62151. centerPosition: Vector2;
  62152. /**
  62153. * Creates a new instance ChromaticAberrationPostProcess
  62154. * @param name The name of the effect.
  62155. * @param screenWidth The width of the screen to apply the effect on.
  62156. * @param screenHeight The height of the screen to apply the effect on.
  62157. * @param options The required width/height ratio to downsize to before computing the render pass.
  62158. * @param camera The camera to apply the render pass to.
  62159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62160. * @param engine The engine which the post process will be applied. (default: current engine)
  62161. * @param reusable If the post process can be reused on the same frame. (default: false)
  62162. * @param textureType Type of textures used when performing the post process. (default: 0)
  62163. * @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)
  62164. */
  62165. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62166. }
  62167. }
  62168. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62169. /** @hidden */
  62170. export var circleOfConfusionPixelShader: {
  62171. name: string;
  62172. shader: string;
  62173. };
  62174. }
  62175. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62176. import { Nullable } from "babylonjs/types";
  62177. import { Engine } from "babylonjs/Engines/engine";
  62178. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62179. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62180. import { Camera } from "babylonjs/Cameras/camera";
  62181. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62182. /**
  62183. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62184. */
  62185. export class CircleOfConfusionPostProcess extends PostProcess {
  62186. /**
  62187. * 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.
  62188. */
  62189. lensSize: number;
  62190. /**
  62191. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62192. */
  62193. fStop: number;
  62194. /**
  62195. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62196. */
  62197. focusDistance: number;
  62198. /**
  62199. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62200. */
  62201. focalLength: number;
  62202. private _depthTexture;
  62203. /**
  62204. * Creates a new instance CircleOfConfusionPostProcess
  62205. * @param name The name of the effect.
  62206. * @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.
  62207. * @param options The required width/height ratio to downsize to before computing the render pass.
  62208. * @param camera The camera to apply the render pass to.
  62209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62210. * @param engine The engine which the post process will be applied. (default: current engine)
  62211. * @param reusable If the post process can be reused on the same frame. (default: false)
  62212. * @param textureType Type of textures used when performing the post process. (default: 0)
  62213. * @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)
  62214. */
  62215. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62216. /**
  62217. * 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.
  62218. */
  62219. depthTexture: RenderTargetTexture;
  62220. }
  62221. }
  62222. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62223. /** @hidden */
  62224. export var colorCorrectionPixelShader: {
  62225. name: string;
  62226. shader: string;
  62227. };
  62228. }
  62229. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62231. import { Engine } from "babylonjs/Engines/engine";
  62232. import { Camera } from "babylonjs/Cameras/camera";
  62233. import "babylonjs/Shaders/colorCorrection.fragment";
  62234. /**
  62235. *
  62236. * This post-process allows the modification of rendered colors by using
  62237. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62238. *
  62239. * The object needs to be provided an url to a texture containing the color
  62240. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62241. * Use an image editing software to tweak the LUT to match your needs.
  62242. *
  62243. * For an example of a color LUT, see here:
  62244. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62245. * For explanations on color grading, see here:
  62246. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62247. *
  62248. */
  62249. export class ColorCorrectionPostProcess extends PostProcess {
  62250. private _colorTableTexture;
  62251. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62252. }
  62253. }
  62254. declare module "babylonjs/Shaders/convolution.fragment" {
  62255. /** @hidden */
  62256. export var convolutionPixelShader: {
  62257. name: string;
  62258. shader: string;
  62259. };
  62260. }
  62261. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62262. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62263. import { Nullable } from "babylonjs/types";
  62264. import { Camera } from "babylonjs/Cameras/camera";
  62265. import { Engine } from "babylonjs/Engines/engine";
  62266. import "babylonjs/Shaders/convolution.fragment";
  62267. /**
  62268. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62269. * input texture to perform effects such as edge detection or sharpening
  62270. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62271. */
  62272. export class ConvolutionPostProcess extends PostProcess {
  62273. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62274. kernel: number[];
  62275. /**
  62276. * Creates a new instance ConvolutionPostProcess
  62277. * @param name The name of the effect.
  62278. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62279. * @param options The required width/height ratio to downsize to before computing the render pass.
  62280. * @param camera The camera to apply the render pass to.
  62281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62282. * @param engine The engine which the post process will be applied. (default: current engine)
  62283. * @param reusable If the post process can be reused on the same frame. (default: false)
  62284. * @param textureType Type of textures used when performing the post process. (default: 0)
  62285. */
  62286. constructor(name: string,
  62287. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62288. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62289. /**
  62290. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62291. */
  62292. static EdgeDetect0Kernel: number[];
  62293. /**
  62294. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62295. */
  62296. static EdgeDetect1Kernel: number[];
  62297. /**
  62298. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62299. */
  62300. static EdgeDetect2Kernel: number[];
  62301. /**
  62302. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62303. */
  62304. static SharpenKernel: number[];
  62305. /**
  62306. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62307. */
  62308. static EmbossKernel: number[];
  62309. /**
  62310. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62311. */
  62312. static GaussianKernel: number[];
  62313. }
  62314. }
  62315. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62316. import { Nullable } from "babylonjs/types";
  62317. import { Vector2 } from "babylonjs/Maths/math.vector";
  62318. import { Camera } from "babylonjs/Cameras/camera";
  62319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62320. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62321. import { Engine } from "babylonjs/Engines/engine";
  62322. import { Scene } from "babylonjs/scene";
  62323. /**
  62324. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62325. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62326. * based on samples that have a large difference in distance than the center pixel.
  62327. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62328. */
  62329. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62330. direction: Vector2;
  62331. /**
  62332. * Creates a new instance CircleOfConfusionPostProcess
  62333. * @param name The name of the effect.
  62334. * @param scene The scene the effect belongs to.
  62335. * @param direction The direction the blur should be applied.
  62336. * @param kernel The size of the kernel used to blur.
  62337. * @param options The required width/height ratio to downsize to before computing the render pass.
  62338. * @param camera The camera to apply the render pass to.
  62339. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62340. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62342. * @param engine The engine which the post process will be applied. (default: current engine)
  62343. * @param reusable If the post process can be reused on the same frame. (default: false)
  62344. * @param textureType Type of textures used when performing the post process. (default: 0)
  62345. * @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)
  62346. */
  62347. 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);
  62348. }
  62349. }
  62350. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62351. /** @hidden */
  62352. export var depthOfFieldMergePixelShader: {
  62353. name: string;
  62354. shader: string;
  62355. };
  62356. }
  62357. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62358. import { Nullable } from "babylonjs/types";
  62359. import { Camera } from "babylonjs/Cameras/camera";
  62360. import { Effect } from "babylonjs/Materials/effect";
  62361. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62362. import { Engine } from "babylonjs/Engines/engine";
  62363. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62364. /**
  62365. * Options to be set when merging outputs from the default pipeline.
  62366. */
  62367. export class DepthOfFieldMergePostProcessOptions {
  62368. /**
  62369. * The original image to merge on top of
  62370. */
  62371. originalFromInput: PostProcess;
  62372. /**
  62373. * Parameters to perform the merge of the depth of field effect
  62374. */
  62375. depthOfField?: {
  62376. circleOfConfusion: PostProcess;
  62377. blurSteps: Array<PostProcess>;
  62378. };
  62379. /**
  62380. * Parameters to perform the merge of bloom effect
  62381. */
  62382. bloom?: {
  62383. blurred: PostProcess;
  62384. weight: number;
  62385. };
  62386. }
  62387. /**
  62388. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62389. */
  62390. export class DepthOfFieldMergePostProcess extends PostProcess {
  62391. private blurSteps;
  62392. /**
  62393. * Creates a new instance of DepthOfFieldMergePostProcess
  62394. * @param name The name of the effect.
  62395. * @param originalFromInput Post process which's input will be used for the merge.
  62396. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62397. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62398. * @param options The required width/height ratio to downsize to before computing the render pass.
  62399. * @param camera The camera to apply the render pass to.
  62400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62401. * @param engine The engine which the post process will be applied. (default: current engine)
  62402. * @param reusable If the post process can be reused on the same frame. (default: false)
  62403. * @param textureType Type of textures used when performing the post process. (default: 0)
  62404. * @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)
  62405. */
  62406. 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);
  62407. /**
  62408. * Updates the effect with the current post process compile time values and recompiles the shader.
  62409. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62410. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62411. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62412. * @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
  62413. * @param onCompiled Called when the shader has been compiled.
  62414. * @param onError Called if there is an error when compiling a shader.
  62415. */
  62416. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62417. }
  62418. }
  62419. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62420. import { Nullable } from "babylonjs/types";
  62421. import { Camera } from "babylonjs/Cameras/camera";
  62422. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62423. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62424. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62425. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62426. import { Scene } from "babylonjs/scene";
  62427. /**
  62428. * Specifies the level of max blur that should be applied when using the depth of field effect
  62429. */
  62430. export enum DepthOfFieldEffectBlurLevel {
  62431. /**
  62432. * Subtle blur
  62433. */
  62434. Low = 0,
  62435. /**
  62436. * Medium blur
  62437. */
  62438. Medium = 1,
  62439. /**
  62440. * Large blur
  62441. */
  62442. High = 2
  62443. }
  62444. /**
  62445. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62446. */
  62447. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62448. private _circleOfConfusion;
  62449. /**
  62450. * @hidden Internal, blurs from high to low
  62451. */
  62452. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62453. private _depthOfFieldBlurY;
  62454. private _dofMerge;
  62455. /**
  62456. * @hidden Internal post processes in depth of field effect
  62457. */
  62458. _effects: Array<PostProcess>;
  62459. /**
  62460. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62461. */
  62462. focalLength: number;
  62463. /**
  62464. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62465. */
  62466. fStop: number;
  62467. /**
  62468. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62469. */
  62470. focusDistance: number;
  62471. /**
  62472. * 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.
  62473. */
  62474. lensSize: number;
  62475. /**
  62476. * Creates a new instance DepthOfFieldEffect
  62477. * @param scene The scene the effect belongs to.
  62478. * @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.
  62479. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62480. * @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)
  62481. */
  62482. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62483. /**
  62484. * Get the current class name of the current effet
  62485. * @returns "DepthOfFieldEffect"
  62486. */
  62487. getClassName(): string;
  62488. /**
  62489. * 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.
  62490. */
  62491. depthTexture: RenderTargetTexture;
  62492. /**
  62493. * Disposes each of the internal effects for a given camera.
  62494. * @param camera The camera to dispose the effect on.
  62495. */
  62496. disposeEffects(camera: Camera): void;
  62497. /**
  62498. * @hidden Internal
  62499. */
  62500. _updateEffects(): void;
  62501. /**
  62502. * Internal
  62503. * @returns if all the contained post processes are ready.
  62504. * @hidden
  62505. */
  62506. _isReady(): boolean;
  62507. }
  62508. }
  62509. declare module "babylonjs/Shaders/displayPass.fragment" {
  62510. /** @hidden */
  62511. export var displayPassPixelShader: {
  62512. name: string;
  62513. shader: string;
  62514. };
  62515. }
  62516. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62517. import { Nullable } from "babylonjs/types";
  62518. import { Camera } from "babylonjs/Cameras/camera";
  62519. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62520. import { Engine } from "babylonjs/Engines/engine";
  62521. import "babylonjs/Shaders/displayPass.fragment";
  62522. /**
  62523. * DisplayPassPostProcess which produces an output the same as it's input
  62524. */
  62525. export class DisplayPassPostProcess extends PostProcess {
  62526. /**
  62527. * Creates the DisplayPassPostProcess
  62528. * @param name The name of the effect.
  62529. * @param options The required width/height ratio to downsize to before computing the render pass.
  62530. * @param camera The camera to apply the render pass to.
  62531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62532. * @param engine The engine which the post process will be applied. (default: current engine)
  62533. * @param reusable If the post process can be reused on the same frame. (default: false)
  62534. */
  62535. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62536. }
  62537. }
  62538. declare module "babylonjs/Shaders/filter.fragment" {
  62539. /** @hidden */
  62540. export var filterPixelShader: {
  62541. name: string;
  62542. shader: string;
  62543. };
  62544. }
  62545. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62546. import { Nullable } from "babylonjs/types";
  62547. import { Matrix } from "babylonjs/Maths/math.vector";
  62548. import { Camera } from "babylonjs/Cameras/camera";
  62549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62550. import { Engine } from "babylonjs/Engines/engine";
  62551. import "babylonjs/Shaders/filter.fragment";
  62552. /**
  62553. * Applies a kernel filter to the image
  62554. */
  62555. export class FilterPostProcess extends PostProcess {
  62556. /** The matrix to be applied to the image */
  62557. kernelMatrix: Matrix;
  62558. /**
  62559. *
  62560. * @param name The name of the effect.
  62561. * @param kernelMatrix The matrix to be applied to the image
  62562. * @param options The required width/height ratio to downsize to before computing the render pass.
  62563. * @param camera The camera to apply the render pass to.
  62564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62565. * @param engine The engine which the post process will be applied. (default: current engine)
  62566. * @param reusable If the post process can be reused on the same frame. (default: false)
  62567. */
  62568. constructor(name: string,
  62569. /** The matrix to be applied to the image */
  62570. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62571. }
  62572. }
  62573. declare module "babylonjs/Shaders/fxaa.fragment" {
  62574. /** @hidden */
  62575. export var fxaaPixelShader: {
  62576. name: string;
  62577. shader: string;
  62578. };
  62579. }
  62580. declare module "babylonjs/Shaders/fxaa.vertex" {
  62581. /** @hidden */
  62582. export var fxaaVertexShader: {
  62583. name: string;
  62584. shader: string;
  62585. };
  62586. }
  62587. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62588. import { Nullable } from "babylonjs/types";
  62589. import { Camera } from "babylonjs/Cameras/camera";
  62590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62591. import { Engine } from "babylonjs/Engines/engine";
  62592. import "babylonjs/Shaders/fxaa.fragment";
  62593. import "babylonjs/Shaders/fxaa.vertex";
  62594. /**
  62595. * Fxaa post process
  62596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62597. */
  62598. export class FxaaPostProcess extends PostProcess {
  62599. /** @hidden */
  62600. texelWidth: number;
  62601. /** @hidden */
  62602. texelHeight: number;
  62603. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62604. private _getDefines;
  62605. }
  62606. }
  62607. declare module "babylonjs/Shaders/grain.fragment" {
  62608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62609. /** @hidden */
  62610. export var grainPixelShader: {
  62611. name: string;
  62612. shader: string;
  62613. };
  62614. }
  62615. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62616. import { Nullable } from "babylonjs/types";
  62617. import { Camera } from "babylonjs/Cameras/camera";
  62618. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62619. import { Engine } from "babylonjs/Engines/engine";
  62620. import "babylonjs/Shaders/grain.fragment";
  62621. /**
  62622. * The GrainPostProcess adds noise to the image at mid luminance levels
  62623. */
  62624. export class GrainPostProcess extends PostProcess {
  62625. /**
  62626. * The intensity of the grain added (default: 30)
  62627. */
  62628. intensity: number;
  62629. /**
  62630. * If the grain should be randomized on every frame
  62631. */
  62632. animated: boolean;
  62633. /**
  62634. * Creates a new instance of @see GrainPostProcess
  62635. * @param name The name of the effect.
  62636. * @param options The required width/height ratio to downsize to before computing the render pass.
  62637. * @param camera The camera to apply the render pass to.
  62638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62639. * @param engine The engine which the post process will be applied. (default: current engine)
  62640. * @param reusable If the post process can be reused on the same frame. (default: false)
  62641. * @param textureType Type of textures used when performing the post process. (default: 0)
  62642. * @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)
  62643. */
  62644. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62645. }
  62646. }
  62647. declare module "babylonjs/Shaders/highlights.fragment" {
  62648. /** @hidden */
  62649. export var highlightsPixelShader: {
  62650. name: string;
  62651. shader: string;
  62652. };
  62653. }
  62654. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62655. import { Nullable } from "babylonjs/types";
  62656. import { Camera } from "babylonjs/Cameras/camera";
  62657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62658. import { Engine } from "babylonjs/Engines/engine";
  62659. import "babylonjs/Shaders/highlights.fragment";
  62660. /**
  62661. * Extracts highlights from the image
  62662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62663. */
  62664. export class HighlightsPostProcess extends PostProcess {
  62665. /**
  62666. * Extracts highlights from the image
  62667. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62668. * @param name The name of the effect.
  62669. * @param options The required width/height ratio to downsize to before computing the render pass.
  62670. * @param camera The camera to apply the render pass to.
  62671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62672. * @param engine The engine which the post process will be applied. (default: current engine)
  62673. * @param reusable If the post process can be reused on the same frame. (default: false)
  62674. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62675. */
  62676. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62677. }
  62678. }
  62679. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62680. /** @hidden */
  62681. export var mrtFragmentDeclaration: {
  62682. name: string;
  62683. shader: string;
  62684. };
  62685. }
  62686. declare module "babylonjs/Shaders/geometry.fragment" {
  62687. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62688. /** @hidden */
  62689. export var geometryPixelShader: {
  62690. name: string;
  62691. shader: string;
  62692. };
  62693. }
  62694. declare module "babylonjs/Shaders/geometry.vertex" {
  62695. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62696. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62697. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62698. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62699. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62700. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62701. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62702. /** @hidden */
  62703. export var geometryVertexShader: {
  62704. name: string;
  62705. shader: string;
  62706. };
  62707. }
  62708. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62709. import { Matrix } from "babylonjs/Maths/math.vector";
  62710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62711. import { Mesh } from "babylonjs/Meshes/mesh";
  62712. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62713. import { Effect } from "babylonjs/Materials/effect";
  62714. import { Scene } from "babylonjs/scene";
  62715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62716. import "babylonjs/Shaders/geometry.fragment";
  62717. import "babylonjs/Shaders/geometry.vertex";
  62718. /** @hidden */
  62719. interface ISavedTransformationMatrix {
  62720. world: Matrix;
  62721. viewProjection: Matrix;
  62722. }
  62723. /**
  62724. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62725. */
  62726. export class GeometryBufferRenderer {
  62727. /**
  62728. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62729. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62730. */
  62731. static readonly POSITION_TEXTURE_TYPE: number;
  62732. /**
  62733. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62734. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62735. */
  62736. static readonly VELOCITY_TEXTURE_TYPE: number;
  62737. /**
  62738. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62739. * in order to compute objects velocities when enableVelocity is set to "true"
  62740. * @hidden
  62741. */
  62742. _previousTransformationMatrices: {
  62743. [index: number]: ISavedTransformationMatrix;
  62744. };
  62745. /**
  62746. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62747. * in order to compute objects velocities when enableVelocity is set to "true"
  62748. * @hidden
  62749. */
  62750. _previousBonesTransformationMatrices: {
  62751. [index: number]: Float32Array;
  62752. };
  62753. /**
  62754. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62755. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62756. */
  62757. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62758. private _scene;
  62759. private _multiRenderTarget;
  62760. private _ratio;
  62761. private _enablePosition;
  62762. private _enableVelocity;
  62763. private _positionIndex;
  62764. private _velocityIndex;
  62765. protected _effect: Effect;
  62766. protected _cachedDefines: string;
  62767. /**
  62768. * Set the render list (meshes to be rendered) used in the G buffer.
  62769. */
  62770. renderList: Mesh[];
  62771. /**
  62772. * Gets wether or not G buffer are supported by the running hardware.
  62773. * This requires draw buffer supports
  62774. */
  62775. readonly isSupported: boolean;
  62776. /**
  62777. * Returns the index of the given texture type in the G-Buffer textures array
  62778. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62779. * @returns the index of the given texture type in the G-Buffer textures array
  62780. */
  62781. getTextureIndex(textureType: number): number;
  62782. /**
  62783. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62784. */
  62785. /**
  62786. * Sets whether or not objects positions are enabled for the G buffer.
  62787. */
  62788. enablePosition: boolean;
  62789. /**
  62790. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62791. */
  62792. /**
  62793. * Sets wether or not objects velocities are enabled for the G buffer.
  62794. */
  62795. enableVelocity: boolean;
  62796. /**
  62797. * Gets the scene associated with the buffer.
  62798. */
  62799. readonly scene: Scene;
  62800. /**
  62801. * Gets the ratio used by the buffer during its creation.
  62802. * How big is the buffer related to the main canvas.
  62803. */
  62804. readonly ratio: number;
  62805. /** @hidden */
  62806. static _SceneComponentInitialization: (scene: Scene) => void;
  62807. /**
  62808. * Creates a new G Buffer for the scene
  62809. * @param scene The scene the buffer belongs to
  62810. * @param ratio How big is the buffer related to the main canvas.
  62811. */
  62812. constructor(scene: Scene, ratio?: number);
  62813. /**
  62814. * Checks wether everything is ready to render a submesh to the G buffer.
  62815. * @param subMesh the submesh to check readiness for
  62816. * @param useInstances is the mesh drawn using instance or not
  62817. * @returns true if ready otherwise false
  62818. */
  62819. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62820. /**
  62821. * Gets the current underlying G Buffer.
  62822. * @returns the buffer
  62823. */
  62824. getGBuffer(): MultiRenderTarget;
  62825. /**
  62826. * Gets the number of samples used to render the buffer (anti aliasing).
  62827. */
  62828. /**
  62829. * Sets the number of samples used to render the buffer (anti aliasing).
  62830. */
  62831. samples: number;
  62832. /**
  62833. * Disposes the renderer and frees up associated resources.
  62834. */
  62835. dispose(): void;
  62836. protected _createRenderTargets(): void;
  62837. private _copyBonesTransformationMatrices;
  62838. }
  62839. }
  62840. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62841. import { Nullable } from "babylonjs/types";
  62842. import { Scene } from "babylonjs/scene";
  62843. import { ISceneComponent } from "babylonjs/sceneComponent";
  62844. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62845. module "babylonjs/scene" {
  62846. interface Scene {
  62847. /** @hidden (Backing field) */
  62848. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62849. /**
  62850. * Gets or Sets the current geometry buffer associated to the scene.
  62851. */
  62852. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62853. /**
  62854. * Enables a GeometryBufferRender and associates it with the scene
  62855. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62856. * @returns the GeometryBufferRenderer
  62857. */
  62858. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62859. /**
  62860. * Disables the GeometryBufferRender associated with the scene
  62861. */
  62862. disableGeometryBufferRenderer(): void;
  62863. }
  62864. }
  62865. /**
  62866. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62867. * in several rendering techniques.
  62868. */
  62869. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62870. /**
  62871. * The component name helpful to identify the component in the list of scene components.
  62872. */
  62873. readonly name: string;
  62874. /**
  62875. * The scene the component belongs to.
  62876. */
  62877. scene: Scene;
  62878. /**
  62879. * Creates a new instance of the component for the given scene
  62880. * @param scene Defines the scene to register the component in
  62881. */
  62882. constructor(scene: Scene);
  62883. /**
  62884. * Registers the component in a given scene
  62885. */
  62886. register(): void;
  62887. /**
  62888. * Rebuilds the elements related to this component in case of
  62889. * context lost for instance.
  62890. */
  62891. rebuild(): void;
  62892. /**
  62893. * Disposes the component and the associated ressources
  62894. */
  62895. dispose(): void;
  62896. private _gatherRenderTargets;
  62897. }
  62898. }
  62899. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62900. /** @hidden */
  62901. export var motionBlurPixelShader: {
  62902. name: string;
  62903. shader: string;
  62904. };
  62905. }
  62906. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62907. import { Nullable } from "babylonjs/types";
  62908. import { Camera } from "babylonjs/Cameras/camera";
  62909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62910. import { Scene } from "babylonjs/scene";
  62911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62912. import "babylonjs/Animations/animatable";
  62913. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62914. import "babylonjs/Shaders/motionBlur.fragment";
  62915. import { Engine } from "babylonjs/Engines/engine";
  62916. /**
  62917. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62918. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62919. * As an example, all you have to do is to create the post-process:
  62920. * var mb = new BABYLON.MotionBlurPostProcess(
  62921. * 'mb', // The name of the effect.
  62922. * scene, // The scene containing the objects to blur according to their velocity.
  62923. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62924. * camera // The camera to apply the render pass to.
  62925. * );
  62926. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62927. */
  62928. export class MotionBlurPostProcess extends PostProcess {
  62929. /**
  62930. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62931. */
  62932. motionStrength: number;
  62933. /**
  62934. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62935. */
  62936. /**
  62937. * Sets the number of iterations to be used for motion blur quality
  62938. */
  62939. motionBlurSamples: number;
  62940. private _motionBlurSamples;
  62941. private _geometryBufferRenderer;
  62942. /**
  62943. * Creates a new instance MotionBlurPostProcess
  62944. * @param name The name of the effect.
  62945. * @param scene The scene containing the objects to blur according to their velocity.
  62946. * @param options The required width/height ratio to downsize to before computing the render pass.
  62947. * @param camera The camera to apply the render pass to.
  62948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62949. * @param engine The engine which the post process will be applied. (default: current engine)
  62950. * @param reusable If the post process can be reused on the same frame. (default: false)
  62951. * @param textureType Type of textures used when performing the post process. (default: 0)
  62952. * @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)
  62953. */
  62954. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62955. /**
  62956. * Excludes the given skinned mesh from computing bones velocities.
  62957. * 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.
  62958. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62959. */
  62960. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62961. /**
  62962. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62963. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62964. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62965. */
  62966. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62967. /**
  62968. * Disposes the post process.
  62969. * @param camera The camera to dispose the post process on.
  62970. */
  62971. dispose(camera?: Camera): void;
  62972. }
  62973. }
  62974. declare module "babylonjs/Shaders/refraction.fragment" {
  62975. /** @hidden */
  62976. export var refractionPixelShader: {
  62977. name: string;
  62978. shader: string;
  62979. };
  62980. }
  62981. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62982. import { Color3 } from "babylonjs/Maths/math.color";
  62983. import { Camera } from "babylonjs/Cameras/camera";
  62984. import { Texture } from "babylonjs/Materials/Textures/texture";
  62985. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62986. import { Engine } from "babylonjs/Engines/engine";
  62987. import "babylonjs/Shaders/refraction.fragment";
  62988. /**
  62989. * Post process which applies a refractin texture
  62990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62991. */
  62992. export class RefractionPostProcess extends PostProcess {
  62993. /** the base color of the refraction (used to taint the rendering) */
  62994. color: Color3;
  62995. /** simulated refraction depth */
  62996. depth: number;
  62997. /** the coefficient of the base color (0 to remove base color tainting) */
  62998. colorLevel: number;
  62999. private _refTexture;
  63000. private _ownRefractionTexture;
  63001. /**
  63002. * Gets or sets the refraction texture
  63003. * Please note that you are responsible for disposing the texture if you set it manually
  63004. */
  63005. refractionTexture: Texture;
  63006. /**
  63007. * Initializes the RefractionPostProcess
  63008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63009. * @param name The name of the effect.
  63010. * @param refractionTextureUrl Url of the refraction texture to use
  63011. * @param color the base color of the refraction (used to taint the rendering)
  63012. * @param depth simulated refraction depth
  63013. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63014. * @param camera The camera to apply the render pass to.
  63015. * @param options The required width/height ratio to downsize to before computing the render pass.
  63016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63017. * @param engine The engine which the post process will be applied. (default: current engine)
  63018. * @param reusable If the post process can be reused on the same frame. (default: false)
  63019. */
  63020. constructor(name: string, refractionTextureUrl: string,
  63021. /** the base color of the refraction (used to taint the rendering) */
  63022. color: Color3,
  63023. /** simulated refraction depth */
  63024. depth: number,
  63025. /** the coefficient of the base color (0 to remove base color tainting) */
  63026. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63027. /**
  63028. * Disposes of the post process
  63029. * @param camera Camera to dispose post process on
  63030. */
  63031. dispose(camera: Camera): void;
  63032. }
  63033. }
  63034. declare module "babylonjs/Shaders/sharpen.fragment" {
  63035. /** @hidden */
  63036. export var sharpenPixelShader: {
  63037. name: string;
  63038. shader: string;
  63039. };
  63040. }
  63041. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63042. import { Nullable } from "babylonjs/types";
  63043. import { Camera } from "babylonjs/Cameras/camera";
  63044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63045. import "babylonjs/Shaders/sharpen.fragment";
  63046. import { Engine } from "babylonjs/Engines/engine";
  63047. /**
  63048. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63049. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63050. */
  63051. export class SharpenPostProcess extends PostProcess {
  63052. /**
  63053. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63054. */
  63055. colorAmount: number;
  63056. /**
  63057. * How much sharpness should be applied (default: 0.3)
  63058. */
  63059. edgeAmount: number;
  63060. /**
  63061. * Creates a new instance ConvolutionPostProcess
  63062. * @param name The name of the effect.
  63063. * @param options The required width/height ratio to downsize to before computing the render pass.
  63064. * @param camera The camera to apply the render pass to.
  63065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63066. * @param engine The engine which the post process will be applied. (default: current engine)
  63067. * @param reusable If the post process can be reused on the same frame. (default: false)
  63068. * @param textureType Type of textures used when performing the post process. (default: 0)
  63069. * @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)
  63070. */
  63071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63072. }
  63073. }
  63074. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63075. import { Nullable } from "babylonjs/types";
  63076. import { Camera } from "babylonjs/Cameras/camera";
  63077. import { Engine } from "babylonjs/Engines/engine";
  63078. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63079. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63080. /**
  63081. * PostProcessRenderPipeline
  63082. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63083. */
  63084. export class PostProcessRenderPipeline {
  63085. private engine;
  63086. private _renderEffects;
  63087. private _renderEffectsForIsolatedPass;
  63088. /**
  63089. * List of inspectable custom properties (used by the Inspector)
  63090. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63091. */
  63092. inspectableCustomProperties: IInspectable[];
  63093. /**
  63094. * @hidden
  63095. */
  63096. protected _cameras: Camera[];
  63097. /** @hidden */
  63098. _name: string;
  63099. /**
  63100. * Gets pipeline name
  63101. */
  63102. readonly name: string;
  63103. /**
  63104. * Initializes a PostProcessRenderPipeline
  63105. * @param engine engine to add the pipeline to
  63106. * @param name name of the pipeline
  63107. */
  63108. constructor(engine: Engine, name: string);
  63109. /**
  63110. * Gets the class name
  63111. * @returns "PostProcessRenderPipeline"
  63112. */
  63113. getClassName(): string;
  63114. /**
  63115. * If all the render effects in the pipeline are supported
  63116. */
  63117. readonly isSupported: boolean;
  63118. /**
  63119. * Adds an effect to the pipeline
  63120. * @param renderEffect the effect to add
  63121. */
  63122. addEffect(renderEffect: PostProcessRenderEffect): void;
  63123. /** @hidden */
  63124. _rebuild(): void;
  63125. /** @hidden */
  63126. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63127. /** @hidden */
  63128. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63129. /** @hidden */
  63130. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63131. /** @hidden */
  63132. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63133. /** @hidden */
  63134. _attachCameras(cameras: Camera, unique: boolean): void;
  63135. /** @hidden */
  63136. _attachCameras(cameras: Camera[], unique: boolean): void;
  63137. /** @hidden */
  63138. _detachCameras(cameras: Camera): void;
  63139. /** @hidden */
  63140. _detachCameras(cameras: Nullable<Camera[]>): void;
  63141. /** @hidden */
  63142. _update(): void;
  63143. /** @hidden */
  63144. _reset(): void;
  63145. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63146. /**
  63147. * Disposes of the pipeline
  63148. */
  63149. dispose(): void;
  63150. }
  63151. }
  63152. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63153. import { Camera } from "babylonjs/Cameras/camera";
  63154. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63155. /**
  63156. * PostProcessRenderPipelineManager class
  63157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63158. */
  63159. export class PostProcessRenderPipelineManager {
  63160. private _renderPipelines;
  63161. /**
  63162. * Initializes a PostProcessRenderPipelineManager
  63163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63164. */
  63165. constructor();
  63166. /**
  63167. * Gets the list of supported render pipelines
  63168. */
  63169. readonly supportedPipelines: PostProcessRenderPipeline[];
  63170. /**
  63171. * Adds a pipeline to the manager
  63172. * @param renderPipeline The pipeline to add
  63173. */
  63174. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63175. /**
  63176. * Attaches a camera to the pipeline
  63177. * @param renderPipelineName The name of the pipeline to attach to
  63178. * @param cameras the camera to attach
  63179. * @param unique if the camera can be attached multiple times to the pipeline
  63180. */
  63181. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63182. /**
  63183. * Detaches a camera from the pipeline
  63184. * @param renderPipelineName The name of the pipeline to detach from
  63185. * @param cameras the camera to detach
  63186. */
  63187. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63188. /**
  63189. * Enables an effect by name on a pipeline
  63190. * @param renderPipelineName the name of the pipeline to enable the effect in
  63191. * @param renderEffectName the name of the effect to enable
  63192. * @param cameras the cameras that the effect should be enabled on
  63193. */
  63194. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63195. /**
  63196. * Disables an effect by name on a pipeline
  63197. * @param renderPipelineName the name of the pipeline to disable the effect in
  63198. * @param renderEffectName the name of the effect to disable
  63199. * @param cameras the cameras that the effect should be disabled on
  63200. */
  63201. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63202. /**
  63203. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63204. */
  63205. update(): void;
  63206. /** @hidden */
  63207. _rebuild(): void;
  63208. /**
  63209. * Disposes of the manager and pipelines
  63210. */
  63211. dispose(): void;
  63212. }
  63213. }
  63214. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63215. import { ISceneComponent } from "babylonjs/sceneComponent";
  63216. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63217. import { Scene } from "babylonjs/scene";
  63218. module "babylonjs/scene" {
  63219. interface Scene {
  63220. /** @hidden (Backing field) */
  63221. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63222. /**
  63223. * Gets the postprocess render pipeline manager
  63224. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63225. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63226. */
  63227. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63228. }
  63229. }
  63230. /**
  63231. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63232. */
  63233. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63234. /**
  63235. * The component name helpfull to identify the component in the list of scene components.
  63236. */
  63237. readonly name: string;
  63238. /**
  63239. * The scene the component belongs to.
  63240. */
  63241. scene: Scene;
  63242. /**
  63243. * Creates a new instance of the component for the given scene
  63244. * @param scene Defines the scene to register the component in
  63245. */
  63246. constructor(scene: Scene);
  63247. /**
  63248. * Registers the component in a given scene
  63249. */
  63250. register(): void;
  63251. /**
  63252. * Rebuilds the elements related to this component in case of
  63253. * context lost for instance.
  63254. */
  63255. rebuild(): void;
  63256. /**
  63257. * Disposes the component and the associated ressources
  63258. */
  63259. dispose(): void;
  63260. private _gatherRenderTargets;
  63261. }
  63262. }
  63263. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63264. import { Nullable } from "babylonjs/types";
  63265. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63266. import { Camera } from "babylonjs/Cameras/camera";
  63267. import { IDisposable } from "babylonjs/scene";
  63268. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63269. import { Scene } from "babylonjs/scene";
  63270. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63271. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63272. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63273. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63274. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63275. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63276. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63277. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63278. import { Animation } from "babylonjs/Animations/animation";
  63279. /**
  63280. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63281. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63282. */
  63283. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63284. private _scene;
  63285. private _camerasToBeAttached;
  63286. /**
  63287. * ID of the sharpen post process,
  63288. */
  63289. private readonly SharpenPostProcessId;
  63290. /**
  63291. * @ignore
  63292. * ID of the image processing post process;
  63293. */
  63294. readonly ImageProcessingPostProcessId: string;
  63295. /**
  63296. * @ignore
  63297. * ID of the Fast Approximate Anti-Aliasing post process;
  63298. */
  63299. readonly FxaaPostProcessId: string;
  63300. /**
  63301. * ID of the chromatic aberration post process,
  63302. */
  63303. private readonly ChromaticAberrationPostProcessId;
  63304. /**
  63305. * ID of the grain post process
  63306. */
  63307. private readonly GrainPostProcessId;
  63308. /**
  63309. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63310. */
  63311. sharpen: SharpenPostProcess;
  63312. private _sharpenEffect;
  63313. private bloom;
  63314. /**
  63315. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63316. */
  63317. depthOfField: DepthOfFieldEffect;
  63318. /**
  63319. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63320. */
  63321. fxaa: FxaaPostProcess;
  63322. /**
  63323. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63324. */
  63325. imageProcessing: ImageProcessingPostProcess;
  63326. /**
  63327. * Chromatic aberration post process which will shift rgb colors in the image
  63328. */
  63329. chromaticAberration: ChromaticAberrationPostProcess;
  63330. private _chromaticAberrationEffect;
  63331. /**
  63332. * Grain post process which add noise to the image
  63333. */
  63334. grain: GrainPostProcess;
  63335. private _grainEffect;
  63336. /**
  63337. * Glow post process which adds a glow to emissive areas of the image
  63338. */
  63339. private _glowLayer;
  63340. /**
  63341. * Animations which can be used to tweak settings over a period of time
  63342. */
  63343. animations: Animation[];
  63344. private _imageProcessingConfigurationObserver;
  63345. private _sharpenEnabled;
  63346. private _bloomEnabled;
  63347. private _depthOfFieldEnabled;
  63348. private _depthOfFieldBlurLevel;
  63349. private _fxaaEnabled;
  63350. private _imageProcessingEnabled;
  63351. private _defaultPipelineTextureType;
  63352. private _bloomScale;
  63353. private _chromaticAberrationEnabled;
  63354. private _grainEnabled;
  63355. private _buildAllowed;
  63356. /**
  63357. * Gets active scene
  63358. */
  63359. readonly scene: Scene;
  63360. /**
  63361. * Enable or disable the sharpen process from the pipeline
  63362. */
  63363. sharpenEnabled: boolean;
  63364. private _resizeObserver;
  63365. private _hardwareScaleLevel;
  63366. private _bloomKernel;
  63367. /**
  63368. * Specifies the size of the bloom blur kernel, relative to the final output size
  63369. */
  63370. bloomKernel: number;
  63371. /**
  63372. * Specifies the weight of the bloom in the final rendering
  63373. */
  63374. private _bloomWeight;
  63375. /**
  63376. * Specifies the luma threshold for the area that will be blurred by the bloom
  63377. */
  63378. private _bloomThreshold;
  63379. private _hdr;
  63380. /**
  63381. * The strength of the bloom.
  63382. */
  63383. bloomWeight: number;
  63384. /**
  63385. * The strength of the bloom.
  63386. */
  63387. bloomThreshold: number;
  63388. /**
  63389. * The scale of the bloom, lower value will provide better performance.
  63390. */
  63391. bloomScale: number;
  63392. /**
  63393. * Enable or disable the bloom from the pipeline
  63394. */
  63395. bloomEnabled: boolean;
  63396. private _rebuildBloom;
  63397. /**
  63398. * If the depth of field is enabled.
  63399. */
  63400. depthOfFieldEnabled: boolean;
  63401. /**
  63402. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63403. */
  63404. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63405. /**
  63406. * If the anti aliasing is enabled.
  63407. */
  63408. fxaaEnabled: boolean;
  63409. private _samples;
  63410. /**
  63411. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63412. */
  63413. samples: number;
  63414. /**
  63415. * If image processing is enabled.
  63416. */
  63417. imageProcessingEnabled: boolean;
  63418. /**
  63419. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63420. */
  63421. glowLayerEnabled: boolean;
  63422. /**
  63423. * Gets the glow layer (or null if not defined)
  63424. */
  63425. readonly glowLayer: Nullable<GlowLayer>;
  63426. /**
  63427. * Enable or disable the chromaticAberration process from the pipeline
  63428. */
  63429. chromaticAberrationEnabled: boolean;
  63430. /**
  63431. * Enable or disable the grain process from the pipeline
  63432. */
  63433. grainEnabled: boolean;
  63434. /**
  63435. * @constructor
  63436. * @param name - The rendering pipeline name (default: "")
  63437. * @param hdr - If high dynamic range textures should be used (default: true)
  63438. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63439. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63440. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63441. */
  63442. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63443. /**
  63444. * Get the class name
  63445. * @returns "DefaultRenderingPipeline"
  63446. */
  63447. getClassName(): string;
  63448. /**
  63449. * Force the compilation of the entire pipeline.
  63450. */
  63451. prepare(): void;
  63452. private _hasCleared;
  63453. private _prevPostProcess;
  63454. private _prevPrevPostProcess;
  63455. private _setAutoClearAndTextureSharing;
  63456. private _depthOfFieldSceneObserver;
  63457. private _buildPipeline;
  63458. private _disposePostProcesses;
  63459. /**
  63460. * Adds a camera to the pipeline
  63461. * @param camera the camera to be added
  63462. */
  63463. addCamera(camera: Camera): void;
  63464. /**
  63465. * Removes a camera from the pipeline
  63466. * @param camera the camera to remove
  63467. */
  63468. removeCamera(camera: Camera): void;
  63469. /**
  63470. * Dispose of the pipeline and stop all post processes
  63471. */
  63472. dispose(): void;
  63473. /**
  63474. * Serialize the rendering pipeline (Used when exporting)
  63475. * @returns the serialized object
  63476. */
  63477. serialize(): any;
  63478. /**
  63479. * Parse the serialized pipeline
  63480. * @param source Source pipeline.
  63481. * @param scene The scene to load the pipeline to.
  63482. * @param rootUrl The URL of the serialized pipeline.
  63483. * @returns An instantiated pipeline from the serialized object.
  63484. */
  63485. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63486. }
  63487. }
  63488. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63489. /** @hidden */
  63490. export var lensHighlightsPixelShader: {
  63491. name: string;
  63492. shader: string;
  63493. };
  63494. }
  63495. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63496. /** @hidden */
  63497. export var depthOfFieldPixelShader: {
  63498. name: string;
  63499. shader: string;
  63500. };
  63501. }
  63502. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63503. import { Camera } from "babylonjs/Cameras/camera";
  63504. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63505. import { Scene } from "babylonjs/scene";
  63506. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63507. import "babylonjs/Shaders/chromaticAberration.fragment";
  63508. import "babylonjs/Shaders/lensHighlights.fragment";
  63509. import "babylonjs/Shaders/depthOfField.fragment";
  63510. /**
  63511. * BABYLON.JS Chromatic Aberration GLSL Shader
  63512. * Author: Olivier Guyot
  63513. * Separates very slightly R, G and B colors on the edges of the screen
  63514. * Inspired by Francois Tarlier & Martins Upitis
  63515. */
  63516. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63517. /**
  63518. * @ignore
  63519. * The chromatic aberration PostProcess id in the pipeline
  63520. */
  63521. LensChromaticAberrationEffect: string;
  63522. /**
  63523. * @ignore
  63524. * The highlights enhancing PostProcess id in the pipeline
  63525. */
  63526. HighlightsEnhancingEffect: string;
  63527. /**
  63528. * @ignore
  63529. * The depth-of-field PostProcess id in the pipeline
  63530. */
  63531. LensDepthOfFieldEffect: string;
  63532. private _scene;
  63533. private _depthTexture;
  63534. private _grainTexture;
  63535. private _chromaticAberrationPostProcess;
  63536. private _highlightsPostProcess;
  63537. private _depthOfFieldPostProcess;
  63538. private _edgeBlur;
  63539. private _grainAmount;
  63540. private _chromaticAberration;
  63541. private _distortion;
  63542. private _highlightsGain;
  63543. private _highlightsThreshold;
  63544. private _dofDistance;
  63545. private _dofAperture;
  63546. private _dofDarken;
  63547. private _dofPentagon;
  63548. private _blurNoise;
  63549. /**
  63550. * @constructor
  63551. *
  63552. * Effect parameters are as follow:
  63553. * {
  63554. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63555. * edge_blur: number; // from 0 to x (1 for realism)
  63556. * distortion: number; // from 0 to x (1 for realism)
  63557. * grain_amount: number; // from 0 to 1
  63558. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63559. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63560. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63561. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63562. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63563. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63564. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63565. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63566. * }
  63567. * Note: if an effect parameter is unset, effect is disabled
  63568. *
  63569. * @param name The rendering pipeline name
  63570. * @param parameters - An object containing all parameters (see above)
  63571. * @param scene The scene linked to this pipeline
  63572. * @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)
  63573. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63574. */
  63575. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63576. /**
  63577. * Get the class name
  63578. * @returns "LensRenderingPipeline"
  63579. */
  63580. getClassName(): string;
  63581. /**
  63582. * Gets associated scene
  63583. */
  63584. readonly scene: Scene;
  63585. /**
  63586. * Gets or sets the edge blur
  63587. */
  63588. edgeBlur: number;
  63589. /**
  63590. * Gets or sets the grain amount
  63591. */
  63592. grainAmount: number;
  63593. /**
  63594. * Gets or sets the chromatic aberration amount
  63595. */
  63596. chromaticAberration: number;
  63597. /**
  63598. * Gets or sets the depth of field aperture
  63599. */
  63600. dofAperture: number;
  63601. /**
  63602. * Gets or sets the edge distortion
  63603. */
  63604. edgeDistortion: number;
  63605. /**
  63606. * Gets or sets the depth of field distortion
  63607. */
  63608. dofDistortion: number;
  63609. /**
  63610. * Gets or sets the darken out of focus amount
  63611. */
  63612. darkenOutOfFocus: number;
  63613. /**
  63614. * Gets or sets a boolean indicating if blur noise is enabled
  63615. */
  63616. blurNoise: boolean;
  63617. /**
  63618. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63619. */
  63620. pentagonBokeh: boolean;
  63621. /**
  63622. * Gets or sets the highlight grain amount
  63623. */
  63624. highlightsGain: number;
  63625. /**
  63626. * Gets or sets the highlight threshold
  63627. */
  63628. highlightsThreshold: number;
  63629. /**
  63630. * Sets the amount of blur at the edges
  63631. * @param amount blur amount
  63632. */
  63633. setEdgeBlur(amount: number): void;
  63634. /**
  63635. * Sets edge blur to 0
  63636. */
  63637. disableEdgeBlur(): void;
  63638. /**
  63639. * Sets the amout of grain
  63640. * @param amount Amount of grain
  63641. */
  63642. setGrainAmount(amount: number): void;
  63643. /**
  63644. * Set grain amount to 0
  63645. */
  63646. disableGrain(): void;
  63647. /**
  63648. * Sets the chromatic aberration amount
  63649. * @param amount amount of chromatic aberration
  63650. */
  63651. setChromaticAberration(amount: number): void;
  63652. /**
  63653. * Sets chromatic aberration amount to 0
  63654. */
  63655. disableChromaticAberration(): void;
  63656. /**
  63657. * Sets the EdgeDistortion amount
  63658. * @param amount amount of EdgeDistortion
  63659. */
  63660. setEdgeDistortion(amount: number): void;
  63661. /**
  63662. * Sets edge distortion to 0
  63663. */
  63664. disableEdgeDistortion(): void;
  63665. /**
  63666. * Sets the FocusDistance amount
  63667. * @param amount amount of FocusDistance
  63668. */
  63669. setFocusDistance(amount: number): void;
  63670. /**
  63671. * Disables depth of field
  63672. */
  63673. disableDepthOfField(): void;
  63674. /**
  63675. * Sets the Aperture amount
  63676. * @param amount amount of Aperture
  63677. */
  63678. setAperture(amount: number): void;
  63679. /**
  63680. * Sets the DarkenOutOfFocus amount
  63681. * @param amount amount of DarkenOutOfFocus
  63682. */
  63683. setDarkenOutOfFocus(amount: number): void;
  63684. private _pentagonBokehIsEnabled;
  63685. /**
  63686. * Creates a pentagon bokeh effect
  63687. */
  63688. enablePentagonBokeh(): void;
  63689. /**
  63690. * Disables the pentagon bokeh effect
  63691. */
  63692. disablePentagonBokeh(): void;
  63693. /**
  63694. * Enables noise blur
  63695. */
  63696. enableNoiseBlur(): void;
  63697. /**
  63698. * Disables noise blur
  63699. */
  63700. disableNoiseBlur(): void;
  63701. /**
  63702. * Sets the HighlightsGain amount
  63703. * @param amount amount of HighlightsGain
  63704. */
  63705. setHighlightsGain(amount: number): void;
  63706. /**
  63707. * Sets the HighlightsThreshold amount
  63708. * @param amount amount of HighlightsThreshold
  63709. */
  63710. setHighlightsThreshold(amount: number): void;
  63711. /**
  63712. * Disables highlights
  63713. */
  63714. disableHighlights(): void;
  63715. /**
  63716. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63717. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63718. */
  63719. dispose(disableDepthRender?: boolean): void;
  63720. private _createChromaticAberrationPostProcess;
  63721. private _createHighlightsPostProcess;
  63722. private _createDepthOfFieldPostProcess;
  63723. private _createGrainTexture;
  63724. }
  63725. }
  63726. declare module "babylonjs/Shaders/ssao2.fragment" {
  63727. /** @hidden */
  63728. export var ssao2PixelShader: {
  63729. name: string;
  63730. shader: string;
  63731. };
  63732. }
  63733. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63734. /** @hidden */
  63735. export var ssaoCombinePixelShader: {
  63736. name: string;
  63737. shader: string;
  63738. };
  63739. }
  63740. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63741. import { Camera } from "babylonjs/Cameras/camera";
  63742. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63743. import { Scene } from "babylonjs/scene";
  63744. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63745. import "babylonjs/Shaders/ssao2.fragment";
  63746. import "babylonjs/Shaders/ssaoCombine.fragment";
  63747. /**
  63748. * Render pipeline to produce ssao effect
  63749. */
  63750. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63751. /**
  63752. * @ignore
  63753. * The PassPostProcess id in the pipeline that contains the original scene color
  63754. */
  63755. SSAOOriginalSceneColorEffect: string;
  63756. /**
  63757. * @ignore
  63758. * The SSAO PostProcess id in the pipeline
  63759. */
  63760. SSAORenderEffect: string;
  63761. /**
  63762. * @ignore
  63763. * The horizontal blur PostProcess id in the pipeline
  63764. */
  63765. SSAOBlurHRenderEffect: string;
  63766. /**
  63767. * @ignore
  63768. * The vertical blur PostProcess id in the pipeline
  63769. */
  63770. SSAOBlurVRenderEffect: string;
  63771. /**
  63772. * @ignore
  63773. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63774. */
  63775. SSAOCombineRenderEffect: string;
  63776. /**
  63777. * The output strength of the SSAO post-process. Default value is 1.0.
  63778. */
  63779. totalStrength: number;
  63780. /**
  63781. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63782. */
  63783. maxZ: number;
  63784. /**
  63785. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63786. */
  63787. minZAspect: number;
  63788. private _samples;
  63789. /**
  63790. * Number of samples used for the SSAO calculations. Default value is 8
  63791. */
  63792. samples: number;
  63793. private _textureSamples;
  63794. /**
  63795. * Number of samples to use for antialiasing
  63796. */
  63797. textureSamples: number;
  63798. /**
  63799. * Ratio object used for SSAO ratio and blur ratio
  63800. */
  63801. private _ratio;
  63802. /**
  63803. * Dynamically generated sphere sampler.
  63804. */
  63805. private _sampleSphere;
  63806. /**
  63807. * Blur filter offsets
  63808. */
  63809. private _samplerOffsets;
  63810. private _expensiveBlur;
  63811. /**
  63812. * If bilateral blur should be used
  63813. */
  63814. expensiveBlur: boolean;
  63815. /**
  63816. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63817. */
  63818. radius: number;
  63819. /**
  63820. * The base color of the SSAO post-process
  63821. * The final result is "base + ssao" between [0, 1]
  63822. */
  63823. base: number;
  63824. /**
  63825. * Support test.
  63826. */
  63827. static readonly IsSupported: boolean;
  63828. private _scene;
  63829. private _depthTexture;
  63830. private _normalTexture;
  63831. private _randomTexture;
  63832. private _originalColorPostProcess;
  63833. private _ssaoPostProcess;
  63834. private _blurHPostProcess;
  63835. private _blurVPostProcess;
  63836. private _ssaoCombinePostProcess;
  63837. private _firstUpdate;
  63838. /**
  63839. * Gets active scene
  63840. */
  63841. readonly scene: Scene;
  63842. /**
  63843. * @constructor
  63844. * @param name The rendering pipeline name
  63845. * @param scene The scene linked to this pipeline
  63846. * @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 }
  63847. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63848. */
  63849. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63850. /**
  63851. * Get the class name
  63852. * @returns "SSAO2RenderingPipeline"
  63853. */
  63854. getClassName(): string;
  63855. /**
  63856. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63857. */
  63858. dispose(disableGeometryBufferRenderer?: boolean): void;
  63859. private _createBlurPostProcess;
  63860. /** @hidden */
  63861. _rebuild(): void;
  63862. private _bits;
  63863. private _radicalInverse_VdC;
  63864. private _hammersley;
  63865. private _hemisphereSample_uniform;
  63866. private _generateHemisphere;
  63867. private _createSSAOPostProcess;
  63868. private _createSSAOCombinePostProcess;
  63869. private _createRandomTexture;
  63870. /**
  63871. * Serialize the rendering pipeline (Used when exporting)
  63872. * @returns the serialized object
  63873. */
  63874. serialize(): any;
  63875. /**
  63876. * Parse the serialized pipeline
  63877. * @param source Source pipeline.
  63878. * @param scene The scene to load the pipeline to.
  63879. * @param rootUrl The URL of the serialized pipeline.
  63880. * @returns An instantiated pipeline from the serialized object.
  63881. */
  63882. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63883. }
  63884. }
  63885. declare module "babylonjs/Shaders/ssao.fragment" {
  63886. /** @hidden */
  63887. export var ssaoPixelShader: {
  63888. name: string;
  63889. shader: string;
  63890. };
  63891. }
  63892. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63893. import { Camera } from "babylonjs/Cameras/camera";
  63894. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63895. import { Scene } from "babylonjs/scene";
  63896. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63897. import "babylonjs/Shaders/ssao.fragment";
  63898. import "babylonjs/Shaders/ssaoCombine.fragment";
  63899. /**
  63900. * Render pipeline to produce ssao effect
  63901. */
  63902. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63903. /**
  63904. * @ignore
  63905. * The PassPostProcess id in the pipeline that contains the original scene color
  63906. */
  63907. SSAOOriginalSceneColorEffect: string;
  63908. /**
  63909. * @ignore
  63910. * The SSAO PostProcess id in the pipeline
  63911. */
  63912. SSAORenderEffect: string;
  63913. /**
  63914. * @ignore
  63915. * The horizontal blur PostProcess id in the pipeline
  63916. */
  63917. SSAOBlurHRenderEffect: string;
  63918. /**
  63919. * @ignore
  63920. * The vertical blur PostProcess id in the pipeline
  63921. */
  63922. SSAOBlurVRenderEffect: string;
  63923. /**
  63924. * @ignore
  63925. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63926. */
  63927. SSAOCombineRenderEffect: string;
  63928. /**
  63929. * The output strength of the SSAO post-process. Default value is 1.0.
  63930. */
  63931. totalStrength: number;
  63932. /**
  63933. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63934. */
  63935. radius: number;
  63936. /**
  63937. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63938. * Must not be equal to fallOff and superior to fallOff.
  63939. * Default value is 0.0075
  63940. */
  63941. area: number;
  63942. /**
  63943. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63944. * Must not be equal to area and inferior to area.
  63945. * Default value is 0.000001
  63946. */
  63947. fallOff: number;
  63948. /**
  63949. * The base color of the SSAO post-process
  63950. * The final result is "base + ssao" between [0, 1]
  63951. */
  63952. base: number;
  63953. private _scene;
  63954. private _depthTexture;
  63955. private _randomTexture;
  63956. private _originalColorPostProcess;
  63957. private _ssaoPostProcess;
  63958. private _blurHPostProcess;
  63959. private _blurVPostProcess;
  63960. private _ssaoCombinePostProcess;
  63961. private _firstUpdate;
  63962. /**
  63963. * Gets active scene
  63964. */
  63965. readonly scene: Scene;
  63966. /**
  63967. * @constructor
  63968. * @param name - The rendering pipeline name
  63969. * @param scene - The scene linked to this pipeline
  63970. * @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 }
  63971. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63972. */
  63973. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63974. /**
  63975. * Get the class name
  63976. * @returns "SSAORenderingPipeline"
  63977. */
  63978. getClassName(): string;
  63979. /**
  63980. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63981. */
  63982. dispose(disableDepthRender?: boolean): void;
  63983. private _createBlurPostProcess;
  63984. /** @hidden */
  63985. _rebuild(): void;
  63986. private _createSSAOPostProcess;
  63987. private _createSSAOCombinePostProcess;
  63988. private _createRandomTexture;
  63989. }
  63990. }
  63991. declare module "babylonjs/Shaders/standard.fragment" {
  63992. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63993. /** @hidden */
  63994. export var standardPixelShader: {
  63995. name: string;
  63996. shader: string;
  63997. };
  63998. }
  63999. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64000. import { Nullable } from "babylonjs/types";
  64001. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64002. import { Camera } from "babylonjs/Cameras/camera";
  64003. import { Texture } from "babylonjs/Materials/Textures/texture";
  64004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64005. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64006. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64007. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64008. import { IDisposable } from "babylonjs/scene";
  64009. import { SpotLight } from "babylonjs/Lights/spotLight";
  64010. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64011. import { Scene } from "babylonjs/scene";
  64012. import { Animation } from "babylonjs/Animations/animation";
  64013. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64014. import "babylonjs/Shaders/standard.fragment";
  64015. /**
  64016. * Standard rendering pipeline
  64017. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64018. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64019. */
  64020. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64021. /**
  64022. * Public members
  64023. */
  64024. /**
  64025. * Post-process which contains the original scene color before the pipeline applies all the effects
  64026. */
  64027. originalPostProcess: Nullable<PostProcess>;
  64028. /**
  64029. * Post-process used to down scale an image x4
  64030. */
  64031. downSampleX4PostProcess: Nullable<PostProcess>;
  64032. /**
  64033. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64034. */
  64035. brightPassPostProcess: Nullable<PostProcess>;
  64036. /**
  64037. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64038. */
  64039. blurHPostProcesses: PostProcess[];
  64040. /**
  64041. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64042. */
  64043. blurVPostProcesses: PostProcess[];
  64044. /**
  64045. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64046. */
  64047. textureAdderPostProcess: Nullable<PostProcess>;
  64048. /**
  64049. * Post-process used to create volumetric lighting effect
  64050. */
  64051. volumetricLightPostProcess: Nullable<PostProcess>;
  64052. /**
  64053. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64054. */
  64055. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64056. /**
  64057. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64058. */
  64059. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64060. /**
  64061. * Post-process used to merge the volumetric light effect and the real scene color
  64062. */
  64063. volumetricLightMergePostProces: Nullable<PostProcess>;
  64064. /**
  64065. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64066. */
  64067. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64068. /**
  64069. * Base post-process used to calculate the average luminance of the final image for HDR
  64070. */
  64071. luminancePostProcess: Nullable<PostProcess>;
  64072. /**
  64073. * Post-processes used to create down sample post-processes in order to get
  64074. * the average luminance of the final image for HDR
  64075. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64076. */
  64077. luminanceDownSamplePostProcesses: PostProcess[];
  64078. /**
  64079. * Post-process used to create a HDR effect (light adaptation)
  64080. */
  64081. hdrPostProcess: Nullable<PostProcess>;
  64082. /**
  64083. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64084. */
  64085. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64086. /**
  64087. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64088. */
  64089. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64090. /**
  64091. * Post-process used to merge the final HDR post-process and the real scene color
  64092. */
  64093. hdrFinalPostProcess: Nullable<PostProcess>;
  64094. /**
  64095. * Post-process used to create a lens flare effect
  64096. */
  64097. lensFlarePostProcess: Nullable<PostProcess>;
  64098. /**
  64099. * Post-process that merges the result of the lens flare post-process and the real scene color
  64100. */
  64101. lensFlareComposePostProcess: Nullable<PostProcess>;
  64102. /**
  64103. * Post-process used to create a motion blur effect
  64104. */
  64105. motionBlurPostProcess: Nullable<PostProcess>;
  64106. /**
  64107. * Post-process used to create a depth of field effect
  64108. */
  64109. depthOfFieldPostProcess: Nullable<PostProcess>;
  64110. /**
  64111. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64112. */
  64113. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64114. /**
  64115. * Represents the brightness threshold in order to configure the illuminated surfaces
  64116. */
  64117. brightThreshold: number;
  64118. /**
  64119. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64120. */
  64121. blurWidth: number;
  64122. /**
  64123. * Sets if the blur for highlighted surfaces must be only horizontal
  64124. */
  64125. horizontalBlur: boolean;
  64126. /**
  64127. * Gets the overall exposure used by the pipeline
  64128. */
  64129. /**
  64130. * Sets the overall exposure used by the pipeline
  64131. */
  64132. exposure: number;
  64133. /**
  64134. * Texture used typically to simulate "dirty" on camera lens
  64135. */
  64136. lensTexture: Nullable<Texture>;
  64137. /**
  64138. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64139. */
  64140. volumetricLightCoefficient: number;
  64141. /**
  64142. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64143. */
  64144. volumetricLightPower: number;
  64145. /**
  64146. * Used the set the blur intensity to smooth the volumetric lights
  64147. */
  64148. volumetricLightBlurScale: number;
  64149. /**
  64150. * Light (spot or directional) used to generate the volumetric lights rays
  64151. * The source light must have a shadow generate so the pipeline can get its
  64152. * depth map
  64153. */
  64154. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64155. /**
  64156. * For eye adaptation, represents the minimum luminance the eye can see
  64157. */
  64158. hdrMinimumLuminance: number;
  64159. /**
  64160. * For eye adaptation, represents the decrease luminance speed
  64161. */
  64162. hdrDecreaseRate: number;
  64163. /**
  64164. * For eye adaptation, represents the increase luminance speed
  64165. */
  64166. hdrIncreaseRate: number;
  64167. /**
  64168. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64169. */
  64170. /**
  64171. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64172. */
  64173. hdrAutoExposure: boolean;
  64174. /**
  64175. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64176. */
  64177. lensColorTexture: Nullable<Texture>;
  64178. /**
  64179. * The overall strengh for the lens flare effect
  64180. */
  64181. lensFlareStrength: number;
  64182. /**
  64183. * Dispersion coefficient for lens flare ghosts
  64184. */
  64185. lensFlareGhostDispersal: number;
  64186. /**
  64187. * Main lens flare halo width
  64188. */
  64189. lensFlareHaloWidth: number;
  64190. /**
  64191. * Based on the lens distortion effect, defines how much the lens flare result
  64192. * is distorted
  64193. */
  64194. lensFlareDistortionStrength: number;
  64195. /**
  64196. * Configures the blur intensity used for for lens flare (halo)
  64197. */
  64198. lensFlareBlurWidth: number;
  64199. /**
  64200. * Lens star texture must be used to simulate rays on the flares and is available
  64201. * in the documentation
  64202. */
  64203. lensStarTexture: Nullable<Texture>;
  64204. /**
  64205. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64206. * flare effect by taking account of the dirt texture
  64207. */
  64208. lensFlareDirtTexture: Nullable<Texture>;
  64209. /**
  64210. * Represents the focal length for the depth of field effect
  64211. */
  64212. depthOfFieldDistance: number;
  64213. /**
  64214. * Represents the blur intensity for the blurred part of the depth of field effect
  64215. */
  64216. depthOfFieldBlurWidth: number;
  64217. /**
  64218. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64219. */
  64220. /**
  64221. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64222. */
  64223. motionStrength: number;
  64224. /**
  64225. * Gets wether or not the motion blur post-process is object based or screen based.
  64226. */
  64227. /**
  64228. * Sets wether or not the motion blur post-process should be object based or screen based
  64229. */
  64230. objectBasedMotionBlur: boolean;
  64231. /**
  64232. * List of animations for the pipeline (IAnimatable implementation)
  64233. */
  64234. animations: Animation[];
  64235. /**
  64236. * Private members
  64237. */
  64238. private _scene;
  64239. private _currentDepthOfFieldSource;
  64240. private _basePostProcess;
  64241. private _fixedExposure;
  64242. private _currentExposure;
  64243. private _hdrAutoExposure;
  64244. private _hdrCurrentLuminance;
  64245. private _motionStrength;
  64246. private _isObjectBasedMotionBlur;
  64247. private _floatTextureType;
  64248. private _camerasToBeAttached;
  64249. private _ratio;
  64250. private _bloomEnabled;
  64251. private _depthOfFieldEnabled;
  64252. private _vlsEnabled;
  64253. private _lensFlareEnabled;
  64254. private _hdrEnabled;
  64255. private _motionBlurEnabled;
  64256. private _fxaaEnabled;
  64257. private _motionBlurSamples;
  64258. private _volumetricLightStepsCount;
  64259. private _samples;
  64260. /**
  64261. * @ignore
  64262. * Specifies if the bloom pipeline is enabled
  64263. */
  64264. BloomEnabled: boolean;
  64265. /**
  64266. * @ignore
  64267. * Specifies if the depth of field pipeline is enabed
  64268. */
  64269. DepthOfFieldEnabled: boolean;
  64270. /**
  64271. * @ignore
  64272. * Specifies if the lens flare pipeline is enabed
  64273. */
  64274. LensFlareEnabled: boolean;
  64275. /**
  64276. * @ignore
  64277. * Specifies if the HDR pipeline is enabled
  64278. */
  64279. HDREnabled: boolean;
  64280. /**
  64281. * @ignore
  64282. * Specifies if the volumetric lights scattering effect is enabled
  64283. */
  64284. VLSEnabled: boolean;
  64285. /**
  64286. * @ignore
  64287. * Specifies if the motion blur effect is enabled
  64288. */
  64289. MotionBlurEnabled: boolean;
  64290. /**
  64291. * Specifies if anti-aliasing is enabled
  64292. */
  64293. fxaaEnabled: boolean;
  64294. /**
  64295. * Specifies the number of steps used to calculate the volumetric lights
  64296. * Typically in interval [50, 200]
  64297. */
  64298. volumetricLightStepsCount: number;
  64299. /**
  64300. * Specifies the number of samples used for the motion blur effect
  64301. * Typically in interval [16, 64]
  64302. */
  64303. motionBlurSamples: number;
  64304. /**
  64305. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64306. */
  64307. samples: number;
  64308. /**
  64309. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64310. * @constructor
  64311. * @param name The rendering pipeline name
  64312. * @param scene The scene linked to this pipeline
  64313. * @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)
  64314. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64315. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64316. */
  64317. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64318. private _buildPipeline;
  64319. private _createDownSampleX4PostProcess;
  64320. private _createBrightPassPostProcess;
  64321. private _createBlurPostProcesses;
  64322. private _createTextureAdderPostProcess;
  64323. private _createVolumetricLightPostProcess;
  64324. private _createLuminancePostProcesses;
  64325. private _createHdrPostProcess;
  64326. private _createLensFlarePostProcess;
  64327. private _createDepthOfFieldPostProcess;
  64328. private _createMotionBlurPostProcess;
  64329. private _getDepthTexture;
  64330. private _disposePostProcesses;
  64331. /**
  64332. * Dispose of the pipeline and stop all post processes
  64333. */
  64334. dispose(): void;
  64335. /**
  64336. * Serialize the rendering pipeline (Used when exporting)
  64337. * @returns the serialized object
  64338. */
  64339. serialize(): any;
  64340. /**
  64341. * Parse the serialized pipeline
  64342. * @param source Source pipeline.
  64343. * @param scene The scene to load the pipeline to.
  64344. * @param rootUrl The URL of the serialized pipeline.
  64345. * @returns An instantiated pipeline from the serialized object.
  64346. */
  64347. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64348. /**
  64349. * Luminance steps
  64350. */
  64351. static LuminanceSteps: number;
  64352. }
  64353. }
  64354. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64355. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64356. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64357. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64358. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64360. }
  64361. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64363. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64364. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64365. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64366. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64367. }
  64368. declare module "babylonjs/Shaders/tonemap.fragment" {
  64369. /** @hidden */
  64370. export var tonemapPixelShader: {
  64371. name: string;
  64372. shader: string;
  64373. };
  64374. }
  64375. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64376. import { Camera } from "babylonjs/Cameras/camera";
  64377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64378. import "babylonjs/Shaders/tonemap.fragment";
  64379. import { Engine } from "babylonjs/Engines/engine";
  64380. /** Defines operator used for tonemapping */
  64381. export enum TonemappingOperator {
  64382. /** Hable */
  64383. Hable = 0,
  64384. /** Reinhard */
  64385. Reinhard = 1,
  64386. /** HejiDawson */
  64387. HejiDawson = 2,
  64388. /** Photographic */
  64389. Photographic = 3
  64390. }
  64391. /**
  64392. * Defines a post process to apply tone mapping
  64393. */
  64394. export class TonemapPostProcess extends PostProcess {
  64395. private _operator;
  64396. /** Defines the required exposure adjustement */
  64397. exposureAdjustment: number;
  64398. /**
  64399. * Creates a new TonemapPostProcess
  64400. * @param name defines the name of the postprocess
  64401. * @param _operator defines the operator to use
  64402. * @param exposureAdjustment defines the required exposure adjustement
  64403. * @param camera defines the camera to use (can be null)
  64404. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64405. * @param engine defines the hosting engine (can be ignore if camera is set)
  64406. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64407. */
  64408. constructor(name: string, _operator: TonemappingOperator,
  64409. /** Defines the required exposure adjustement */
  64410. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64411. }
  64412. }
  64413. declare module "babylonjs/Shaders/depth.vertex" {
  64414. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64415. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64417. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64418. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64419. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64420. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64421. /** @hidden */
  64422. export var depthVertexShader: {
  64423. name: string;
  64424. shader: string;
  64425. };
  64426. }
  64427. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64428. /** @hidden */
  64429. export var volumetricLightScatteringPixelShader: {
  64430. name: string;
  64431. shader: string;
  64432. };
  64433. }
  64434. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64435. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64437. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64438. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64440. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64441. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64442. /** @hidden */
  64443. export var volumetricLightScatteringPassVertexShader: {
  64444. name: string;
  64445. shader: string;
  64446. };
  64447. }
  64448. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64449. /** @hidden */
  64450. export var volumetricLightScatteringPassPixelShader: {
  64451. name: string;
  64452. shader: string;
  64453. };
  64454. }
  64455. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64456. import { Vector3 } from "babylonjs/Maths/math.vector";
  64457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64458. import { Mesh } from "babylonjs/Meshes/mesh";
  64459. import { Camera } from "babylonjs/Cameras/camera";
  64460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64461. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64462. import { Scene } from "babylonjs/scene";
  64463. import "babylonjs/Meshes/Builders/planeBuilder";
  64464. import "babylonjs/Shaders/depth.vertex";
  64465. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64466. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64467. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64468. import { Engine } from "babylonjs/Engines/engine";
  64469. /**
  64470. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64471. */
  64472. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64473. private _volumetricLightScatteringPass;
  64474. private _volumetricLightScatteringRTT;
  64475. private _viewPort;
  64476. private _screenCoordinates;
  64477. private _cachedDefines;
  64478. /**
  64479. * If not undefined, the mesh position is computed from the attached node position
  64480. */
  64481. attachedNode: {
  64482. position: Vector3;
  64483. };
  64484. /**
  64485. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64486. */
  64487. customMeshPosition: Vector3;
  64488. /**
  64489. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64490. */
  64491. useCustomMeshPosition: boolean;
  64492. /**
  64493. * If the post-process should inverse the light scattering direction
  64494. */
  64495. invert: boolean;
  64496. /**
  64497. * The internal mesh used by the post-process
  64498. */
  64499. mesh: Mesh;
  64500. /**
  64501. * @hidden
  64502. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64503. */
  64504. useDiffuseColor: boolean;
  64505. /**
  64506. * Array containing the excluded meshes not rendered in the internal pass
  64507. */
  64508. excludedMeshes: AbstractMesh[];
  64509. /**
  64510. * Controls the overall intensity of the post-process
  64511. */
  64512. exposure: number;
  64513. /**
  64514. * Dissipates each sample's contribution in range [0, 1]
  64515. */
  64516. decay: number;
  64517. /**
  64518. * Controls the overall intensity of each sample
  64519. */
  64520. weight: number;
  64521. /**
  64522. * Controls the density of each sample
  64523. */
  64524. density: number;
  64525. /**
  64526. * @constructor
  64527. * @param name The post-process name
  64528. * @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)
  64529. * @param camera The camera that the post-process will be attached to
  64530. * @param mesh The mesh used to create the light scattering
  64531. * @param samples The post-process quality, default 100
  64532. * @param samplingModeThe post-process filtering mode
  64533. * @param engine The babylon engine
  64534. * @param reusable If the post-process is reusable
  64535. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64536. */
  64537. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64538. /**
  64539. * Returns the string "VolumetricLightScatteringPostProcess"
  64540. * @returns "VolumetricLightScatteringPostProcess"
  64541. */
  64542. getClassName(): string;
  64543. private _isReady;
  64544. /**
  64545. * Sets the new light position for light scattering effect
  64546. * @param position The new custom light position
  64547. */
  64548. setCustomMeshPosition(position: Vector3): void;
  64549. /**
  64550. * Returns the light position for light scattering effect
  64551. * @return Vector3 The custom light position
  64552. */
  64553. getCustomMeshPosition(): Vector3;
  64554. /**
  64555. * Disposes the internal assets and detaches the post-process from the camera
  64556. */
  64557. dispose(camera: Camera): void;
  64558. /**
  64559. * Returns the render target texture used by the post-process
  64560. * @return the render target texture used by the post-process
  64561. */
  64562. getPass(): RenderTargetTexture;
  64563. private _meshExcluded;
  64564. private _createPass;
  64565. private _updateMeshScreenCoordinates;
  64566. /**
  64567. * Creates a default mesh for the Volumeric Light Scattering post-process
  64568. * @param name The mesh name
  64569. * @param scene The scene where to create the mesh
  64570. * @return the default mesh
  64571. */
  64572. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64573. }
  64574. }
  64575. declare module "babylonjs/PostProcesses/index" {
  64576. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64577. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64578. export * from "babylonjs/PostProcesses/bloomEffect";
  64579. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64580. export * from "babylonjs/PostProcesses/blurPostProcess";
  64581. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64582. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64583. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64584. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64585. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64586. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64587. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64588. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64589. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64590. export * from "babylonjs/PostProcesses/filterPostProcess";
  64591. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64592. export * from "babylonjs/PostProcesses/grainPostProcess";
  64593. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64594. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64595. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64596. export * from "babylonjs/PostProcesses/passPostProcess";
  64597. export * from "babylonjs/PostProcesses/postProcess";
  64598. export * from "babylonjs/PostProcesses/postProcessManager";
  64599. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64600. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64601. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64602. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64603. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64604. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64605. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64606. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64607. }
  64608. declare module "babylonjs/Probes/index" {
  64609. export * from "babylonjs/Probes/reflectionProbe";
  64610. }
  64611. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64612. import { Scene } from "babylonjs/scene";
  64613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64614. import { SmartArray } from "babylonjs/Misc/smartArray";
  64615. import { ISceneComponent } from "babylonjs/sceneComponent";
  64616. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64617. import "babylonjs/Meshes/Builders/boxBuilder";
  64618. import "babylonjs/Shaders/color.fragment";
  64619. import "babylonjs/Shaders/color.vertex";
  64620. import { Color3 } from "babylonjs/Maths/math.color";
  64621. module "babylonjs/scene" {
  64622. interface Scene {
  64623. /** @hidden (Backing field) */
  64624. _boundingBoxRenderer: BoundingBoxRenderer;
  64625. /** @hidden (Backing field) */
  64626. _forceShowBoundingBoxes: boolean;
  64627. /**
  64628. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64629. */
  64630. forceShowBoundingBoxes: boolean;
  64631. /**
  64632. * Gets the bounding box renderer associated with the scene
  64633. * @returns a BoundingBoxRenderer
  64634. */
  64635. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64636. }
  64637. }
  64638. module "babylonjs/Meshes/abstractMesh" {
  64639. interface AbstractMesh {
  64640. /** @hidden (Backing field) */
  64641. _showBoundingBox: boolean;
  64642. /**
  64643. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64644. */
  64645. showBoundingBox: boolean;
  64646. }
  64647. }
  64648. /**
  64649. * Component responsible of rendering the bounding box of the meshes in a scene.
  64650. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64651. */
  64652. export class BoundingBoxRenderer implements ISceneComponent {
  64653. /**
  64654. * The component name helpfull to identify the component in the list of scene components.
  64655. */
  64656. readonly name: string;
  64657. /**
  64658. * The scene the component belongs to.
  64659. */
  64660. scene: Scene;
  64661. /**
  64662. * Color of the bounding box lines placed in front of an object
  64663. */
  64664. frontColor: Color3;
  64665. /**
  64666. * Color of the bounding box lines placed behind an object
  64667. */
  64668. backColor: Color3;
  64669. /**
  64670. * Defines if the renderer should show the back lines or not
  64671. */
  64672. showBackLines: boolean;
  64673. /**
  64674. * @hidden
  64675. */
  64676. renderList: SmartArray<BoundingBox>;
  64677. private _colorShader;
  64678. private _vertexBuffers;
  64679. private _indexBuffer;
  64680. private _fillIndexBuffer;
  64681. private _fillIndexData;
  64682. /**
  64683. * Instantiates a new bounding box renderer in a scene.
  64684. * @param scene the scene the renderer renders in
  64685. */
  64686. constructor(scene: Scene);
  64687. /**
  64688. * Registers the component in a given scene
  64689. */
  64690. register(): void;
  64691. private _evaluateSubMesh;
  64692. private _activeMesh;
  64693. private _prepareRessources;
  64694. private _createIndexBuffer;
  64695. /**
  64696. * Rebuilds the elements related to this component in case of
  64697. * context lost for instance.
  64698. */
  64699. rebuild(): void;
  64700. /**
  64701. * @hidden
  64702. */
  64703. reset(): void;
  64704. /**
  64705. * Render the bounding boxes of a specific rendering group
  64706. * @param renderingGroupId defines the rendering group to render
  64707. */
  64708. render(renderingGroupId: number): void;
  64709. /**
  64710. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64711. * @param mesh Define the mesh to render the occlusion bounding box for
  64712. */
  64713. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64714. /**
  64715. * Dispose and release the resources attached to this renderer.
  64716. */
  64717. dispose(): void;
  64718. }
  64719. }
  64720. declare module "babylonjs/Shaders/depth.fragment" {
  64721. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64722. /** @hidden */
  64723. export var depthPixelShader: {
  64724. name: string;
  64725. shader: string;
  64726. };
  64727. }
  64728. declare module "babylonjs/Rendering/depthRenderer" {
  64729. import { Nullable } from "babylonjs/types";
  64730. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64731. import { Scene } from "babylonjs/scene";
  64732. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64733. import { Camera } from "babylonjs/Cameras/camera";
  64734. import "babylonjs/Shaders/depth.fragment";
  64735. import "babylonjs/Shaders/depth.vertex";
  64736. /**
  64737. * This represents a depth renderer in Babylon.
  64738. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64739. */
  64740. export class DepthRenderer {
  64741. private _scene;
  64742. private _depthMap;
  64743. private _effect;
  64744. private readonly _storeNonLinearDepth;
  64745. private readonly _clearColor;
  64746. /** Get if the depth renderer is using packed depth or not */
  64747. readonly isPacked: boolean;
  64748. private _cachedDefines;
  64749. private _camera;
  64750. /**
  64751. * Specifiess that the depth renderer will only be used within
  64752. * the camera it is created for.
  64753. * This can help forcing its rendering during the camera processing.
  64754. */
  64755. useOnlyInActiveCamera: boolean;
  64756. /** @hidden */
  64757. static _SceneComponentInitialization: (scene: Scene) => void;
  64758. /**
  64759. * Instantiates a depth renderer
  64760. * @param scene The scene the renderer belongs to
  64761. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64762. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64763. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64764. */
  64765. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64766. /**
  64767. * Creates the depth rendering effect and checks if the effect is ready.
  64768. * @param subMesh The submesh to be used to render the depth map of
  64769. * @param useInstances If multiple world instances should be used
  64770. * @returns if the depth renderer is ready to render the depth map
  64771. */
  64772. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64773. /**
  64774. * Gets the texture which the depth map will be written to.
  64775. * @returns The depth map texture
  64776. */
  64777. getDepthMap(): RenderTargetTexture;
  64778. /**
  64779. * Disposes of the depth renderer.
  64780. */
  64781. dispose(): void;
  64782. }
  64783. }
  64784. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64785. import { Nullable } from "babylonjs/types";
  64786. import { Scene } from "babylonjs/scene";
  64787. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64788. import { Camera } from "babylonjs/Cameras/camera";
  64789. import { ISceneComponent } from "babylonjs/sceneComponent";
  64790. module "babylonjs/scene" {
  64791. interface Scene {
  64792. /** @hidden (Backing field) */
  64793. _depthRenderer: {
  64794. [id: string]: DepthRenderer;
  64795. };
  64796. /**
  64797. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64798. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64799. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64800. * @returns the created depth renderer
  64801. */
  64802. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64803. /**
  64804. * Disables a depth renderer for a given camera
  64805. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64806. */
  64807. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64808. }
  64809. }
  64810. /**
  64811. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64812. * in several rendering techniques.
  64813. */
  64814. export class DepthRendererSceneComponent implements ISceneComponent {
  64815. /**
  64816. * The component name helpfull to identify the component in the list of scene components.
  64817. */
  64818. readonly name: string;
  64819. /**
  64820. * The scene the component belongs to.
  64821. */
  64822. scene: Scene;
  64823. /**
  64824. * Creates a new instance of the component for the given scene
  64825. * @param scene Defines the scene to register the component in
  64826. */
  64827. constructor(scene: Scene);
  64828. /**
  64829. * Registers the component in a given scene
  64830. */
  64831. register(): void;
  64832. /**
  64833. * Rebuilds the elements related to this component in case of
  64834. * context lost for instance.
  64835. */
  64836. rebuild(): void;
  64837. /**
  64838. * Disposes the component and the associated ressources
  64839. */
  64840. dispose(): void;
  64841. private _gatherRenderTargets;
  64842. private _gatherActiveCameraRenderTargets;
  64843. }
  64844. }
  64845. declare module "babylonjs/Shaders/outline.fragment" {
  64846. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64847. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64848. /** @hidden */
  64849. export var outlinePixelShader: {
  64850. name: string;
  64851. shader: string;
  64852. };
  64853. }
  64854. declare module "babylonjs/Shaders/outline.vertex" {
  64855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64861. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64862. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64863. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64864. /** @hidden */
  64865. export var outlineVertexShader: {
  64866. name: string;
  64867. shader: string;
  64868. };
  64869. }
  64870. declare module "babylonjs/Rendering/outlineRenderer" {
  64871. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64872. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64873. import { Scene } from "babylonjs/scene";
  64874. import { ISceneComponent } from "babylonjs/sceneComponent";
  64875. import "babylonjs/Shaders/outline.fragment";
  64876. import "babylonjs/Shaders/outline.vertex";
  64877. module "babylonjs/scene" {
  64878. interface Scene {
  64879. /** @hidden */
  64880. _outlineRenderer: OutlineRenderer;
  64881. /**
  64882. * Gets the outline renderer associated with the scene
  64883. * @returns a OutlineRenderer
  64884. */
  64885. getOutlineRenderer(): OutlineRenderer;
  64886. }
  64887. }
  64888. module "babylonjs/Meshes/abstractMesh" {
  64889. interface AbstractMesh {
  64890. /** @hidden (Backing field) */
  64891. _renderOutline: boolean;
  64892. /**
  64893. * Gets or sets a boolean indicating if the outline must be rendered as well
  64894. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64895. */
  64896. renderOutline: boolean;
  64897. /** @hidden (Backing field) */
  64898. _renderOverlay: boolean;
  64899. /**
  64900. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64901. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64902. */
  64903. renderOverlay: boolean;
  64904. }
  64905. }
  64906. /**
  64907. * This class is responsible to draw bothe outline/overlay of meshes.
  64908. * It should not be used directly but through the available method on mesh.
  64909. */
  64910. export class OutlineRenderer implements ISceneComponent {
  64911. /**
  64912. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64913. */
  64914. private static _StencilReference;
  64915. /**
  64916. * The name of the component. Each component must have a unique name.
  64917. */
  64918. name: string;
  64919. /**
  64920. * The scene the component belongs to.
  64921. */
  64922. scene: Scene;
  64923. /**
  64924. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64925. */
  64926. zOffset: number;
  64927. private _engine;
  64928. private _effect;
  64929. private _cachedDefines;
  64930. private _savedDepthWrite;
  64931. /**
  64932. * Instantiates a new outline renderer. (There could be only one per scene).
  64933. * @param scene Defines the scene it belongs to
  64934. */
  64935. constructor(scene: Scene);
  64936. /**
  64937. * Register the component to one instance of a scene.
  64938. */
  64939. register(): void;
  64940. /**
  64941. * Rebuilds the elements related to this component in case of
  64942. * context lost for instance.
  64943. */
  64944. rebuild(): void;
  64945. /**
  64946. * Disposes the component and the associated ressources.
  64947. */
  64948. dispose(): void;
  64949. /**
  64950. * Renders the outline in the canvas.
  64951. * @param subMesh Defines the sumesh to render
  64952. * @param batch Defines the batch of meshes in case of instances
  64953. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64954. */
  64955. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64956. /**
  64957. * Returns whether or not the outline renderer is ready for a given submesh.
  64958. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64959. * @param subMesh Defines the submesh to check readyness for
  64960. * @param useInstances Defines wheter wee are trying to render instances or not
  64961. * @returns true if ready otherwise false
  64962. */
  64963. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64964. private _beforeRenderingMesh;
  64965. private _afterRenderingMesh;
  64966. }
  64967. }
  64968. declare module "babylonjs/Rendering/index" {
  64969. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64970. export * from "babylonjs/Rendering/depthRenderer";
  64971. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64972. export * from "babylonjs/Rendering/edgesRenderer";
  64973. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64974. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64975. export * from "babylonjs/Rendering/outlineRenderer";
  64976. export * from "babylonjs/Rendering/renderingGroup";
  64977. export * from "babylonjs/Rendering/renderingManager";
  64978. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64979. }
  64980. declare module "babylonjs/Sprites/spritePackedManager" {
  64981. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64982. import { Scene } from "babylonjs/scene";
  64983. /**
  64984. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64985. * @see http://doc.babylonjs.com/babylon101/sprites
  64986. */
  64987. export class SpritePackedManager extends SpriteManager {
  64988. /** defines the packed manager's name */
  64989. name: string;
  64990. /**
  64991. * Creates a new sprite manager from a packed sprite sheet
  64992. * @param name defines the manager's name
  64993. * @param imgUrl defines the sprite sheet url
  64994. * @param capacity defines the maximum allowed number of sprites
  64995. * @param scene defines the hosting scene
  64996. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64997. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64998. * @param samplingMode defines the smapling mode to use with spritesheet
  64999. * @param fromPacked set to true; do not alter
  65000. */
  65001. constructor(
  65002. /** defines the packed manager's name */
  65003. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65004. }
  65005. }
  65006. declare module "babylonjs/Sprites/index" {
  65007. export * from "babylonjs/Sprites/sprite";
  65008. export * from "babylonjs/Sprites/spriteManager";
  65009. export * from "babylonjs/Sprites/spritePackedManager";
  65010. export * from "babylonjs/Sprites/spriteSceneComponent";
  65011. }
  65012. declare module "babylonjs/States/index" {
  65013. export * from "babylonjs/States/alphaCullingState";
  65014. export * from "babylonjs/States/depthCullingState";
  65015. export * from "babylonjs/States/stencilState";
  65016. }
  65017. declare module "babylonjs/Misc/assetsManager" {
  65018. import { Scene } from "babylonjs/scene";
  65019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65020. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65021. import { Skeleton } from "babylonjs/Bones/skeleton";
  65022. import { Observable } from "babylonjs/Misc/observable";
  65023. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65024. import { Texture } from "babylonjs/Materials/Textures/texture";
  65025. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65026. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65027. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65028. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65029. /**
  65030. * Defines the list of states available for a task inside a AssetsManager
  65031. */
  65032. export enum AssetTaskState {
  65033. /**
  65034. * Initialization
  65035. */
  65036. INIT = 0,
  65037. /**
  65038. * Running
  65039. */
  65040. RUNNING = 1,
  65041. /**
  65042. * Done
  65043. */
  65044. DONE = 2,
  65045. /**
  65046. * Error
  65047. */
  65048. ERROR = 3
  65049. }
  65050. /**
  65051. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65052. */
  65053. export abstract class AbstractAssetTask {
  65054. /**
  65055. * Task name
  65056. */ name: string;
  65057. /**
  65058. * Callback called when the task is successful
  65059. */
  65060. onSuccess: (task: any) => void;
  65061. /**
  65062. * Callback called when the task is not successful
  65063. */
  65064. onError: (task: any, message?: string, exception?: any) => void;
  65065. /**
  65066. * Creates a new AssetsManager
  65067. * @param name defines the name of the task
  65068. */
  65069. constructor(
  65070. /**
  65071. * Task name
  65072. */ name: string);
  65073. private _isCompleted;
  65074. private _taskState;
  65075. private _errorObject;
  65076. /**
  65077. * Get if the task is completed
  65078. */
  65079. readonly isCompleted: boolean;
  65080. /**
  65081. * Gets the current state of the task
  65082. */
  65083. readonly taskState: AssetTaskState;
  65084. /**
  65085. * Gets the current error object (if task is in error)
  65086. */
  65087. readonly errorObject: {
  65088. message?: string;
  65089. exception?: any;
  65090. };
  65091. /**
  65092. * Internal only
  65093. * @hidden
  65094. */
  65095. _setErrorObject(message?: string, exception?: any): void;
  65096. /**
  65097. * Execute the current task
  65098. * @param scene defines the scene where you want your assets to be loaded
  65099. * @param onSuccess is a callback called when the task is successfully executed
  65100. * @param onError is a callback called if an error occurs
  65101. */
  65102. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65103. /**
  65104. * Execute the current task
  65105. * @param scene defines the scene where you want your assets to be loaded
  65106. * @param onSuccess is a callback called when the task is successfully executed
  65107. * @param onError is a callback called if an error occurs
  65108. */
  65109. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65110. /**
  65111. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65112. * This can be used with failed tasks that have the reason for failure fixed.
  65113. */
  65114. reset(): void;
  65115. private onErrorCallback;
  65116. private onDoneCallback;
  65117. }
  65118. /**
  65119. * Define the interface used by progress events raised during assets loading
  65120. */
  65121. export interface IAssetsProgressEvent {
  65122. /**
  65123. * Defines the number of remaining tasks to process
  65124. */
  65125. remainingCount: number;
  65126. /**
  65127. * Defines the total number of tasks
  65128. */
  65129. totalCount: number;
  65130. /**
  65131. * Defines the task that was just processed
  65132. */
  65133. task: AbstractAssetTask;
  65134. }
  65135. /**
  65136. * Class used to share progress information about assets loading
  65137. */
  65138. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65139. /**
  65140. * Defines the number of remaining tasks to process
  65141. */
  65142. remainingCount: number;
  65143. /**
  65144. * Defines the total number of tasks
  65145. */
  65146. totalCount: number;
  65147. /**
  65148. * Defines the task that was just processed
  65149. */
  65150. task: AbstractAssetTask;
  65151. /**
  65152. * Creates a AssetsProgressEvent
  65153. * @param remainingCount defines the number of remaining tasks to process
  65154. * @param totalCount defines the total number of tasks
  65155. * @param task defines the task that was just processed
  65156. */
  65157. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65158. }
  65159. /**
  65160. * Define a task used by AssetsManager to load meshes
  65161. */
  65162. export class MeshAssetTask extends AbstractAssetTask {
  65163. /**
  65164. * Defines the name of the task
  65165. */
  65166. name: string;
  65167. /**
  65168. * Defines the list of mesh's names you want to load
  65169. */
  65170. meshesNames: any;
  65171. /**
  65172. * Defines the root url to use as a base to load your meshes and associated resources
  65173. */
  65174. rootUrl: string;
  65175. /**
  65176. * Defines the filename of the scene to load from
  65177. */
  65178. sceneFilename: string;
  65179. /**
  65180. * Gets the list of loaded meshes
  65181. */
  65182. loadedMeshes: Array<AbstractMesh>;
  65183. /**
  65184. * Gets the list of loaded particle systems
  65185. */
  65186. loadedParticleSystems: Array<IParticleSystem>;
  65187. /**
  65188. * Gets the list of loaded skeletons
  65189. */
  65190. loadedSkeletons: Array<Skeleton>;
  65191. /**
  65192. * Gets the list of loaded animation groups
  65193. */
  65194. loadedAnimationGroups: Array<AnimationGroup>;
  65195. /**
  65196. * Callback called when the task is successful
  65197. */
  65198. onSuccess: (task: MeshAssetTask) => void;
  65199. /**
  65200. * Callback called when the task is successful
  65201. */
  65202. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65203. /**
  65204. * Creates a new MeshAssetTask
  65205. * @param name defines the name of the task
  65206. * @param meshesNames defines the list of mesh's names you want to load
  65207. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65208. * @param sceneFilename defines the filename of the scene to load from
  65209. */
  65210. constructor(
  65211. /**
  65212. * Defines the name of the task
  65213. */
  65214. name: string,
  65215. /**
  65216. * Defines the list of mesh's names you want to load
  65217. */
  65218. meshesNames: any,
  65219. /**
  65220. * Defines the root url to use as a base to load your meshes and associated resources
  65221. */
  65222. rootUrl: string,
  65223. /**
  65224. * Defines the filename of the scene to load from
  65225. */
  65226. sceneFilename: string);
  65227. /**
  65228. * Execute the current task
  65229. * @param scene defines the scene where you want your assets to be loaded
  65230. * @param onSuccess is a callback called when the task is successfully executed
  65231. * @param onError is a callback called if an error occurs
  65232. */
  65233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65234. }
  65235. /**
  65236. * Define a task used by AssetsManager to load text content
  65237. */
  65238. export class TextFileAssetTask extends AbstractAssetTask {
  65239. /**
  65240. * Defines the name of the task
  65241. */
  65242. name: string;
  65243. /**
  65244. * Defines the location of the file to load
  65245. */
  65246. url: string;
  65247. /**
  65248. * Gets the loaded text string
  65249. */
  65250. text: string;
  65251. /**
  65252. * Callback called when the task is successful
  65253. */
  65254. onSuccess: (task: TextFileAssetTask) => void;
  65255. /**
  65256. * Callback called when the task is successful
  65257. */
  65258. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65259. /**
  65260. * Creates a new TextFileAssetTask object
  65261. * @param name defines the name of the task
  65262. * @param url defines the location of the file to load
  65263. */
  65264. constructor(
  65265. /**
  65266. * Defines the name of the task
  65267. */
  65268. name: string,
  65269. /**
  65270. * Defines the location of the file to load
  65271. */
  65272. url: string);
  65273. /**
  65274. * Execute the current task
  65275. * @param scene defines the scene where you want your assets to be loaded
  65276. * @param onSuccess is a callback called when the task is successfully executed
  65277. * @param onError is a callback called if an error occurs
  65278. */
  65279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65280. }
  65281. /**
  65282. * Define a task used by AssetsManager to load binary data
  65283. */
  65284. export class BinaryFileAssetTask extends AbstractAssetTask {
  65285. /**
  65286. * Defines the name of the task
  65287. */
  65288. name: string;
  65289. /**
  65290. * Defines the location of the file to load
  65291. */
  65292. url: string;
  65293. /**
  65294. * Gets the lodaded data (as an array buffer)
  65295. */
  65296. data: ArrayBuffer;
  65297. /**
  65298. * Callback called when the task is successful
  65299. */
  65300. onSuccess: (task: BinaryFileAssetTask) => void;
  65301. /**
  65302. * Callback called when the task is successful
  65303. */
  65304. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65305. /**
  65306. * Creates a new BinaryFileAssetTask object
  65307. * @param name defines the name of the new task
  65308. * @param url defines the location of the file to load
  65309. */
  65310. constructor(
  65311. /**
  65312. * Defines the name of the task
  65313. */
  65314. name: string,
  65315. /**
  65316. * Defines the location of the file to load
  65317. */
  65318. url: string);
  65319. /**
  65320. * Execute the current task
  65321. * @param scene defines the scene where you want your assets to be loaded
  65322. * @param onSuccess is a callback called when the task is successfully executed
  65323. * @param onError is a callback called if an error occurs
  65324. */
  65325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65326. }
  65327. /**
  65328. * Define a task used by AssetsManager to load images
  65329. */
  65330. export class ImageAssetTask extends AbstractAssetTask {
  65331. /**
  65332. * Defines the name of the task
  65333. */
  65334. name: string;
  65335. /**
  65336. * Defines the location of the image to load
  65337. */
  65338. url: string;
  65339. /**
  65340. * Gets the loaded images
  65341. */
  65342. image: HTMLImageElement;
  65343. /**
  65344. * Callback called when the task is successful
  65345. */
  65346. onSuccess: (task: ImageAssetTask) => void;
  65347. /**
  65348. * Callback called when the task is successful
  65349. */
  65350. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65351. /**
  65352. * Creates a new ImageAssetTask
  65353. * @param name defines the name of the task
  65354. * @param url defines the location of the image to load
  65355. */
  65356. constructor(
  65357. /**
  65358. * Defines the name of the task
  65359. */
  65360. name: string,
  65361. /**
  65362. * Defines the location of the image to load
  65363. */
  65364. url: string);
  65365. /**
  65366. * Execute the current task
  65367. * @param scene defines the scene where you want your assets to be loaded
  65368. * @param onSuccess is a callback called when the task is successfully executed
  65369. * @param onError is a callback called if an error occurs
  65370. */
  65371. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65372. }
  65373. /**
  65374. * Defines the interface used by texture loading tasks
  65375. */
  65376. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65377. /**
  65378. * Gets the loaded texture
  65379. */
  65380. texture: TEX;
  65381. }
  65382. /**
  65383. * Define a task used by AssetsManager to load 2D textures
  65384. */
  65385. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65386. /**
  65387. * Defines the name of the task
  65388. */
  65389. name: string;
  65390. /**
  65391. * Defines the location of the file to load
  65392. */
  65393. url: string;
  65394. /**
  65395. * Defines if mipmap should not be generated (default is false)
  65396. */
  65397. noMipmap?: boolean | undefined;
  65398. /**
  65399. * Defines if texture must be inverted on Y axis (default is false)
  65400. */
  65401. invertY?: boolean | undefined;
  65402. /**
  65403. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65404. */
  65405. samplingMode: number;
  65406. /**
  65407. * Gets the loaded texture
  65408. */
  65409. texture: Texture;
  65410. /**
  65411. * Callback called when the task is successful
  65412. */
  65413. onSuccess: (task: TextureAssetTask) => void;
  65414. /**
  65415. * Callback called when the task is successful
  65416. */
  65417. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65418. /**
  65419. * Creates a new TextureAssetTask object
  65420. * @param name defines the name of the task
  65421. * @param url defines the location of the file to load
  65422. * @param noMipmap defines if mipmap should not be generated (default is false)
  65423. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65424. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65425. */
  65426. constructor(
  65427. /**
  65428. * Defines the name of the task
  65429. */
  65430. name: string,
  65431. /**
  65432. * Defines the location of the file to load
  65433. */
  65434. url: string,
  65435. /**
  65436. * Defines if mipmap should not be generated (default is false)
  65437. */
  65438. noMipmap?: boolean | undefined,
  65439. /**
  65440. * Defines if texture must be inverted on Y axis (default is false)
  65441. */
  65442. invertY?: boolean | undefined,
  65443. /**
  65444. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65445. */
  65446. samplingMode?: number);
  65447. /**
  65448. * Execute the current task
  65449. * @param scene defines the scene where you want your assets to be loaded
  65450. * @param onSuccess is a callback called when the task is successfully executed
  65451. * @param onError is a callback called if an error occurs
  65452. */
  65453. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65454. }
  65455. /**
  65456. * Define a task used by AssetsManager to load cube textures
  65457. */
  65458. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65459. /**
  65460. * Defines the name of the task
  65461. */
  65462. name: string;
  65463. /**
  65464. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65465. */
  65466. url: string;
  65467. /**
  65468. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65469. */
  65470. extensions?: string[] | undefined;
  65471. /**
  65472. * Defines if mipmaps should not be generated (default is false)
  65473. */
  65474. noMipmap?: boolean | undefined;
  65475. /**
  65476. * Defines the explicit list of files (undefined by default)
  65477. */
  65478. files?: string[] | undefined;
  65479. /**
  65480. * Gets the loaded texture
  65481. */
  65482. texture: CubeTexture;
  65483. /**
  65484. * Callback called when the task is successful
  65485. */
  65486. onSuccess: (task: CubeTextureAssetTask) => void;
  65487. /**
  65488. * Callback called when the task is successful
  65489. */
  65490. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65491. /**
  65492. * Creates a new CubeTextureAssetTask
  65493. * @param name defines the name of the task
  65494. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65495. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65496. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65497. * @param files defines the explicit list of files (undefined by default)
  65498. */
  65499. constructor(
  65500. /**
  65501. * Defines the name of the task
  65502. */
  65503. name: string,
  65504. /**
  65505. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65506. */
  65507. url: string,
  65508. /**
  65509. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65510. */
  65511. extensions?: string[] | undefined,
  65512. /**
  65513. * Defines if mipmaps should not be generated (default is false)
  65514. */
  65515. noMipmap?: boolean | undefined,
  65516. /**
  65517. * Defines the explicit list of files (undefined by default)
  65518. */
  65519. files?: string[] | undefined);
  65520. /**
  65521. * Execute the current task
  65522. * @param scene defines the scene where you want your assets to be loaded
  65523. * @param onSuccess is a callback called when the task is successfully executed
  65524. * @param onError is a callback called if an error occurs
  65525. */
  65526. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65527. }
  65528. /**
  65529. * Define a task used by AssetsManager to load HDR cube textures
  65530. */
  65531. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65532. /**
  65533. * Defines the name of the task
  65534. */
  65535. name: string;
  65536. /**
  65537. * Defines the location of the file to load
  65538. */
  65539. url: string;
  65540. /**
  65541. * Defines the desired size (the more it increases the longer the generation will be)
  65542. */
  65543. size: number;
  65544. /**
  65545. * Defines if mipmaps should not be generated (default is false)
  65546. */
  65547. noMipmap: boolean;
  65548. /**
  65549. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65550. */
  65551. generateHarmonics: boolean;
  65552. /**
  65553. * 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)
  65554. */
  65555. gammaSpace: boolean;
  65556. /**
  65557. * Internal Use Only
  65558. */
  65559. reserved: boolean;
  65560. /**
  65561. * Gets the loaded texture
  65562. */
  65563. texture: HDRCubeTexture;
  65564. /**
  65565. * Callback called when the task is successful
  65566. */
  65567. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65568. /**
  65569. * Callback called when the task is successful
  65570. */
  65571. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65572. /**
  65573. * Creates a new HDRCubeTextureAssetTask object
  65574. * @param name defines the name of the task
  65575. * @param url defines the location of the file to load
  65576. * @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.
  65577. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65578. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65579. * @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)
  65580. * @param reserved Internal use only
  65581. */
  65582. constructor(
  65583. /**
  65584. * Defines the name of the task
  65585. */
  65586. name: string,
  65587. /**
  65588. * Defines the location of the file to load
  65589. */
  65590. url: string,
  65591. /**
  65592. * Defines the desired size (the more it increases the longer the generation will be)
  65593. */
  65594. size: number,
  65595. /**
  65596. * Defines if mipmaps should not be generated (default is false)
  65597. */
  65598. noMipmap?: boolean,
  65599. /**
  65600. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65601. */
  65602. generateHarmonics?: boolean,
  65603. /**
  65604. * 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)
  65605. */
  65606. gammaSpace?: boolean,
  65607. /**
  65608. * Internal Use Only
  65609. */
  65610. reserved?: boolean);
  65611. /**
  65612. * Execute the current task
  65613. * @param scene defines the scene where you want your assets to be loaded
  65614. * @param onSuccess is a callback called when the task is successfully executed
  65615. * @param onError is a callback called if an error occurs
  65616. */
  65617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65618. }
  65619. /**
  65620. * Define a task used by AssetsManager to load Equirectangular cube textures
  65621. */
  65622. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65623. /**
  65624. * Defines the name of the task
  65625. */
  65626. name: string;
  65627. /**
  65628. * Defines the location of the file to load
  65629. */
  65630. url: string;
  65631. /**
  65632. * Defines the desired size (the more it increases the longer the generation will be)
  65633. */
  65634. size: number;
  65635. /**
  65636. * Defines if mipmaps should not be generated (default is false)
  65637. */
  65638. noMipmap: boolean;
  65639. /**
  65640. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65641. * but the standard material would require them in Gamma space) (default is true)
  65642. */
  65643. gammaSpace: boolean;
  65644. /**
  65645. * Gets the loaded texture
  65646. */
  65647. texture: EquiRectangularCubeTexture;
  65648. /**
  65649. * Callback called when the task is successful
  65650. */
  65651. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65652. /**
  65653. * Callback called when the task is successful
  65654. */
  65655. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65656. /**
  65657. * Creates a new EquiRectangularCubeTextureAssetTask object
  65658. * @param name defines the name of the task
  65659. * @param url defines the location of the file to load
  65660. * @param size defines the desired size (the more it increases the longer the generation will be)
  65661. * If the size is omitted this implies you are using a preprocessed cubemap.
  65662. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65663. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65664. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65665. * (default is true)
  65666. */
  65667. constructor(
  65668. /**
  65669. * Defines the name of the task
  65670. */
  65671. name: string,
  65672. /**
  65673. * Defines the location of the file to load
  65674. */
  65675. url: string,
  65676. /**
  65677. * Defines the desired size (the more it increases the longer the generation will be)
  65678. */
  65679. size: number,
  65680. /**
  65681. * Defines if mipmaps should not be generated (default is false)
  65682. */
  65683. noMipmap?: boolean,
  65684. /**
  65685. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65686. * but the standard material would require them in Gamma space) (default is true)
  65687. */
  65688. gammaSpace?: boolean);
  65689. /**
  65690. * Execute the current task
  65691. * @param scene defines the scene where you want your assets to be loaded
  65692. * @param onSuccess is a callback called when the task is successfully executed
  65693. * @param onError is a callback called if an error occurs
  65694. */
  65695. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65696. }
  65697. /**
  65698. * This class can be used to easily import assets into a scene
  65699. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65700. */
  65701. export class AssetsManager {
  65702. private _scene;
  65703. private _isLoading;
  65704. protected _tasks: AbstractAssetTask[];
  65705. protected _waitingTasksCount: number;
  65706. protected _totalTasksCount: number;
  65707. /**
  65708. * Callback called when all tasks are processed
  65709. */
  65710. onFinish: (tasks: AbstractAssetTask[]) => void;
  65711. /**
  65712. * Callback called when a task is successful
  65713. */
  65714. onTaskSuccess: (task: AbstractAssetTask) => void;
  65715. /**
  65716. * Callback called when a task had an error
  65717. */
  65718. onTaskError: (task: AbstractAssetTask) => void;
  65719. /**
  65720. * Callback called when a task is done (whatever the result is)
  65721. */
  65722. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65723. /**
  65724. * Observable called when all tasks are processed
  65725. */
  65726. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65727. /**
  65728. * Observable called when a task had an error
  65729. */
  65730. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65731. /**
  65732. * Observable called when all tasks were executed
  65733. */
  65734. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65735. /**
  65736. * Observable called when a task is done (whatever the result is)
  65737. */
  65738. onProgressObservable: Observable<IAssetsProgressEvent>;
  65739. /**
  65740. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65742. */
  65743. useDefaultLoadingScreen: boolean;
  65744. /**
  65745. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65746. * when all assets have been downloaded.
  65747. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65748. */
  65749. autoHideLoadingUI: boolean;
  65750. /**
  65751. * Creates a new AssetsManager
  65752. * @param scene defines the scene to work on
  65753. */
  65754. constructor(scene: Scene);
  65755. /**
  65756. * Add a MeshAssetTask to the list of active tasks
  65757. * @param taskName defines the name of the new task
  65758. * @param meshesNames defines the name of meshes to load
  65759. * @param rootUrl defines the root url to use to locate files
  65760. * @param sceneFilename defines the filename of the scene file
  65761. * @returns a new MeshAssetTask object
  65762. */
  65763. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65764. /**
  65765. * Add a TextFileAssetTask to the list of active tasks
  65766. * @param taskName defines the name of the new task
  65767. * @param url defines the url of the file to load
  65768. * @returns a new TextFileAssetTask object
  65769. */
  65770. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65771. /**
  65772. * Add a BinaryFileAssetTask to the list of active tasks
  65773. * @param taskName defines the name of the new task
  65774. * @param url defines the url of the file to load
  65775. * @returns a new BinaryFileAssetTask object
  65776. */
  65777. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65778. /**
  65779. * Add a ImageAssetTask to the list of active tasks
  65780. * @param taskName defines the name of the new task
  65781. * @param url defines the url of the file to load
  65782. * @returns a new ImageAssetTask object
  65783. */
  65784. addImageTask(taskName: string, url: string): ImageAssetTask;
  65785. /**
  65786. * Add a TextureAssetTask to the list of active tasks
  65787. * @param taskName defines the name of the new task
  65788. * @param url defines the url of the file to load
  65789. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65790. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65791. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65792. * @returns a new TextureAssetTask object
  65793. */
  65794. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65795. /**
  65796. * Add a CubeTextureAssetTask to the list of active tasks
  65797. * @param taskName defines the name of the new task
  65798. * @param url defines the url of the file to load
  65799. * @param extensions defines the extension to use to load the cube map (can be null)
  65800. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65801. * @param files defines the list of files to load (can be null)
  65802. * @returns a new CubeTextureAssetTask object
  65803. */
  65804. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65805. /**
  65806. *
  65807. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65808. * @param taskName defines the name of the new task
  65809. * @param url defines the url of the file to load
  65810. * @param size defines the size you want for the cubemap (can be null)
  65811. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65812. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65813. * @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)
  65814. * @param reserved Internal use only
  65815. * @returns a new HDRCubeTextureAssetTask object
  65816. */
  65817. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65818. /**
  65819. *
  65820. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65821. * @param taskName defines the name of the new task
  65822. * @param url defines the url of the file to load
  65823. * @param size defines the size you want for the cubemap (can be null)
  65824. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65825. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65826. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65827. * @returns a new EquiRectangularCubeTextureAssetTask object
  65828. */
  65829. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65830. /**
  65831. * Remove a task from the assets manager.
  65832. * @param task the task to remove
  65833. */
  65834. removeTask(task: AbstractAssetTask): void;
  65835. private _decreaseWaitingTasksCount;
  65836. private _runTask;
  65837. /**
  65838. * Reset the AssetsManager and remove all tasks
  65839. * @return the current instance of the AssetsManager
  65840. */
  65841. reset(): AssetsManager;
  65842. /**
  65843. * Start the loading process
  65844. * @return the current instance of the AssetsManager
  65845. */
  65846. load(): AssetsManager;
  65847. /**
  65848. * Start the loading process as an async operation
  65849. * @return a promise returning the list of failed tasks
  65850. */
  65851. loadAsync(): Promise<void>;
  65852. }
  65853. }
  65854. declare module "babylonjs/Misc/deferred" {
  65855. /**
  65856. * Wrapper class for promise with external resolve and reject.
  65857. */
  65858. export class Deferred<T> {
  65859. /**
  65860. * The promise associated with this deferred object.
  65861. */
  65862. readonly promise: Promise<T>;
  65863. private _resolve;
  65864. private _reject;
  65865. /**
  65866. * The resolve method of the promise associated with this deferred object.
  65867. */
  65868. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65869. /**
  65870. * The reject method of the promise associated with this deferred object.
  65871. */
  65872. readonly reject: (reason?: any) => void;
  65873. /**
  65874. * Constructor for this deferred object.
  65875. */
  65876. constructor();
  65877. }
  65878. }
  65879. declare module "babylonjs/Misc/meshExploder" {
  65880. import { Mesh } from "babylonjs/Meshes/mesh";
  65881. /**
  65882. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65883. */
  65884. export class MeshExploder {
  65885. private _centerMesh;
  65886. private _meshes;
  65887. private _meshesOrigins;
  65888. private _toCenterVectors;
  65889. private _scaledDirection;
  65890. private _newPosition;
  65891. private _centerPosition;
  65892. /**
  65893. * Explodes meshes from a center mesh.
  65894. * @param meshes The meshes to explode.
  65895. * @param centerMesh The mesh to be center of explosion.
  65896. */
  65897. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65898. private _setCenterMesh;
  65899. /**
  65900. * Get class name
  65901. * @returns "MeshExploder"
  65902. */
  65903. getClassName(): string;
  65904. /**
  65905. * "Exploded meshes"
  65906. * @returns Array of meshes with the centerMesh at index 0.
  65907. */
  65908. getMeshes(): Array<Mesh>;
  65909. /**
  65910. * Explodes meshes giving a specific direction
  65911. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65912. */
  65913. explode(direction?: number): void;
  65914. }
  65915. }
  65916. declare module "babylonjs/Misc/filesInput" {
  65917. import { Engine } from "babylonjs/Engines/engine";
  65918. import { Scene } from "babylonjs/scene";
  65919. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65920. /**
  65921. * Class used to help managing file picking and drag'n'drop
  65922. */
  65923. export class FilesInput {
  65924. /**
  65925. * List of files ready to be loaded
  65926. */
  65927. static readonly FilesToLoad: {
  65928. [key: string]: File;
  65929. };
  65930. /**
  65931. * Callback called when a file is processed
  65932. */
  65933. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65934. private _engine;
  65935. private _currentScene;
  65936. private _sceneLoadedCallback;
  65937. private _progressCallback;
  65938. private _additionalRenderLoopLogicCallback;
  65939. private _textureLoadingCallback;
  65940. private _startingProcessingFilesCallback;
  65941. private _onReloadCallback;
  65942. private _errorCallback;
  65943. private _elementToMonitor;
  65944. private _sceneFileToLoad;
  65945. private _filesToLoad;
  65946. /**
  65947. * Creates a new FilesInput
  65948. * @param engine defines the rendering engine
  65949. * @param scene defines the hosting scene
  65950. * @param sceneLoadedCallback callback called when scene is loaded
  65951. * @param progressCallback callback called to track progress
  65952. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65953. * @param textureLoadingCallback callback called when a texture is loading
  65954. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65955. * @param onReloadCallback callback called when a reload is requested
  65956. * @param errorCallback callback call if an error occurs
  65957. */
  65958. 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);
  65959. private _dragEnterHandler;
  65960. private _dragOverHandler;
  65961. private _dropHandler;
  65962. /**
  65963. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65964. * @param elementToMonitor defines the DOM element to track
  65965. */
  65966. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65967. /**
  65968. * Release all associated resources
  65969. */
  65970. dispose(): void;
  65971. private renderFunction;
  65972. private drag;
  65973. private drop;
  65974. private _traverseFolder;
  65975. private _processFiles;
  65976. /**
  65977. * Load files from a drop event
  65978. * @param event defines the drop event to use as source
  65979. */
  65980. loadFiles(event: any): void;
  65981. private _processReload;
  65982. /**
  65983. * Reload the current scene from the loaded files
  65984. */
  65985. reload(): void;
  65986. }
  65987. }
  65988. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65989. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65990. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65991. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65992. }
  65993. declare module "babylonjs/Misc/sceneOptimizer" {
  65994. import { Scene, IDisposable } from "babylonjs/scene";
  65995. import { Observable } from "babylonjs/Misc/observable";
  65996. /**
  65997. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65999. */
  66000. export class SceneOptimization {
  66001. /**
  66002. * Defines the priority of this optimization (0 by default which means first in the list)
  66003. */
  66004. priority: number;
  66005. /**
  66006. * Gets a string describing the action executed by the current optimization
  66007. * @returns description string
  66008. */
  66009. getDescription(): string;
  66010. /**
  66011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66012. * @param scene defines the current scene where to apply this optimization
  66013. * @param optimizer defines the current optimizer
  66014. * @returns true if everything that can be done was applied
  66015. */
  66016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66017. /**
  66018. * Creates the SceneOptimization object
  66019. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66020. * @param desc defines the description associated with the optimization
  66021. */
  66022. constructor(
  66023. /**
  66024. * Defines the priority of this optimization (0 by default which means first in the list)
  66025. */
  66026. priority?: number);
  66027. }
  66028. /**
  66029. * Defines an optimization used to reduce the size of render target textures
  66030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66031. */
  66032. export class TextureOptimization extends SceneOptimization {
  66033. /**
  66034. * Defines the priority of this optimization (0 by default which means first in the list)
  66035. */
  66036. priority: number;
  66037. /**
  66038. * 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
  66039. */
  66040. maximumSize: number;
  66041. /**
  66042. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66043. */
  66044. step: number;
  66045. /**
  66046. * Gets a string describing the action executed by the current optimization
  66047. * @returns description string
  66048. */
  66049. getDescription(): string;
  66050. /**
  66051. * Creates the TextureOptimization object
  66052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66053. * @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
  66054. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66055. */
  66056. constructor(
  66057. /**
  66058. * Defines the priority of this optimization (0 by default which means first in the list)
  66059. */
  66060. priority?: number,
  66061. /**
  66062. * 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
  66063. */
  66064. maximumSize?: number,
  66065. /**
  66066. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66067. */
  66068. step?: number);
  66069. /**
  66070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66071. * @param scene defines the current scene where to apply this optimization
  66072. * @param optimizer defines the current optimizer
  66073. * @returns true if everything that can be done was applied
  66074. */
  66075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66076. }
  66077. /**
  66078. * Defines an optimization used to increase or decrease the rendering resolution
  66079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66080. */
  66081. export class HardwareScalingOptimization extends SceneOptimization {
  66082. /**
  66083. * Defines the priority of this optimization (0 by default which means first in the list)
  66084. */
  66085. priority: number;
  66086. /**
  66087. * Defines the maximum scale to use (2 by default)
  66088. */
  66089. maximumScale: number;
  66090. /**
  66091. * Defines the step to use between two passes (0.5 by default)
  66092. */
  66093. step: number;
  66094. private _currentScale;
  66095. private _directionOffset;
  66096. /**
  66097. * Gets a string describing the action executed by the current optimization
  66098. * @return description string
  66099. */
  66100. getDescription(): string;
  66101. /**
  66102. * Creates the HardwareScalingOptimization object
  66103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66104. * @param maximumScale defines the maximum scale to use (2 by default)
  66105. * @param step defines the step to use between two passes (0.5 by default)
  66106. */
  66107. constructor(
  66108. /**
  66109. * Defines the priority of this optimization (0 by default which means first in the list)
  66110. */
  66111. priority?: number,
  66112. /**
  66113. * Defines the maximum scale to use (2 by default)
  66114. */
  66115. maximumScale?: number,
  66116. /**
  66117. * Defines the step to use between two passes (0.5 by default)
  66118. */
  66119. step?: number);
  66120. /**
  66121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66122. * @param scene defines the current scene where to apply this optimization
  66123. * @param optimizer defines the current optimizer
  66124. * @returns true if everything that can be done was applied
  66125. */
  66126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66127. }
  66128. /**
  66129. * Defines an optimization used to remove shadows
  66130. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66131. */
  66132. export class ShadowsOptimization extends SceneOptimization {
  66133. /**
  66134. * Gets a string describing the action executed by the current optimization
  66135. * @return description string
  66136. */
  66137. getDescription(): string;
  66138. /**
  66139. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66140. * @param scene defines the current scene where to apply this optimization
  66141. * @param optimizer defines the current optimizer
  66142. * @returns true if everything that can be done was applied
  66143. */
  66144. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66145. }
  66146. /**
  66147. * Defines an optimization used to turn post-processes off
  66148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66149. */
  66150. export class PostProcessesOptimization extends SceneOptimization {
  66151. /**
  66152. * Gets a string describing the action executed by the current optimization
  66153. * @return description string
  66154. */
  66155. getDescription(): string;
  66156. /**
  66157. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66158. * @param scene defines the current scene where to apply this optimization
  66159. * @param optimizer defines the current optimizer
  66160. * @returns true if everything that can be done was applied
  66161. */
  66162. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66163. }
  66164. /**
  66165. * Defines an optimization used to turn lens flares off
  66166. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66167. */
  66168. export class LensFlaresOptimization extends SceneOptimization {
  66169. /**
  66170. * Gets a string describing the action executed by the current optimization
  66171. * @return description string
  66172. */
  66173. getDescription(): string;
  66174. /**
  66175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66176. * @param scene defines the current scene where to apply this optimization
  66177. * @param optimizer defines the current optimizer
  66178. * @returns true if everything that can be done was applied
  66179. */
  66180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66181. }
  66182. /**
  66183. * Defines an optimization based on user defined callback.
  66184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66185. */
  66186. export class CustomOptimization extends SceneOptimization {
  66187. /**
  66188. * Callback called to apply the custom optimization.
  66189. */
  66190. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66191. /**
  66192. * Callback called to get custom description
  66193. */
  66194. onGetDescription: () => string;
  66195. /**
  66196. * Gets a string describing the action executed by the current optimization
  66197. * @returns description string
  66198. */
  66199. getDescription(): string;
  66200. /**
  66201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66202. * @param scene defines the current scene where to apply this optimization
  66203. * @param optimizer defines the current optimizer
  66204. * @returns true if everything that can be done was applied
  66205. */
  66206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66207. }
  66208. /**
  66209. * Defines an optimization used to turn particles off
  66210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66211. */
  66212. export class ParticlesOptimization extends SceneOptimization {
  66213. /**
  66214. * Gets a string describing the action executed by the current optimization
  66215. * @return description string
  66216. */
  66217. getDescription(): string;
  66218. /**
  66219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66220. * @param scene defines the current scene where to apply this optimization
  66221. * @param optimizer defines the current optimizer
  66222. * @returns true if everything that can be done was applied
  66223. */
  66224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66225. }
  66226. /**
  66227. * Defines an optimization used to turn render targets off
  66228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66229. */
  66230. export class RenderTargetsOptimization extends SceneOptimization {
  66231. /**
  66232. * Gets a string describing the action executed by the current optimization
  66233. * @return description string
  66234. */
  66235. getDescription(): string;
  66236. /**
  66237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66238. * @param scene defines the current scene where to apply this optimization
  66239. * @param optimizer defines the current optimizer
  66240. * @returns true if everything that can be done was applied
  66241. */
  66242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66243. }
  66244. /**
  66245. * Defines an optimization used to merge meshes with compatible materials
  66246. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66247. */
  66248. export class MergeMeshesOptimization extends SceneOptimization {
  66249. private static _UpdateSelectionTree;
  66250. /**
  66251. * Gets or sets a boolean which defines if optimization octree has to be updated
  66252. */
  66253. /**
  66254. * Gets or sets a boolean which defines if optimization octree has to be updated
  66255. */
  66256. static UpdateSelectionTree: boolean;
  66257. /**
  66258. * Gets a string describing the action executed by the current optimization
  66259. * @return description string
  66260. */
  66261. getDescription(): string;
  66262. private _canBeMerged;
  66263. /**
  66264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66265. * @param scene defines the current scene where to apply this optimization
  66266. * @param optimizer defines the current optimizer
  66267. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66268. * @returns true if everything that can be done was applied
  66269. */
  66270. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66271. }
  66272. /**
  66273. * Defines a list of options used by SceneOptimizer
  66274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66275. */
  66276. export class SceneOptimizerOptions {
  66277. /**
  66278. * Defines the target frame rate to reach (60 by default)
  66279. */
  66280. targetFrameRate: number;
  66281. /**
  66282. * Defines the interval between two checkes (2000ms by default)
  66283. */
  66284. trackerDuration: number;
  66285. /**
  66286. * Gets the list of optimizations to apply
  66287. */
  66288. optimizations: SceneOptimization[];
  66289. /**
  66290. * Creates a new list of options used by SceneOptimizer
  66291. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66292. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66293. */
  66294. constructor(
  66295. /**
  66296. * Defines the target frame rate to reach (60 by default)
  66297. */
  66298. targetFrameRate?: number,
  66299. /**
  66300. * Defines the interval between two checkes (2000ms by default)
  66301. */
  66302. trackerDuration?: number);
  66303. /**
  66304. * Add a new optimization
  66305. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66306. * @returns the current SceneOptimizerOptions
  66307. */
  66308. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66309. /**
  66310. * Add a new custom optimization
  66311. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66312. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66313. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66314. * @returns the current SceneOptimizerOptions
  66315. */
  66316. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66317. /**
  66318. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66319. * @param targetFrameRate defines the target frame rate (60 by default)
  66320. * @returns a SceneOptimizerOptions object
  66321. */
  66322. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66323. /**
  66324. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66325. * @param targetFrameRate defines the target frame rate (60 by default)
  66326. * @returns a SceneOptimizerOptions object
  66327. */
  66328. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66329. /**
  66330. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66331. * @param targetFrameRate defines the target frame rate (60 by default)
  66332. * @returns a SceneOptimizerOptions object
  66333. */
  66334. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66335. }
  66336. /**
  66337. * Class used to run optimizations in order to reach a target frame rate
  66338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66339. */
  66340. export class SceneOptimizer implements IDisposable {
  66341. private _isRunning;
  66342. private _options;
  66343. private _scene;
  66344. private _currentPriorityLevel;
  66345. private _targetFrameRate;
  66346. private _trackerDuration;
  66347. private _currentFrameRate;
  66348. private _sceneDisposeObserver;
  66349. private _improvementMode;
  66350. /**
  66351. * Defines an observable called when the optimizer reaches the target frame rate
  66352. */
  66353. onSuccessObservable: Observable<SceneOptimizer>;
  66354. /**
  66355. * Defines an observable called when the optimizer enables an optimization
  66356. */
  66357. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66358. /**
  66359. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66360. */
  66361. onFailureObservable: Observable<SceneOptimizer>;
  66362. /**
  66363. * Gets a boolean indicating if the optimizer is in improvement mode
  66364. */
  66365. readonly isInImprovementMode: boolean;
  66366. /**
  66367. * Gets the current priority level (0 at start)
  66368. */
  66369. readonly currentPriorityLevel: number;
  66370. /**
  66371. * Gets the current frame rate checked by the SceneOptimizer
  66372. */
  66373. readonly currentFrameRate: number;
  66374. /**
  66375. * Gets or sets the current target frame rate (60 by default)
  66376. */
  66377. /**
  66378. * Gets or sets the current target frame rate (60 by default)
  66379. */
  66380. targetFrameRate: number;
  66381. /**
  66382. * Gets or sets the current interval between two checks (every 2000ms by default)
  66383. */
  66384. /**
  66385. * Gets or sets the current interval between two checks (every 2000ms by default)
  66386. */
  66387. trackerDuration: number;
  66388. /**
  66389. * Gets the list of active optimizations
  66390. */
  66391. readonly optimizations: SceneOptimization[];
  66392. /**
  66393. * Creates a new SceneOptimizer
  66394. * @param scene defines the scene to work on
  66395. * @param options defines the options to use with the SceneOptimizer
  66396. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66397. * @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)
  66398. */
  66399. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66400. /**
  66401. * Stops the current optimizer
  66402. */
  66403. stop(): void;
  66404. /**
  66405. * Reset the optimizer to initial step (current priority level = 0)
  66406. */
  66407. reset(): void;
  66408. /**
  66409. * Start the optimizer. By default it will try to reach a specific framerate
  66410. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66411. */
  66412. start(): void;
  66413. private _checkCurrentState;
  66414. /**
  66415. * Release all resources
  66416. */
  66417. dispose(): void;
  66418. /**
  66419. * Helper function to create a SceneOptimizer with one single line of code
  66420. * @param scene defines the scene to work on
  66421. * @param options defines the options to use with the SceneOptimizer
  66422. * @param onSuccess defines a callback to call on success
  66423. * @param onFailure defines a callback to call on failure
  66424. * @returns the new SceneOptimizer object
  66425. */
  66426. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66427. }
  66428. }
  66429. declare module "babylonjs/Misc/sceneSerializer" {
  66430. import { Scene } from "babylonjs/scene";
  66431. /**
  66432. * Class used to serialize a scene into a string
  66433. */
  66434. export class SceneSerializer {
  66435. /**
  66436. * Clear cache used by a previous serialization
  66437. */
  66438. static ClearCache(): void;
  66439. /**
  66440. * Serialize a scene into a JSON compatible object
  66441. * @param scene defines the scene to serialize
  66442. * @returns a JSON compatible object
  66443. */
  66444. static Serialize(scene: Scene): any;
  66445. /**
  66446. * Serialize a mesh into a JSON compatible object
  66447. * @param toSerialize defines the mesh to serialize
  66448. * @param withParents defines if parents must be serialized as well
  66449. * @param withChildren defines if children must be serialized as well
  66450. * @returns a JSON compatible object
  66451. */
  66452. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66453. }
  66454. }
  66455. declare module "babylonjs/Misc/textureTools" {
  66456. import { Texture } from "babylonjs/Materials/Textures/texture";
  66457. /**
  66458. * Class used to host texture specific utilities
  66459. */
  66460. export class TextureTools {
  66461. /**
  66462. * Uses the GPU to create a copy texture rescaled at a given size
  66463. * @param texture Texture to copy from
  66464. * @param width defines the desired width
  66465. * @param height defines the desired height
  66466. * @param useBilinearMode defines if bilinear mode has to be used
  66467. * @return the generated texture
  66468. */
  66469. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66470. }
  66471. }
  66472. declare module "babylonjs/Misc/videoRecorder" {
  66473. import { Nullable } from "babylonjs/types";
  66474. import { Engine } from "babylonjs/Engines/engine";
  66475. /**
  66476. * This represents the different options available for the video capture.
  66477. */
  66478. export interface VideoRecorderOptions {
  66479. /** Defines the mime type of the video. */
  66480. mimeType: string;
  66481. /** Defines the FPS the video should be recorded at. */
  66482. fps: number;
  66483. /** Defines the chunk size for the recording data. */
  66484. recordChunckSize: number;
  66485. /** The audio tracks to attach to the recording. */
  66486. audioTracks?: MediaStreamTrack[];
  66487. }
  66488. /**
  66489. * This can help with recording videos from BabylonJS.
  66490. * This is based on the available WebRTC functionalities of the browser.
  66491. *
  66492. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66493. */
  66494. export class VideoRecorder {
  66495. private static readonly _defaultOptions;
  66496. /**
  66497. * Returns whether or not the VideoRecorder is available in your browser.
  66498. * @param engine Defines the Babylon Engine.
  66499. * @returns true if supported otherwise false.
  66500. */
  66501. static IsSupported(engine: Engine): boolean;
  66502. private readonly _options;
  66503. private _canvas;
  66504. private _mediaRecorder;
  66505. private _recordedChunks;
  66506. private _fileName;
  66507. private _resolve;
  66508. private _reject;
  66509. /**
  66510. * True when a recording is already in progress.
  66511. */
  66512. readonly isRecording: boolean;
  66513. /**
  66514. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66515. * @param engine Defines the BabylonJS Engine you wish to record.
  66516. * @param options Defines options that can be used to customize the capture.
  66517. */
  66518. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66519. /**
  66520. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66521. */
  66522. stopRecording(): void;
  66523. /**
  66524. * Starts recording the canvas for a max duration specified in parameters.
  66525. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66526. * If null no automatic download will start and you can rely on the promise to get the data back.
  66527. * @param maxDuration Defines the maximum recording time in seconds.
  66528. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66529. * @return A promise callback at the end of the recording with the video data in Blob.
  66530. */
  66531. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66532. /**
  66533. * Releases internal resources used during the recording.
  66534. */
  66535. dispose(): void;
  66536. private _handleDataAvailable;
  66537. private _handleError;
  66538. private _handleStop;
  66539. }
  66540. }
  66541. declare module "babylonjs/Misc/screenshotTools" {
  66542. import { Camera } from "babylonjs/Cameras/camera";
  66543. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66544. import { Engine } from "babylonjs/Engines/engine";
  66545. /**
  66546. * Class containing a set of static utilities functions for screenshots
  66547. */
  66548. export class ScreenshotTools {
  66549. /**
  66550. * Captures a screenshot of the current rendering
  66551. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66552. * @param engine defines the rendering engine
  66553. * @param camera defines the source camera
  66554. * @param size This parameter can be set to a single number or to an object with the
  66555. * following (optional) properties: precision, width, height. If a single number is passed,
  66556. * it will be used for both width and height. If an object is passed, the screenshot size
  66557. * will be derived from the parameters. The precision property is a multiplier allowing
  66558. * rendering at a higher or lower resolution
  66559. * @param successCallback defines the callback receives a single parameter which contains the
  66560. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66561. * src parameter of an <img> to display it
  66562. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66563. * Check your browser for supported MIME types
  66564. */
  66565. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66566. /**
  66567. * Captures a screenshot of the current rendering
  66568. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66569. * @param engine defines the rendering engine
  66570. * @param camera defines the source camera
  66571. * @param size This parameter can be set to a single number or to an object with the
  66572. * following (optional) properties: precision, width, height. If a single number is passed,
  66573. * it will be used for both width and height. If an object is passed, the screenshot size
  66574. * will be derived from the parameters. The precision property is a multiplier allowing
  66575. * rendering at a higher or lower resolution
  66576. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66577. * Check your browser for supported MIME types
  66578. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66579. * to the src parameter of an <img> to display it
  66580. */
  66581. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66582. /**
  66583. * Generates an image screenshot from the specified camera.
  66584. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66585. * @param engine The engine to use for rendering
  66586. * @param camera The camera to use for rendering
  66587. * @param size This parameter can be set to a single number or to an object with the
  66588. * following (optional) properties: precision, width, height. If a single number is passed,
  66589. * it will be used for both width and height. If an object is passed, the screenshot size
  66590. * will be derived from the parameters. The precision property is a multiplier allowing
  66591. * rendering at a higher or lower resolution
  66592. * @param successCallback The callback receives a single parameter which contains the
  66593. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66594. * src parameter of an <img> to display it
  66595. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66596. * Check your browser for supported MIME types
  66597. * @param samples Texture samples (default: 1)
  66598. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66599. * @param fileName A name for for the downloaded file.
  66600. */
  66601. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66602. /**
  66603. * Generates an image screenshot from the specified camera.
  66604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66605. * @param engine The engine to use for rendering
  66606. * @param camera The camera to use for rendering
  66607. * @param size This parameter can be set to a single number or to an object with the
  66608. * following (optional) properties: precision, width, height. If a single number is passed,
  66609. * it will be used for both width and height. If an object is passed, the screenshot size
  66610. * will be derived from the parameters. The precision property is a multiplier allowing
  66611. * rendering at a higher or lower resolution
  66612. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66613. * Check your browser for supported MIME types
  66614. * @param samples Texture samples (default: 1)
  66615. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66616. * @param fileName A name for for the downloaded file.
  66617. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66618. * to the src parameter of an <img> to display it
  66619. */
  66620. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66621. /**
  66622. * Gets height and width for screenshot size
  66623. * @private
  66624. */
  66625. private static _getScreenshotSize;
  66626. }
  66627. }
  66628. declare module "babylonjs/Misc/index" {
  66629. export * from "babylonjs/Misc/andOrNotEvaluator";
  66630. export * from "babylonjs/Misc/assetsManager";
  66631. export * from "babylonjs/Misc/dds";
  66632. export * from "babylonjs/Misc/decorators";
  66633. export * from "babylonjs/Misc/deferred";
  66634. export * from "babylonjs/Misc/environmentTextureTools";
  66635. export * from "babylonjs/Misc/meshExploder";
  66636. export * from "babylonjs/Misc/filesInput";
  66637. export * from "babylonjs/Misc/HighDynamicRange/index";
  66638. export * from "babylonjs/Misc/khronosTextureContainer";
  66639. export * from "babylonjs/Misc/observable";
  66640. export * from "babylonjs/Misc/performanceMonitor";
  66641. export * from "babylonjs/Misc/promise";
  66642. export * from "babylonjs/Misc/sceneOptimizer";
  66643. export * from "babylonjs/Misc/sceneSerializer";
  66644. export * from "babylonjs/Misc/smartArray";
  66645. export * from "babylonjs/Misc/stringDictionary";
  66646. export * from "babylonjs/Misc/tags";
  66647. export * from "babylonjs/Misc/textureTools";
  66648. export * from "babylonjs/Misc/tga";
  66649. export * from "babylonjs/Misc/tools";
  66650. export * from "babylonjs/Misc/videoRecorder";
  66651. export * from "babylonjs/Misc/virtualJoystick";
  66652. export * from "babylonjs/Misc/workerPool";
  66653. export * from "babylonjs/Misc/logger";
  66654. export * from "babylonjs/Misc/typeStore";
  66655. export * from "babylonjs/Misc/filesInputStore";
  66656. export * from "babylonjs/Misc/deepCopier";
  66657. export * from "babylonjs/Misc/pivotTools";
  66658. export * from "babylonjs/Misc/precisionDate";
  66659. export * from "babylonjs/Misc/screenshotTools";
  66660. export * from "babylonjs/Misc/typeStore";
  66661. export * from "babylonjs/Misc/webRequest";
  66662. export * from "babylonjs/Misc/iInspectable";
  66663. export * from "babylonjs/Misc/brdfTextureTools";
  66664. export * from "babylonjs/Misc/rgbdTextureTools";
  66665. export * from "babylonjs/Misc/gradients";
  66666. export * from "babylonjs/Misc/perfCounter";
  66667. export * from "babylonjs/Misc/fileRequest";
  66668. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66669. export * from "babylonjs/Misc/retryStrategy";
  66670. export * from "babylonjs/Misc/loadFileError";
  66671. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66672. }
  66673. declare module "babylonjs/index" {
  66674. export * from "babylonjs/abstractScene";
  66675. export * from "babylonjs/Actions/index";
  66676. export * from "babylonjs/Animations/index";
  66677. export * from "babylonjs/assetContainer";
  66678. export * from "babylonjs/Audio/index";
  66679. export * from "babylonjs/Behaviors/index";
  66680. export * from "babylonjs/Bones/index";
  66681. export * from "babylonjs/Cameras/index";
  66682. export * from "babylonjs/Collisions/index";
  66683. export * from "babylonjs/Culling/index";
  66684. export * from "babylonjs/Debug/index";
  66685. export * from "babylonjs/Engines/index";
  66686. export * from "babylonjs/Events/index";
  66687. export * from "babylonjs/Gamepads/index";
  66688. export * from "babylonjs/Gizmos/index";
  66689. export * from "babylonjs/Helpers/index";
  66690. export * from "babylonjs/Instrumentation/index";
  66691. export * from "babylonjs/Layers/index";
  66692. export * from "babylonjs/LensFlares/index";
  66693. export * from "babylonjs/Lights/index";
  66694. export * from "babylonjs/Loading/index";
  66695. export * from "babylonjs/Materials/index";
  66696. export * from "babylonjs/Maths/index";
  66697. export * from "babylonjs/Meshes/index";
  66698. export * from "babylonjs/Morph/index";
  66699. export * from "babylonjs/Navigation/index";
  66700. export * from "babylonjs/node";
  66701. export * from "babylonjs/Offline/index";
  66702. export * from "babylonjs/Particles/index";
  66703. export * from "babylonjs/Physics/index";
  66704. export * from "babylonjs/PostProcesses/index";
  66705. export * from "babylonjs/Probes/index";
  66706. export * from "babylonjs/Rendering/index";
  66707. export * from "babylonjs/scene";
  66708. export * from "babylonjs/sceneComponent";
  66709. export * from "babylonjs/Sprites/index";
  66710. export * from "babylonjs/States/index";
  66711. export * from "babylonjs/Misc/index";
  66712. export * from "babylonjs/types";
  66713. }
  66714. declare module "babylonjs/Animations/pathCursor" {
  66715. import { Vector3 } from "babylonjs/Maths/math.vector";
  66716. import { Path2 } from "babylonjs/Maths/math.path";
  66717. /**
  66718. * A cursor which tracks a point on a path
  66719. */
  66720. export class PathCursor {
  66721. private path;
  66722. /**
  66723. * Stores path cursor callbacks for when an onchange event is triggered
  66724. */
  66725. private _onchange;
  66726. /**
  66727. * The value of the path cursor
  66728. */
  66729. value: number;
  66730. /**
  66731. * The animation array of the path cursor
  66732. */
  66733. animations: Animation[];
  66734. /**
  66735. * Initializes the path cursor
  66736. * @param path The path to track
  66737. */
  66738. constructor(path: Path2);
  66739. /**
  66740. * Gets the cursor point on the path
  66741. * @returns A point on the path cursor at the cursor location
  66742. */
  66743. getPoint(): Vector3;
  66744. /**
  66745. * Moves the cursor ahead by the step amount
  66746. * @param step The amount to move the cursor forward
  66747. * @returns This path cursor
  66748. */
  66749. moveAhead(step?: number): PathCursor;
  66750. /**
  66751. * Moves the cursor behind by the step amount
  66752. * @param step The amount to move the cursor back
  66753. * @returns This path cursor
  66754. */
  66755. moveBack(step?: number): PathCursor;
  66756. /**
  66757. * Moves the cursor by the step amount
  66758. * If the step amount is greater than one, an exception is thrown
  66759. * @param step The amount to move the cursor
  66760. * @returns This path cursor
  66761. */
  66762. move(step: number): PathCursor;
  66763. /**
  66764. * Ensures that the value is limited between zero and one
  66765. * @returns This path cursor
  66766. */
  66767. private ensureLimits;
  66768. /**
  66769. * Runs onchange callbacks on change (used by the animation engine)
  66770. * @returns This path cursor
  66771. */
  66772. private raiseOnChange;
  66773. /**
  66774. * Executes a function on change
  66775. * @param f A path cursor onchange callback
  66776. * @returns This path cursor
  66777. */
  66778. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66779. }
  66780. }
  66781. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66782. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66783. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66784. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66785. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66786. }
  66787. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66788. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66789. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66790. }
  66791. declare module "babylonjs/Engines/Processors/index" {
  66792. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66793. export * from "babylonjs/Engines/Processors/Expressions/index";
  66794. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66795. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66796. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66797. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66798. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66799. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66800. }
  66801. declare module "babylonjs/Legacy/legacy" {
  66802. import * as Babylon from "babylonjs/index";
  66803. export * from "babylonjs/index";
  66804. }
  66805. declare module "babylonjs/Shaders/blur.fragment" {
  66806. /** @hidden */
  66807. export var blurPixelShader: {
  66808. name: string;
  66809. shader: string;
  66810. };
  66811. }
  66812. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66813. /** @hidden */
  66814. export var pointCloudVertexDeclaration: {
  66815. name: string;
  66816. shader: string;
  66817. };
  66818. }
  66819. declare module "babylonjs" {
  66820. export * from "babylonjs/Legacy/legacy";
  66821. }
  66822. declare module BABYLON {
  66823. /** Alias type for value that can be null */
  66824. export type Nullable<T> = T | null;
  66825. /**
  66826. * Alias type for number that are floats
  66827. * @ignorenaming
  66828. */
  66829. export type float = number;
  66830. /**
  66831. * Alias type for number that are doubles.
  66832. * @ignorenaming
  66833. */
  66834. export type double = number;
  66835. /**
  66836. * Alias type for number that are integer
  66837. * @ignorenaming
  66838. */
  66839. export type int = number;
  66840. /** Alias type for number array or Float32Array */
  66841. export type FloatArray = number[] | Float32Array;
  66842. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66843. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66844. /**
  66845. * Alias for types that can be used by a Buffer or VertexBuffer.
  66846. */
  66847. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66848. /**
  66849. * Alias type for primitive types
  66850. * @ignorenaming
  66851. */
  66852. type Primitive = undefined | null | boolean | string | number | Function;
  66853. /**
  66854. * Type modifier to make all the properties of an object Readonly
  66855. */
  66856. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66857. /**
  66858. * Type modifier to make all the properties of an object Readonly recursively
  66859. */
  66860. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66861. /**
  66862. * Type modifier to make object properties readonly.
  66863. */
  66864. export type DeepImmutableObject<T> = {
  66865. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66866. };
  66867. /** @hidden */
  66868. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /**
  66873. * A class serves as a medium between the observable and its observers
  66874. */
  66875. export class EventState {
  66876. /**
  66877. * Create a new EventState
  66878. * @param mask defines the mask associated with this state
  66879. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66880. * @param target defines the original target of the state
  66881. * @param currentTarget defines the current target of the state
  66882. */
  66883. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66884. /**
  66885. * Initialize the current event state
  66886. * @param mask defines the mask associated with this state
  66887. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66888. * @param target defines the original target of the state
  66889. * @param currentTarget defines the current target of the state
  66890. * @returns the current event state
  66891. */
  66892. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66893. /**
  66894. * An Observer can set this property to true to prevent subsequent observers of being notified
  66895. */
  66896. skipNextObservers: boolean;
  66897. /**
  66898. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66899. */
  66900. mask: number;
  66901. /**
  66902. * The object that originally notified the event
  66903. */
  66904. target?: any;
  66905. /**
  66906. * The current object in the bubbling phase
  66907. */
  66908. currentTarget?: any;
  66909. /**
  66910. * This will be populated with the return value of the last function that was executed.
  66911. * If it is the first function in the callback chain it will be the event data.
  66912. */
  66913. lastReturnValue?: any;
  66914. }
  66915. /**
  66916. * Represent an Observer registered to a given Observable object.
  66917. */
  66918. export class Observer<T> {
  66919. /**
  66920. * Defines the callback to call when the observer is notified
  66921. */
  66922. callback: (eventData: T, eventState: EventState) => void;
  66923. /**
  66924. * Defines the mask of the observer (used to filter notifications)
  66925. */
  66926. mask: number;
  66927. /**
  66928. * Defines the current scope used to restore the JS context
  66929. */
  66930. scope: any;
  66931. /** @hidden */
  66932. _willBeUnregistered: boolean;
  66933. /**
  66934. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66935. */
  66936. unregisterOnNextCall: boolean;
  66937. /**
  66938. * Creates a new observer
  66939. * @param callback defines the callback to call when the observer is notified
  66940. * @param mask defines the mask of the observer (used to filter notifications)
  66941. * @param scope defines the current scope used to restore the JS context
  66942. */
  66943. constructor(
  66944. /**
  66945. * Defines the callback to call when the observer is notified
  66946. */
  66947. callback: (eventData: T, eventState: EventState) => void,
  66948. /**
  66949. * Defines the mask of the observer (used to filter notifications)
  66950. */
  66951. mask: number,
  66952. /**
  66953. * Defines the current scope used to restore the JS context
  66954. */
  66955. scope?: any);
  66956. }
  66957. /**
  66958. * Represent a list of observers registered to multiple Observables object.
  66959. */
  66960. export class MultiObserver<T> {
  66961. private _observers;
  66962. private _observables;
  66963. /**
  66964. * Release associated resources
  66965. */
  66966. dispose(): void;
  66967. /**
  66968. * Raise a callback when one of the observable will notify
  66969. * @param observables defines a list of observables to watch
  66970. * @param callback defines the callback to call on notification
  66971. * @param mask defines the mask used to filter notifications
  66972. * @param scope defines the current scope used to restore the JS context
  66973. * @returns the new MultiObserver
  66974. */
  66975. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66976. }
  66977. /**
  66978. * The Observable class is a simple implementation of the Observable pattern.
  66979. *
  66980. * 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.
  66981. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66982. * 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).
  66983. * 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.
  66984. */
  66985. export class Observable<T> {
  66986. private _observers;
  66987. private _eventState;
  66988. private _onObserverAdded;
  66989. /**
  66990. * Gets the list of observers
  66991. */
  66992. readonly observers: Array<Observer<T>>;
  66993. /**
  66994. * Creates a new observable
  66995. * @param onObserverAdded defines a callback to call when a new observer is added
  66996. */
  66997. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66998. /**
  66999. * Create a new Observer with the specified callback
  67000. * @param callback the callback that will be executed for that Observer
  67001. * @param mask the mask used to filter observers
  67002. * @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.
  67003. * @param scope optional scope for the callback to be called from
  67004. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67005. * @returns the new observer created for the callback
  67006. */
  67007. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67008. /**
  67009. * Create a new Observer with the specified callback and unregisters after the next notification
  67010. * @param callback the callback that will be executed for that Observer
  67011. * @returns the new observer created for the callback
  67012. */
  67013. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67014. /**
  67015. * Remove an Observer from the Observable object
  67016. * @param observer the instance of the Observer to remove
  67017. * @returns false if it doesn't belong to this Observable
  67018. */
  67019. remove(observer: Nullable<Observer<T>>): boolean;
  67020. /**
  67021. * Remove a callback from the Observable object
  67022. * @param callback the callback to remove
  67023. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67024. * @returns false if it doesn't belong to this Observable
  67025. */
  67026. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67027. private _deferUnregister;
  67028. private _remove;
  67029. /**
  67030. * Moves the observable to the top of the observer list making it get called first when notified
  67031. * @param observer the observer to move
  67032. */
  67033. makeObserverTopPriority(observer: Observer<T>): void;
  67034. /**
  67035. * Moves the observable to the bottom of the observer list making it get called last when notified
  67036. * @param observer the observer to move
  67037. */
  67038. makeObserverBottomPriority(observer: Observer<T>): void;
  67039. /**
  67040. * Notify all Observers by calling their respective callback with the given data
  67041. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67042. * @param eventData defines the data to send to all observers
  67043. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67044. * @param target defines the original target of the state
  67045. * @param currentTarget defines the current target of the state
  67046. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67047. */
  67048. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67049. /**
  67050. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67051. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67052. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67053. * and it is crucial that all callbacks will be executed.
  67054. * The order of the callbacks is kept, callbacks are not executed parallel.
  67055. *
  67056. * @param eventData The data to be sent to each callback
  67057. * @param mask is used to filter observers defaults to -1
  67058. * @param target defines the callback target (see EventState)
  67059. * @param currentTarget defines he current object in the bubbling phase
  67060. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67061. */
  67062. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67063. /**
  67064. * Notify a specific observer
  67065. * @param observer defines the observer to notify
  67066. * @param eventData defines the data to be sent to each callback
  67067. * @param mask is used to filter observers defaults to -1
  67068. */
  67069. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67070. /**
  67071. * Gets a boolean indicating if the observable has at least one observer
  67072. * @returns true is the Observable has at least one Observer registered
  67073. */
  67074. hasObservers(): boolean;
  67075. /**
  67076. * Clear the list of observers
  67077. */
  67078. clear(): void;
  67079. /**
  67080. * Clone the current observable
  67081. * @returns a new observable
  67082. */
  67083. clone(): Observable<T>;
  67084. /**
  67085. * Does this observable handles observer registered with a given mask
  67086. * @param mask defines the mask to be tested
  67087. * @return whether or not one observer registered with the given mask is handeled
  67088. **/
  67089. hasSpecificMask(mask?: number): boolean;
  67090. }
  67091. }
  67092. declare module BABYLON {
  67093. /**
  67094. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67095. * Babylon.js
  67096. */
  67097. export class DomManagement {
  67098. /**
  67099. * Checks if the window object exists
  67100. * @returns true if the window object exists
  67101. */
  67102. static IsWindowObjectExist(): boolean;
  67103. /**
  67104. * Checks if the navigator object exists
  67105. * @returns true if the navigator object exists
  67106. */
  67107. static IsNavigatorAvailable(): boolean;
  67108. /**
  67109. * Extracts text content from a DOM element hierarchy
  67110. * @param element defines the root element
  67111. * @returns a string
  67112. */
  67113. static GetDOMTextContent(element: HTMLElement): string;
  67114. }
  67115. }
  67116. declare module BABYLON {
  67117. /**
  67118. * Logger used througouht the application to allow configuration of
  67119. * the log level required for the messages.
  67120. */
  67121. export class Logger {
  67122. /**
  67123. * No log
  67124. */
  67125. static readonly NoneLogLevel: number;
  67126. /**
  67127. * Only message logs
  67128. */
  67129. static readonly MessageLogLevel: number;
  67130. /**
  67131. * Only warning logs
  67132. */
  67133. static readonly WarningLogLevel: number;
  67134. /**
  67135. * Only error logs
  67136. */
  67137. static readonly ErrorLogLevel: number;
  67138. /**
  67139. * All logs
  67140. */
  67141. static readonly AllLogLevel: number;
  67142. private static _LogCache;
  67143. /**
  67144. * Gets a value indicating the number of loading errors
  67145. * @ignorenaming
  67146. */
  67147. static errorsCount: number;
  67148. /**
  67149. * Callback called when a new log is added
  67150. */
  67151. static OnNewCacheEntry: (entry: string) => void;
  67152. private static _AddLogEntry;
  67153. private static _FormatMessage;
  67154. private static _LogDisabled;
  67155. private static _LogEnabled;
  67156. private static _WarnDisabled;
  67157. private static _WarnEnabled;
  67158. private static _ErrorDisabled;
  67159. private static _ErrorEnabled;
  67160. /**
  67161. * Log a message to the console
  67162. */
  67163. static Log: (message: string) => void;
  67164. /**
  67165. * Write a warning message to the console
  67166. */
  67167. static Warn: (message: string) => void;
  67168. /**
  67169. * Write an error message to the console
  67170. */
  67171. static Error: (message: string) => void;
  67172. /**
  67173. * Gets current log cache (list of logs)
  67174. */
  67175. static readonly LogCache: string;
  67176. /**
  67177. * Clears the log cache
  67178. */
  67179. static ClearLogCache(): void;
  67180. /**
  67181. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67182. */
  67183. static LogLevels: number;
  67184. }
  67185. }
  67186. declare module BABYLON {
  67187. /** @hidden */
  67188. export class _TypeStore {
  67189. /** @hidden */
  67190. static RegisteredTypes: {
  67191. [key: string]: Object;
  67192. };
  67193. /** @hidden */
  67194. static GetClass(fqdn: string): any;
  67195. }
  67196. }
  67197. declare module BABYLON {
  67198. /**
  67199. * Class containing a set of static utilities functions for deep copy.
  67200. */
  67201. export class DeepCopier {
  67202. /**
  67203. * Tries to copy an object by duplicating every property
  67204. * @param source defines the source object
  67205. * @param destination defines the target object
  67206. * @param doNotCopyList defines a list of properties to avoid
  67207. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67208. */
  67209. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /**
  67214. * Class containing a set of static utilities functions for precision date
  67215. */
  67216. export class PrecisionDate {
  67217. /**
  67218. * Gets either window.performance.now() if supported or Date.now() else
  67219. */
  67220. static readonly Now: number;
  67221. }
  67222. }
  67223. declare module BABYLON {
  67224. /** @hidden */
  67225. export class _DevTools {
  67226. static WarnImport(name: string): string;
  67227. }
  67228. }
  67229. declare module BABYLON {
  67230. /**
  67231. * Interface used to define the mechanism to get data from the network
  67232. */
  67233. export interface IWebRequest {
  67234. /**
  67235. * Returns client's response url
  67236. */
  67237. responseURL: string;
  67238. /**
  67239. * Returns client's status
  67240. */
  67241. status: number;
  67242. /**
  67243. * Returns client's status as a text
  67244. */
  67245. statusText: string;
  67246. }
  67247. }
  67248. declare module BABYLON {
  67249. /**
  67250. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67251. */
  67252. export class WebRequest implements IWebRequest {
  67253. private _xhr;
  67254. /**
  67255. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67256. * i.e. when loading files, where the server/service expects an Authorization header
  67257. */
  67258. static CustomRequestHeaders: {
  67259. [key: string]: string;
  67260. };
  67261. /**
  67262. * Add callback functions in this array to update all the requests before they get sent to the network
  67263. */
  67264. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67265. private _injectCustomRequestHeaders;
  67266. /**
  67267. * Gets or sets a function to be called when loading progress changes
  67268. */
  67269. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67270. /**
  67271. * Returns client's state
  67272. */
  67273. readonly readyState: number;
  67274. /**
  67275. * Returns client's status
  67276. */
  67277. readonly status: number;
  67278. /**
  67279. * Returns client's status as a text
  67280. */
  67281. readonly statusText: string;
  67282. /**
  67283. * Returns client's response
  67284. */
  67285. readonly response: any;
  67286. /**
  67287. * Returns client's response url
  67288. */
  67289. readonly responseURL: string;
  67290. /**
  67291. * Returns client's response as text
  67292. */
  67293. readonly responseText: string;
  67294. /**
  67295. * Gets or sets the expected response type
  67296. */
  67297. responseType: XMLHttpRequestResponseType;
  67298. /** @hidden */
  67299. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67300. /** @hidden */
  67301. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67302. /**
  67303. * Cancels any network activity
  67304. */
  67305. abort(): void;
  67306. /**
  67307. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67308. * @param body defines an optional request body
  67309. */
  67310. send(body?: Document | BodyInit | null): void;
  67311. /**
  67312. * Sets the request method, request URL
  67313. * @param method defines the method to use (GET, POST, etc..)
  67314. * @param url defines the url to connect with
  67315. */
  67316. open(method: string, url: string): void;
  67317. }
  67318. }
  67319. declare module BABYLON {
  67320. /**
  67321. * File request interface
  67322. */
  67323. export interface IFileRequest {
  67324. /**
  67325. * Raised when the request is complete (success or error).
  67326. */
  67327. onCompleteObservable: Observable<IFileRequest>;
  67328. /**
  67329. * Aborts the request for a file.
  67330. */
  67331. abort: () => void;
  67332. }
  67333. }
  67334. declare module BABYLON {
  67335. /**
  67336. * Define options used to create a render target texture
  67337. */
  67338. export class RenderTargetCreationOptions {
  67339. /**
  67340. * Specifies is mipmaps must be generated
  67341. */
  67342. generateMipMaps?: boolean;
  67343. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67344. generateDepthBuffer?: boolean;
  67345. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67346. generateStencilBuffer?: boolean;
  67347. /** Defines texture type (int by default) */
  67348. type?: number;
  67349. /** Defines sampling mode (trilinear by default) */
  67350. samplingMode?: number;
  67351. /** Defines format (RGBA by default) */
  67352. format?: number;
  67353. }
  67354. }
  67355. declare module BABYLON {
  67356. /**
  67357. * @hidden
  67358. **/
  67359. export class _TimeToken {
  67360. _startTimeQuery: Nullable<WebGLQuery>;
  67361. _endTimeQuery: Nullable<WebGLQuery>;
  67362. _timeElapsedQuery: Nullable<WebGLQuery>;
  67363. _timeElapsedQueryEnded: boolean;
  67364. }
  67365. }
  67366. declare module BABYLON {
  67367. /** Defines the cross module used constants to avoid circular dependncies */
  67368. export class Constants {
  67369. /** Defines that alpha blending is disabled */
  67370. static readonly ALPHA_DISABLE: number;
  67371. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67372. static readonly ALPHA_ADD: number;
  67373. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67374. static readonly ALPHA_COMBINE: number;
  67375. /** Defines that alpha blending to DEST - SRC * DEST */
  67376. static readonly ALPHA_SUBTRACT: number;
  67377. /** Defines that alpha blending to SRC * DEST */
  67378. static readonly ALPHA_MULTIPLY: number;
  67379. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67380. static readonly ALPHA_MAXIMIZED: number;
  67381. /** Defines that alpha blending to SRC + DEST */
  67382. static readonly ALPHA_ONEONE: number;
  67383. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67384. static readonly ALPHA_PREMULTIPLIED: number;
  67385. /**
  67386. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67387. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67388. */
  67389. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67390. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67391. static readonly ALPHA_INTERPOLATE: number;
  67392. /**
  67393. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67394. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67395. */
  67396. static readonly ALPHA_SCREENMODE: number;
  67397. /**
  67398. * Defines that alpha blending to SRC + DST
  67399. * Alpha will be set to SRC ALPHA + DST ALPHA
  67400. */
  67401. static readonly ALPHA_ONEONE_ONEONE: number;
  67402. /**
  67403. * Defines that alpha blending to SRC * DST ALPHA + DST
  67404. * Alpha will be set to 0
  67405. */
  67406. static readonly ALPHA_ALPHATOCOLOR: number;
  67407. /**
  67408. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67409. */
  67410. static readonly ALPHA_REVERSEONEMINUS: number;
  67411. /**
  67412. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67413. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67414. */
  67415. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67416. /**
  67417. * Defines that alpha blending to SRC + DST
  67418. * Alpha will be set to SRC ALPHA
  67419. */
  67420. static readonly ALPHA_ONEONE_ONEZERO: number;
  67421. /** Defines that alpha blending equation a SUM */
  67422. static readonly ALPHA_EQUATION_ADD: number;
  67423. /** Defines that alpha blending equation a SUBSTRACTION */
  67424. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67425. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67426. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67427. /** Defines that alpha blending equation a MAX operation */
  67428. static readonly ALPHA_EQUATION_MAX: number;
  67429. /** Defines that alpha blending equation a MIN operation */
  67430. static readonly ALPHA_EQUATION_MIN: number;
  67431. /**
  67432. * Defines that alpha blending equation a DARKEN operation:
  67433. * It takes the min of the src and sums the alpha channels.
  67434. */
  67435. static readonly ALPHA_EQUATION_DARKEN: number;
  67436. /** Defines that the ressource is not delayed*/
  67437. static readonly DELAYLOADSTATE_NONE: number;
  67438. /** Defines that the ressource was successfully delay loaded */
  67439. static readonly DELAYLOADSTATE_LOADED: number;
  67440. /** Defines that the ressource is currently delay loading */
  67441. static readonly DELAYLOADSTATE_LOADING: number;
  67442. /** Defines that the ressource is delayed and has not started loading */
  67443. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67444. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67445. static readonly NEVER: number;
  67446. /** 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 */
  67447. static readonly ALWAYS: number;
  67448. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67449. static readonly LESS: number;
  67450. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67451. static readonly EQUAL: number;
  67452. /** 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 */
  67453. static readonly LEQUAL: number;
  67454. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67455. static readonly GREATER: number;
  67456. /** 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 */
  67457. static readonly GEQUAL: number;
  67458. /** 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 */
  67459. static readonly NOTEQUAL: number;
  67460. /** Passed to stencilOperation to specify that stencil value must be kept */
  67461. static readonly KEEP: number;
  67462. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67463. static readonly REPLACE: number;
  67464. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67465. static readonly INCR: number;
  67466. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67467. static readonly DECR: number;
  67468. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67469. static readonly INVERT: number;
  67470. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67471. static readonly INCR_WRAP: number;
  67472. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67473. static readonly DECR_WRAP: number;
  67474. /** Texture is not repeating outside of 0..1 UVs */
  67475. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67476. /** Texture is repeating outside of 0..1 UVs */
  67477. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67478. /** Texture is repeating and mirrored */
  67479. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67480. /** ALPHA */
  67481. static readonly TEXTUREFORMAT_ALPHA: number;
  67482. /** LUMINANCE */
  67483. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67484. /** LUMINANCE_ALPHA */
  67485. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67486. /** RGB */
  67487. static readonly TEXTUREFORMAT_RGB: number;
  67488. /** RGBA */
  67489. static readonly TEXTUREFORMAT_RGBA: number;
  67490. /** RED */
  67491. static readonly TEXTUREFORMAT_RED: number;
  67492. /** RED (2nd reference) */
  67493. static readonly TEXTUREFORMAT_R: number;
  67494. /** RG */
  67495. static readonly TEXTUREFORMAT_RG: number;
  67496. /** RED_INTEGER */
  67497. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67498. /** RED_INTEGER (2nd reference) */
  67499. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67500. /** RG_INTEGER */
  67501. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67502. /** RGB_INTEGER */
  67503. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67504. /** RGBA_INTEGER */
  67505. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67506. /** UNSIGNED_BYTE */
  67507. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67508. /** UNSIGNED_BYTE (2nd reference) */
  67509. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67510. /** FLOAT */
  67511. static readonly TEXTURETYPE_FLOAT: number;
  67512. /** HALF_FLOAT */
  67513. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67514. /** BYTE */
  67515. static readonly TEXTURETYPE_BYTE: number;
  67516. /** SHORT */
  67517. static readonly TEXTURETYPE_SHORT: number;
  67518. /** UNSIGNED_SHORT */
  67519. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67520. /** INT */
  67521. static readonly TEXTURETYPE_INT: number;
  67522. /** UNSIGNED_INT */
  67523. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67524. /** UNSIGNED_SHORT_4_4_4_4 */
  67525. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67526. /** UNSIGNED_SHORT_5_5_5_1 */
  67527. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67528. /** UNSIGNED_SHORT_5_6_5 */
  67529. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67530. /** UNSIGNED_INT_2_10_10_10_REV */
  67531. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67532. /** UNSIGNED_INT_24_8 */
  67533. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67534. /** UNSIGNED_INT_10F_11F_11F_REV */
  67535. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67536. /** UNSIGNED_INT_5_9_9_9_REV */
  67537. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67538. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67539. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67540. /** nearest is mag = nearest and min = nearest and mip = linear */
  67541. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67542. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67543. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67544. /** Trilinear is mag = linear and min = linear and mip = linear */
  67545. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67546. /** nearest is mag = nearest and min = nearest and mip = linear */
  67547. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67548. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67549. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67550. /** Trilinear is mag = linear and min = linear and mip = linear */
  67551. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67552. /** mag = nearest and min = nearest and mip = nearest */
  67553. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67554. /** mag = nearest and min = linear and mip = nearest */
  67555. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67556. /** mag = nearest and min = linear and mip = linear */
  67557. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67558. /** mag = nearest and min = linear and mip = none */
  67559. static readonly TEXTURE_NEAREST_LINEAR: number;
  67560. /** mag = nearest and min = nearest and mip = none */
  67561. static readonly TEXTURE_NEAREST_NEAREST: number;
  67562. /** mag = linear and min = nearest and mip = nearest */
  67563. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67564. /** mag = linear and min = nearest and mip = linear */
  67565. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67566. /** mag = linear and min = linear and mip = none */
  67567. static readonly TEXTURE_LINEAR_LINEAR: number;
  67568. /** mag = linear and min = nearest and mip = none */
  67569. static readonly TEXTURE_LINEAR_NEAREST: number;
  67570. /** Explicit coordinates mode */
  67571. static readonly TEXTURE_EXPLICIT_MODE: number;
  67572. /** Spherical coordinates mode */
  67573. static readonly TEXTURE_SPHERICAL_MODE: number;
  67574. /** Planar coordinates mode */
  67575. static readonly TEXTURE_PLANAR_MODE: number;
  67576. /** Cubic coordinates mode */
  67577. static readonly TEXTURE_CUBIC_MODE: number;
  67578. /** Projection coordinates mode */
  67579. static readonly TEXTURE_PROJECTION_MODE: number;
  67580. /** Skybox coordinates mode */
  67581. static readonly TEXTURE_SKYBOX_MODE: number;
  67582. /** Inverse Cubic coordinates mode */
  67583. static readonly TEXTURE_INVCUBIC_MODE: number;
  67584. /** Equirectangular coordinates mode */
  67585. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67586. /** Equirectangular Fixed coordinates mode */
  67587. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67588. /** Equirectangular Fixed Mirrored coordinates mode */
  67589. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67590. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67591. static readonly SCALEMODE_FLOOR: number;
  67592. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67593. static readonly SCALEMODE_NEAREST: number;
  67594. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67595. static readonly SCALEMODE_CEILING: number;
  67596. /**
  67597. * The dirty texture flag value
  67598. */
  67599. static readonly MATERIAL_TextureDirtyFlag: number;
  67600. /**
  67601. * The dirty light flag value
  67602. */
  67603. static readonly MATERIAL_LightDirtyFlag: number;
  67604. /**
  67605. * The dirty fresnel flag value
  67606. */
  67607. static readonly MATERIAL_FresnelDirtyFlag: number;
  67608. /**
  67609. * The dirty attribute flag value
  67610. */
  67611. static readonly MATERIAL_AttributesDirtyFlag: number;
  67612. /**
  67613. * The dirty misc flag value
  67614. */
  67615. static readonly MATERIAL_MiscDirtyFlag: number;
  67616. /**
  67617. * The all dirty flag value
  67618. */
  67619. static readonly MATERIAL_AllDirtyFlag: number;
  67620. /**
  67621. * Returns the triangle fill mode
  67622. */
  67623. static readonly MATERIAL_TriangleFillMode: number;
  67624. /**
  67625. * Returns the wireframe mode
  67626. */
  67627. static readonly MATERIAL_WireFrameFillMode: number;
  67628. /**
  67629. * Returns the point fill mode
  67630. */
  67631. static readonly MATERIAL_PointFillMode: number;
  67632. /**
  67633. * Returns the point list draw mode
  67634. */
  67635. static readonly MATERIAL_PointListDrawMode: number;
  67636. /**
  67637. * Returns the line list draw mode
  67638. */
  67639. static readonly MATERIAL_LineListDrawMode: number;
  67640. /**
  67641. * Returns the line loop draw mode
  67642. */
  67643. static readonly MATERIAL_LineLoopDrawMode: number;
  67644. /**
  67645. * Returns the line strip draw mode
  67646. */
  67647. static readonly MATERIAL_LineStripDrawMode: number;
  67648. /**
  67649. * Returns the triangle strip draw mode
  67650. */
  67651. static readonly MATERIAL_TriangleStripDrawMode: number;
  67652. /**
  67653. * Returns the triangle fan draw mode
  67654. */
  67655. static readonly MATERIAL_TriangleFanDrawMode: number;
  67656. /**
  67657. * Stores the clock-wise side orientation
  67658. */
  67659. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67660. /**
  67661. * Stores the counter clock-wise side orientation
  67662. */
  67663. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67664. /**
  67665. * Nothing
  67666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67667. */
  67668. static readonly ACTION_NothingTrigger: number;
  67669. /**
  67670. * On pick
  67671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67672. */
  67673. static readonly ACTION_OnPickTrigger: number;
  67674. /**
  67675. * On left pick
  67676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67677. */
  67678. static readonly ACTION_OnLeftPickTrigger: number;
  67679. /**
  67680. * On right pick
  67681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67682. */
  67683. static readonly ACTION_OnRightPickTrigger: number;
  67684. /**
  67685. * On center pick
  67686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67687. */
  67688. static readonly ACTION_OnCenterPickTrigger: number;
  67689. /**
  67690. * On pick down
  67691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67692. */
  67693. static readonly ACTION_OnPickDownTrigger: number;
  67694. /**
  67695. * On double pick
  67696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67697. */
  67698. static readonly ACTION_OnDoublePickTrigger: number;
  67699. /**
  67700. * On pick up
  67701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67702. */
  67703. static readonly ACTION_OnPickUpTrigger: number;
  67704. /**
  67705. * On pick out.
  67706. * This trigger will only be raised if you also declared a OnPickDown
  67707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67708. */
  67709. static readonly ACTION_OnPickOutTrigger: number;
  67710. /**
  67711. * On long press
  67712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67713. */
  67714. static readonly ACTION_OnLongPressTrigger: number;
  67715. /**
  67716. * On pointer over
  67717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67718. */
  67719. static readonly ACTION_OnPointerOverTrigger: number;
  67720. /**
  67721. * On pointer out
  67722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67723. */
  67724. static readonly ACTION_OnPointerOutTrigger: number;
  67725. /**
  67726. * On every frame
  67727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67728. */
  67729. static readonly ACTION_OnEveryFrameTrigger: number;
  67730. /**
  67731. * On intersection enter
  67732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67733. */
  67734. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67735. /**
  67736. * On intersection exit
  67737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67738. */
  67739. static readonly ACTION_OnIntersectionExitTrigger: number;
  67740. /**
  67741. * On key down
  67742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67743. */
  67744. static readonly ACTION_OnKeyDownTrigger: number;
  67745. /**
  67746. * On key up
  67747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67748. */
  67749. static readonly ACTION_OnKeyUpTrigger: number;
  67750. /**
  67751. * Billboard mode will only apply to Y axis
  67752. */
  67753. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67754. /**
  67755. * Billboard mode will apply to all axes
  67756. */
  67757. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67758. /**
  67759. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67760. */
  67761. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67762. /**
  67763. * Gets or sets base Assets URL
  67764. */
  67765. static PARTICLES_BaseAssetsUrl: string;
  67766. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67767. * Test order :
  67768. * Is the bounding sphere outside the frustum ?
  67769. * If not, are the bounding box vertices outside the frustum ?
  67770. * It not, then the cullable object is in the frustum.
  67771. */
  67772. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67773. /** Culling strategy : Bounding Sphere Only.
  67774. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67775. * It's also less accurate than the standard because some not visible objects can still be selected.
  67776. * Test : is the bounding sphere outside the frustum ?
  67777. * If not, then the cullable object is in the frustum.
  67778. */
  67779. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67780. /** Culling strategy : Optimistic Inclusion.
  67781. * This in an inclusion test first, then the standard exclusion test.
  67782. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67783. * 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.
  67784. * Anyway, it's as accurate as the standard strategy.
  67785. * Test :
  67786. * Is the cullable object bounding sphere center in the frustum ?
  67787. * If not, apply the default culling strategy.
  67788. */
  67789. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67790. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67791. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67792. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67793. * 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.
  67794. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67795. * Test :
  67796. * Is the cullable object bounding sphere center in the frustum ?
  67797. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67798. */
  67799. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67800. /**
  67801. * No logging while loading
  67802. */
  67803. static readonly SCENELOADER_NO_LOGGING: number;
  67804. /**
  67805. * Minimal logging while loading
  67806. */
  67807. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67808. /**
  67809. * Summary logging while loading
  67810. */
  67811. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67812. /**
  67813. * Detailled logging while loading
  67814. */
  67815. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67816. }
  67817. }
  67818. declare module BABYLON {
  67819. /**
  67820. * This represents the required contract to create a new type of texture loader.
  67821. */
  67822. export interface IInternalTextureLoader {
  67823. /**
  67824. * Defines wether the loader supports cascade loading the different faces.
  67825. */
  67826. supportCascades: boolean;
  67827. /**
  67828. * This returns if the loader support the current file information.
  67829. * @param extension defines the file extension of the file being loaded
  67830. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67831. * @param fallback defines the fallback internal texture if any
  67832. * @param isBase64 defines whether the texture is encoded as a base64
  67833. * @param isBuffer defines whether the texture data are stored as a buffer
  67834. * @returns true if the loader can load the specified file
  67835. */
  67836. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67837. /**
  67838. * Transform the url before loading if required.
  67839. * @param rootUrl the url of the texture
  67840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67841. * @returns the transformed texture
  67842. */
  67843. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67844. /**
  67845. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67846. * @param rootUrl the url of the texture
  67847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67848. * @returns the fallback texture
  67849. */
  67850. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67851. /**
  67852. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67853. * @param data contains the texture data
  67854. * @param texture defines the BabylonJS internal texture
  67855. * @param createPolynomials will be true if polynomials have been requested
  67856. * @param onLoad defines the callback to trigger once the texture is ready
  67857. * @param onError defines the callback to trigger in case of error
  67858. */
  67859. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67860. /**
  67861. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67862. * @param data contains the texture data
  67863. * @param texture defines the BabylonJS internal texture
  67864. * @param callback defines the method to call once ready to upload
  67865. */
  67866. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67867. }
  67868. }
  67869. declare module BABYLON {
  67870. /**
  67871. * Class used to store and describe the pipeline context associated with an effect
  67872. */
  67873. export interface IPipelineContext {
  67874. /**
  67875. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67876. */
  67877. isAsync: boolean;
  67878. /**
  67879. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67880. */
  67881. isReady: boolean;
  67882. /** @hidden */
  67883. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67884. }
  67885. }
  67886. declare module BABYLON {
  67887. /**
  67888. * Class used to store gfx data (like WebGLBuffer)
  67889. */
  67890. export class DataBuffer {
  67891. /**
  67892. * Gets or sets the number of objects referencing this buffer
  67893. */
  67894. references: number;
  67895. /** Gets or sets the size of the underlying buffer */
  67896. capacity: number;
  67897. /**
  67898. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67899. */
  67900. is32Bits: boolean;
  67901. /**
  67902. * Gets the underlying buffer
  67903. */
  67904. readonly underlyingResource: any;
  67905. }
  67906. }
  67907. declare module BABYLON {
  67908. /** @hidden */
  67909. export interface IShaderProcessor {
  67910. attributeProcessor?: (attribute: string) => string;
  67911. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67912. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67913. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67914. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67915. lineProcessor?: (line: string, isFragment: boolean) => string;
  67916. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67917. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /** @hidden */
  67922. export interface ProcessingOptions {
  67923. defines: string[];
  67924. indexParameters: any;
  67925. isFragment: boolean;
  67926. shouldUseHighPrecisionShader: boolean;
  67927. supportsUniformBuffers: boolean;
  67928. shadersRepository: string;
  67929. includesShadersStore: {
  67930. [key: string]: string;
  67931. };
  67932. processor?: IShaderProcessor;
  67933. version: string;
  67934. platformName: string;
  67935. lookForClosingBracketForUniformBuffer?: boolean;
  67936. }
  67937. }
  67938. declare module BABYLON {
  67939. /**
  67940. * Helper to manipulate strings
  67941. */
  67942. export class StringTools {
  67943. /**
  67944. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67945. * @param str Source string
  67946. * @param suffix Suffix to search for in the source string
  67947. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67948. */
  67949. static EndsWith(str: string, suffix: string): boolean;
  67950. /**
  67951. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67952. * @param str Source string
  67953. * @param suffix Suffix to search for in the source string
  67954. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67955. */
  67956. static StartsWith(str: string, suffix: string): boolean;
  67957. }
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export class ShaderCodeNode {
  67962. line: string;
  67963. children: ShaderCodeNode[];
  67964. additionalDefineKey?: string;
  67965. additionalDefineValue?: string;
  67966. isValid(preprocessors: {
  67967. [key: string]: string;
  67968. }): boolean;
  67969. process(preprocessors: {
  67970. [key: string]: string;
  67971. }, options: ProcessingOptions): string;
  67972. }
  67973. }
  67974. declare module BABYLON {
  67975. /** @hidden */
  67976. export class ShaderCodeCursor {
  67977. private _lines;
  67978. lineIndex: number;
  67979. readonly currentLine: string;
  67980. readonly canRead: boolean;
  67981. lines: string[];
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67987. process(preprocessors: {
  67988. [key: string]: string;
  67989. }, options: ProcessingOptions): string;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /** @hidden */
  67994. export class ShaderDefineExpression {
  67995. isTrue(preprocessors: {
  67996. [key: string]: string;
  67997. }): boolean;
  67998. }
  67999. }
  68000. declare module BABYLON {
  68001. /** @hidden */
  68002. export class ShaderCodeTestNode extends ShaderCodeNode {
  68003. testExpression: ShaderDefineExpression;
  68004. isValid(preprocessors: {
  68005. [key: string]: string;
  68006. }): boolean;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /** @hidden */
  68011. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68012. define: string;
  68013. not: boolean;
  68014. constructor(define: string, not?: boolean);
  68015. isTrue(preprocessors: {
  68016. [key: string]: string;
  68017. }): boolean;
  68018. }
  68019. }
  68020. declare module BABYLON {
  68021. /** @hidden */
  68022. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68023. leftOperand: ShaderDefineExpression;
  68024. rightOperand: ShaderDefineExpression;
  68025. isTrue(preprocessors: {
  68026. [key: string]: string;
  68027. }): boolean;
  68028. }
  68029. }
  68030. declare module BABYLON {
  68031. /** @hidden */
  68032. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68033. leftOperand: ShaderDefineExpression;
  68034. rightOperand: ShaderDefineExpression;
  68035. isTrue(preprocessors: {
  68036. [key: string]: string;
  68037. }): boolean;
  68038. }
  68039. }
  68040. declare module BABYLON {
  68041. /** @hidden */
  68042. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68043. define: string;
  68044. operand: string;
  68045. testValue: string;
  68046. constructor(define: string, operand: string, testValue: string);
  68047. isTrue(preprocessors: {
  68048. [key: string]: string;
  68049. }): boolean;
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. /**
  68054. * @ignore
  68055. * Application error to support additional information when loading a file
  68056. */
  68057. export class LoadFileError extends Error {
  68058. /** defines the optional web request */
  68059. request?: WebRequest | undefined;
  68060. private static _setPrototypeOf;
  68061. /**
  68062. * Creates a new LoadFileError
  68063. * @param message defines the message of the error
  68064. * @param request defines the optional web request
  68065. */
  68066. constructor(message: string,
  68067. /** defines the optional web request */
  68068. request?: WebRequest | undefined);
  68069. }
  68070. }
  68071. declare module BABYLON {
  68072. /**
  68073. * Class used to enable access to offline support
  68074. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68075. */
  68076. export interface IOfflineProvider {
  68077. /**
  68078. * Gets a boolean indicating if scene must be saved in the database
  68079. */
  68080. enableSceneOffline: boolean;
  68081. /**
  68082. * Gets a boolean indicating if textures must be saved in the database
  68083. */
  68084. enableTexturesOffline: boolean;
  68085. /**
  68086. * Open the offline support and make it available
  68087. * @param successCallback defines the callback to call on success
  68088. * @param errorCallback defines the callback to call on error
  68089. */
  68090. open(successCallback: () => void, errorCallback: () => void): void;
  68091. /**
  68092. * Loads an image from the offline support
  68093. * @param url defines the url to load from
  68094. * @param image defines the target DOM image
  68095. */
  68096. loadImage(url: string, image: HTMLImageElement): void;
  68097. /**
  68098. * Loads a file from offline support
  68099. * @param url defines the URL to load from
  68100. * @param sceneLoaded defines a callback to call on success
  68101. * @param progressCallBack defines a callback to call when progress changed
  68102. * @param errorCallback defines a callback to call on error
  68103. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68104. */
  68105. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68106. }
  68107. }
  68108. declare module BABYLON {
  68109. /**
  68110. * Class used to help managing file picking and drag'n'drop
  68111. * File Storage
  68112. */
  68113. export class FilesInputStore {
  68114. /**
  68115. * List of files ready to be loaded
  68116. */
  68117. static FilesToLoad: {
  68118. [key: string]: File;
  68119. };
  68120. }
  68121. }
  68122. declare module BABYLON {
  68123. /**
  68124. * Class used to define a retry strategy when error happens while loading assets
  68125. */
  68126. export class RetryStrategy {
  68127. /**
  68128. * Function used to defines an exponential back off strategy
  68129. * @param maxRetries defines the maximum number of retries (3 by default)
  68130. * @param baseInterval defines the interval between retries
  68131. * @returns the strategy function to use
  68132. */
  68133. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68134. }
  68135. }
  68136. declare module BABYLON {
  68137. /**
  68138. * @hidden
  68139. */
  68140. export class FileTools {
  68141. /**
  68142. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68143. */
  68144. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68145. /**
  68146. * Gets or sets the base URL to use to load assets
  68147. */
  68148. static BaseUrl: string;
  68149. /**
  68150. * Default behaviour for cors in the application.
  68151. * It can be a string if the expected behavior is identical in the entire app.
  68152. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68153. */
  68154. static CorsBehavior: string | ((url: string | string[]) => string);
  68155. /**
  68156. * Gets or sets a function used to pre-process url before using them to load assets
  68157. */
  68158. static PreprocessUrl: (url: string) => string;
  68159. /**
  68160. * Removes unwanted characters from an url
  68161. * @param url defines the url to clean
  68162. * @returns the cleaned url
  68163. */
  68164. private static _CleanUrl;
  68165. /**
  68166. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68167. * @param url define the url we are trying
  68168. * @param element define the dom element where to configure the cors policy
  68169. */
  68170. static SetCorsBehavior(url: string | string[], element: {
  68171. crossOrigin: string | null;
  68172. }): void;
  68173. /**
  68174. * Loads an image as an HTMLImageElement.
  68175. * @param input url string, ArrayBuffer, or Blob to load
  68176. * @param onLoad callback called when the image successfully loads
  68177. * @param onError callback called when the image fails to load
  68178. * @param offlineProvider offline provider for caching
  68179. * @returns the HTMLImageElement of the loaded image
  68180. */
  68181. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68182. /**
  68183. * Loads a file
  68184. * @param fileToLoad defines the file to load
  68185. * @param callback defines the callback to call when data is loaded
  68186. * @param progressCallBack defines the callback to call during loading process
  68187. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68188. * @returns a file request object
  68189. */
  68190. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68191. /**
  68192. * Loads a file
  68193. * @param url url string, ArrayBuffer, or Blob to load
  68194. * @param onSuccess callback called when the file successfully loads
  68195. * @param onProgress callback called while file is loading (if the server supports this mode)
  68196. * @param offlineProvider defines the offline provider for caching
  68197. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68198. * @param onError callback called when the file fails to load
  68199. * @returns a file request object
  68200. */
  68201. 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;
  68202. /**
  68203. * Checks if the loaded document was accessed via `file:`-Protocol.
  68204. * @returns boolean
  68205. */
  68206. static IsFileURL(): boolean;
  68207. }
  68208. }
  68209. declare module BABYLON {
  68210. /** @hidden */
  68211. export class ShaderProcessor {
  68212. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68213. private static _ProcessPrecision;
  68214. private static _ExtractOperation;
  68215. private static _BuildSubExpression;
  68216. private static _BuildExpression;
  68217. private static _MoveCursorWithinIf;
  68218. private static _MoveCursor;
  68219. private static _EvaluatePreProcessors;
  68220. private static _PreparePreProcessors;
  68221. private static _ProcessShaderConversion;
  68222. private static _ProcessIncludes;
  68223. }
  68224. }
  68225. declare module BABYLON {
  68226. /**
  68227. * @hidden
  68228. */
  68229. export interface IColor4Like {
  68230. r: float;
  68231. g: float;
  68232. b: float;
  68233. a: float;
  68234. }
  68235. /**
  68236. * @hidden
  68237. */
  68238. export interface IColor3Like {
  68239. r: float;
  68240. g: float;
  68241. b: float;
  68242. }
  68243. /**
  68244. * @hidden
  68245. */
  68246. export interface IVector4Like {
  68247. x: float;
  68248. y: float;
  68249. z: float;
  68250. w: float;
  68251. }
  68252. /**
  68253. * @hidden
  68254. */
  68255. export interface IVector3Like {
  68256. x: float;
  68257. y: float;
  68258. z: float;
  68259. }
  68260. /**
  68261. * @hidden
  68262. */
  68263. export interface IVector2Like {
  68264. x: float;
  68265. y: float;
  68266. }
  68267. /**
  68268. * @hidden
  68269. */
  68270. export interface IMatrixLike {
  68271. toArray(): DeepImmutable<Float32Array>;
  68272. updateFlag: int;
  68273. }
  68274. /**
  68275. * @hidden
  68276. */
  68277. export interface IViewportLike {
  68278. x: float;
  68279. y: float;
  68280. width: float;
  68281. height: float;
  68282. }
  68283. /**
  68284. * @hidden
  68285. */
  68286. export interface IPlaneLike {
  68287. normal: IVector3Like;
  68288. d: float;
  68289. normalize(): void;
  68290. }
  68291. }
  68292. declare module BABYLON {
  68293. /**
  68294. * Interface used to define common properties for effect fallbacks
  68295. */
  68296. export interface IEffectFallbacks {
  68297. /**
  68298. * Removes the defines that should be removed when falling back.
  68299. * @param currentDefines defines the current define statements for the shader.
  68300. * @param effect defines the current effect we try to compile
  68301. * @returns The resulting defines with defines of the current rank removed.
  68302. */
  68303. reduce(currentDefines: string, effect: Effect): string;
  68304. /**
  68305. * Removes the fallback from the bound mesh.
  68306. */
  68307. unBindMesh(): void;
  68308. /**
  68309. * Checks to see if more fallbacks are still availible.
  68310. */
  68311. hasMoreFallbacks: boolean;
  68312. }
  68313. }
  68314. declare module BABYLON {
  68315. /**
  68316. * Class used to evalaute queries containing `and` and `or` operators
  68317. */
  68318. export class AndOrNotEvaluator {
  68319. /**
  68320. * Evaluate a query
  68321. * @param query defines the query to evaluate
  68322. * @param evaluateCallback defines the callback used to filter result
  68323. * @returns true if the query matches
  68324. */
  68325. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68326. private static _HandleParenthesisContent;
  68327. private static _SimplifyNegation;
  68328. }
  68329. }
  68330. declare module BABYLON {
  68331. /**
  68332. * Class used to store custom tags
  68333. */
  68334. export class Tags {
  68335. /**
  68336. * Adds support for tags on the given object
  68337. * @param obj defines the object to use
  68338. */
  68339. static EnableFor(obj: any): void;
  68340. /**
  68341. * Removes tags support
  68342. * @param obj defines the object to use
  68343. */
  68344. static DisableFor(obj: any): void;
  68345. /**
  68346. * Gets a boolean indicating if the given object has tags
  68347. * @param obj defines the object to use
  68348. * @returns a boolean
  68349. */
  68350. static HasTags(obj: any): boolean;
  68351. /**
  68352. * Gets the tags available on a given object
  68353. * @param obj defines the object to use
  68354. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68355. * @returns the tags
  68356. */
  68357. static GetTags(obj: any, asString?: boolean): any;
  68358. /**
  68359. * Adds tags to an object
  68360. * @param obj defines the object to use
  68361. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68362. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68363. */
  68364. static AddTagsTo(obj: any, tagsString: string): void;
  68365. /**
  68366. * @hidden
  68367. */
  68368. static _AddTagTo(obj: any, tag: string): void;
  68369. /**
  68370. * Removes specific tags from a specific object
  68371. * @param obj defines the object to use
  68372. * @param tagsString defines the tags to remove
  68373. */
  68374. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68375. /**
  68376. * @hidden
  68377. */
  68378. static _RemoveTagFrom(obj: any, tag: string): void;
  68379. /**
  68380. * Defines if tags hosted on an object match a given query
  68381. * @param obj defines the object to use
  68382. * @param tagsQuery defines the tag query
  68383. * @returns a boolean
  68384. */
  68385. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68386. }
  68387. }
  68388. declare module BABYLON {
  68389. /**
  68390. * Scalar computation library
  68391. */
  68392. export class Scalar {
  68393. /**
  68394. * Two pi constants convenient for computation.
  68395. */
  68396. static TwoPi: number;
  68397. /**
  68398. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68399. * @param a number
  68400. * @param b number
  68401. * @param epsilon (default = 1.401298E-45)
  68402. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68403. */
  68404. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68405. /**
  68406. * Returns a string : the upper case translation of the number i to hexadecimal.
  68407. * @param i number
  68408. * @returns the upper case translation of the number i to hexadecimal.
  68409. */
  68410. static ToHex(i: number): string;
  68411. /**
  68412. * Returns -1 if value is negative and +1 is value is positive.
  68413. * @param value the value
  68414. * @returns the value itself if it's equal to zero.
  68415. */
  68416. static Sign(value: number): number;
  68417. /**
  68418. * Returns the value itself if it's between min and max.
  68419. * Returns min if the value is lower than min.
  68420. * Returns max if the value is greater than max.
  68421. * @param value the value to clmap
  68422. * @param min the min value to clamp to (default: 0)
  68423. * @param max the max value to clamp to (default: 1)
  68424. * @returns the clamped value
  68425. */
  68426. static Clamp(value: number, min?: number, max?: number): number;
  68427. /**
  68428. * the log2 of value.
  68429. * @param value the value to compute log2 of
  68430. * @returns the log2 of value.
  68431. */
  68432. static Log2(value: number): number;
  68433. /**
  68434. * Loops the value, so that it is never larger than length and never smaller than 0.
  68435. *
  68436. * This is similar to the modulo operator but it works with floating point numbers.
  68437. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68438. * With t = 5 and length = 2.5, the result would be 0.0.
  68439. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68440. * @param value the value
  68441. * @param length the length
  68442. * @returns the looped value
  68443. */
  68444. static Repeat(value: number, length: number): number;
  68445. /**
  68446. * Normalize the value between 0.0 and 1.0 using min and max values
  68447. * @param value value to normalize
  68448. * @param min max to normalize between
  68449. * @param max min to normalize between
  68450. * @returns the normalized value
  68451. */
  68452. static Normalize(value: number, min: number, max: number): number;
  68453. /**
  68454. * Denormalize the value from 0.0 and 1.0 using min and max values
  68455. * @param normalized value to denormalize
  68456. * @param min max to denormalize between
  68457. * @param max min to denormalize between
  68458. * @returns the denormalized value
  68459. */
  68460. static Denormalize(normalized: number, min: number, max: number): number;
  68461. /**
  68462. * Calculates the shortest difference between two given angles given in degrees.
  68463. * @param current current angle in degrees
  68464. * @param target target angle in degrees
  68465. * @returns the delta
  68466. */
  68467. static DeltaAngle(current: number, target: number): number;
  68468. /**
  68469. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68470. * @param tx value
  68471. * @param length length
  68472. * @returns The returned value will move back and forth between 0 and length
  68473. */
  68474. static PingPong(tx: number, length: number): number;
  68475. /**
  68476. * Interpolates between min and max with smoothing at the limits.
  68477. *
  68478. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68479. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68480. * @param from from
  68481. * @param to to
  68482. * @param tx value
  68483. * @returns the smooth stepped value
  68484. */
  68485. static SmoothStep(from: number, to: number, tx: number): number;
  68486. /**
  68487. * Moves a value current towards target.
  68488. *
  68489. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68490. * Negative values of maxDelta pushes the value away from target.
  68491. * @param current current value
  68492. * @param target target value
  68493. * @param maxDelta max distance to move
  68494. * @returns resulting value
  68495. */
  68496. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68497. /**
  68498. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68499. *
  68500. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68501. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68502. * @param current current value
  68503. * @param target target value
  68504. * @param maxDelta max distance to move
  68505. * @returns resulting angle
  68506. */
  68507. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68508. /**
  68509. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68510. * @param start start value
  68511. * @param end target value
  68512. * @param amount amount to lerp between
  68513. * @returns the lerped value
  68514. */
  68515. static Lerp(start: number, end: number, amount: number): number;
  68516. /**
  68517. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68518. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68519. * @param start start value
  68520. * @param end target value
  68521. * @param amount amount to lerp between
  68522. * @returns the lerped value
  68523. */
  68524. static LerpAngle(start: number, end: number, amount: number): number;
  68525. /**
  68526. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68527. * @param a start value
  68528. * @param b target value
  68529. * @param value value between a and b
  68530. * @returns the inverseLerp value
  68531. */
  68532. static InverseLerp(a: number, b: number, value: number): number;
  68533. /**
  68534. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68535. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68536. * @param value1 spline value
  68537. * @param tangent1 spline value
  68538. * @param value2 spline value
  68539. * @param tangent2 spline value
  68540. * @param amount input value
  68541. * @returns hermite result
  68542. */
  68543. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68544. /**
  68545. * Returns a random float number between and min and max values
  68546. * @param min min value of random
  68547. * @param max max value of random
  68548. * @returns random value
  68549. */
  68550. static RandomRange(min: number, max: number): number;
  68551. /**
  68552. * This function returns percentage of a number in a given range.
  68553. *
  68554. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68555. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68556. * @param number to convert to percentage
  68557. * @param min min range
  68558. * @param max max range
  68559. * @returns the percentage
  68560. */
  68561. static RangeToPercent(number: number, min: number, max: number): number;
  68562. /**
  68563. * This function returns number that corresponds to the percentage in a given range.
  68564. *
  68565. * PercentToRange(0.34,0,100) will return 34.
  68566. * @param percent to convert to number
  68567. * @param min min range
  68568. * @param max max range
  68569. * @returns the number
  68570. */
  68571. static PercentToRange(percent: number, min: number, max: number): number;
  68572. /**
  68573. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68574. * @param angle The angle to normalize in radian.
  68575. * @return The converted angle.
  68576. */
  68577. static NormalizeRadians(angle: number): number;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /**
  68582. * Constant used to convert a value to gamma space
  68583. * @ignorenaming
  68584. */
  68585. export const ToGammaSpace: number;
  68586. /**
  68587. * Constant used to convert a value to linear space
  68588. * @ignorenaming
  68589. */
  68590. export const ToLinearSpace = 2.2;
  68591. /**
  68592. * Constant used to define the minimal number value in Babylon.js
  68593. * @ignorenaming
  68594. */
  68595. let Epsilon: number;
  68596. }
  68597. declare module BABYLON {
  68598. /**
  68599. * Class used to represent a viewport on screen
  68600. */
  68601. export class Viewport {
  68602. /** viewport left coordinate */
  68603. x: number;
  68604. /** viewport top coordinate */
  68605. y: number;
  68606. /**viewport width */
  68607. width: number;
  68608. /** viewport height */
  68609. height: number;
  68610. /**
  68611. * Creates a Viewport object located at (x, y) and sized (width, height)
  68612. * @param x defines viewport left coordinate
  68613. * @param y defines viewport top coordinate
  68614. * @param width defines the viewport width
  68615. * @param height defines the viewport height
  68616. */
  68617. constructor(
  68618. /** viewport left coordinate */
  68619. x: number,
  68620. /** viewport top coordinate */
  68621. y: number,
  68622. /**viewport width */
  68623. width: number,
  68624. /** viewport height */
  68625. height: number);
  68626. /**
  68627. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68628. * @param renderWidth defines the rendering width
  68629. * @param renderHeight defines the rendering height
  68630. * @returns a new Viewport
  68631. */
  68632. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68633. /**
  68634. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68635. * @param renderWidth defines the rendering width
  68636. * @param renderHeight defines the rendering height
  68637. * @param ref defines the target viewport
  68638. * @returns the current viewport
  68639. */
  68640. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68641. /**
  68642. * Returns a new Viewport copied from the current one
  68643. * @returns a new Viewport
  68644. */
  68645. clone(): Viewport;
  68646. }
  68647. }
  68648. declare module BABYLON {
  68649. /**
  68650. * Class containing a set of static utilities functions for arrays.
  68651. */
  68652. export class ArrayTools {
  68653. /**
  68654. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68655. * @param size the number of element to construct and put in the array
  68656. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68657. * @returns a new array filled with new objects
  68658. */
  68659. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68660. }
  68661. }
  68662. declare module BABYLON {
  68663. /**
  68664. * Class representing a vector containing 2 coordinates
  68665. */
  68666. export class Vector2 {
  68667. /** defines the first coordinate */
  68668. x: number;
  68669. /** defines the second coordinate */
  68670. y: number;
  68671. /**
  68672. * Creates a new Vector2 from the given x and y coordinates
  68673. * @param x defines the first coordinate
  68674. * @param y defines the second coordinate
  68675. */
  68676. constructor(
  68677. /** defines the first coordinate */
  68678. x?: number,
  68679. /** defines the second coordinate */
  68680. y?: number);
  68681. /**
  68682. * Gets a string with the Vector2 coordinates
  68683. * @returns a string with the Vector2 coordinates
  68684. */
  68685. toString(): string;
  68686. /**
  68687. * Gets class name
  68688. * @returns the string "Vector2"
  68689. */
  68690. getClassName(): string;
  68691. /**
  68692. * Gets current vector hash code
  68693. * @returns the Vector2 hash code as a number
  68694. */
  68695. getHashCode(): number;
  68696. /**
  68697. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68698. * @param array defines the source array
  68699. * @param index defines the offset in source array
  68700. * @returns the current Vector2
  68701. */
  68702. toArray(array: FloatArray, index?: number): Vector2;
  68703. /**
  68704. * Copy the current vector to an array
  68705. * @returns a new array with 2 elements: the Vector2 coordinates.
  68706. */
  68707. asArray(): number[];
  68708. /**
  68709. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68710. * @param source defines the source Vector2
  68711. * @returns the current updated Vector2
  68712. */
  68713. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68714. /**
  68715. * Sets the Vector2 coordinates with the given floats
  68716. * @param x defines the first coordinate
  68717. * @param y defines the second coordinate
  68718. * @returns the current updated Vector2
  68719. */
  68720. copyFromFloats(x: number, y: number): Vector2;
  68721. /**
  68722. * Sets the Vector2 coordinates with the given floats
  68723. * @param x defines the first coordinate
  68724. * @param y defines the second coordinate
  68725. * @returns the current updated Vector2
  68726. */
  68727. set(x: number, y: number): Vector2;
  68728. /**
  68729. * Add another vector with the current one
  68730. * @param otherVector defines the other vector
  68731. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68732. */
  68733. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68734. /**
  68735. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68736. * @param otherVector defines the other vector
  68737. * @param result defines the target vector
  68738. * @returns the unmodified current Vector2
  68739. */
  68740. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68741. /**
  68742. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68743. * @param otherVector defines the other vector
  68744. * @returns the current updated Vector2
  68745. */
  68746. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68747. /**
  68748. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68749. * @param otherVector defines the other vector
  68750. * @returns a new Vector2
  68751. */
  68752. addVector3(otherVector: Vector3): Vector2;
  68753. /**
  68754. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68755. * @param otherVector defines the other vector
  68756. * @returns a new Vector2
  68757. */
  68758. subtract(otherVector: Vector2): Vector2;
  68759. /**
  68760. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68761. * @param otherVector defines the other vector
  68762. * @param result defines the target vector
  68763. * @returns the unmodified current Vector2
  68764. */
  68765. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68766. /**
  68767. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68768. * @param otherVector defines the other vector
  68769. * @returns the current updated Vector2
  68770. */
  68771. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68772. /**
  68773. * Multiplies in place the current Vector2 coordinates by the given ones
  68774. * @param otherVector defines the other vector
  68775. * @returns the current updated Vector2
  68776. */
  68777. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68778. /**
  68779. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68780. * @param otherVector defines the other vector
  68781. * @returns a new Vector2
  68782. */
  68783. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68784. /**
  68785. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68786. * @param otherVector defines the other vector
  68787. * @param result defines the target vector
  68788. * @returns the unmodified current Vector2
  68789. */
  68790. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68791. /**
  68792. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68793. * @param x defines the first coordinate
  68794. * @param y defines the second coordinate
  68795. * @returns a new Vector2
  68796. */
  68797. multiplyByFloats(x: number, y: number): Vector2;
  68798. /**
  68799. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68800. * @param otherVector defines the other vector
  68801. * @returns a new Vector2
  68802. */
  68803. divide(otherVector: Vector2): Vector2;
  68804. /**
  68805. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68806. * @param otherVector defines the other vector
  68807. * @param result defines the target vector
  68808. * @returns the unmodified current Vector2
  68809. */
  68810. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68811. /**
  68812. * Divides the current Vector2 coordinates by the given ones
  68813. * @param otherVector defines the other vector
  68814. * @returns the current updated Vector2
  68815. */
  68816. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68817. /**
  68818. * Gets a new Vector2 with current Vector2 negated coordinates
  68819. * @returns a new Vector2
  68820. */
  68821. negate(): Vector2;
  68822. /**
  68823. * Multiply the Vector2 coordinates by scale
  68824. * @param scale defines the scaling factor
  68825. * @returns the current updated Vector2
  68826. */
  68827. scaleInPlace(scale: number): Vector2;
  68828. /**
  68829. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68830. * @param scale defines the scaling factor
  68831. * @returns a new Vector2
  68832. */
  68833. scale(scale: number): Vector2;
  68834. /**
  68835. * Scale the current Vector2 values by a factor to a given Vector2
  68836. * @param scale defines the scale factor
  68837. * @param result defines the Vector2 object where to store the result
  68838. * @returns the unmodified current Vector2
  68839. */
  68840. scaleToRef(scale: number, result: Vector2): Vector2;
  68841. /**
  68842. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68843. * @param scale defines the scale factor
  68844. * @param result defines the Vector2 object where to store the result
  68845. * @returns the unmodified current Vector2
  68846. */
  68847. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68848. /**
  68849. * Gets a boolean if two vectors are equals
  68850. * @param otherVector defines the other vector
  68851. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68852. */
  68853. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68854. /**
  68855. * Gets a boolean if two vectors are equals (using an epsilon value)
  68856. * @param otherVector defines the other vector
  68857. * @param epsilon defines the minimal distance to consider equality
  68858. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68859. */
  68860. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68861. /**
  68862. * Gets a new Vector2 from current Vector2 floored values
  68863. * @returns a new Vector2
  68864. */
  68865. floor(): Vector2;
  68866. /**
  68867. * Gets a new Vector2 from current Vector2 floored values
  68868. * @returns a new Vector2
  68869. */
  68870. fract(): Vector2;
  68871. /**
  68872. * Gets the length of the vector
  68873. * @returns the vector length (float)
  68874. */
  68875. length(): number;
  68876. /**
  68877. * Gets the vector squared length
  68878. * @returns the vector squared length (float)
  68879. */
  68880. lengthSquared(): number;
  68881. /**
  68882. * Normalize the vector
  68883. * @returns the current updated Vector2
  68884. */
  68885. normalize(): Vector2;
  68886. /**
  68887. * Gets a new Vector2 copied from the Vector2
  68888. * @returns a new Vector2
  68889. */
  68890. clone(): Vector2;
  68891. /**
  68892. * Gets a new Vector2(0, 0)
  68893. * @returns a new Vector2
  68894. */
  68895. static Zero(): Vector2;
  68896. /**
  68897. * Gets a new Vector2(1, 1)
  68898. * @returns a new Vector2
  68899. */
  68900. static One(): Vector2;
  68901. /**
  68902. * Gets a new Vector2 set from the given index element of the given array
  68903. * @param array defines the data source
  68904. * @param offset defines the offset in the data source
  68905. * @returns a new Vector2
  68906. */
  68907. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68908. /**
  68909. * Sets "result" from the given index element of the given array
  68910. * @param array defines the data source
  68911. * @param offset defines the offset in the data source
  68912. * @param result defines the target vector
  68913. */
  68914. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68915. /**
  68916. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68917. * @param value1 defines 1st point of control
  68918. * @param value2 defines 2nd point of control
  68919. * @param value3 defines 3rd point of control
  68920. * @param value4 defines 4th point of control
  68921. * @param amount defines the interpolation factor
  68922. * @returns a new Vector2
  68923. */
  68924. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68925. /**
  68926. * 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".
  68927. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68928. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68929. * @param value defines the value to clamp
  68930. * @param min defines the lower limit
  68931. * @param max defines the upper limit
  68932. * @returns a new Vector2
  68933. */
  68934. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68935. /**
  68936. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68937. * @param value1 defines the 1st control point
  68938. * @param tangent1 defines the outgoing tangent
  68939. * @param value2 defines the 2nd control point
  68940. * @param tangent2 defines the incoming tangent
  68941. * @param amount defines the interpolation factor
  68942. * @returns a new Vector2
  68943. */
  68944. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68945. /**
  68946. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68947. * @param start defines the start vector
  68948. * @param end defines the end vector
  68949. * @param amount defines the interpolation factor
  68950. * @returns a new Vector2
  68951. */
  68952. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68953. /**
  68954. * Gets the dot product of the vector "left" and the vector "right"
  68955. * @param left defines first vector
  68956. * @param right defines second vector
  68957. * @returns the dot product (float)
  68958. */
  68959. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68960. /**
  68961. * Returns a new Vector2 equal to the normalized given vector
  68962. * @param vector defines the vector to normalize
  68963. * @returns a new Vector2
  68964. */
  68965. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68966. /**
  68967. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68968. * @param left defines 1st vector
  68969. * @param right defines 2nd vector
  68970. * @returns a new Vector2
  68971. */
  68972. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68973. /**
  68974. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68975. * @param left defines 1st vector
  68976. * @param right defines 2nd vector
  68977. * @returns a new Vector2
  68978. */
  68979. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68980. /**
  68981. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68982. * @param vector defines the vector to transform
  68983. * @param transformation defines the matrix to apply
  68984. * @returns a new Vector2
  68985. */
  68986. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  68987. /**
  68988. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68989. * @param vector defines the vector to transform
  68990. * @param transformation defines the matrix to apply
  68991. * @param result defines the target vector
  68992. */
  68993. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  68994. /**
  68995. * Determines if a given vector is included in a triangle
  68996. * @param p defines the vector to test
  68997. * @param p0 defines 1st triangle point
  68998. * @param p1 defines 2nd triangle point
  68999. * @param p2 defines 3rd triangle point
  69000. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69001. */
  69002. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69003. /**
  69004. * Gets the distance between the vectors "value1" and "value2"
  69005. * @param value1 defines first vector
  69006. * @param value2 defines second vector
  69007. * @returns the distance between vectors
  69008. */
  69009. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69010. /**
  69011. * Returns the squared distance between the vectors "value1" and "value2"
  69012. * @param value1 defines first vector
  69013. * @param value2 defines second vector
  69014. * @returns the squared distance between vectors
  69015. */
  69016. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69017. /**
  69018. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69019. * @param value1 defines first vector
  69020. * @param value2 defines second vector
  69021. * @returns a new Vector2
  69022. */
  69023. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69024. /**
  69025. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69026. * @param p defines the middle point
  69027. * @param segA defines one point of the segment
  69028. * @param segB defines the other point of the segment
  69029. * @returns the shortest distance
  69030. */
  69031. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69032. }
  69033. /**
  69034. * Classed used to store (x,y,z) vector representation
  69035. * A Vector3 is the main object used in 3D geometry
  69036. * It can represent etiher the coordinates of a point the space, either a direction
  69037. * Reminder: js uses a left handed forward facing system
  69038. */
  69039. export class Vector3 {
  69040. /**
  69041. * Defines the first coordinates (on X axis)
  69042. */
  69043. x: number;
  69044. /**
  69045. * Defines the second coordinates (on Y axis)
  69046. */
  69047. y: number;
  69048. /**
  69049. * Defines the third coordinates (on Z axis)
  69050. */
  69051. z: number;
  69052. private static _UpReadOnly;
  69053. private static _ZeroReadOnly;
  69054. /**
  69055. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69056. * @param x defines the first coordinates (on X axis)
  69057. * @param y defines the second coordinates (on Y axis)
  69058. * @param z defines the third coordinates (on Z axis)
  69059. */
  69060. constructor(
  69061. /**
  69062. * Defines the first coordinates (on X axis)
  69063. */
  69064. x?: number,
  69065. /**
  69066. * Defines the second coordinates (on Y axis)
  69067. */
  69068. y?: number,
  69069. /**
  69070. * Defines the third coordinates (on Z axis)
  69071. */
  69072. z?: number);
  69073. /**
  69074. * Creates a string representation of the Vector3
  69075. * @returns a string with the Vector3 coordinates.
  69076. */
  69077. toString(): string;
  69078. /**
  69079. * Gets the class name
  69080. * @returns the string "Vector3"
  69081. */
  69082. getClassName(): string;
  69083. /**
  69084. * Creates the Vector3 hash code
  69085. * @returns a number which tends to be unique between Vector3 instances
  69086. */
  69087. getHashCode(): number;
  69088. /**
  69089. * Creates an array containing three elements : the coordinates of the Vector3
  69090. * @returns a new array of numbers
  69091. */
  69092. asArray(): number[];
  69093. /**
  69094. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69095. * @param array defines the destination array
  69096. * @param index defines the offset in the destination array
  69097. * @returns the current Vector3
  69098. */
  69099. toArray(array: FloatArray, index?: number): Vector3;
  69100. /**
  69101. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69102. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69103. */
  69104. toQuaternion(): Quaternion;
  69105. /**
  69106. * Adds the given vector to the current Vector3
  69107. * @param otherVector defines the second operand
  69108. * @returns the current updated Vector3
  69109. */
  69110. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69111. /**
  69112. * Adds the given coordinates to the current Vector3
  69113. * @param x defines the x coordinate of the operand
  69114. * @param y defines the y coordinate of the operand
  69115. * @param z defines the z coordinate of the operand
  69116. * @returns the current updated Vector3
  69117. */
  69118. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69119. /**
  69120. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69121. * @param otherVector defines the second operand
  69122. * @returns the resulting Vector3
  69123. */
  69124. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69125. /**
  69126. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69127. * @param otherVector defines the second operand
  69128. * @param result defines the Vector3 object where to store the result
  69129. * @returns the current Vector3
  69130. */
  69131. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69132. /**
  69133. * Subtract the given vector from the current Vector3
  69134. * @param otherVector defines the second operand
  69135. * @returns the current updated Vector3
  69136. */
  69137. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69138. /**
  69139. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69140. * @param otherVector defines the second operand
  69141. * @returns the resulting Vector3
  69142. */
  69143. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69144. /**
  69145. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69146. * @param otherVector defines the second operand
  69147. * @param result defines the Vector3 object where to store the result
  69148. * @returns the current Vector3
  69149. */
  69150. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69151. /**
  69152. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69153. * @param x defines the x coordinate of the operand
  69154. * @param y defines the y coordinate of the operand
  69155. * @param z defines the z coordinate of the operand
  69156. * @returns the resulting Vector3
  69157. */
  69158. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69159. /**
  69160. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69161. * @param x defines the x coordinate of the operand
  69162. * @param y defines the y coordinate of the operand
  69163. * @param z defines the z coordinate of the operand
  69164. * @param result defines the Vector3 object where to store the result
  69165. * @returns the current Vector3
  69166. */
  69167. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69168. /**
  69169. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69170. * @returns a new Vector3
  69171. */
  69172. negate(): Vector3;
  69173. /**
  69174. * Multiplies the Vector3 coordinates by the float "scale"
  69175. * @param scale defines the multiplier factor
  69176. * @returns the current updated Vector3
  69177. */
  69178. scaleInPlace(scale: number): Vector3;
  69179. /**
  69180. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69181. * @param scale defines the multiplier factor
  69182. * @returns a new Vector3
  69183. */
  69184. scale(scale: number): Vector3;
  69185. /**
  69186. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69187. * @param scale defines the multiplier factor
  69188. * @param result defines the Vector3 object where to store the result
  69189. * @returns the current Vector3
  69190. */
  69191. scaleToRef(scale: number, result: Vector3): Vector3;
  69192. /**
  69193. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69194. * @param scale defines the scale factor
  69195. * @param result defines the Vector3 object where to store the result
  69196. * @returns the unmodified current Vector3
  69197. */
  69198. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69199. /**
  69200. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69201. * @param otherVector defines the second operand
  69202. * @returns true if both vectors are equals
  69203. */
  69204. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69205. /**
  69206. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69207. * @param otherVector defines the second operand
  69208. * @param epsilon defines the minimal distance to define values as equals
  69209. * @returns true if both vectors are distant less than epsilon
  69210. */
  69211. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69212. /**
  69213. * Returns true if the current Vector3 coordinates equals the given floats
  69214. * @param x defines the x coordinate of the operand
  69215. * @param y defines the y coordinate of the operand
  69216. * @param z defines the z coordinate of the operand
  69217. * @returns true if both vectors are equals
  69218. */
  69219. equalsToFloats(x: number, y: number, z: number): boolean;
  69220. /**
  69221. * Multiplies the current Vector3 coordinates by the given ones
  69222. * @param otherVector defines the second operand
  69223. * @returns the current updated Vector3
  69224. */
  69225. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69226. /**
  69227. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69228. * @param otherVector defines the second operand
  69229. * @returns the new Vector3
  69230. */
  69231. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69232. /**
  69233. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69234. * @param otherVector defines the second operand
  69235. * @param result defines the Vector3 object where to store the result
  69236. * @returns the current Vector3
  69237. */
  69238. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69239. /**
  69240. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69241. * @param x defines the x coordinate of the operand
  69242. * @param y defines the y coordinate of the operand
  69243. * @param z defines the z coordinate of the operand
  69244. * @returns the new Vector3
  69245. */
  69246. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69247. /**
  69248. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69249. * @param otherVector defines the second operand
  69250. * @returns the new Vector3
  69251. */
  69252. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69253. /**
  69254. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69255. * @param otherVector defines the second operand
  69256. * @param result defines the Vector3 object where to store the result
  69257. * @returns the current Vector3
  69258. */
  69259. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69260. /**
  69261. * Divides the current Vector3 coordinates by the given ones.
  69262. * @param otherVector defines the second operand
  69263. * @returns the current updated Vector3
  69264. */
  69265. divideInPlace(otherVector: Vector3): Vector3;
  69266. /**
  69267. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69268. * @param other defines the second operand
  69269. * @returns the current updated Vector3
  69270. */
  69271. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69272. /**
  69273. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69274. * @param other defines the second operand
  69275. * @returns the current updated Vector3
  69276. */
  69277. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69278. /**
  69279. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69280. * @param x defines the x coordinate of the operand
  69281. * @param y defines the y coordinate of the operand
  69282. * @param z defines the z coordinate of the operand
  69283. * @returns the current updated Vector3
  69284. */
  69285. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69286. /**
  69287. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69288. * @param x defines the x coordinate of the operand
  69289. * @param y defines the y coordinate of the operand
  69290. * @param z defines the z coordinate of the operand
  69291. * @returns the current updated Vector3
  69292. */
  69293. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69294. /**
  69295. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69296. * Check if is non uniform within a certain amount of decimal places to account for this
  69297. * @param epsilon the amount the values can differ
  69298. * @returns if the the vector is non uniform to a certain number of decimal places
  69299. */
  69300. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69301. /**
  69302. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69303. */
  69304. readonly isNonUniform: boolean;
  69305. /**
  69306. * Gets a new Vector3 from current Vector3 floored values
  69307. * @returns a new Vector3
  69308. */
  69309. floor(): Vector3;
  69310. /**
  69311. * Gets a new Vector3 from current Vector3 floored values
  69312. * @returns a new Vector3
  69313. */
  69314. fract(): Vector3;
  69315. /**
  69316. * Gets the length of the Vector3
  69317. * @returns the length of the Vector3
  69318. */
  69319. length(): number;
  69320. /**
  69321. * Gets the squared length of the Vector3
  69322. * @returns squared length of the Vector3
  69323. */
  69324. lengthSquared(): number;
  69325. /**
  69326. * Normalize the current Vector3.
  69327. * Please note that this is an in place operation.
  69328. * @returns the current updated Vector3
  69329. */
  69330. normalize(): Vector3;
  69331. /**
  69332. * Reorders the x y z properties of the vector in place
  69333. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69334. * @returns the current updated vector
  69335. */
  69336. reorderInPlace(order: string): this;
  69337. /**
  69338. * Rotates the vector around 0,0,0 by a quaternion
  69339. * @param quaternion the rotation quaternion
  69340. * @param result vector to store the result
  69341. * @returns the resulting vector
  69342. */
  69343. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69344. /**
  69345. * Rotates a vector around a given point
  69346. * @param quaternion the rotation quaternion
  69347. * @param point the point to rotate around
  69348. * @param result vector to store the result
  69349. * @returns the resulting vector
  69350. */
  69351. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69352. /**
  69353. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69354. * The cross product is then orthogonal to both current and "other"
  69355. * @param other defines the right operand
  69356. * @returns the cross product
  69357. */
  69358. cross(other: Vector3): Vector3;
  69359. /**
  69360. * Normalize the current Vector3 with the given input length.
  69361. * Please note that this is an in place operation.
  69362. * @param len the length of the vector
  69363. * @returns the current updated Vector3
  69364. */
  69365. normalizeFromLength(len: number): Vector3;
  69366. /**
  69367. * Normalize the current Vector3 to a new vector
  69368. * @returns the new Vector3
  69369. */
  69370. normalizeToNew(): Vector3;
  69371. /**
  69372. * Normalize the current Vector3 to the reference
  69373. * @param reference define the Vector3 to update
  69374. * @returns the updated Vector3
  69375. */
  69376. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69377. /**
  69378. * Creates a new Vector3 copied from the current Vector3
  69379. * @returns the new Vector3
  69380. */
  69381. clone(): Vector3;
  69382. /**
  69383. * Copies the given vector coordinates to the current Vector3 ones
  69384. * @param source defines the source Vector3
  69385. * @returns the current updated Vector3
  69386. */
  69387. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69388. /**
  69389. * Copies the given floats to the current Vector3 coordinates
  69390. * @param x defines the x coordinate of the operand
  69391. * @param y defines the y coordinate of the operand
  69392. * @param z defines the z coordinate of the operand
  69393. * @returns the current updated Vector3
  69394. */
  69395. copyFromFloats(x: number, y: number, z: number): Vector3;
  69396. /**
  69397. * Copies the given floats to the current Vector3 coordinates
  69398. * @param x defines the x coordinate of the operand
  69399. * @param y defines the y coordinate of the operand
  69400. * @param z defines the z coordinate of the operand
  69401. * @returns the current updated Vector3
  69402. */
  69403. set(x: number, y: number, z: number): Vector3;
  69404. /**
  69405. * Copies the given float to the current Vector3 coordinates
  69406. * @param v defines the x, y and z coordinates of the operand
  69407. * @returns the current updated Vector3
  69408. */
  69409. setAll(v: number): Vector3;
  69410. /**
  69411. * Get the clip factor between two vectors
  69412. * @param vector0 defines the first operand
  69413. * @param vector1 defines the second operand
  69414. * @param axis defines the axis to use
  69415. * @param size defines the size along the axis
  69416. * @returns the clip factor
  69417. */
  69418. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69419. /**
  69420. * Get angle between two vectors
  69421. * @param vector0 angle between vector0 and vector1
  69422. * @param vector1 angle between vector0 and vector1
  69423. * @param normal direction of the normal
  69424. * @return the angle between vector0 and vector1
  69425. */
  69426. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69427. /**
  69428. * Returns a new Vector3 set from the index "offset" of the given array
  69429. * @param array defines the source array
  69430. * @param offset defines the offset in the source array
  69431. * @returns the new Vector3
  69432. */
  69433. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69434. /**
  69435. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69436. * This function is deprecated. Use FromArray instead
  69437. * @param array defines the source array
  69438. * @param offset defines the offset in the source array
  69439. * @returns the new Vector3
  69440. */
  69441. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69442. /**
  69443. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69444. * @param array defines the source array
  69445. * @param offset defines the offset in the source array
  69446. * @param result defines the Vector3 where to store the result
  69447. */
  69448. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69449. /**
  69450. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69451. * This function is deprecated. Use FromArrayToRef instead.
  69452. * @param array defines the source array
  69453. * @param offset defines the offset in the source array
  69454. * @param result defines the Vector3 where to store the result
  69455. */
  69456. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69457. /**
  69458. * Sets the given vector "result" with the given floats.
  69459. * @param x defines the x coordinate of the source
  69460. * @param y defines the y coordinate of the source
  69461. * @param z defines the z coordinate of the source
  69462. * @param result defines the Vector3 where to store the result
  69463. */
  69464. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69465. /**
  69466. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69467. * @returns a new empty Vector3
  69468. */
  69469. static Zero(): Vector3;
  69470. /**
  69471. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69472. * @returns a new unit Vector3
  69473. */
  69474. static One(): Vector3;
  69475. /**
  69476. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69477. * @returns a new up Vector3
  69478. */
  69479. static Up(): Vector3;
  69480. /**
  69481. * Gets a up Vector3 that must not be updated
  69482. */
  69483. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69484. /**
  69485. * Gets a zero Vector3 that must not be updated
  69486. */
  69487. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69488. /**
  69489. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69490. * @returns a new down Vector3
  69491. */
  69492. static Down(): Vector3;
  69493. /**
  69494. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69495. * @returns a new forward Vector3
  69496. */
  69497. static Forward(): Vector3;
  69498. /**
  69499. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69500. * @returns a new forward Vector3
  69501. */
  69502. static Backward(): Vector3;
  69503. /**
  69504. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69505. * @returns a new right Vector3
  69506. */
  69507. static Right(): Vector3;
  69508. /**
  69509. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69510. * @returns a new left Vector3
  69511. */
  69512. static Left(): Vector3;
  69513. /**
  69514. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69515. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69516. * @param vector defines the Vector3 to transform
  69517. * @param transformation defines the transformation matrix
  69518. * @returns the transformed Vector3
  69519. */
  69520. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69521. /**
  69522. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69523. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69524. * @param vector defines the Vector3 to transform
  69525. * @param transformation defines the transformation matrix
  69526. * @param result defines the Vector3 where to store the result
  69527. */
  69528. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69529. /**
  69530. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69531. * This method computes tranformed coordinates only, not transformed direction vectors
  69532. * @param x define the x coordinate of the source vector
  69533. * @param y define the y coordinate of the source vector
  69534. * @param z define the z coordinate of the source vector
  69535. * @param transformation defines the transformation matrix
  69536. * @param result defines the Vector3 where to store the result
  69537. */
  69538. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69539. /**
  69540. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69541. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69542. * @param vector defines the Vector3 to transform
  69543. * @param transformation defines the transformation matrix
  69544. * @returns the new Vector3
  69545. */
  69546. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69547. /**
  69548. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69549. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69550. * @param vector defines the Vector3 to transform
  69551. * @param transformation defines the transformation matrix
  69552. * @param result defines the Vector3 where to store the result
  69553. */
  69554. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69555. /**
  69556. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69557. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69558. * @param x define the x coordinate of the source vector
  69559. * @param y define the y coordinate of the source vector
  69560. * @param z define the z coordinate of the source vector
  69561. * @param transformation defines the transformation matrix
  69562. * @param result defines the Vector3 where to store the result
  69563. */
  69564. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69565. /**
  69566. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69567. * @param value1 defines the first control point
  69568. * @param value2 defines the second control point
  69569. * @param value3 defines the third control point
  69570. * @param value4 defines the fourth control point
  69571. * @param amount defines the amount on the spline to use
  69572. * @returns the new Vector3
  69573. */
  69574. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69575. /**
  69576. * 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"
  69577. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69578. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69579. * @param value defines the current value
  69580. * @param min defines the lower range value
  69581. * @param max defines the upper range value
  69582. * @returns the new Vector3
  69583. */
  69584. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69585. /**
  69586. * 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"
  69587. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69588. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69589. * @param value defines the current value
  69590. * @param min defines the lower range value
  69591. * @param max defines the upper range value
  69592. * @param result defines the Vector3 where to store the result
  69593. */
  69594. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69595. /**
  69596. * Checks if a given vector is inside a specific range
  69597. * @param v defines the vector to test
  69598. * @param min defines the minimum range
  69599. * @param max defines the maximum range
  69600. */
  69601. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69602. /**
  69603. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69604. * @param value1 defines the first control point
  69605. * @param tangent1 defines the first tangent vector
  69606. * @param value2 defines the second control point
  69607. * @param tangent2 defines the second tangent vector
  69608. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69609. * @returns the new Vector3
  69610. */
  69611. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69612. /**
  69613. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69614. * @param start defines the start value
  69615. * @param end defines the end value
  69616. * @param amount max defines amount between both (between 0 and 1)
  69617. * @returns the new Vector3
  69618. */
  69619. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69620. /**
  69621. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69622. * @param start defines the start value
  69623. * @param end defines the end value
  69624. * @param amount max defines amount between both (between 0 and 1)
  69625. * @param result defines the Vector3 where to store the result
  69626. */
  69627. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69628. /**
  69629. * Returns the dot product (float) between the vectors "left" and "right"
  69630. * @param left defines the left operand
  69631. * @param right defines the right operand
  69632. * @returns the dot product
  69633. */
  69634. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69635. /**
  69636. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69637. * The cross product is then orthogonal to both "left" and "right"
  69638. * @param left defines the left operand
  69639. * @param right defines the right operand
  69640. * @returns the cross product
  69641. */
  69642. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69643. /**
  69644. * Sets the given vector "result" with the cross product of "left" and "right"
  69645. * The cross product is then orthogonal to both "left" and "right"
  69646. * @param left defines the left operand
  69647. * @param right defines the right operand
  69648. * @param result defines the Vector3 where to store the result
  69649. */
  69650. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69651. /**
  69652. * Returns a new Vector3 as the normalization of the given vector
  69653. * @param vector defines the Vector3 to normalize
  69654. * @returns the new Vector3
  69655. */
  69656. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69657. /**
  69658. * Sets the given vector "result" with the normalization of the given first vector
  69659. * @param vector defines the Vector3 to normalize
  69660. * @param result defines the Vector3 where to store the result
  69661. */
  69662. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69663. /**
  69664. * Project a Vector3 onto screen space
  69665. * @param vector defines the Vector3 to project
  69666. * @param world defines the world matrix to use
  69667. * @param transform defines the transform (view x projection) matrix to use
  69668. * @param viewport defines the screen viewport to use
  69669. * @returns the new Vector3
  69670. */
  69671. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69672. /** @hidden */
  69673. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69674. /**
  69675. * Unproject from screen space to object space
  69676. * @param source defines the screen space Vector3 to use
  69677. * @param viewportWidth defines the current width of the viewport
  69678. * @param viewportHeight defines the current height of the viewport
  69679. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69680. * @param transform defines the transform (view x projection) matrix to use
  69681. * @returns the new Vector3
  69682. */
  69683. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69684. /**
  69685. * Unproject from screen space to object space
  69686. * @param source defines the screen space Vector3 to use
  69687. * @param viewportWidth defines the current width of the viewport
  69688. * @param viewportHeight defines the current height of the viewport
  69689. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69690. * @param view defines the view matrix to use
  69691. * @param projection defines the projection matrix to use
  69692. * @returns the new Vector3
  69693. */
  69694. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69695. /**
  69696. * Unproject from screen space to object space
  69697. * @param source defines the screen space Vector3 to use
  69698. * @param viewportWidth defines the current width of the viewport
  69699. * @param viewportHeight defines the current height of the viewport
  69700. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69701. * @param view defines the view matrix to use
  69702. * @param projection defines the projection matrix to use
  69703. * @param result defines the Vector3 where to store the result
  69704. */
  69705. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69706. /**
  69707. * Unproject from screen space to object space
  69708. * @param sourceX defines the screen space x coordinate to use
  69709. * @param sourceY defines the screen space y coordinate to use
  69710. * @param sourceZ defines the screen space z coordinate to use
  69711. * @param viewportWidth defines the current width of the viewport
  69712. * @param viewportHeight defines the current height of the viewport
  69713. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69714. * @param view defines the view matrix to use
  69715. * @param projection defines the projection matrix to use
  69716. * @param result defines the Vector3 where to store the result
  69717. */
  69718. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69719. /**
  69720. * Gets the minimal coordinate values between two Vector3
  69721. * @param left defines the first operand
  69722. * @param right defines the second operand
  69723. * @returns the new Vector3
  69724. */
  69725. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69726. /**
  69727. * Gets the maximal coordinate values between two Vector3
  69728. * @param left defines the first operand
  69729. * @param right defines the second operand
  69730. * @returns the new Vector3
  69731. */
  69732. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69733. /**
  69734. * Returns the distance between the vectors "value1" and "value2"
  69735. * @param value1 defines the first operand
  69736. * @param value2 defines the second operand
  69737. * @returns the distance
  69738. */
  69739. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69740. /**
  69741. * Returns the squared distance between the vectors "value1" and "value2"
  69742. * @param value1 defines the first operand
  69743. * @param value2 defines the second operand
  69744. * @returns the squared distance
  69745. */
  69746. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69747. /**
  69748. * Returns a new Vector3 located at the center between "value1" and "value2"
  69749. * @param value1 defines the first operand
  69750. * @param value2 defines the second operand
  69751. * @returns the new Vector3
  69752. */
  69753. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69754. /**
  69755. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69756. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69757. * to something in order to rotate it from its local system to the given target system
  69758. * Note: axis1, axis2 and axis3 are normalized during this operation
  69759. * @param axis1 defines the first axis
  69760. * @param axis2 defines the second axis
  69761. * @param axis3 defines the third axis
  69762. * @returns a new Vector3
  69763. */
  69764. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69765. /**
  69766. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69767. * @param axis1 defines the first axis
  69768. * @param axis2 defines the second axis
  69769. * @param axis3 defines the third axis
  69770. * @param ref defines the Vector3 where to store the result
  69771. */
  69772. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69773. }
  69774. /**
  69775. * Vector4 class created for EulerAngle class conversion to Quaternion
  69776. */
  69777. export class Vector4 {
  69778. /** x value of the vector */
  69779. x: number;
  69780. /** y value of the vector */
  69781. y: number;
  69782. /** z value of the vector */
  69783. z: number;
  69784. /** w value of the vector */
  69785. w: number;
  69786. /**
  69787. * Creates a Vector4 object from the given floats.
  69788. * @param x x value of the vector
  69789. * @param y y value of the vector
  69790. * @param z z value of the vector
  69791. * @param w w value of the vector
  69792. */
  69793. constructor(
  69794. /** x value of the vector */
  69795. x: number,
  69796. /** y value of the vector */
  69797. y: number,
  69798. /** z value of the vector */
  69799. z: number,
  69800. /** w value of the vector */
  69801. w: number);
  69802. /**
  69803. * Returns the string with the Vector4 coordinates.
  69804. * @returns a string containing all the vector values
  69805. */
  69806. toString(): string;
  69807. /**
  69808. * Returns the string "Vector4".
  69809. * @returns "Vector4"
  69810. */
  69811. getClassName(): string;
  69812. /**
  69813. * Returns the Vector4 hash code.
  69814. * @returns a unique hash code
  69815. */
  69816. getHashCode(): number;
  69817. /**
  69818. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69819. * @returns the resulting array
  69820. */
  69821. asArray(): number[];
  69822. /**
  69823. * Populates the given array from the given index with the Vector4 coordinates.
  69824. * @param array array to populate
  69825. * @param index index of the array to start at (default: 0)
  69826. * @returns the Vector4.
  69827. */
  69828. toArray(array: FloatArray, index?: number): Vector4;
  69829. /**
  69830. * Adds the given vector to the current Vector4.
  69831. * @param otherVector the vector to add
  69832. * @returns the updated Vector4.
  69833. */
  69834. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69835. /**
  69836. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69837. * @param otherVector the vector to add
  69838. * @returns the resulting vector
  69839. */
  69840. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69841. /**
  69842. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69843. * @param otherVector the vector to add
  69844. * @param result the vector to store the result
  69845. * @returns the current Vector4.
  69846. */
  69847. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69848. /**
  69849. * Subtract in place the given vector from the current Vector4.
  69850. * @param otherVector the vector to subtract
  69851. * @returns the updated Vector4.
  69852. */
  69853. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69854. /**
  69855. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69856. * @param otherVector the vector to add
  69857. * @returns the new vector with the result
  69858. */
  69859. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69860. /**
  69861. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69862. * @param otherVector the vector to subtract
  69863. * @param result the vector to store the result
  69864. * @returns the current Vector4.
  69865. */
  69866. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69867. /**
  69868. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69869. */
  69870. /**
  69871. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69872. * @param x value to subtract
  69873. * @param y value to subtract
  69874. * @param z value to subtract
  69875. * @param w value to subtract
  69876. * @returns new vector containing the result
  69877. */
  69878. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69879. /**
  69880. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69881. * @param x value to subtract
  69882. * @param y value to subtract
  69883. * @param z value to subtract
  69884. * @param w value to subtract
  69885. * @param result the vector to store the result in
  69886. * @returns the current Vector4.
  69887. */
  69888. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69889. /**
  69890. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69891. * @returns a new vector with the negated values
  69892. */
  69893. negate(): Vector4;
  69894. /**
  69895. * Multiplies the current Vector4 coordinates by scale (float).
  69896. * @param scale the number to scale with
  69897. * @returns the updated Vector4.
  69898. */
  69899. scaleInPlace(scale: number): Vector4;
  69900. /**
  69901. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69902. * @param scale the number to scale with
  69903. * @returns a new vector with the result
  69904. */
  69905. scale(scale: number): Vector4;
  69906. /**
  69907. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69908. * @param scale the number to scale with
  69909. * @param result a vector to store the result in
  69910. * @returns the current Vector4.
  69911. */
  69912. scaleToRef(scale: number, result: Vector4): Vector4;
  69913. /**
  69914. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69915. * @param scale defines the scale factor
  69916. * @param result defines the Vector4 object where to store the result
  69917. * @returns the unmodified current Vector4
  69918. */
  69919. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69920. /**
  69921. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69922. * @param otherVector the vector to compare against
  69923. * @returns true if they are equal
  69924. */
  69925. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69926. /**
  69927. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69928. * @param otherVector vector to compare against
  69929. * @param epsilon (Default: very small number)
  69930. * @returns true if they are equal
  69931. */
  69932. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69933. /**
  69934. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69935. * @param x x value to compare against
  69936. * @param y y value to compare against
  69937. * @param z z value to compare against
  69938. * @param w w value to compare against
  69939. * @returns true if equal
  69940. */
  69941. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69942. /**
  69943. * Multiplies in place the current Vector4 by the given one.
  69944. * @param otherVector vector to multiple with
  69945. * @returns the updated Vector4.
  69946. */
  69947. multiplyInPlace(otherVector: Vector4): Vector4;
  69948. /**
  69949. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69950. * @param otherVector vector to multiple with
  69951. * @returns resulting new vector
  69952. */
  69953. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69954. /**
  69955. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69956. * @param otherVector vector to multiple with
  69957. * @param result vector to store the result
  69958. * @returns the current Vector4.
  69959. */
  69960. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69961. /**
  69962. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69963. * @param x x value multiply with
  69964. * @param y y value multiply with
  69965. * @param z z value multiply with
  69966. * @param w w value multiply with
  69967. * @returns resulting new vector
  69968. */
  69969. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69970. /**
  69971. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69972. * @param otherVector vector to devide with
  69973. * @returns resulting new vector
  69974. */
  69975. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69976. /**
  69977. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69978. * @param otherVector vector to devide with
  69979. * @param result vector to store the result
  69980. * @returns the current Vector4.
  69981. */
  69982. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69983. /**
  69984. * Divides the current Vector3 coordinates by the given ones.
  69985. * @param otherVector vector to devide with
  69986. * @returns the updated Vector3.
  69987. */
  69988. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69989. /**
  69990. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69991. * @param other defines the second operand
  69992. * @returns the current updated Vector4
  69993. */
  69994. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  69995. /**
  69996. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  69997. * @param other defines the second operand
  69998. * @returns the current updated Vector4
  69999. */
  70000. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70001. /**
  70002. * Gets a new Vector4 from current Vector4 floored values
  70003. * @returns a new Vector4
  70004. */
  70005. floor(): Vector4;
  70006. /**
  70007. * Gets a new Vector4 from current Vector3 floored values
  70008. * @returns a new Vector4
  70009. */
  70010. fract(): Vector4;
  70011. /**
  70012. * Returns the Vector4 length (float).
  70013. * @returns the length
  70014. */
  70015. length(): number;
  70016. /**
  70017. * Returns the Vector4 squared length (float).
  70018. * @returns the length squared
  70019. */
  70020. lengthSquared(): number;
  70021. /**
  70022. * Normalizes in place the Vector4.
  70023. * @returns the updated Vector4.
  70024. */
  70025. normalize(): Vector4;
  70026. /**
  70027. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70028. * @returns this converted to a new vector3
  70029. */
  70030. toVector3(): Vector3;
  70031. /**
  70032. * Returns a new Vector4 copied from the current one.
  70033. * @returns the new cloned vector
  70034. */
  70035. clone(): Vector4;
  70036. /**
  70037. * Updates the current Vector4 with the given one coordinates.
  70038. * @param source the source vector to copy from
  70039. * @returns the updated Vector4.
  70040. */
  70041. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70042. /**
  70043. * Updates the current Vector4 coordinates with the given floats.
  70044. * @param x float to copy from
  70045. * @param y float to copy from
  70046. * @param z float to copy from
  70047. * @param w float to copy from
  70048. * @returns the updated Vector4.
  70049. */
  70050. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70051. /**
  70052. * Updates the current Vector4 coordinates with the given floats.
  70053. * @param x float to set from
  70054. * @param y float to set from
  70055. * @param z float to set from
  70056. * @param w float to set from
  70057. * @returns the updated Vector4.
  70058. */
  70059. set(x: number, y: number, z: number, w: number): Vector4;
  70060. /**
  70061. * Copies the given float to the current Vector3 coordinates
  70062. * @param v defines the x, y, z and w coordinates of the operand
  70063. * @returns the current updated Vector3
  70064. */
  70065. setAll(v: number): Vector4;
  70066. /**
  70067. * Returns a new Vector4 set from the starting index of the given array.
  70068. * @param array the array to pull values from
  70069. * @param offset the offset into the array to start at
  70070. * @returns the new vector
  70071. */
  70072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70073. /**
  70074. * Updates the given vector "result" from the starting index of the given array.
  70075. * @param array the array to pull values from
  70076. * @param offset the offset into the array to start at
  70077. * @param result the vector to store the result in
  70078. */
  70079. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70080. /**
  70081. * Updates the given vector "result" from the starting index of the given Float32Array.
  70082. * @param array the array to pull values from
  70083. * @param offset the offset into the array to start at
  70084. * @param result the vector to store the result in
  70085. */
  70086. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70087. /**
  70088. * Updates the given vector "result" coordinates from the given floats.
  70089. * @param x float to set from
  70090. * @param y float to set from
  70091. * @param z float to set from
  70092. * @param w float to set from
  70093. * @param result the vector to the floats in
  70094. */
  70095. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70096. /**
  70097. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70098. * @returns the new vector
  70099. */
  70100. static Zero(): Vector4;
  70101. /**
  70102. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70103. * @returns the new vector
  70104. */
  70105. static One(): Vector4;
  70106. /**
  70107. * Returns a new normalized Vector4 from the given one.
  70108. * @param vector the vector to normalize
  70109. * @returns the vector
  70110. */
  70111. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70112. /**
  70113. * Updates the given vector "result" from the normalization of the given one.
  70114. * @param vector the vector to normalize
  70115. * @param result the vector to store the result in
  70116. */
  70117. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70118. /**
  70119. * Returns a vector with the minimum values from the left and right vectors
  70120. * @param left left vector to minimize
  70121. * @param right right vector to minimize
  70122. * @returns a new vector with the minimum of the left and right vector values
  70123. */
  70124. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70125. /**
  70126. * Returns a vector with the maximum values from the left and right vectors
  70127. * @param left left vector to maximize
  70128. * @param right right vector to maximize
  70129. * @returns a new vector with the maximum of the left and right vector values
  70130. */
  70131. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70132. /**
  70133. * Returns the distance (float) between the vectors "value1" and "value2".
  70134. * @param value1 value to calulate the distance between
  70135. * @param value2 value to calulate the distance between
  70136. * @return the distance between the two vectors
  70137. */
  70138. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70139. /**
  70140. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70141. * @param value1 value to calulate the distance between
  70142. * @param value2 value to calulate the distance between
  70143. * @return the distance between the two vectors squared
  70144. */
  70145. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70146. /**
  70147. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70148. * @param value1 value to calulate the center between
  70149. * @param value2 value to calulate the center between
  70150. * @return the center between the two vectors
  70151. */
  70152. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70153. /**
  70154. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70155. * This methods computes transformed normalized direction vectors only.
  70156. * @param vector the vector to transform
  70157. * @param transformation the transformation matrix to apply
  70158. * @returns the new vector
  70159. */
  70160. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70161. /**
  70162. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70163. * This methods computes transformed normalized direction vectors only.
  70164. * @param vector the vector to transform
  70165. * @param transformation the transformation matrix to apply
  70166. * @param result the vector to store the result in
  70167. */
  70168. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70169. /**
  70170. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70171. * This methods computes transformed normalized direction vectors only.
  70172. * @param x value to transform
  70173. * @param y value to transform
  70174. * @param z value to transform
  70175. * @param w value to transform
  70176. * @param transformation the transformation matrix to apply
  70177. * @param result the vector to store the results in
  70178. */
  70179. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70180. /**
  70181. * Creates a new Vector4 from a Vector3
  70182. * @param source defines the source data
  70183. * @param w defines the 4th component (default is 0)
  70184. * @returns a new Vector4
  70185. */
  70186. static FromVector3(source: Vector3, w?: number): Vector4;
  70187. }
  70188. /**
  70189. * Class used to store quaternion data
  70190. * @see https://en.wikipedia.org/wiki/Quaternion
  70191. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70192. */
  70193. export class Quaternion {
  70194. /** defines the first component (0 by default) */
  70195. x: number;
  70196. /** defines the second component (0 by default) */
  70197. y: number;
  70198. /** defines the third component (0 by default) */
  70199. z: number;
  70200. /** defines the fourth component (1.0 by default) */
  70201. w: number;
  70202. /**
  70203. * Creates a new Quaternion from the given floats
  70204. * @param x defines the first component (0 by default)
  70205. * @param y defines the second component (0 by default)
  70206. * @param z defines the third component (0 by default)
  70207. * @param w defines the fourth component (1.0 by default)
  70208. */
  70209. constructor(
  70210. /** defines the first component (0 by default) */
  70211. x?: number,
  70212. /** defines the second component (0 by default) */
  70213. y?: number,
  70214. /** defines the third component (0 by default) */
  70215. z?: number,
  70216. /** defines the fourth component (1.0 by default) */
  70217. w?: number);
  70218. /**
  70219. * Gets a string representation for the current quaternion
  70220. * @returns a string with the Quaternion coordinates
  70221. */
  70222. toString(): string;
  70223. /**
  70224. * Gets the class name of the quaternion
  70225. * @returns the string "Quaternion"
  70226. */
  70227. getClassName(): string;
  70228. /**
  70229. * Gets a hash code for this quaternion
  70230. * @returns the quaternion hash code
  70231. */
  70232. getHashCode(): number;
  70233. /**
  70234. * Copy the quaternion to an array
  70235. * @returns a new array populated with 4 elements from the quaternion coordinates
  70236. */
  70237. asArray(): number[];
  70238. /**
  70239. * Check if two quaternions are equals
  70240. * @param otherQuaternion defines the second operand
  70241. * @return true if the current quaternion and the given one coordinates are strictly equals
  70242. */
  70243. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70244. /**
  70245. * Clone the current quaternion
  70246. * @returns a new quaternion copied from the current one
  70247. */
  70248. clone(): Quaternion;
  70249. /**
  70250. * Copy a quaternion to the current one
  70251. * @param other defines the other quaternion
  70252. * @returns the updated current quaternion
  70253. */
  70254. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70255. /**
  70256. * Updates the current quaternion with the given float coordinates
  70257. * @param x defines the x coordinate
  70258. * @param y defines the y coordinate
  70259. * @param z defines the z coordinate
  70260. * @param w defines the w coordinate
  70261. * @returns the updated current quaternion
  70262. */
  70263. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70264. /**
  70265. * Updates the current quaternion from the given float coordinates
  70266. * @param x defines the x coordinate
  70267. * @param y defines the y coordinate
  70268. * @param z defines the z coordinate
  70269. * @param w defines the w coordinate
  70270. * @returns the updated current quaternion
  70271. */
  70272. set(x: number, y: number, z: number, w: number): Quaternion;
  70273. /**
  70274. * Adds two quaternions
  70275. * @param other defines the second operand
  70276. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70277. */
  70278. add(other: DeepImmutable<Quaternion>): Quaternion;
  70279. /**
  70280. * Add a quaternion to the current one
  70281. * @param other defines the quaternion to add
  70282. * @returns the current quaternion
  70283. */
  70284. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70285. /**
  70286. * Subtract two quaternions
  70287. * @param other defines the second operand
  70288. * @returns a new quaternion as the subtraction result of the given one from the current one
  70289. */
  70290. subtract(other: Quaternion): Quaternion;
  70291. /**
  70292. * Multiplies the current quaternion by a scale factor
  70293. * @param value defines the scale factor
  70294. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70295. */
  70296. scale(value: number): Quaternion;
  70297. /**
  70298. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70299. * @param scale defines the scale factor
  70300. * @param result defines the Quaternion object where to store the result
  70301. * @returns the unmodified current quaternion
  70302. */
  70303. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70304. /**
  70305. * Multiplies in place the current quaternion by a scale factor
  70306. * @param value defines the scale factor
  70307. * @returns the current modified quaternion
  70308. */
  70309. scaleInPlace(value: number): Quaternion;
  70310. /**
  70311. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70312. * @param scale defines the scale factor
  70313. * @param result defines the Quaternion object where to store the result
  70314. * @returns the unmodified current quaternion
  70315. */
  70316. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70317. /**
  70318. * Multiplies two quaternions
  70319. * @param q1 defines the second operand
  70320. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70321. */
  70322. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70323. /**
  70324. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70325. * @param q1 defines the second operand
  70326. * @param result defines the target quaternion
  70327. * @returns the current quaternion
  70328. */
  70329. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70330. /**
  70331. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70332. * @param q1 defines the second operand
  70333. * @returns the currentupdated quaternion
  70334. */
  70335. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70336. /**
  70337. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70338. * @param ref defines the target quaternion
  70339. * @returns the current quaternion
  70340. */
  70341. conjugateToRef(ref: Quaternion): Quaternion;
  70342. /**
  70343. * Conjugates in place (1-q) the current quaternion
  70344. * @returns the current updated quaternion
  70345. */
  70346. conjugateInPlace(): Quaternion;
  70347. /**
  70348. * Conjugates in place (1-q) the current quaternion
  70349. * @returns a new quaternion
  70350. */
  70351. conjugate(): Quaternion;
  70352. /**
  70353. * Gets length of current quaternion
  70354. * @returns the quaternion length (float)
  70355. */
  70356. length(): number;
  70357. /**
  70358. * Normalize in place the current quaternion
  70359. * @returns the current updated quaternion
  70360. */
  70361. normalize(): Quaternion;
  70362. /**
  70363. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70364. * @param order is a reserved parameter and is ignore for now
  70365. * @returns a new Vector3 containing the Euler angles
  70366. */
  70367. toEulerAngles(order?: string): Vector3;
  70368. /**
  70369. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70370. * @param result defines the vector which will be filled with the Euler angles
  70371. * @param order is a reserved parameter and is ignore for now
  70372. * @returns the current unchanged quaternion
  70373. */
  70374. toEulerAnglesToRef(result: Vector3): Quaternion;
  70375. /**
  70376. * Updates the given rotation matrix with the current quaternion values
  70377. * @param result defines the target matrix
  70378. * @returns the current unchanged quaternion
  70379. */
  70380. toRotationMatrix(result: Matrix): Quaternion;
  70381. /**
  70382. * Updates the current quaternion from the given rotation matrix values
  70383. * @param matrix defines the source matrix
  70384. * @returns the current updated quaternion
  70385. */
  70386. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70387. /**
  70388. * Creates a new quaternion from a rotation matrix
  70389. * @param matrix defines the source matrix
  70390. * @returns a new quaternion created from the given rotation matrix values
  70391. */
  70392. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70393. /**
  70394. * Updates the given quaternion with the given rotation matrix values
  70395. * @param matrix defines the source matrix
  70396. * @param result defines the target quaternion
  70397. */
  70398. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70399. /**
  70400. * Returns the dot product (float) between the quaternions "left" and "right"
  70401. * @param left defines the left operand
  70402. * @param right defines the right operand
  70403. * @returns the dot product
  70404. */
  70405. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70406. /**
  70407. * Checks if the two quaternions are close to each other
  70408. * @param quat0 defines the first quaternion to check
  70409. * @param quat1 defines the second quaternion to check
  70410. * @returns true if the two quaternions are close to each other
  70411. */
  70412. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70413. /**
  70414. * Creates an empty quaternion
  70415. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70416. */
  70417. static Zero(): Quaternion;
  70418. /**
  70419. * Inverse a given quaternion
  70420. * @param q defines the source quaternion
  70421. * @returns a new quaternion as the inverted current quaternion
  70422. */
  70423. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70424. /**
  70425. * Inverse a given quaternion
  70426. * @param q defines the source quaternion
  70427. * @param result the quaternion the result will be stored in
  70428. * @returns the result quaternion
  70429. */
  70430. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70431. /**
  70432. * Creates an identity quaternion
  70433. * @returns the identity quaternion
  70434. */
  70435. static Identity(): Quaternion;
  70436. /**
  70437. * Gets a boolean indicating if the given quaternion is identity
  70438. * @param quaternion defines the quaternion to check
  70439. * @returns true if the quaternion is identity
  70440. */
  70441. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70442. /**
  70443. * Creates a quaternion from a rotation around an axis
  70444. * @param axis defines the axis to use
  70445. * @param angle defines the angle to use
  70446. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70447. */
  70448. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70449. /**
  70450. * Creates a rotation around an axis and stores it into the given quaternion
  70451. * @param axis defines the axis to use
  70452. * @param angle defines the angle to use
  70453. * @param result defines the target quaternion
  70454. * @returns the target quaternion
  70455. */
  70456. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70457. /**
  70458. * Creates a new quaternion from data stored into an array
  70459. * @param array defines the data source
  70460. * @param offset defines the offset in the source array where the data starts
  70461. * @returns a new quaternion
  70462. */
  70463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70464. /**
  70465. * Create a quaternion from Euler rotation angles
  70466. * @param x Pitch
  70467. * @param y Yaw
  70468. * @param z Roll
  70469. * @returns the new Quaternion
  70470. */
  70471. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70472. /**
  70473. * Updates a quaternion from Euler rotation angles
  70474. * @param x Pitch
  70475. * @param y Yaw
  70476. * @param z Roll
  70477. * @param result the quaternion to store the result
  70478. * @returns the updated quaternion
  70479. */
  70480. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70481. /**
  70482. * Create a quaternion from Euler rotation vector
  70483. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70484. * @returns the new Quaternion
  70485. */
  70486. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70487. /**
  70488. * Updates a quaternion from Euler rotation vector
  70489. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70490. * @param result the quaternion to store the result
  70491. * @returns the updated quaternion
  70492. */
  70493. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70494. /**
  70495. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70496. * @param yaw defines the rotation around Y axis
  70497. * @param pitch defines the rotation around X axis
  70498. * @param roll defines the rotation around Z axis
  70499. * @returns the new quaternion
  70500. */
  70501. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70502. /**
  70503. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70504. * @param yaw defines the rotation around Y axis
  70505. * @param pitch defines the rotation around X axis
  70506. * @param roll defines the rotation around Z axis
  70507. * @param result defines the target quaternion
  70508. */
  70509. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70510. /**
  70511. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70512. * @param alpha defines the rotation around first axis
  70513. * @param beta defines the rotation around second axis
  70514. * @param gamma defines the rotation around third axis
  70515. * @returns the new quaternion
  70516. */
  70517. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70518. /**
  70519. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70520. * @param alpha defines the rotation around first axis
  70521. * @param beta defines the rotation around second axis
  70522. * @param gamma defines the rotation around third axis
  70523. * @param result defines the target quaternion
  70524. */
  70525. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70526. /**
  70527. * 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)
  70528. * @param axis1 defines the first axis
  70529. * @param axis2 defines the second axis
  70530. * @param axis3 defines the third axis
  70531. * @returns the new quaternion
  70532. */
  70533. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70534. /**
  70535. * 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
  70536. * @param axis1 defines the first axis
  70537. * @param axis2 defines the second axis
  70538. * @param axis3 defines the third axis
  70539. * @param ref defines the target quaternion
  70540. */
  70541. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70542. /**
  70543. * Interpolates between two quaternions
  70544. * @param left defines first quaternion
  70545. * @param right defines second quaternion
  70546. * @param amount defines the gradient to use
  70547. * @returns the new interpolated quaternion
  70548. */
  70549. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70550. /**
  70551. * Interpolates between two quaternions and stores it into a target quaternion
  70552. * @param left defines first quaternion
  70553. * @param right defines second quaternion
  70554. * @param amount defines the gradient to use
  70555. * @param result defines the target quaternion
  70556. */
  70557. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70558. /**
  70559. * Interpolate between two quaternions using Hermite interpolation
  70560. * @param value1 defines first quaternion
  70561. * @param tangent1 defines the incoming tangent
  70562. * @param value2 defines second quaternion
  70563. * @param tangent2 defines the outgoing tangent
  70564. * @param amount defines the target quaternion
  70565. * @returns the new interpolated quaternion
  70566. */
  70567. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70568. }
  70569. /**
  70570. * Class used to store matrix data (4x4)
  70571. */
  70572. export class Matrix {
  70573. private static _updateFlagSeed;
  70574. private static _identityReadOnly;
  70575. private _isIdentity;
  70576. private _isIdentityDirty;
  70577. private _isIdentity3x2;
  70578. private _isIdentity3x2Dirty;
  70579. /**
  70580. * Gets the update flag of the matrix which is an unique number for the matrix.
  70581. * It will be incremented every time the matrix data change.
  70582. * You can use it to speed the comparison between two versions of the same matrix.
  70583. */
  70584. updateFlag: number;
  70585. private readonly _m;
  70586. /**
  70587. * Gets the internal data of the matrix
  70588. */
  70589. readonly m: DeepImmutable<Float32Array>;
  70590. /** @hidden */
  70591. _markAsUpdated(): void;
  70592. /** @hidden */
  70593. private _updateIdentityStatus;
  70594. /**
  70595. * Creates an empty matrix (filled with zeros)
  70596. */
  70597. constructor();
  70598. /**
  70599. * Check if the current matrix is identity
  70600. * @returns true is the matrix is the identity matrix
  70601. */
  70602. isIdentity(): boolean;
  70603. /**
  70604. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70605. * @returns true is the matrix is the identity matrix
  70606. */
  70607. isIdentityAs3x2(): boolean;
  70608. /**
  70609. * Gets the determinant of the matrix
  70610. * @returns the matrix determinant
  70611. */
  70612. determinant(): number;
  70613. /**
  70614. * Returns the matrix as a Float32Array
  70615. * @returns the matrix underlying array
  70616. */
  70617. toArray(): DeepImmutable<Float32Array>;
  70618. /**
  70619. * Returns the matrix as a Float32Array
  70620. * @returns the matrix underlying array.
  70621. */
  70622. asArray(): DeepImmutable<Float32Array>;
  70623. /**
  70624. * Inverts the current matrix in place
  70625. * @returns the current inverted matrix
  70626. */
  70627. invert(): Matrix;
  70628. /**
  70629. * Sets all the matrix elements to zero
  70630. * @returns the current matrix
  70631. */
  70632. reset(): Matrix;
  70633. /**
  70634. * Adds the current matrix with a second one
  70635. * @param other defines the matrix to add
  70636. * @returns a new matrix as the addition of the current matrix and the given one
  70637. */
  70638. add(other: DeepImmutable<Matrix>): Matrix;
  70639. /**
  70640. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70641. * @param other defines the matrix to add
  70642. * @param result defines the target matrix
  70643. * @returns the current matrix
  70644. */
  70645. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70646. /**
  70647. * Adds in place the given matrix to the current matrix
  70648. * @param other defines the second operand
  70649. * @returns the current updated matrix
  70650. */
  70651. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70652. /**
  70653. * Sets the given matrix to the current inverted Matrix
  70654. * @param other defines the target matrix
  70655. * @returns the unmodified current matrix
  70656. */
  70657. invertToRef(other: Matrix): Matrix;
  70658. /**
  70659. * add a value at the specified position in the current Matrix
  70660. * @param index the index of the value within the matrix. between 0 and 15.
  70661. * @param value the value to be added
  70662. * @returns the current updated matrix
  70663. */
  70664. addAtIndex(index: number, value: number): Matrix;
  70665. /**
  70666. * mutiply the specified position in the current Matrix by a value
  70667. * @param index the index of the value within the matrix. between 0 and 15.
  70668. * @param value the value to be added
  70669. * @returns the current updated matrix
  70670. */
  70671. multiplyAtIndex(index: number, value: number): Matrix;
  70672. /**
  70673. * Inserts the translation vector (using 3 floats) in the current matrix
  70674. * @param x defines the 1st component of the translation
  70675. * @param y defines the 2nd component of the translation
  70676. * @param z defines the 3rd component of the translation
  70677. * @returns the current updated matrix
  70678. */
  70679. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70680. /**
  70681. * Adds the translation vector (using 3 floats) in the current matrix
  70682. * @param x defines the 1st component of the translation
  70683. * @param y defines the 2nd component of the translation
  70684. * @param z defines the 3rd component of the translation
  70685. * @returns the current updated matrix
  70686. */
  70687. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70688. /**
  70689. * Inserts the translation vector in the current matrix
  70690. * @param vector3 defines the translation to insert
  70691. * @returns the current updated matrix
  70692. */
  70693. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70694. /**
  70695. * Gets the translation value of the current matrix
  70696. * @returns a new Vector3 as the extracted translation from the matrix
  70697. */
  70698. getTranslation(): Vector3;
  70699. /**
  70700. * Fill a Vector3 with the extracted translation from the matrix
  70701. * @param result defines the Vector3 where to store the translation
  70702. * @returns the current matrix
  70703. */
  70704. getTranslationToRef(result: Vector3): Matrix;
  70705. /**
  70706. * Remove rotation and scaling part from the matrix
  70707. * @returns the updated matrix
  70708. */
  70709. removeRotationAndScaling(): Matrix;
  70710. /**
  70711. * Multiply two matrices
  70712. * @param other defines the second operand
  70713. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70714. */
  70715. multiply(other: DeepImmutable<Matrix>): Matrix;
  70716. /**
  70717. * Copy the current matrix from the given one
  70718. * @param other defines the source matrix
  70719. * @returns the current updated matrix
  70720. */
  70721. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70722. /**
  70723. * Populates the given array from the starting index with the current matrix values
  70724. * @param array defines the target array
  70725. * @param offset defines the offset in the target array where to start storing values
  70726. * @returns the current matrix
  70727. */
  70728. copyToArray(array: Float32Array, offset?: number): Matrix;
  70729. /**
  70730. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70731. * @param other defines the second operand
  70732. * @param result defines the matrix where to store the multiplication
  70733. * @returns the current matrix
  70734. */
  70735. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70736. /**
  70737. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70738. * @param other defines the second operand
  70739. * @param result defines the array where to store the multiplication
  70740. * @param offset defines the offset in the target array where to start storing values
  70741. * @returns the current matrix
  70742. */
  70743. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70744. /**
  70745. * Check equality between this matrix and a second one
  70746. * @param value defines the second matrix to compare
  70747. * @returns true is the current matrix and the given one values are strictly equal
  70748. */
  70749. equals(value: DeepImmutable<Matrix>): boolean;
  70750. /**
  70751. * Clone the current matrix
  70752. * @returns a new matrix from the current matrix
  70753. */
  70754. clone(): Matrix;
  70755. /**
  70756. * Returns the name of the current matrix class
  70757. * @returns the string "Matrix"
  70758. */
  70759. getClassName(): string;
  70760. /**
  70761. * Gets the hash code of the current matrix
  70762. * @returns the hash code
  70763. */
  70764. getHashCode(): number;
  70765. /**
  70766. * Decomposes the current Matrix into a translation, rotation and scaling components
  70767. * @param scale defines the scale vector3 given as a reference to update
  70768. * @param rotation defines the rotation quaternion given as a reference to update
  70769. * @param translation defines the translation vector3 given as a reference to update
  70770. * @returns true if operation was successful
  70771. */
  70772. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70773. /**
  70774. * Gets specific row of the matrix
  70775. * @param index defines the number of the row to get
  70776. * @returns the index-th row of the current matrix as a new Vector4
  70777. */
  70778. getRow(index: number): Nullable<Vector4>;
  70779. /**
  70780. * Sets the index-th row of the current matrix to the vector4 values
  70781. * @param index defines the number of the row to set
  70782. * @param row defines the target vector4
  70783. * @returns the updated current matrix
  70784. */
  70785. setRow(index: number, row: Vector4): Matrix;
  70786. /**
  70787. * Compute the transpose of the matrix
  70788. * @returns the new transposed matrix
  70789. */
  70790. transpose(): Matrix;
  70791. /**
  70792. * Compute the transpose of the matrix and store it in a given matrix
  70793. * @param result defines the target matrix
  70794. * @returns the current matrix
  70795. */
  70796. transposeToRef(result: Matrix): Matrix;
  70797. /**
  70798. * Sets the index-th row of the current matrix with the given 4 x float values
  70799. * @param index defines the row index
  70800. * @param x defines the x component to set
  70801. * @param y defines the y component to set
  70802. * @param z defines the z component to set
  70803. * @param w defines the w component to set
  70804. * @returns the updated current matrix
  70805. */
  70806. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70807. /**
  70808. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70809. * @param scale defines the scale factor
  70810. * @returns a new matrix
  70811. */
  70812. scale(scale: number): Matrix;
  70813. /**
  70814. * Scale the current matrix values by a factor to a given result matrix
  70815. * @param scale defines the scale factor
  70816. * @param result defines the matrix to store the result
  70817. * @returns the current matrix
  70818. */
  70819. scaleToRef(scale: number, result: Matrix): Matrix;
  70820. /**
  70821. * Scale the current matrix values by a factor and add the result to a given matrix
  70822. * @param scale defines the scale factor
  70823. * @param result defines the Matrix to store the result
  70824. * @returns the current matrix
  70825. */
  70826. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70827. /**
  70828. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70829. * @param ref matrix to store the result
  70830. */
  70831. toNormalMatrix(ref: Matrix): void;
  70832. /**
  70833. * Gets only rotation part of the current matrix
  70834. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70835. */
  70836. getRotationMatrix(): Matrix;
  70837. /**
  70838. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70839. * @param result defines the target matrix to store data to
  70840. * @returns the current matrix
  70841. */
  70842. getRotationMatrixToRef(result: Matrix): Matrix;
  70843. /**
  70844. * Toggles model matrix from being right handed to left handed in place and vice versa
  70845. */
  70846. toggleModelMatrixHandInPlace(): void;
  70847. /**
  70848. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70849. */
  70850. toggleProjectionMatrixHandInPlace(): void;
  70851. /**
  70852. * Creates a matrix from an array
  70853. * @param array defines the source array
  70854. * @param offset defines an offset in the source array
  70855. * @returns a new Matrix set from the starting index of the given array
  70856. */
  70857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70858. /**
  70859. * Copy the content of an array into a given matrix
  70860. * @param array defines the source array
  70861. * @param offset defines an offset in the source array
  70862. * @param result defines the target matrix
  70863. */
  70864. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70865. /**
  70866. * Stores an array into a matrix after having multiplied each component by a given factor
  70867. * @param array defines the source array
  70868. * @param offset defines the offset in the source array
  70869. * @param scale defines the scaling factor
  70870. * @param result defines the target matrix
  70871. */
  70872. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70873. /**
  70874. * Gets an identity matrix that must not be updated
  70875. */
  70876. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70877. /**
  70878. * Stores a list of values (16) inside a given matrix
  70879. * @param initialM11 defines 1st value of 1st row
  70880. * @param initialM12 defines 2nd value of 1st row
  70881. * @param initialM13 defines 3rd value of 1st row
  70882. * @param initialM14 defines 4th value of 1st row
  70883. * @param initialM21 defines 1st value of 2nd row
  70884. * @param initialM22 defines 2nd value of 2nd row
  70885. * @param initialM23 defines 3rd value of 2nd row
  70886. * @param initialM24 defines 4th value of 2nd row
  70887. * @param initialM31 defines 1st value of 3rd row
  70888. * @param initialM32 defines 2nd value of 3rd row
  70889. * @param initialM33 defines 3rd value of 3rd row
  70890. * @param initialM34 defines 4th value of 3rd row
  70891. * @param initialM41 defines 1st value of 4th row
  70892. * @param initialM42 defines 2nd value of 4th row
  70893. * @param initialM43 defines 3rd value of 4th row
  70894. * @param initialM44 defines 4th value of 4th row
  70895. * @param result defines the target matrix
  70896. */
  70897. 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;
  70898. /**
  70899. * Creates new matrix from a list of values (16)
  70900. * @param initialM11 defines 1st value of 1st row
  70901. * @param initialM12 defines 2nd value of 1st row
  70902. * @param initialM13 defines 3rd value of 1st row
  70903. * @param initialM14 defines 4th value of 1st row
  70904. * @param initialM21 defines 1st value of 2nd row
  70905. * @param initialM22 defines 2nd value of 2nd row
  70906. * @param initialM23 defines 3rd value of 2nd row
  70907. * @param initialM24 defines 4th value of 2nd row
  70908. * @param initialM31 defines 1st value of 3rd row
  70909. * @param initialM32 defines 2nd value of 3rd row
  70910. * @param initialM33 defines 3rd value of 3rd row
  70911. * @param initialM34 defines 4th value of 3rd row
  70912. * @param initialM41 defines 1st value of 4th row
  70913. * @param initialM42 defines 2nd value of 4th row
  70914. * @param initialM43 defines 3rd value of 4th row
  70915. * @param initialM44 defines 4th value of 4th row
  70916. * @returns the new matrix
  70917. */
  70918. 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;
  70919. /**
  70920. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70921. * @param scale defines the scale vector3
  70922. * @param rotation defines the rotation quaternion
  70923. * @param translation defines the translation vector3
  70924. * @returns a new matrix
  70925. */
  70926. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70927. /**
  70928. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70929. * @param scale defines the scale vector3
  70930. * @param rotation defines the rotation quaternion
  70931. * @param translation defines the translation vector3
  70932. * @param result defines the target matrix
  70933. */
  70934. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70935. /**
  70936. * Creates a new identity matrix
  70937. * @returns a new identity matrix
  70938. */
  70939. static Identity(): Matrix;
  70940. /**
  70941. * Creates a new identity matrix and stores the result in a given matrix
  70942. * @param result defines the target matrix
  70943. */
  70944. static IdentityToRef(result: Matrix): void;
  70945. /**
  70946. * Creates a new zero matrix
  70947. * @returns a new zero matrix
  70948. */
  70949. static Zero(): Matrix;
  70950. /**
  70951. * Creates a new rotation matrix for "angle" radians around the X axis
  70952. * @param angle defines the angle (in radians) to use
  70953. * @return the new matrix
  70954. */
  70955. static RotationX(angle: number): Matrix;
  70956. /**
  70957. * Creates a new matrix as the invert of a given matrix
  70958. * @param source defines the source matrix
  70959. * @returns the new matrix
  70960. */
  70961. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70962. /**
  70963. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70964. * @param angle defines the angle (in radians) to use
  70965. * @param result defines the target matrix
  70966. */
  70967. static RotationXToRef(angle: number, result: Matrix): void;
  70968. /**
  70969. * Creates a new rotation matrix for "angle" radians around the Y axis
  70970. * @param angle defines the angle (in radians) to use
  70971. * @return the new matrix
  70972. */
  70973. static RotationY(angle: number): Matrix;
  70974. /**
  70975. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70976. * @param angle defines the angle (in radians) to use
  70977. * @param result defines the target matrix
  70978. */
  70979. static RotationYToRef(angle: number, result: Matrix): void;
  70980. /**
  70981. * Creates a new rotation matrix for "angle" radians around the Z axis
  70982. * @param angle defines the angle (in radians) to use
  70983. * @return the new matrix
  70984. */
  70985. static RotationZ(angle: number): Matrix;
  70986. /**
  70987. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  70988. * @param angle defines the angle (in radians) to use
  70989. * @param result defines the target matrix
  70990. */
  70991. static RotationZToRef(angle: number, result: Matrix): void;
  70992. /**
  70993. * Creates a new rotation matrix for "angle" radians around the given axis
  70994. * @param axis defines the axis to use
  70995. * @param angle defines the angle (in radians) to use
  70996. * @return the new matrix
  70997. */
  70998. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  70999. /**
  71000. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71001. * @param axis defines the axis to use
  71002. * @param angle defines the angle (in radians) to use
  71003. * @param result defines the target matrix
  71004. */
  71005. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71006. /**
  71007. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71008. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71009. * @param from defines the vector to align
  71010. * @param to defines the vector to align to
  71011. * @param result defines the target matrix
  71012. */
  71013. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71014. /**
  71015. * Creates a rotation matrix
  71016. * @param yaw defines the yaw angle in radians (Y axis)
  71017. * @param pitch defines the pitch angle in radians (X axis)
  71018. * @param roll defines the roll angle in radians (X axis)
  71019. * @returns the new rotation matrix
  71020. */
  71021. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71022. /**
  71023. * Creates a rotation matrix and stores it in a given matrix
  71024. * @param yaw defines the yaw angle in radians (Y axis)
  71025. * @param pitch defines the pitch angle in radians (X axis)
  71026. * @param roll defines the roll angle in radians (X axis)
  71027. * @param result defines the target matrix
  71028. */
  71029. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71030. /**
  71031. * Creates a scaling matrix
  71032. * @param x defines the scale factor on X axis
  71033. * @param y defines the scale factor on Y axis
  71034. * @param z defines the scale factor on Z axis
  71035. * @returns the new matrix
  71036. */
  71037. static Scaling(x: number, y: number, z: number): Matrix;
  71038. /**
  71039. * Creates a scaling matrix and stores it in a given matrix
  71040. * @param x defines the scale factor on X axis
  71041. * @param y defines the scale factor on Y axis
  71042. * @param z defines the scale factor on Z axis
  71043. * @param result defines the target matrix
  71044. */
  71045. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71046. /**
  71047. * Creates a translation matrix
  71048. * @param x defines the translation on X axis
  71049. * @param y defines the translation on Y axis
  71050. * @param z defines the translationon Z axis
  71051. * @returns the new matrix
  71052. */
  71053. static Translation(x: number, y: number, z: number): Matrix;
  71054. /**
  71055. * Creates a translation matrix and stores it in a given matrix
  71056. * @param x defines the translation on X axis
  71057. * @param y defines the translation on Y axis
  71058. * @param z defines the translationon Z axis
  71059. * @param result defines the target matrix
  71060. */
  71061. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71062. /**
  71063. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71064. * @param startValue defines the start value
  71065. * @param endValue defines the end value
  71066. * @param gradient defines the gradient factor
  71067. * @returns the new matrix
  71068. */
  71069. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71070. /**
  71071. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71072. * @param startValue defines the start value
  71073. * @param endValue defines the end value
  71074. * @param gradient defines the gradient factor
  71075. * @param result defines the Matrix object where to store data
  71076. */
  71077. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71078. /**
  71079. * Builds a new matrix whose values are computed by:
  71080. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71081. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71082. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71083. * @param startValue defines the first matrix
  71084. * @param endValue defines the second matrix
  71085. * @param gradient defines the gradient between the two matrices
  71086. * @returns the new matrix
  71087. */
  71088. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71089. /**
  71090. * Update a matrix to values which are computed by:
  71091. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71092. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71093. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71094. * @param startValue defines the first matrix
  71095. * @param endValue defines the second matrix
  71096. * @param gradient defines the gradient between the two matrices
  71097. * @param result defines the target matrix
  71098. */
  71099. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71100. /**
  71101. * 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"
  71102. * This function works in left handed mode
  71103. * @param eye defines the final position of the entity
  71104. * @param target defines where the entity should look at
  71105. * @param up defines the up vector for the entity
  71106. * @returns the new matrix
  71107. */
  71108. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71109. /**
  71110. * 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".
  71111. * This function works in left handed mode
  71112. * @param eye defines the final position of the entity
  71113. * @param target defines where the entity should look at
  71114. * @param up defines the up vector for the entity
  71115. * @param result defines the target matrix
  71116. */
  71117. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71118. /**
  71119. * 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"
  71120. * This function works in right handed mode
  71121. * @param eye defines the final position of the entity
  71122. * @param target defines where the entity should look at
  71123. * @param up defines the up vector for the entity
  71124. * @returns the new matrix
  71125. */
  71126. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71127. /**
  71128. * 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".
  71129. * This function works in right handed mode
  71130. * @param eye defines the final position of the entity
  71131. * @param target defines where the entity should look at
  71132. * @param up defines the up vector for the entity
  71133. * @param result defines the target matrix
  71134. */
  71135. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71136. /**
  71137. * Create a left-handed orthographic projection matrix
  71138. * @param width defines the viewport width
  71139. * @param height defines the viewport height
  71140. * @param znear defines the near clip plane
  71141. * @param zfar defines the far clip plane
  71142. * @returns a new matrix as a left-handed orthographic projection matrix
  71143. */
  71144. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71145. /**
  71146. * Store a left-handed orthographic projection to a given matrix
  71147. * @param width defines the viewport width
  71148. * @param height defines the viewport height
  71149. * @param znear defines the near clip plane
  71150. * @param zfar defines the far clip plane
  71151. * @param result defines the target matrix
  71152. */
  71153. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71154. /**
  71155. * Create a left-handed orthographic projection matrix
  71156. * @param left defines the viewport left coordinate
  71157. * @param right defines the viewport right coordinate
  71158. * @param bottom defines the viewport bottom coordinate
  71159. * @param top defines the viewport top coordinate
  71160. * @param znear defines the near clip plane
  71161. * @param zfar defines the far clip plane
  71162. * @returns a new matrix as a left-handed orthographic projection matrix
  71163. */
  71164. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71165. /**
  71166. * Stores a left-handed orthographic projection into a given matrix
  71167. * @param left defines the viewport left coordinate
  71168. * @param right defines the viewport right coordinate
  71169. * @param bottom defines the viewport bottom coordinate
  71170. * @param top defines the viewport top coordinate
  71171. * @param znear defines the near clip plane
  71172. * @param zfar defines the far clip plane
  71173. * @param result defines the target matrix
  71174. */
  71175. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71176. /**
  71177. * Creates a right-handed orthographic projection matrix
  71178. * @param left defines the viewport left coordinate
  71179. * @param right defines the viewport right coordinate
  71180. * @param bottom defines the viewport bottom coordinate
  71181. * @param top defines the viewport top coordinate
  71182. * @param znear defines the near clip plane
  71183. * @param zfar defines the far clip plane
  71184. * @returns a new matrix as a right-handed orthographic projection matrix
  71185. */
  71186. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71187. /**
  71188. * Stores a right-handed orthographic projection into a given matrix
  71189. * @param left defines the viewport left coordinate
  71190. * @param right defines the viewport right coordinate
  71191. * @param bottom defines the viewport bottom coordinate
  71192. * @param top defines the viewport top coordinate
  71193. * @param znear defines the near clip plane
  71194. * @param zfar defines the far clip plane
  71195. * @param result defines the target matrix
  71196. */
  71197. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71198. /**
  71199. * Creates a left-handed perspective projection matrix
  71200. * @param width defines the viewport width
  71201. * @param height defines the viewport height
  71202. * @param znear defines the near clip plane
  71203. * @param zfar defines the far clip plane
  71204. * @returns a new matrix as a left-handed perspective projection matrix
  71205. */
  71206. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71207. /**
  71208. * Creates a left-handed perspective projection matrix
  71209. * @param fov defines the horizontal field of view
  71210. * @param aspect defines the aspect ratio
  71211. * @param znear defines the near clip plane
  71212. * @param zfar defines the far clip plane
  71213. * @returns a new matrix as a left-handed perspective projection matrix
  71214. */
  71215. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71216. /**
  71217. * Stores a left-handed perspective projection into a given matrix
  71218. * @param fov defines the horizontal field of view
  71219. * @param aspect defines the aspect ratio
  71220. * @param znear defines the near clip plane
  71221. * @param zfar defines the far clip plane
  71222. * @param result defines the target matrix
  71223. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71224. */
  71225. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71226. /**
  71227. * Creates a right-handed perspective projection matrix
  71228. * @param fov defines the horizontal field of view
  71229. * @param aspect defines the aspect ratio
  71230. * @param znear defines the near clip plane
  71231. * @param zfar defines the far clip plane
  71232. * @returns a new matrix as a right-handed perspective projection matrix
  71233. */
  71234. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71235. /**
  71236. * Stores a right-handed perspective projection into a given matrix
  71237. * @param fov defines the horizontal field of view
  71238. * @param aspect defines the aspect ratio
  71239. * @param znear defines the near clip plane
  71240. * @param zfar defines the far clip plane
  71241. * @param result defines the target matrix
  71242. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71243. */
  71244. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71245. /**
  71246. * Stores a perspective projection for WebVR info a given matrix
  71247. * @param fov defines the field of view
  71248. * @param znear defines the near clip plane
  71249. * @param zfar defines the far clip plane
  71250. * @param result defines the target matrix
  71251. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71252. */
  71253. static PerspectiveFovWebVRToRef(fov: {
  71254. upDegrees: number;
  71255. downDegrees: number;
  71256. leftDegrees: number;
  71257. rightDegrees: number;
  71258. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71259. /**
  71260. * Computes a complete transformation matrix
  71261. * @param viewport defines the viewport to use
  71262. * @param world defines the world matrix
  71263. * @param view defines the view matrix
  71264. * @param projection defines the projection matrix
  71265. * @param zmin defines the near clip plane
  71266. * @param zmax defines the far clip plane
  71267. * @returns the transformation matrix
  71268. */
  71269. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71270. /**
  71271. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71272. * @param matrix defines the matrix to use
  71273. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71274. */
  71275. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71276. /**
  71277. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71278. * @param matrix defines the matrix to use
  71279. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71280. */
  71281. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71282. /**
  71283. * Compute the transpose of a given matrix
  71284. * @param matrix defines the matrix to transpose
  71285. * @returns the new matrix
  71286. */
  71287. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71288. /**
  71289. * Compute the transpose of a matrix and store it in a target matrix
  71290. * @param matrix defines the matrix to transpose
  71291. * @param result defines the target matrix
  71292. */
  71293. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71294. /**
  71295. * Computes a reflection matrix from a plane
  71296. * @param plane defines the reflection plane
  71297. * @returns a new matrix
  71298. */
  71299. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71300. /**
  71301. * Computes a reflection matrix from a plane
  71302. * @param plane defines the reflection plane
  71303. * @param result defines the target matrix
  71304. */
  71305. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71306. /**
  71307. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71308. * @param xaxis defines the value of the 1st axis
  71309. * @param yaxis defines the value of the 2nd axis
  71310. * @param zaxis defines the value of the 3rd axis
  71311. * @param result defines the target matrix
  71312. */
  71313. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71314. /**
  71315. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71316. * @param quat defines the quaternion to use
  71317. * @param result defines the target matrix
  71318. */
  71319. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71320. }
  71321. /**
  71322. * @hidden
  71323. */
  71324. export class TmpVectors {
  71325. static Vector2: Vector2[];
  71326. static Vector3: Vector3[];
  71327. static Vector4: Vector4[];
  71328. static Quaternion: Quaternion[];
  71329. static Matrix: Matrix[];
  71330. }
  71331. }
  71332. declare module BABYLON {
  71333. /**
  71334. * Defines potential orientation for back face culling
  71335. */
  71336. export enum Orientation {
  71337. /**
  71338. * Clockwise
  71339. */
  71340. CW = 0,
  71341. /** Counter clockwise */
  71342. CCW = 1
  71343. }
  71344. /** Class used to represent a Bezier curve */
  71345. export class BezierCurve {
  71346. /**
  71347. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71348. * @param t defines the time
  71349. * @param x1 defines the left coordinate on X axis
  71350. * @param y1 defines the left coordinate on Y axis
  71351. * @param x2 defines the right coordinate on X axis
  71352. * @param y2 defines the right coordinate on Y axis
  71353. * @returns the interpolated value
  71354. */
  71355. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71356. }
  71357. /**
  71358. * Defines angle representation
  71359. */
  71360. export class Angle {
  71361. private _radians;
  71362. /**
  71363. * Creates an Angle object of "radians" radians (float).
  71364. * @param radians the angle in radians
  71365. */
  71366. constructor(radians: number);
  71367. /**
  71368. * Get value in degrees
  71369. * @returns the Angle value in degrees (float)
  71370. */
  71371. degrees(): number;
  71372. /**
  71373. * Get value in radians
  71374. * @returns the Angle value in radians (float)
  71375. */
  71376. radians(): number;
  71377. /**
  71378. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71379. * @param a defines first vector
  71380. * @param b defines second vector
  71381. * @returns a new Angle
  71382. */
  71383. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71384. /**
  71385. * Gets a new Angle object from the given float in radians
  71386. * @param radians defines the angle value in radians
  71387. * @returns a new Angle
  71388. */
  71389. static FromRadians(radians: number): Angle;
  71390. /**
  71391. * Gets a new Angle object from the given float in degrees
  71392. * @param degrees defines the angle value in degrees
  71393. * @returns a new Angle
  71394. */
  71395. static FromDegrees(degrees: number): Angle;
  71396. }
  71397. /**
  71398. * This represents an arc in a 2d space.
  71399. */
  71400. export class Arc2 {
  71401. /** Defines the start point of the arc */
  71402. startPoint: Vector2;
  71403. /** Defines the mid point of the arc */
  71404. midPoint: Vector2;
  71405. /** Defines the end point of the arc */
  71406. endPoint: Vector2;
  71407. /**
  71408. * Defines the center point of the arc.
  71409. */
  71410. centerPoint: Vector2;
  71411. /**
  71412. * Defines the radius of the arc.
  71413. */
  71414. radius: number;
  71415. /**
  71416. * Defines the angle of the arc (from mid point to end point).
  71417. */
  71418. angle: Angle;
  71419. /**
  71420. * Defines the start angle of the arc (from start point to middle point).
  71421. */
  71422. startAngle: Angle;
  71423. /**
  71424. * Defines the orientation of the arc (clock wise/counter clock wise).
  71425. */
  71426. orientation: Orientation;
  71427. /**
  71428. * Creates an Arc object from the three given points : start, middle and end.
  71429. * @param startPoint Defines the start point of the arc
  71430. * @param midPoint Defines the midlle point of the arc
  71431. * @param endPoint Defines the end point of the arc
  71432. */
  71433. constructor(
  71434. /** Defines the start point of the arc */
  71435. startPoint: Vector2,
  71436. /** Defines the mid point of the arc */
  71437. midPoint: Vector2,
  71438. /** Defines the end point of the arc */
  71439. endPoint: Vector2);
  71440. }
  71441. /**
  71442. * Represents a 2D path made up of multiple 2D points
  71443. */
  71444. export class Path2 {
  71445. private _points;
  71446. private _length;
  71447. /**
  71448. * If the path start and end point are the same
  71449. */
  71450. closed: boolean;
  71451. /**
  71452. * Creates a Path2 object from the starting 2D coordinates x and y.
  71453. * @param x the starting points x value
  71454. * @param y the starting points y value
  71455. */
  71456. constructor(x: number, y: number);
  71457. /**
  71458. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71459. * @param x the added points x value
  71460. * @param y the added points y value
  71461. * @returns the updated Path2.
  71462. */
  71463. addLineTo(x: number, y: number): Path2;
  71464. /**
  71465. * 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.
  71466. * @param midX middle point x value
  71467. * @param midY middle point y value
  71468. * @param endX end point x value
  71469. * @param endY end point y value
  71470. * @param numberOfSegments (default: 36)
  71471. * @returns the updated Path2.
  71472. */
  71473. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71474. /**
  71475. * Closes the Path2.
  71476. * @returns the Path2.
  71477. */
  71478. close(): Path2;
  71479. /**
  71480. * Gets the sum of the distance between each sequential point in the path
  71481. * @returns the Path2 total length (float).
  71482. */
  71483. length(): number;
  71484. /**
  71485. * Gets the points which construct the path
  71486. * @returns the Path2 internal array of points.
  71487. */
  71488. getPoints(): Vector2[];
  71489. /**
  71490. * Retreives the point at the distance aways from the starting point
  71491. * @param normalizedLengthPosition the length along the path to retreive the point from
  71492. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71493. */
  71494. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71495. /**
  71496. * Creates a new path starting from an x and y position
  71497. * @param x starting x value
  71498. * @param y starting y value
  71499. * @returns a new Path2 starting at the coordinates (x, y).
  71500. */
  71501. static StartingAt(x: number, y: number): Path2;
  71502. }
  71503. /**
  71504. * Represents a 3D path made up of multiple 3D points
  71505. */
  71506. export class Path3D {
  71507. /**
  71508. * an array of Vector3, the curve axis of the Path3D
  71509. */
  71510. path: Vector3[];
  71511. private _curve;
  71512. private _distances;
  71513. private _tangents;
  71514. private _normals;
  71515. private _binormals;
  71516. private _raw;
  71517. /**
  71518. * new Path3D(path, normal, raw)
  71519. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71520. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71521. * @param path an array of Vector3, the curve axis of the Path3D
  71522. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71523. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71524. */
  71525. constructor(
  71526. /**
  71527. * an array of Vector3, the curve axis of the Path3D
  71528. */
  71529. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71530. /**
  71531. * Returns the Path3D array of successive Vector3 designing its curve.
  71532. * @returns the Path3D array of successive Vector3 designing its curve.
  71533. */
  71534. getCurve(): Vector3[];
  71535. /**
  71536. * Returns an array populated with tangent vectors on each Path3D curve point.
  71537. * @returns an array populated with tangent vectors on each Path3D curve point.
  71538. */
  71539. getTangents(): Vector3[];
  71540. /**
  71541. * Returns an array populated with normal vectors on each Path3D curve point.
  71542. * @returns an array populated with normal vectors on each Path3D curve point.
  71543. */
  71544. getNormals(): Vector3[];
  71545. /**
  71546. * Returns an array populated with binormal vectors on each Path3D curve point.
  71547. * @returns an array populated with binormal vectors on each Path3D curve point.
  71548. */
  71549. getBinormals(): Vector3[];
  71550. /**
  71551. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71552. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71553. */
  71554. getDistances(): number[];
  71555. /**
  71556. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71557. * @param path path which all values are copied into the curves points
  71558. * @param firstNormal which should be projected onto the curve
  71559. * @returns the same object updated.
  71560. */
  71561. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71562. private _compute;
  71563. private _getFirstNonNullVector;
  71564. private _getLastNonNullVector;
  71565. private _normalVector;
  71566. }
  71567. /**
  71568. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71569. * A Curve3 is designed from a series of successive Vector3.
  71570. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71571. */
  71572. export class Curve3 {
  71573. private _points;
  71574. private _length;
  71575. /**
  71576. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71577. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71578. * @param v1 (Vector3) the control point
  71579. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71580. * @param nbPoints (integer) the wanted number of points in the curve
  71581. * @returns the created Curve3
  71582. */
  71583. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71584. /**
  71585. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71586. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71587. * @param v1 (Vector3) the first control point
  71588. * @param v2 (Vector3) the second control point
  71589. * @param v3 (Vector3) the end point of the Cubic Bezier
  71590. * @param nbPoints (integer) the wanted number of points in the curve
  71591. * @returns the created Curve3
  71592. */
  71593. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71594. /**
  71595. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71596. * @param p1 (Vector3) the origin point of the Hermite Spline
  71597. * @param t1 (Vector3) the tangent vector at the origin point
  71598. * @param p2 (Vector3) the end point of the Hermite Spline
  71599. * @param t2 (Vector3) the tangent vector at the end point
  71600. * @param nbPoints (integer) the wanted number of points in the curve
  71601. * @returns the created Curve3
  71602. */
  71603. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71604. /**
  71605. * Returns a Curve3 object along a CatmullRom Spline curve :
  71606. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71607. * @param nbPoints (integer) the wanted number of points between each curve control points
  71608. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71609. * @returns the created Curve3
  71610. */
  71611. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71612. /**
  71613. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71614. * A Curve3 is designed from a series of successive Vector3.
  71615. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71616. * @param points points which make up the curve
  71617. */
  71618. constructor(points: Vector3[]);
  71619. /**
  71620. * @returns the Curve3 stored array of successive Vector3
  71621. */
  71622. getPoints(): Vector3[];
  71623. /**
  71624. * @returns the computed length (float) of the curve.
  71625. */
  71626. length(): number;
  71627. /**
  71628. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71629. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71630. * curveA and curveB keep unchanged.
  71631. * @param curve the curve to continue from this curve
  71632. * @returns the newly constructed curve
  71633. */
  71634. continue(curve: DeepImmutable<Curve3>): Curve3;
  71635. private _computeLength;
  71636. }
  71637. }
  71638. declare module BABYLON {
  71639. /**
  71640. * This represents the main contract an easing function should follow.
  71641. * Easing functions are used throughout the animation system.
  71642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71643. */
  71644. export interface IEasingFunction {
  71645. /**
  71646. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71647. * of the easing function.
  71648. * The link below provides some of the most common examples of easing functions.
  71649. * @see https://easings.net/
  71650. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71651. * @returns the corresponding value on the curve defined by the easing function
  71652. */
  71653. ease(gradient: number): number;
  71654. }
  71655. /**
  71656. * Base class used for every default easing function.
  71657. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71658. */
  71659. export class EasingFunction implements IEasingFunction {
  71660. /**
  71661. * Interpolation follows the mathematical formula associated with the easing function.
  71662. */
  71663. static readonly EASINGMODE_EASEIN: number;
  71664. /**
  71665. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71666. */
  71667. static readonly EASINGMODE_EASEOUT: number;
  71668. /**
  71669. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71670. */
  71671. static readonly EASINGMODE_EASEINOUT: number;
  71672. private _easingMode;
  71673. /**
  71674. * Sets the easing mode of the current function.
  71675. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71676. */
  71677. setEasingMode(easingMode: number): void;
  71678. /**
  71679. * Gets the current easing mode.
  71680. * @returns the easing mode
  71681. */
  71682. getEasingMode(): number;
  71683. /**
  71684. * @hidden
  71685. */
  71686. easeInCore(gradient: number): number;
  71687. /**
  71688. * Given an input gradient between 0 and 1, this returns the corresponding value
  71689. * of the easing function.
  71690. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71691. * @returns the corresponding value on the curve defined by the easing function
  71692. */
  71693. ease(gradient: number): number;
  71694. }
  71695. /**
  71696. * Easing function with a circle shape (see link below).
  71697. * @see https://easings.net/#easeInCirc
  71698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71699. */
  71700. export class CircleEase extends EasingFunction implements IEasingFunction {
  71701. /** @hidden */
  71702. easeInCore(gradient: number): number;
  71703. }
  71704. /**
  71705. * Easing function with a ease back shape (see link below).
  71706. * @see https://easings.net/#easeInBack
  71707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71708. */
  71709. export class BackEase extends EasingFunction implements IEasingFunction {
  71710. /** Defines the amplitude of the function */
  71711. amplitude: number;
  71712. /**
  71713. * Instantiates a back ease easing
  71714. * @see https://easings.net/#easeInBack
  71715. * @param amplitude Defines the amplitude of the function
  71716. */
  71717. constructor(
  71718. /** Defines the amplitude of the function */
  71719. amplitude?: number);
  71720. /** @hidden */
  71721. easeInCore(gradient: number): number;
  71722. }
  71723. /**
  71724. * Easing function with a bouncing shape (see link below).
  71725. * @see https://easings.net/#easeInBounce
  71726. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71727. */
  71728. export class BounceEase extends EasingFunction implements IEasingFunction {
  71729. /** Defines the number of bounces */
  71730. bounces: number;
  71731. /** Defines the amplitude of the bounce */
  71732. bounciness: number;
  71733. /**
  71734. * Instantiates a bounce easing
  71735. * @see https://easings.net/#easeInBounce
  71736. * @param bounces Defines the number of bounces
  71737. * @param bounciness Defines the amplitude of the bounce
  71738. */
  71739. constructor(
  71740. /** Defines the number of bounces */
  71741. bounces?: number,
  71742. /** Defines the amplitude of the bounce */
  71743. bounciness?: number);
  71744. /** @hidden */
  71745. easeInCore(gradient: number): number;
  71746. }
  71747. /**
  71748. * Easing function with a power of 3 shape (see link below).
  71749. * @see https://easings.net/#easeInCubic
  71750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71751. */
  71752. export class CubicEase extends EasingFunction implements IEasingFunction {
  71753. /** @hidden */
  71754. easeInCore(gradient: number): number;
  71755. }
  71756. /**
  71757. * Easing function with an elastic shape (see link below).
  71758. * @see https://easings.net/#easeInElastic
  71759. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71760. */
  71761. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71762. /** Defines the number of oscillations*/
  71763. oscillations: number;
  71764. /** Defines the amplitude of the oscillations*/
  71765. springiness: number;
  71766. /**
  71767. * Instantiates an elastic easing function
  71768. * @see https://easings.net/#easeInElastic
  71769. * @param oscillations Defines the number of oscillations
  71770. * @param springiness Defines the amplitude of the oscillations
  71771. */
  71772. constructor(
  71773. /** Defines the number of oscillations*/
  71774. oscillations?: number,
  71775. /** Defines the amplitude of the oscillations*/
  71776. springiness?: number);
  71777. /** @hidden */
  71778. easeInCore(gradient: number): number;
  71779. }
  71780. /**
  71781. * Easing function with an exponential shape (see link below).
  71782. * @see https://easings.net/#easeInExpo
  71783. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71784. */
  71785. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71786. /** Defines the exponent of the function */
  71787. exponent: number;
  71788. /**
  71789. * Instantiates an exponential easing function
  71790. * @see https://easings.net/#easeInExpo
  71791. * @param exponent Defines the exponent of the function
  71792. */
  71793. constructor(
  71794. /** Defines the exponent of the function */
  71795. exponent?: number);
  71796. /** @hidden */
  71797. easeInCore(gradient: number): number;
  71798. }
  71799. /**
  71800. * Easing function with a power shape (see link below).
  71801. * @see https://easings.net/#easeInQuad
  71802. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71803. */
  71804. export class PowerEase extends EasingFunction implements IEasingFunction {
  71805. /** Defines the power of the function */
  71806. power: number;
  71807. /**
  71808. * Instantiates an power base easing function
  71809. * @see https://easings.net/#easeInQuad
  71810. * @param power Defines the power of the function
  71811. */
  71812. constructor(
  71813. /** Defines the power of the function */
  71814. power?: number);
  71815. /** @hidden */
  71816. easeInCore(gradient: number): number;
  71817. }
  71818. /**
  71819. * Easing function with a power of 2 shape (see link below).
  71820. * @see https://easings.net/#easeInQuad
  71821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71822. */
  71823. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71824. /** @hidden */
  71825. easeInCore(gradient: number): number;
  71826. }
  71827. /**
  71828. * Easing function with a power of 4 shape (see link below).
  71829. * @see https://easings.net/#easeInQuart
  71830. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71831. */
  71832. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71833. /** @hidden */
  71834. easeInCore(gradient: number): number;
  71835. }
  71836. /**
  71837. * Easing function with a power of 5 shape (see link below).
  71838. * @see https://easings.net/#easeInQuint
  71839. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71840. */
  71841. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71842. /** @hidden */
  71843. easeInCore(gradient: number): number;
  71844. }
  71845. /**
  71846. * Easing function with a sin shape (see link below).
  71847. * @see https://easings.net/#easeInSine
  71848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71849. */
  71850. export class SineEase extends EasingFunction implements IEasingFunction {
  71851. /** @hidden */
  71852. easeInCore(gradient: number): number;
  71853. }
  71854. /**
  71855. * Easing function with a bezier shape (see link below).
  71856. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71857. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71858. */
  71859. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71860. /** Defines the x component of the start tangent in the bezier curve */
  71861. x1: number;
  71862. /** Defines the y component of the start tangent in the bezier curve */
  71863. y1: number;
  71864. /** Defines the x component of the end tangent in the bezier curve */
  71865. x2: number;
  71866. /** Defines the y component of the end tangent in the bezier curve */
  71867. y2: number;
  71868. /**
  71869. * Instantiates a bezier function
  71870. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71871. * @param x1 Defines the x component of the start tangent in the bezier curve
  71872. * @param y1 Defines the y component of the start tangent in the bezier curve
  71873. * @param x2 Defines the x component of the end tangent in the bezier curve
  71874. * @param y2 Defines the y component of the end tangent in the bezier curve
  71875. */
  71876. constructor(
  71877. /** Defines the x component of the start tangent in the bezier curve */
  71878. x1?: number,
  71879. /** Defines the y component of the start tangent in the bezier curve */
  71880. y1?: number,
  71881. /** Defines the x component of the end tangent in the bezier curve */
  71882. x2?: number,
  71883. /** Defines the y component of the end tangent in the bezier curve */
  71884. y2?: number);
  71885. /** @hidden */
  71886. easeInCore(gradient: number): number;
  71887. }
  71888. }
  71889. declare module BABYLON {
  71890. /**
  71891. * Class used to hold a RBG color
  71892. */
  71893. export class Color3 {
  71894. /**
  71895. * Defines the red component (between 0 and 1, default is 0)
  71896. */
  71897. r: number;
  71898. /**
  71899. * Defines the green component (between 0 and 1, default is 0)
  71900. */
  71901. g: number;
  71902. /**
  71903. * Defines the blue component (between 0 and 1, default is 0)
  71904. */
  71905. b: number;
  71906. /**
  71907. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71908. * @param r defines the red component (between 0 and 1, default is 0)
  71909. * @param g defines the green component (between 0 and 1, default is 0)
  71910. * @param b defines the blue component (between 0 and 1, default is 0)
  71911. */
  71912. constructor(
  71913. /**
  71914. * Defines the red component (between 0 and 1, default is 0)
  71915. */
  71916. r?: number,
  71917. /**
  71918. * Defines the green component (between 0 and 1, default is 0)
  71919. */
  71920. g?: number,
  71921. /**
  71922. * Defines the blue component (between 0 and 1, default is 0)
  71923. */
  71924. b?: number);
  71925. /**
  71926. * Creates a string with the Color3 current values
  71927. * @returns the string representation of the Color3 object
  71928. */
  71929. toString(): string;
  71930. /**
  71931. * Returns the string "Color3"
  71932. * @returns "Color3"
  71933. */
  71934. getClassName(): string;
  71935. /**
  71936. * Compute the Color3 hash code
  71937. * @returns an unique number that can be used to hash Color3 objects
  71938. */
  71939. getHashCode(): number;
  71940. /**
  71941. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71942. * @param array defines the array where to store the r,g,b components
  71943. * @param index defines an optional index in the target array to define where to start storing values
  71944. * @returns the current Color3 object
  71945. */
  71946. toArray(array: FloatArray, index?: number): Color3;
  71947. /**
  71948. * Returns a new Color4 object from the current Color3 and the given alpha
  71949. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71950. * @returns a new Color4 object
  71951. */
  71952. toColor4(alpha?: number): Color4;
  71953. /**
  71954. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71955. * @returns the new array
  71956. */
  71957. asArray(): number[];
  71958. /**
  71959. * Returns the luminance value
  71960. * @returns a float value
  71961. */
  71962. toLuminance(): number;
  71963. /**
  71964. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71965. * @param otherColor defines the second operand
  71966. * @returns the new Color3 object
  71967. */
  71968. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71969. /**
  71970. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71971. * @param otherColor defines the second operand
  71972. * @param result defines the Color3 object where to store the result
  71973. * @returns the current Color3
  71974. */
  71975. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71976. /**
  71977. * Determines equality between Color3 objects
  71978. * @param otherColor defines the second operand
  71979. * @returns true if the rgb values are equal to the given ones
  71980. */
  71981. equals(otherColor: DeepImmutable<Color3>): boolean;
  71982. /**
  71983. * Determines equality between the current Color3 object and a set of r,b,g values
  71984. * @param r defines the red component to check
  71985. * @param g defines the green component to check
  71986. * @param b defines the blue component to check
  71987. * @returns true if the rgb values are equal to the given ones
  71988. */
  71989. equalsFloats(r: number, g: number, b: number): boolean;
  71990. /**
  71991. * Multiplies in place each rgb value by scale
  71992. * @param scale defines the scaling factor
  71993. * @returns the updated Color3
  71994. */
  71995. scale(scale: number): Color3;
  71996. /**
  71997. * Multiplies the rgb values by scale and stores the result into "result"
  71998. * @param scale defines the scaling factor
  71999. * @param result defines the Color3 object where to store the result
  72000. * @returns the unmodified current Color3
  72001. */
  72002. scaleToRef(scale: number, result: Color3): Color3;
  72003. /**
  72004. * Scale the current Color3 values by a factor and add the result to a given Color3
  72005. * @param scale defines the scale factor
  72006. * @param result defines color to store the result into
  72007. * @returns the unmodified current Color3
  72008. */
  72009. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72010. /**
  72011. * Clamps the rgb values by the min and max values and stores the result into "result"
  72012. * @param min defines minimum clamping value (default is 0)
  72013. * @param max defines maximum clamping value (default is 1)
  72014. * @param result defines color to store the result into
  72015. * @returns the original Color3
  72016. */
  72017. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72018. /**
  72019. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72020. * @param otherColor defines the second operand
  72021. * @returns the new Color3
  72022. */
  72023. add(otherColor: DeepImmutable<Color3>): Color3;
  72024. /**
  72025. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72026. * @param otherColor defines the second operand
  72027. * @param result defines Color3 object to store the result into
  72028. * @returns the unmodified current Color3
  72029. */
  72030. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72031. /**
  72032. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72033. * @param otherColor defines the second operand
  72034. * @returns the new Color3
  72035. */
  72036. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72037. /**
  72038. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72039. * @param otherColor defines the second operand
  72040. * @param result defines Color3 object to store the result into
  72041. * @returns the unmodified current Color3
  72042. */
  72043. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72044. /**
  72045. * Copy the current object
  72046. * @returns a new Color3 copied the current one
  72047. */
  72048. clone(): Color3;
  72049. /**
  72050. * Copies the rgb values from the source in the current Color3
  72051. * @param source defines the source Color3 object
  72052. * @returns the updated Color3 object
  72053. */
  72054. copyFrom(source: DeepImmutable<Color3>): Color3;
  72055. /**
  72056. * Updates the Color3 rgb values from the given floats
  72057. * @param r defines the red component to read from
  72058. * @param g defines the green component to read from
  72059. * @param b defines the blue component to read from
  72060. * @returns the current Color3 object
  72061. */
  72062. copyFromFloats(r: number, g: number, b: number): Color3;
  72063. /**
  72064. * Updates the Color3 rgb values from the given floats
  72065. * @param r defines the red component to read from
  72066. * @param g defines the green component to read from
  72067. * @param b defines the blue component to read from
  72068. * @returns the current Color3 object
  72069. */
  72070. set(r: number, g: number, b: number): Color3;
  72071. /**
  72072. * Compute the Color3 hexadecimal code as a string
  72073. * @returns a string containing the hexadecimal representation of the Color3 object
  72074. */
  72075. toHexString(): string;
  72076. /**
  72077. * Computes a new Color3 converted from the current one to linear space
  72078. * @returns a new Color3 object
  72079. */
  72080. toLinearSpace(): Color3;
  72081. /**
  72082. * Converts current color in rgb space to HSV values
  72083. * @returns a new color3 representing the HSV values
  72084. */
  72085. toHSV(): Color3;
  72086. /**
  72087. * Converts current color in rgb space to HSV values
  72088. * @param result defines the Color3 where to store the HSV values
  72089. */
  72090. toHSVToRef(result: Color3): void;
  72091. /**
  72092. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72093. * @param convertedColor defines the Color3 object where to store the linear space version
  72094. * @returns the unmodified Color3
  72095. */
  72096. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72097. /**
  72098. * Computes a new Color3 converted from the current one to gamma space
  72099. * @returns a new Color3 object
  72100. */
  72101. toGammaSpace(): Color3;
  72102. /**
  72103. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72104. * @param convertedColor defines the Color3 object where to store the gamma space version
  72105. * @returns the unmodified Color3
  72106. */
  72107. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72108. private static _BlackReadOnly;
  72109. /**
  72110. * Convert Hue, saturation and value to a Color3 (RGB)
  72111. * @param hue defines the hue
  72112. * @param saturation defines the saturation
  72113. * @param value defines the value
  72114. * @param result defines the Color3 where to store the RGB values
  72115. */
  72116. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72117. /**
  72118. * Creates a new Color3 from the string containing valid hexadecimal values
  72119. * @param hex defines a string containing valid hexadecimal values
  72120. * @returns a new Color3 object
  72121. */
  72122. static FromHexString(hex: string): Color3;
  72123. /**
  72124. * Creates a new Color3 from the starting index of the given array
  72125. * @param array defines the source array
  72126. * @param offset defines an offset in the source array
  72127. * @returns a new Color3 object
  72128. */
  72129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72130. /**
  72131. * Creates a new Color3 from integer values (< 256)
  72132. * @param r defines the red component to read from (value between 0 and 255)
  72133. * @param g defines the green component to read from (value between 0 and 255)
  72134. * @param b defines the blue component to read from (value between 0 and 255)
  72135. * @returns a new Color3 object
  72136. */
  72137. static FromInts(r: number, g: number, b: number): Color3;
  72138. /**
  72139. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72140. * @param start defines the start Color3 value
  72141. * @param end defines the end Color3 value
  72142. * @param amount defines the gradient value between start and end
  72143. * @returns a new Color3 object
  72144. */
  72145. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72146. /**
  72147. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72148. * @param left defines the start value
  72149. * @param right defines the end value
  72150. * @param amount defines the gradient factor
  72151. * @param result defines the Color3 object where to store the result
  72152. */
  72153. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72154. /**
  72155. * Returns a Color3 value containing a red color
  72156. * @returns a new Color3 object
  72157. */
  72158. static Red(): Color3;
  72159. /**
  72160. * Returns a Color3 value containing a green color
  72161. * @returns a new Color3 object
  72162. */
  72163. static Green(): Color3;
  72164. /**
  72165. * Returns a Color3 value containing a blue color
  72166. * @returns a new Color3 object
  72167. */
  72168. static Blue(): Color3;
  72169. /**
  72170. * Returns a Color3 value containing a black color
  72171. * @returns a new Color3 object
  72172. */
  72173. static Black(): Color3;
  72174. /**
  72175. * Gets a Color3 value containing a black color that must not be updated
  72176. */
  72177. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72178. /**
  72179. * Returns a Color3 value containing a white color
  72180. * @returns a new Color3 object
  72181. */
  72182. static White(): Color3;
  72183. /**
  72184. * Returns a Color3 value containing a purple color
  72185. * @returns a new Color3 object
  72186. */
  72187. static Purple(): Color3;
  72188. /**
  72189. * Returns a Color3 value containing a magenta color
  72190. * @returns a new Color3 object
  72191. */
  72192. static Magenta(): Color3;
  72193. /**
  72194. * Returns a Color3 value containing a yellow color
  72195. * @returns a new Color3 object
  72196. */
  72197. static Yellow(): Color3;
  72198. /**
  72199. * Returns a Color3 value containing a gray color
  72200. * @returns a new Color3 object
  72201. */
  72202. static Gray(): Color3;
  72203. /**
  72204. * Returns a Color3 value containing a teal color
  72205. * @returns a new Color3 object
  72206. */
  72207. static Teal(): Color3;
  72208. /**
  72209. * Returns a Color3 value containing a random color
  72210. * @returns a new Color3 object
  72211. */
  72212. static Random(): Color3;
  72213. }
  72214. /**
  72215. * Class used to hold a RBGA color
  72216. */
  72217. export class Color4 {
  72218. /**
  72219. * Defines the red component (between 0 and 1, default is 0)
  72220. */
  72221. r: number;
  72222. /**
  72223. * Defines the green component (between 0 and 1, default is 0)
  72224. */
  72225. g: number;
  72226. /**
  72227. * Defines the blue component (between 0 and 1, default is 0)
  72228. */
  72229. b: number;
  72230. /**
  72231. * Defines the alpha component (between 0 and 1, default is 1)
  72232. */
  72233. a: number;
  72234. /**
  72235. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72236. * @param r defines the red component (between 0 and 1, default is 0)
  72237. * @param g defines the green component (between 0 and 1, default is 0)
  72238. * @param b defines the blue component (between 0 and 1, default is 0)
  72239. * @param a defines the alpha component (between 0 and 1, default is 1)
  72240. */
  72241. constructor(
  72242. /**
  72243. * Defines the red component (between 0 and 1, default is 0)
  72244. */
  72245. r?: number,
  72246. /**
  72247. * Defines the green component (between 0 and 1, default is 0)
  72248. */
  72249. g?: number,
  72250. /**
  72251. * Defines the blue component (between 0 and 1, default is 0)
  72252. */
  72253. b?: number,
  72254. /**
  72255. * Defines the alpha component (between 0 and 1, default is 1)
  72256. */
  72257. a?: number);
  72258. /**
  72259. * Adds in place the given Color4 values to the current Color4 object
  72260. * @param right defines the second operand
  72261. * @returns the current updated Color4 object
  72262. */
  72263. addInPlace(right: DeepImmutable<Color4>): Color4;
  72264. /**
  72265. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72266. * @returns the new array
  72267. */
  72268. asArray(): number[];
  72269. /**
  72270. * Stores from the starting index in the given array the Color4 successive values
  72271. * @param array defines the array where to store the r,g,b components
  72272. * @param index defines an optional index in the target array to define where to start storing values
  72273. * @returns the current Color4 object
  72274. */
  72275. toArray(array: number[], index?: number): Color4;
  72276. /**
  72277. * Determines equality between Color4 objects
  72278. * @param otherColor defines the second operand
  72279. * @returns true if the rgba values are equal to the given ones
  72280. */
  72281. equals(otherColor: DeepImmutable<Color4>): boolean;
  72282. /**
  72283. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72284. * @param right defines the second operand
  72285. * @returns a new Color4 object
  72286. */
  72287. add(right: DeepImmutable<Color4>): Color4;
  72288. /**
  72289. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72290. * @param right defines the second operand
  72291. * @returns a new Color4 object
  72292. */
  72293. subtract(right: DeepImmutable<Color4>): Color4;
  72294. /**
  72295. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72296. * @param right defines the second operand
  72297. * @param result defines the Color4 object where to store the result
  72298. * @returns the current Color4 object
  72299. */
  72300. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72301. /**
  72302. * Creates a new Color4 with the current Color4 values multiplied by scale
  72303. * @param scale defines the scaling factor to apply
  72304. * @returns a new Color4 object
  72305. */
  72306. scale(scale: number): Color4;
  72307. /**
  72308. * Multiplies the current Color4 values by scale and stores the result in "result"
  72309. * @param scale defines the scaling factor to apply
  72310. * @param result defines the Color4 object where to store the result
  72311. * @returns the current unmodified Color4
  72312. */
  72313. scaleToRef(scale: number, result: Color4): Color4;
  72314. /**
  72315. * Scale the current Color4 values by a factor and add the result to a given Color4
  72316. * @param scale defines the scale factor
  72317. * @param result defines the Color4 object where to store the result
  72318. * @returns the unmodified current Color4
  72319. */
  72320. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72321. /**
  72322. * Clamps the rgb values by the min and max values and stores the result into "result"
  72323. * @param min defines minimum clamping value (default is 0)
  72324. * @param max defines maximum clamping value (default is 1)
  72325. * @param result defines color to store the result into.
  72326. * @returns the cuurent Color4
  72327. */
  72328. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72329. /**
  72330. * Multipy an Color4 value by another and return a new Color4 object
  72331. * @param color defines the Color4 value to multiply by
  72332. * @returns a new Color4 object
  72333. */
  72334. multiply(color: Color4): Color4;
  72335. /**
  72336. * Multipy a Color4 value by another and push the result in a reference value
  72337. * @param color defines the Color4 value to multiply by
  72338. * @param result defines the Color4 to fill the result in
  72339. * @returns the result Color4
  72340. */
  72341. multiplyToRef(color: Color4, result: Color4): Color4;
  72342. /**
  72343. * Creates a string with the Color4 current values
  72344. * @returns the string representation of the Color4 object
  72345. */
  72346. toString(): string;
  72347. /**
  72348. * Returns the string "Color4"
  72349. * @returns "Color4"
  72350. */
  72351. getClassName(): string;
  72352. /**
  72353. * Compute the Color4 hash code
  72354. * @returns an unique number that can be used to hash Color4 objects
  72355. */
  72356. getHashCode(): number;
  72357. /**
  72358. * Creates a new Color4 copied from the current one
  72359. * @returns a new Color4 object
  72360. */
  72361. clone(): Color4;
  72362. /**
  72363. * Copies the given Color4 values into the current one
  72364. * @param source defines the source Color4 object
  72365. * @returns the current updated Color4 object
  72366. */
  72367. copyFrom(source: Color4): Color4;
  72368. /**
  72369. * Copies the given float values into the current one
  72370. * @param r defines the red component to read from
  72371. * @param g defines the green component to read from
  72372. * @param b defines the blue component to read from
  72373. * @param a defines the alpha component to read from
  72374. * @returns the current updated Color4 object
  72375. */
  72376. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72377. /**
  72378. * Copies the given float values into the current one
  72379. * @param r defines the red component to read from
  72380. * @param g defines the green component to read from
  72381. * @param b defines the blue component to read from
  72382. * @param a defines the alpha component to read from
  72383. * @returns the current updated Color4 object
  72384. */
  72385. set(r: number, g: number, b: number, a: number): Color4;
  72386. /**
  72387. * Compute the Color4 hexadecimal code as a string
  72388. * @returns a string containing the hexadecimal representation of the Color4 object
  72389. */
  72390. toHexString(): string;
  72391. /**
  72392. * Computes a new Color4 converted from the current one to linear space
  72393. * @returns a new Color4 object
  72394. */
  72395. toLinearSpace(): Color4;
  72396. /**
  72397. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72398. * @param convertedColor defines the Color4 object where to store the linear space version
  72399. * @returns the unmodified Color4
  72400. */
  72401. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72402. /**
  72403. * Computes a new Color4 converted from the current one to gamma space
  72404. * @returns a new Color4 object
  72405. */
  72406. toGammaSpace(): Color4;
  72407. /**
  72408. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72409. * @param convertedColor defines the Color4 object where to store the gamma space version
  72410. * @returns the unmodified Color4
  72411. */
  72412. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72413. /**
  72414. * Creates a new Color4 from the string containing valid hexadecimal values
  72415. * @param hex defines a string containing valid hexadecimal values
  72416. * @returns a new Color4 object
  72417. */
  72418. static FromHexString(hex: string): Color4;
  72419. /**
  72420. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72421. * @param left defines the start value
  72422. * @param right defines the end value
  72423. * @param amount defines the gradient factor
  72424. * @returns a new Color4 object
  72425. */
  72426. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72427. /**
  72428. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72429. * @param left defines the start value
  72430. * @param right defines the end value
  72431. * @param amount defines the gradient factor
  72432. * @param result defines the Color4 object where to store data
  72433. */
  72434. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72435. /**
  72436. * Creates a new Color4 from a Color3 and an alpha value
  72437. * @param color3 defines the source Color3 to read from
  72438. * @param alpha defines the alpha component (1.0 by default)
  72439. * @returns a new Color4 object
  72440. */
  72441. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72442. /**
  72443. * Creates a new Color4 from the starting index element of the given array
  72444. * @param array defines the source array to read from
  72445. * @param offset defines the offset in the source array
  72446. * @returns a new Color4 object
  72447. */
  72448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72449. /**
  72450. * Creates a new Color3 from integer values (< 256)
  72451. * @param r defines the red component to read from (value between 0 and 255)
  72452. * @param g defines the green component to read from (value between 0 and 255)
  72453. * @param b defines the blue component to read from (value between 0 and 255)
  72454. * @param a defines the alpha component to read from (value between 0 and 255)
  72455. * @returns a new Color3 object
  72456. */
  72457. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72458. /**
  72459. * Check the content of a given array and convert it to an array containing RGBA data
  72460. * If the original array was already containing count * 4 values then it is returned directly
  72461. * @param colors defines the array to check
  72462. * @param count defines the number of RGBA data to expect
  72463. * @returns an array containing count * 4 values (RGBA)
  72464. */
  72465. static CheckColors4(colors: number[], count: number): number[];
  72466. }
  72467. /**
  72468. * @hidden
  72469. */
  72470. export class TmpColors {
  72471. static Color3: Color3[];
  72472. static Color4: Color4[];
  72473. }
  72474. }
  72475. declare module BABYLON {
  72476. /**
  72477. * Defines an interface which represents an animation key frame
  72478. */
  72479. export interface IAnimationKey {
  72480. /**
  72481. * Frame of the key frame
  72482. */
  72483. frame: number;
  72484. /**
  72485. * Value at the specifies key frame
  72486. */
  72487. value: any;
  72488. /**
  72489. * The input tangent for the cubic hermite spline
  72490. */
  72491. inTangent?: any;
  72492. /**
  72493. * The output tangent for the cubic hermite spline
  72494. */
  72495. outTangent?: any;
  72496. /**
  72497. * The animation interpolation type
  72498. */
  72499. interpolation?: AnimationKeyInterpolation;
  72500. }
  72501. /**
  72502. * Enum for the animation key frame interpolation type
  72503. */
  72504. export enum AnimationKeyInterpolation {
  72505. /**
  72506. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72507. */
  72508. STEP = 1
  72509. }
  72510. }
  72511. declare module BABYLON {
  72512. /**
  72513. * Represents the range of an animation
  72514. */
  72515. export class AnimationRange {
  72516. /**The name of the animation range**/
  72517. name: string;
  72518. /**The starting frame of the animation */
  72519. from: number;
  72520. /**The ending frame of the animation*/
  72521. to: number;
  72522. /**
  72523. * Initializes the range of an animation
  72524. * @param name The name of the animation range
  72525. * @param from The starting frame of the animation
  72526. * @param to The ending frame of the animation
  72527. */
  72528. constructor(
  72529. /**The name of the animation range**/
  72530. name: string,
  72531. /**The starting frame of the animation */
  72532. from: number,
  72533. /**The ending frame of the animation*/
  72534. to: number);
  72535. /**
  72536. * Makes a copy of the animation range
  72537. * @returns A copy of the animation range
  72538. */
  72539. clone(): AnimationRange;
  72540. }
  72541. }
  72542. declare module BABYLON {
  72543. /**
  72544. * Composed of a frame, and an action function
  72545. */
  72546. export class AnimationEvent {
  72547. /** The frame for which the event is triggered **/
  72548. frame: number;
  72549. /** The event to perform when triggered **/
  72550. action: (currentFrame: number) => void;
  72551. /** Specifies if the event should be triggered only once**/
  72552. onlyOnce?: boolean | undefined;
  72553. /**
  72554. * Specifies if the animation event is done
  72555. */
  72556. isDone: boolean;
  72557. /**
  72558. * Initializes the animation event
  72559. * @param frame The frame for which the event is triggered
  72560. * @param action The event to perform when triggered
  72561. * @param onlyOnce Specifies if the event should be triggered only once
  72562. */
  72563. constructor(
  72564. /** The frame for which the event is triggered **/
  72565. frame: number,
  72566. /** The event to perform when triggered **/
  72567. action: (currentFrame: number) => void,
  72568. /** Specifies if the event should be triggered only once**/
  72569. onlyOnce?: boolean | undefined);
  72570. /** @hidden */
  72571. _clone(): AnimationEvent;
  72572. }
  72573. }
  72574. declare module BABYLON {
  72575. /**
  72576. * Interface used to define a behavior
  72577. */
  72578. export interface Behavior<T> {
  72579. /** gets or sets behavior's name */
  72580. name: string;
  72581. /**
  72582. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72583. */
  72584. init(): void;
  72585. /**
  72586. * Called when the behavior is attached to a target
  72587. * @param target defines the target where the behavior is attached to
  72588. */
  72589. attach(target: T): void;
  72590. /**
  72591. * Called when the behavior is detached from its target
  72592. */
  72593. detach(): void;
  72594. }
  72595. /**
  72596. * Interface implemented by classes supporting behaviors
  72597. */
  72598. export interface IBehaviorAware<T> {
  72599. /**
  72600. * Attach a behavior
  72601. * @param behavior defines the behavior to attach
  72602. * @returns the current host
  72603. */
  72604. addBehavior(behavior: Behavior<T>): T;
  72605. /**
  72606. * Remove a behavior from the current object
  72607. * @param behavior defines the behavior to detach
  72608. * @returns the current host
  72609. */
  72610. removeBehavior(behavior: Behavior<T>): T;
  72611. /**
  72612. * Gets a behavior using its name to search
  72613. * @param name defines the name to search
  72614. * @returns the behavior or null if not found
  72615. */
  72616. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72617. }
  72618. }
  72619. declare module BABYLON {
  72620. /**
  72621. * Defines an array and its length.
  72622. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72623. */
  72624. export interface ISmartArrayLike<T> {
  72625. /**
  72626. * The data of the array.
  72627. */
  72628. data: Array<T>;
  72629. /**
  72630. * The active length of the array.
  72631. */
  72632. length: number;
  72633. }
  72634. /**
  72635. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72636. */
  72637. export class SmartArray<T> implements ISmartArrayLike<T> {
  72638. /**
  72639. * The full set of data from the array.
  72640. */
  72641. data: Array<T>;
  72642. /**
  72643. * The active length of the array.
  72644. */
  72645. length: number;
  72646. protected _id: number;
  72647. /**
  72648. * Instantiates a Smart Array.
  72649. * @param capacity defines the default capacity of the array.
  72650. */
  72651. constructor(capacity: number);
  72652. /**
  72653. * Pushes a value at the end of the active data.
  72654. * @param value defines the object to push in the array.
  72655. */
  72656. push(value: T): void;
  72657. /**
  72658. * Iterates over the active data and apply the lambda to them.
  72659. * @param func defines the action to apply on each value.
  72660. */
  72661. forEach(func: (content: T) => void): void;
  72662. /**
  72663. * Sorts the full sets of data.
  72664. * @param compareFn defines the comparison function to apply.
  72665. */
  72666. sort(compareFn: (a: T, b: T) => number): void;
  72667. /**
  72668. * Resets the active data to an empty array.
  72669. */
  72670. reset(): void;
  72671. /**
  72672. * Releases all the data from the array as well as the array.
  72673. */
  72674. dispose(): void;
  72675. /**
  72676. * Concats the active data with a given array.
  72677. * @param array defines the data to concatenate with.
  72678. */
  72679. concat(array: any): void;
  72680. /**
  72681. * Returns the position of a value in the active data.
  72682. * @param value defines the value to find the index for
  72683. * @returns the index if found in the active data otherwise -1
  72684. */
  72685. indexOf(value: T): number;
  72686. /**
  72687. * Returns whether an element is part of the active data.
  72688. * @param value defines the value to look for
  72689. * @returns true if found in the active data otherwise false
  72690. */
  72691. contains(value: T): boolean;
  72692. private static _GlobalId;
  72693. }
  72694. /**
  72695. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72696. * The data in this array can only be present once
  72697. */
  72698. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72699. private _duplicateId;
  72700. /**
  72701. * Pushes a value at the end of the active data.
  72702. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72703. * @param value defines the object to push in the array.
  72704. */
  72705. push(value: T): void;
  72706. /**
  72707. * Pushes a value at the end of the active data.
  72708. * If the data is already present, it won t be added again
  72709. * @param value defines the object to push in the array.
  72710. * @returns true if added false if it was already present
  72711. */
  72712. pushNoDuplicate(value: T): boolean;
  72713. /**
  72714. * Resets the active data to an empty array.
  72715. */
  72716. reset(): void;
  72717. /**
  72718. * Concats the active data with a given array.
  72719. * This ensures no dupplicate will be present in the result.
  72720. * @param array defines the data to concatenate with.
  72721. */
  72722. concatWithNoDuplicate(array: any): void;
  72723. }
  72724. }
  72725. declare module BABYLON {
  72726. /**
  72727. * @ignore
  72728. * This is a list of all the different input types that are available in the application.
  72729. * Fo instance: ArcRotateCameraGamepadInput...
  72730. */
  72731. export var CameraInputTypes: {};
  72732. /**
  72733. * This is the contract to implement in order to create a new input class.
  72734. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72735. */
  72736. export interface ICameraInput<TCamera extends Camera> {
  72737. /**
  72738. * Defines the camera the input is attached to.
  72739. */
  72740. camera: Nullable<TCamera>;
  72741. /**
  72742. * Gets the class name of the current intput.
  72743. * @returns the class name
  72744. */
  72745. getClassName(): string;
  72746. /**
  72747. * Get the friendly name associated with the input class.
  72748. * @returns the input friendly name
  72749. */
  72750. getSimpleName(): string;
  72751. /**
  72752. * Attach the input controls to a specific dom element to get the input from.
  72753. * @param element Defines the element the controls should be listened from
  72754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72755. */
  72756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72757. /**
  72758. * Detach the current controls from the specified dom element.
  72759. * @param element Defines the element to stop listening the inputs from
  72760. */
  72761. detachControl(element: Nullable<HTMLElement>): void;
  72762. /**
  72763. * Update the current camera state depending on the inputs that have been used this frame.
  72764. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72765. */
  72766. checkInputs?: () => void;
  72767. }
  72768. /**
  72769. * Represents a map of input types to input instance or input index to input instance.
  72770. */
  72771. export interface CameraInputsMap<TCamera extends Camera> {
  72772. /**
  72773. * Accessor to the input by input type.
  72774. */
  72775. [name: string]: ICameraInput<TCamera>;
  72776. /**
  72777. * Accessor to the input by input index.
  72778. */
  72779. [idx: number]: ICameraInput<TCamera>;
  72780. }
  72781. /**
  72782. * This represents the input manager used within a camera.
  72783. * It helps dealing with all the different kind of input attached to a camera.
  72784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72785. */
  72786. export class CameraInputsManager<TCamera extends Camera> {
  72787. /**
  72788. * Defines the list of inputs attahed to the camera.
  72789. */
  72790. attached: CameraInputsMap<TCamera>;
  72791. /**
  72792. * Defines the dom element the camera is collecting inputs from.
  72793. * This is null if the controls have not been attached.
  72794. */
  72795. attachedElement: Nullable<HTMLElement>;
  72796. /**
  72797. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72798. */
  72799. noPreventDefault: boolean;
  72800. /**
  72801. * Defined the camera the input manager belongs to.
  72802. */
  72803. camera: TCamera;
  72804. /**
  72805. * Update the current camera state depending on the inputs that have been used this frame.
  72806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72807. */
  72808. checkInputs: () => void;
  72809. /**
  72810. * Instantiate a new Camera Input Manager.
  72811. * @param camera Defines the camera the input manager blongs to
  72812. */
  72813. constructor(camera: TCamera);
  72814. /**
  72815. * Add an input method to a camera
  72816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72817. * @param input camera input method
  72818. */
  72819. add(input: ICameraInput<TCamera>): void;
  72820. /**
  72821. * Remove a specific input method from a camera
  72822. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72823. * @param inputToRemove camera input method
  72824. */
  72825. remove(inputToRemove: ICameraInput<TCamera>): void;
  72826. /**
  72827. * Remove a specific input type from a camera
  72828. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72829. * @param inputType the type of the input to remove
  72830. */
  72831. removeByType(inputType: string): void;
  72832. private _addCheckInputs;
  72833. /**
  72834. * Attach the input controls to the currently attached dom element to listen the events from.
  72835. * @param input Defines the input to attach
  72836. */
  72837. attachInput(input: ICameraInput<TCamera>): void;
  72838. /**
  72839. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72840. * @param element Defines the dom element to collect the events from
  72841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72842. */
  72843. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72844. /**
  72845. * Detach the current manager inputs controls from a specific dom element.
  72846. * @param element Defines the dom element to collect the events from
  72847. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72848. */
  72849. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72850. /**
  72851. * Rebuild the dynamic inputCheck function from the current list of
  72852. * defined inputs in the manager.
  72853. */
  72854. rebuildInputCheck(): void;
  72855. /**
  72856. * Remove all attached input methods from a camera
  72857. */
  72858. clear(): void;
  72859. /**
  72860. * Serialize the current input manager attached to a camera.
  72861. * This ensures than once parsed,
  72862. * the input associated to the camera will be identical to the current ones
  72863. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72864. */
  72865. serialize(serializedCamera: any): void;
  72866. /**
  72867. * Parses an input manager serialized JSON to restore the previous list of inputs
  72868. * and states associated to a camera.
  72869. * @param parsedCamera Defines the JSON to parse
  72870. */
  72871. parse(parsedCamera: any): void;
  72872. }
  72873. }
  72874. declare module BABYLON {
  72875. /**
  72876. * Class used to store data that will be store in GPU memory
  72877. */
  72878. export class Buffer {
  72879. private _engine;
  72880. private _buffer;
  72881. /** @hidden */
  72882. _data: Nullable<DataArray>;
  72883. private _updatable;
  72884. private _instanced;
  72885. /**
  72886. * Gets the byte stride.
  72887. */
  72888. readonly byteStride: number;
  72889. /**
  72890. * Constructor
  72891. * @param engine the engine
  72892. * @param data the data to use for this buffer
  72893. * @param updatable whether the data is updatable
  72894. * @param stride the stride (optional)
  72895. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72896. * @param instanced whether the buffer is instanced (optional)
  72897. * @param useBytes set to true if the stride in in bytes (optional)
  72898. */
  72899. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72900. /**
  72901. * Create a new VertexBuffer based on the current buffer
  72902. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72903. * @param offset defines offset in the buffer (0 by default)
  72904. * @param size defines the size in floats of attributes (position is 3 for instance)
  72905. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72906. * @param instanced defines if the vertex buffer contains indexed data
  72907. * @param useBytes defines if the offset and stride are in bytes
  72908. * @returns the new vertex buffer
  72909. */
  72910. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72911. /**
  72912. * Gets a boolean indicating if the Buffer is updatable?
  72913. * @returns true if the buffer is updatable
  72914. */
  72915. isUpdatable(): boolean;
  72916. /**
  72917. * Gets current buffer's data
  72918. * @returns a DataArray or null
  72919. */
  72920. getData(): Nullable<DataArray>;
  72921. /**
  72922. * Gets underlying native buffer
  72923. * @returns underlying native buffer
  72924. */
  72925. getBuffer(): Nullable<DataBuffer>;
  72926. /**
  72927. * Gets the stride in float32 units (i.e. byte stride / 4).
  72928. * May not be an integer if the byte stride is not divisible by 4.
  72929. * DEPRECATED. Use byteStride instead.
  72930. * @returns the stride in float32 units
  72931. */
  72932. getStrideSize(): number;
  72933. /**
  72934. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72935. * @param data defines the data to store
  72936. */
  72937. create(data?: Nullable<DataArray>): void;
  72938. /** @hidden */
  72939. _rebuild(): void;
  72940. /**
  72941. * Update current buffer data
  72942. * @param data defines the data to store
  72943. */
  72944. update(data: DataArray): void;
  72945. /**
  72946. * Updates the data directly.
  72947. * @param data the new data
  72948. * @param offset the new offset
  72949. * @param vertexCount the vertex count (optional)
  72950. * @param useBytes set to true if the offset is in bytes
  72951. */
  72952. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72953. /**
  72954. * Release all resources
  72955. */
  72956. dispose(): void;
  72957. }
  72958. /**
  72959. * Specialized buffer used to store vertex data
  72960. */
  72961. export class VertexBuffer {
  72962. /** @hidden */
  72963. _buffer: Buffer;
  72964. private _kind;
  72965. private _size;
  72966. private _ownsBuffer;
  72967. private _instanced;
  72968. private _instanceDivisor;
  72969. /**
  72970. * The byte type.
  72971. */
  72972. static readonly BYTE: number;
  72973. /**
  72974. * The unsigned byte type.
  72975. */
  72976. static readonly UNSIGNED_BYTE: number;
  72977. /**
  72978. * The short type.
  72979. */
  72980. static readonly SHORT: number;
  72981. /**
  72982. * The unsigned short type.
  72983. */
  72984. static readonly UNSIGNED_SHORT: number;
  72985. /**
  72986. * The integer type.
  72987. */
  72988. static readonly INT: number;
  72989. /**
  72990. * The unsigned integer type.
  72991. */
  72992. static readonly UNSIGNED_INT: number;
  72993. /**
  72994. * The float type.
  72995. */
  72996. static readonly FLOAT: number;
  72997. /**
  72998. * Gets or sets the instance divisor when in instanced mode
  72999. */
  73000. instanceDivisor: number;
  73001. /**
  73002. * Gets the byte stride.
  73003. */
  73004. readonly byteStride: number;
  73005. /**
  73006. * Gets the byte offset.
  73007. */
  73008. readonly byteOffset: number;
  73009. /**
  73010. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73011. */
  73012. readonly normalized: boolean;
  73013. /**
  73014. * Gets the data type of each component in the array.
  73015. */
  73016. readonly type: number;
  73017. /**
  73018. * Constructor
  73019. * @param engine the engine
  73020. * @param data the data to use for this vertex buffer
  73021. * @param kind the vertex buffer kind
  73022. * @param updatable whether the data is updatable
  73023. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73024. * @param stride the stride (optional)
  73025. * @param instanced whether the buffer is instanced (optional)
  73026. * @param offset the offset of the data (optional)
  73027. * @param size the number of components (optional)
  73028. * @param type the type of the component (optional)
  73029. * @param normalized whether the data contains normalized data (optional)
  73030. * @param useBytes set to true if stride and offset are in bytes (optional)
  73031. */
  73032. 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);
  73033. /** @hidden */
  73034. _rebuild(): void;
  73035. /**
  73036. * Returns the kind of the VertexBuffer (string)
  73037. * @returns a string
  73038. */
  73039. getKind(): string;
  73040. /**
  73041. * Gets a boolean indicating if the VertexBuffer is updatable?
  73042. * @returns true if the buffer is updatable
  73043. */
  73044. isUpdatable(): boolean;
  73045. /**
  73046. * Gets current buffer's data
  73047. * @returns a DataArray or null
  73048. */
  73049. getData(): Nullable<DataArray>;
  73050. /**
  73051. * Gets underlying native buffer
  73052. * @returns underlying native buffer
  73053. */
  73054. getBuffer(): Nullable<DataBuffer>;
  73055. /**
  73056. * Gets the stride in float32 units (i.e. byte stride / 4).
  73057. * May not be an integer if the byte stride is not divisible by 4.
  73058. * DEPRECATED. Use byteStride instead.
  73059. * @returns the stride in float32 units
  73060. */
  73061. getStrideSize(): number;
  73062. /**
  73063. * Returns the offset as a multiple of the type byte length.
  73064. * DEPRECATED. Use byteOffset instead.
  73065. * @returns the offset in bytes
  73066. */
  73067. getOffset(): number;
  73068. /**
  73069. * Returns the number of components per vertex attribute (integer)
  73070. * @returns the size in float
  73071. */
  73072. getSize(): number;
  73073. /**
  73074. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73075. * @returns true if this buffer is instanced
  73076. */
  73077. getIsInstanced(): boolean;
  73078. /**
  73079. * Returns the instancing divisor, zero for non-instanced (integer).
  73080. * @returns a number
  73081. */
  73082. getInstanceDivisor(): number;
  73083. /**
  73084. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73085. * @param data defines the data to store
  73086. */
  73087. create(data?: DataArray): void;
  73088. /**
  73089. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73090. * This function will create a new buffer if the current one is not updatable
  73091. * @param data defines the data to store
  73092. */
  73093. update(data: DataArray): void;
  73094. /**
  73095. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73096. * Returns the directly updated WebGLBuffer.
  73097. * @param data the new data
  73098. * @param offset the new offset
  73099. * @param useBytes set to true if the offset is in bytes
  73100. */
  73101. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73102. /**
  73103. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73104. */
  73105. dispose(): void;
  73106. /**
  73107. * Enumerates each value of this vertex buffer as numbers.
  73108. * @param count the number of values to enumerate
  73109. * @param callback the callback function called for each value
  73110. */
  73111. forEach(count: number, callback: (value: number, index: number) => void): void;
  73112. /**
  73113. * Positions
  73114. */
  73115. static readonly PositionKind: string;
  73116. /**
  73117. * Normals
  73118. */
  73119. static readonly NormalKind: string;
  73120. /**
  73121. * Tangents
  73122. */
  73123. static readonly TangentKind: string;
  73124. /**
  73125. * Texture coordinates
  73126. */
  73127. static readonly UVKind: string;
  73128. /**
  73129. * Texture coordinates 2
  73130. */
  73131. static readonly UV2Kind: string;
  73132. /**
  73133. * Texture coordinates 3
  73134. */
  73135. static readonly UV3Kind: string;
  73136. /**
  73137. * Texture coordinates 4
  73138. */
  73139. static readonly UV4Kind: string;
  73140. /**
  73141. * Texture coordinates 5
  73142. */
  73143. static readonly UV5Kind: string;
  73144. /**
  73145. * Texture coordinates 6
  73146. */
  73147. static readonly UV6Kind: string;
  73148. /**
  73149. * Colors
  73150. */
  73151. static readonly ColorKind: string;
  73152. /**
  73153. * Matrix indices (for bones)
  73154. */
  73155. static readonly MatricesIndicesKind: string;
  73156. /**
  73157. * Matrix weights (for bones)
  73158. */
  73159. static readonly MatricesWeightsKind: string;
  73160. /**
  73161. * Additional matrix indices (for bones)
  73162. */
  73163. static readonly MatricesIndicesExtraKind: string;
  73164. /**
  73165. * Additional matrix weights (for bones)
  73166. */
  73167. static readonly MatricesWeightsExtraKind: string;
  73168. /**
  73169. * Deduces the stride given a kind.
  73170. * @param kind The kind string to deduce
  73171. * @returns The deduced stride
  73172. */
  73173. static DeduceStride(kind: string): number;
  73174. /**
  73175. * Gets the byte length of the given type.
  73176. * @param type the type
  73177. * @returns the number of bytes
  73178. */
  73179. static GetTypeByteLength(type: number): number;
  73180. /**
  73181. * Enumerates each value of the given parameters as numbers.
  73182. * @param data the data to enumerate
  73183. * @param byteOffset the byte offset of the data
  73184. * @param byteStride the byte stride of the data
  73185. * @param componentCount the number of components per element
  73186. * @param componentType the type of the component
  73187. * @param count the number of values to enumerate
  73188. * @param normalized whether the data is normalized
  73189. * @param callback the callback function called for each value
  73190. */
  73191. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73192. private static _GetFloatValue;
  73193. }
  73194. }
  73195. declare module BABYLON {
  73196. /**
  73197. * @hidden
  73198. */
  73199. export class IntersectionInfo {
  73200. bu: Nullable<number>;
  73201. bv: Nullable<number>;
  73202. distance: number;
  73203. faceId: number;
  73204. subMeshId: number;
  73205. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73206. }
  73207. }
  73208. declare module BABYLON {
  73209. /**
  73210. * Represens a plane by the equation ax + by + cz + d = 0
  73211. */
  73212. export class Plane {
  73213. private static _TmpMatrix;
  73214. /**
  73215. * Normal of the plane (a,b,c)
  73216. */
  73217. normal: Vector3;
  73218. /**
  73219. * d component of the plane
  73220. */
  73221. d: number;
  73222. /**
  73223. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73224. * @param a a component of the plane
  73225. * @param b b component of the plane
  73226. * @param c c component of the plane
  73227. * @param d d component of the plane
  73228. */
  73229. constructor(a: number, b: number, c: number, d: number);
  73230. /**
  73231. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73232. */
  73233. asArray(): number[];
  73234. /**
  73235. * @returns a new plane copied from the current Plane.
  73236. */
  73237. clone(): Plane;
  73238. /**
  73239. * @returns the string "Plane".
  73240. */
  73241. getClassName(): string;
  73242. /**
  73243. * @returns the Plane hash code.
  73244. */
  73245. getHashCode(): number;
  73246. /**
  73247. * Normalize the current Plane in place.
  73248. * @returns the updated Plane.
  73249. */
  73250. normalize(): Plane;
  73251. /**
  73252. * Applies a transformation the plane and returns the result
  73253. * @param transformation the transformation matrix to be applied to the plane
  73254. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73255. */
  73256. transform(transformation: DeepImmutable<Matrix>): Plane;
  73257. /**
  73258. * Calcualtte the dot product between the point and the plane normal
  73259. * @param point point to calculate the dot product with
  73260. * @returns the dot product (float) of the point coordinates and the plane normal.
  73261. */
  73262. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73263. /**
  73264. * Updates the current Plane from the plane defined by the three given points.
  73265. * @param point1 one of the points used to contruct the plane
  73266. * @param point2 one of the points used to contruct the plane
  73267. * @param point3 one of the points used to contruct the plane
  73268. * @returns the updated Plane.
  73269. */
  73270. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73271. /**
  73272. * Checks if the plane is facing a given direction
  73273. * @param direction the direction to check if the plane is facing
  73274. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73275. * @returns True is the vector "direction" is the same side than the plane normal.
  73276. */
  73277. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73278. /**
  73279. * Calculates the distance to a point
  73280. * @param point point to calculate distance to
  73281. * @returns the signed distance (float) from the given point to the Plane.
  73282. */
  73283. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73284. /**
  73285. * Creates a plane from an array
  73286. * @param array the array to create a plane from
  73287. * @returns a new Plane from the given array.
  73288. */
  73289. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73290. /**
  73291. * Creates a plane from three points
  73292. * @param point1 point used to create the plane
  73293. * @param point2 point used to create the plane
  73294. * @param point3 point used to create the plane
  73295. * @returns a new Plane defined by the three given points.
  73296. */
  73297. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73298. /**
  73299. * Creates a plane from an origin point and a normal
  73300. * @param origin origin of the plane to be constructed
  73301. * @param normal normal of the plane to be constructed
  73302. * @returns a new Plane the normal vector to this plane at the given origin point.
  73303. * Note : the vector "normal" is updated because normalized.
  73304. */
  73305. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73306. /**
  73307. * Calculates the distance from a plane and a point
  73308. * @param origin origin of the plane to be constructed
  73309. * @param normal normal of the plane to be constructed
  73310. * @param point point to calculate distance to
  73311. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73312. */
  73313. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73314. }
  73315. }
  73316. declare module BABYLON {
  73317. /**
  73318. * Class used to store bounding sphere information
  73319. */
  73320. export class BoundingSphere {
  73321. /**
  73322. * Gets the center of the bounding sphere in local space
  73323. */
  73324. readonly center: Vector3;
  73325. /**
  73326. * Radius of the bounding sphere in local space
  73327. */
  73328. radius: number;
  73329. /**
  73330. * Gets the center of the bounding sphere in world space
  73331. */
  73332. readonly centerWorld: Vector3;
  73333. /**
  73334. * Radius of the bounding sphere in world space
  73335. */
  73336. radiusWorld: number;
  73337. /**
  73338. * Gets the minimum vector in local space
  73339. */
  73340. readonly minimum: Vector3;
  73341. /**
  73342. * Gets the maximum vector in local space
  73343. */
  73344. readonly maximum: Vector3;
  73345. private _worldMatrix;
  73346. private static readonly TmpVector3;
  73347. /**
  73348. * Creates a new bounding sphere
  73349. * @param min defines the minimum vector (in local space)
  73350. * @param max defines the maximum vector (in local space)
  73351. * @param worldMatrix defines the new world matrix
  73352. */
  73353. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73354. /**
  73355. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73356. * @param min defines the new minimum vector (in local space)
  73357. * @param max defines the new maximum vector (in local space)
  73358. * @param worldMatrix defines the new world matrix
  73359. */
  73360. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73361. /**
  73362. * Scale the current bounding sphere by applying a scale factor
  73363. * @param factor defines the scale factor to apply
  73364. * @returns the current bounding box
  73365. */
  73366. scale(factor: number): BoundingSphere;
  73367. /**
  73368. * Gets the world matrix of the bounding box
  73369. * @returns a matrix
  73370. */
  73371. getWorldMatrix(): DeepImmutable<Matrix>;
  73372. /** @hidden */
  73373. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73374. /**
  73375. * Tests if the bounding sphere is intersecting the frustum planes
  73376. * @param frustumPlanes defines the frustum planes to test
  73377. * @returns true if there is an intersection
  73378. */
  73379. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73380. /**
  73381. * Tests if the bounding sphere center is in between the frustum planes.
  73382. * Used for optimistic fast inclusion.
  73383. * @param frustumPlanes defines the frustum planes to test
  73384. * @returns true if the sphere center is in between the frustum planes
  73385. */
  73386. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73387. /**
  73388. * Tests if a point is inside the bounding sphere
  73389. * @param point defines the point to test
  73390. * @returns true if the point is inside the bounding sphere
  73391. */
  73392. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73393. /**
  73394. * Checks if two sphere intersct
  73395. * @param sphere0 sphere 0
  73396. * @param sphere1 sphere 1
  73397. * @returns true if the speres intersect
  73398. */
  73399. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73400. }
  73401. }
  73402. declare module BABYLON {
  73403. /**
  73404. * Class used to store bounding box information
  73405. */
  73406. export class BoundingBox implements ICullable {
  73407. /**
  73408. * Gets the 8 vectors representing the bounding box in local space
  73409. */
  73410. readonly vectors: Vector3[];
  73411. /**
  73412. * Gets the center of the bounding box in local space
  73413. */
  73414. readonly center: Vector3;
  73415. /**
  73416. * Gets the center of the bounding box in world space
  73417. */
  73418. readonly centerWorld: Vector3;
  73419. /**
  73420. * Gets the extend size in local space
  73421. */
  73422. readonly extendSize: Vector3;
  73423. /**
  73424. * Gets the extend size in world space
  73425. */
  73426. readonly extendSizeWorld: Vector3;
  73427. /**
  73428. * Gets the OBB (object bounding box) directions
  73429. */
  73430. readonly directions: Vector3[];
  73431. /**
  73432. * Gets the 8 vectors representing the bounding box in world space
  73433. */
  73434. readonly vectorsWorld: Vector3[];
  73435. /**
  73436. * Gets the minimum vector in world space
  73437. */
  73438. readonly minimumWorld: Vector3;
  73439. /**
  73440. * Gets the maximum vector in world space
  73441. */
  73442. readonly maximumWorld: Vector3;
  73443. /**
  73444. * Gets the minimum vector in local space
  73445. */
  73446. readonly minimum: Vector3;
  73447. /**
  73448. * Gets the maximum vector in local space
  73449. */
  73450. readonly maximum: Vector3;
  73451. private _worldMatrix;
  73452. private static readonly TmpVector3;
  73453. /**
  73454. * @hidden
  73455. */
  73456. _tag: number;
  73457. /**
  73458. * Creates a new bounding box
  73459. * @param min defines the minimum vector (in local space)
  73460. * @param max defines the maximum vector (in local space)
  73461. * @param worldMatrix defines the new world matrix
  73462. */
  73463. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73464. /**
  73465. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73466. * @param min defines the new minimum vector (in local space)
  73467. * @param max defines the new maximum vector (in local space)
  73468. * @param worldMatrix defines the new world matrix
  73469. */
  73470. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73471. /**
  73472. * Scale the current bounding box by applying a scale factor
  73473. * @param factor defines the scale factor to apply
  73474. * @returns the current bounding box
  73475. */
  73476. scale(factor: number): BoundingBox;
  73477. /**
  73478. * Gets the world matrix of the bounding box
  73479. * @returns a matrix
  73480. */
  73481. getWorldMatrix(): DeepImmutable<Matrix>;
  73482. /** @hidden */
  73483. _update(world: DeepImmutable<Matrix>): void;
  73484. /**
  73485. * Tests if the bounding box is intersecting the frustum planes
  73486. * @param frustumPlanes defines the frustum planes to test
  73487. * @returns true if there is an intersection
  73488. */
  73489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73490. /**
  73491. * Tests if the bounding box is entirely inside the frustum planes
  73492. * @param frustumPlanes defines the frustum planes to test
  73493. * @returns true if there is an inclusion
  73494. */
  73495. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73496. /**
  73497. * Tests if a point is inside the bounding box
  73498. * @param point defines the point to test
  73499. * @returns true if the point is inside the bounding box
  73500. */
  73501. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73502. /**
  73503. * Tests if the bounding box intersects with a bounding sphere
  73504. * @param sphere defines the sphere to test
  73505. * @returns true if there is an intersection
  73506. */
  73507. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73508. /**
  73509. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73510. * @param min defines the min vector to use
  73511. * @param max defines the max vector to use
  73512. * @returns true if there is an intersection
  73513. */
  73514. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73515. /**
  73516. * Tests if two bounding boxes are intersections
  73517. * @param box0 defines the first box to test
  73518. * @param box1 defines the second box to test
  73519. * @returns true if there is an intersection
  73520. */
  73521. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73522. /**
  73523. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73524. * @param minPoint defines the minimum vector of the bounding box
  73525. * @param maxPoint defines the maximum vector of the bounding box
  73526. * @param sphereCenter defines the sphere center
  73527. * @param sphereRadius defines the sphere radius
  73528. * @returns true if there is an intersection
  73529. */
  73530. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73531. /**
  73532. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73533. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73534. * @param frustumPlanes defines the frustum planes to test
  73535. * @return true if there is an inclusion
  73536. */
  73537. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73538. /**
  73539. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73540. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73541. * @param frustumPlanes defines the frustum planes to test
  73542. * @return true if there is an intersection
  73543. */
  73544. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73545. }
  73546. }
  73547. declare module BABYLON {
  73548. /** @hidden */
  73549. export class Collider {
  73550. /** Define if a collision was found */
  73551. collisionFound: boolean;
  73552. /**
  73553. * Define last intersection point in local space
  73554. */
  73555. intersectionPoint: Vector3;
  73556. /**
  73557. * Define last collided mesh
  73558. */
  73559. collidedMesh: Nullable<AbstractMesh>;
  73560. private _collisionPoint;
  73561. private _planeIntersectionPoint;
  73562. private _tempVector;
  73563. private _tempVector2;
  73564. private _tempVector3;
  73565. private _tempVector4;
  73566. private _edge;
  73567. private _baseToVertex;
  73568. private _destinationPoint;
  73569. private _slidePlaneNormal;
  73570. private _displacementVector;
  73571. /** @hidden */
  73572. _radius: Vector3;
  73573. /** @hidden */
  73574. _retry: number;
  73575. private _velocity;
  73576. private _basePoint;
  73577. private _epsilon;
  73578. /** @hidden */
  73579. _velocityWorldLength: number;
  73580. /** @hidden */
  73581. _basePointWorld: Vector3;
  73582. private _velocityWorld;
  73583. private _normalizedVelocity;
  73584. /** @hidden */
  73585. _initialVelocity: Vector3;
  73586. /** @hidden */
  73587. _initialPosition: Vector3;
  73588. private _nearestDistance;
  73589. private _collisionMask;
  73590. collisionMask: number;
  73591. /**
  73592. * Gets the plane normal used to compute the sliding response (in local space)
  73593. */
  73594. readonly slidePlaneNormal: Vector3;
  73595. /** @hidden */
  73596. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73597. /** @hidden */
  73598. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73599. /** @hidden */
  73600. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73601. /** @hidden */
  73602. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73603. /** @hidden */
  73604. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73605. /** @hidden */
  73606. _getResponse(pos: Vector3, vel: Vector3): void;
  73607. }
  73608. }
  73609. declare module BABYLON {
  73610. /**
  73611. * Interface for cullable objects
  73612. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73613. */
  73614. export interface ICullable {
  73615. /**
  73616. * Checks if the object or part of the object is in the frustum
  73617. * @param frustumPlanes Camera near/planes
  73618. * @returns true if the object is in frustum otherwise false
  73619. */
  73620. isInFrustum(frustumPlanes: Plane[]): boolean;
  73621. /**
  73622. * Checks if a cullable object (mesh...) is in the camera frustum
  73623. * Unlike isInFrustum this cheks the full bounding box
  73624. * @param frustumPlanes Camera near/planes
  73625. * @returns true if the object is in frustum otherwise false
  73626. */
  73627. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73628. }
  73629. /**
  73630. * Info for a bounding data of a mesh
  73631. */
  73632. export class BoundingInfo implements ICullable {
  73633. /**
  73634. * Bounding box for the mesh
  73635. */
  73636. readonly boundingBox: BoundingBox;
  73637. /**
  73638. * Bounding sphere for the mesh
  73639. */
  73640. readonly boundingSphere: BoundingSphere;
  73641. private _isLocked;
  73642. private static readonly TmpVector3;
  73643. /**
  73644. * Constructs bounding info
  73645. * @param minimum min vector of the bounding box/sphere
  73646. * @param maximum max vector of the bounding box/sphere
  73647. * @param worldMatrix defines the new world matrix
  73648. */
  73649. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73650. /**
  73651. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73652. * @param min defines the new minimum vector (in local space)
  73653. * @param max defines the new maximum vector (in local space)
  73654. * @param worldMatrix defines the new world matrix
  73655. */
  73656. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73657. /**
  73658. * min vector of the bounding box/sphere
  73659. */
  73660. readonly minimum: Vector3;
  73661. /**
  73662. * max vector of the bounding box/sphere
  73663. */
  73664. readonly maximum: Vector3;
  73665. /**
  73666. * If the info is locked and won't be updated to avoid perf overhead
  73667. */
  73668. isLocked: boolean;
  73669. /**
  73670. * Updates the bounding sphere and box
  73671. * @param world world matrix to be used to update
  73672. */
  73673. update(world: DeepImmutable<Matrix>): void;
  73674. /**
  73675. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73676. * @param center New center of the bounding info
  73677. * @param extend New extend of the bounding info
  73678. * @returns the current bounding info
  73679. */
  73680. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73681. /**
  73682. * Scale the current bounding info by applying a scale factor
  73683. * @param factor defines the scale factor to apply
  73684. * @returns the current bounding info
  73685. */
  73686. scale(factor: number): BoundingInfo;
  73687. /**
  73688. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73689. * @param frustumPlanes defines the frustum to test
  73690. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73691. * @returns true if the bounding info is in the frustum planes
  73692. */
  73693. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73694. /**
  73695. * Gets the world distance between the min and max points of the bounding box
  73696. */
  73697. readonly diagonalLength: number;
  73698. /**
  73699. * Checks if a cullable object (mesh...) is in the camera frustum
  73700. * Unlike isInFrustum this cheks the full bounding box
  73701. * @param frustumPlanes Camera near/planes
  73702. * @returns true if the object is in frustum otherwise false
  73703. */
  73704. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73705. /** @hidden */
  73706. _checkCollision(collider: Collider): boolean;
  73707. /**
  73708. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73709. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73710. * @param point the point to check intersection with
  73711. * @returns if the point intersects
  73712. */
  73713. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73714. /**
  73715. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73716. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73717. * @param boundingInfo the bounding info to check intersection with
  73718. * @param precise if the intersection should be done using OBB
  73719. * @returns if the bounding info intersects
  73720. */
  73721. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73722. }
  73723. }
  73724. declare module BABYLON {
  73725. /**
  73726. * Extracts minimum and maximum values from a list of indexed positions
  73727. * @param positions defines the positions to use
  73728. * @param indices defines the indices to the positions
  73729. * @param indexStart defines the start index
  73730. * @param indexCount defines the end index
  73731. * @param bias defines bias value to add to the result
  73732. * @return minimum and maximum values
  73733. */
  73734. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73735. minimum: Vector3;
  73736. maximum: Vector3;
  73737. };
  73738. /**
  73739. * Extracts minimum and maximum values from a list of positions
  73740. * @param positions defines the positions to use
  73741. * @param start defines the start index in the positions array
  73742. * @param count defines the number of positions to handle
  73743. * @param bias defines bias value to add to the result
  73744. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73745. * @return minimum and maximum values
  73746. */
  73747. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73748. minimum: Vector3;
  73749. maximum: Vector3;
  73750. };
  73751. }
  73752. declare module BABYLON {
  73753. /** @hidden */
  73754. export class WebGLDataBuffer extends DataBuffer {
  73755. private _buffer;
  73756. constructor(resource: WebGLBuffer);
  73757. readonly underlyingResource: any;
  73758. }
  73759. }
  73760. declare module BABYLON {
  73761. /** @hidden */
  73762. export class WebGLPipelineContext implements IPipelineContext {
  73763. engine: ThinEngine;
  73764. program: Nullable<WebGLProgram>;
  73765. context?: WebGLRenderingContext;
  73766. vertexShader?: WebGLShader;
  73767. fragmentShader?: WebGLShader;
  73768. isParallelCompiled: boolean;
  73769. onCompiled?: () => void;
  73770. transformFeedback?: WebGLTransformFeedback | null;
  73771. readonly isAsync: boolean;
  73772. readonly isReady: boolean;
  73773. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73774. }
  73775. }
  73776. declare module BABYLON {
  73777. interface ThinEngine {
  73778. /**
  73779. * Create an uniform buffer
  73780. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73781. * @param elements defines the content of the uniform buffer
  73782. * @returns the webGL uniform buffer
  73783. */
  73784. createUniformBuffer(elements: FloatArray): DataBuffer;
  73785. /**
  73786. * Create a dynamic uniform buffer
  73787. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73788. * @param elements defines the content of the uniform buffer
  73789. * @returns the webGL uniform buffer
  73790. */
  73791. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73792. /**
  73793. * Update an existing uniform buffer
  73794. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73795. * @param uniformBuffer defines the target uniform buffer
  73796. * @param elements defines the content to update
  73797. * @param offset defines the offset in the uniform buffer where update should start
  73798. * @param count defines the size of the data to update
  73799. */
  73800. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73801. /**
  73802. * Bind an uniform buffer to the current webGL context
  73803. * @param buffer defines the buffer to bind
  73804. */
  73805. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73806. /**
  73807. * Bind a buffer to the current webGL context at a given location
  73808. * @param buffer defines the buffer to bind
  73809. * @param location defines the index where to bind the buffer
  73810. */
  73811. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73812. /**
  73813. * Bind a specific block at a given index in a specific shader program
  73814. * @param pipelineContext defines the pipeline context to use
  73815. * @param blockName defines the block name
  73816. * @param index defines the index where to bind the block
  73817. */
  73818. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73819. }
  73820. }
  73821. declare module BABYLON {
  73822. /**
  73823. * Uniform buffer objects.
  73824. *
  73825. * Handles blocks of uniform on the GPU.
  73826. *
  73827. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73828. *
  73829. * For more information, please refer to :
  73830. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73831. */
  73832. export class UniformBuffer {
  73833. private _engine;
  73834. private _buffer;
  73835. private _data;
  73836. private _bufferData;
  73837. private _dynamic?;
  73838. private _uniformLocations;
  73839. private _uniformSizes;
  73840. private _uniformLocationPointer;
  73841. private _needSync;
  73842. private _noUBO;
  73843. private _currentEffect;
  73844. private static _MAX_UNIFORM_SIZE;
  73845. private static _tempBuffer;
  73846. /**
  73847. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73848. * This is dynamic to allow compat with webgl 1 and 2.
  73849. * You will need to pass the name of the uniform as well as the value.
  73850. */
  73851. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73852. /**
  73853. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73854. * This is dynamic to allow compat with webgl 1 and 2.
  73855. * You will need to pass the name of the uniform as well as the value.
  73856. */
  73857. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73858. /**
  73859. * Lambda to Update a single float in a uniform buffer.
  73860. * This is dynamic to allow compat with webgl 1 and 2.
  73861. * You will need to pass the name of the uniform as well as the value.
  73862. */
  73863. updateFloat: (name: string, x: number) => void;
  73864. /**
  73865. * Lambda to Update a vec2 of float in a uniform buffer.
  73866. * This is dynamic to allow compat with webgl 1 and 2.
  73867. * You will need to pass the name of the uniform as well as the value.
  73868. */
  73869. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73870. /**
  73871. * Lambda to Update a vec3 of float in a uniform buffer.
  73872. * This is dynamic to allow compat with webgl 1 and 2.
  73873. * You will need to pass the name of the uniform as well as the value.
  73874. */
  73875. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73876. /**
  73877. * Lambda to Update a vec4 of float in a uniform buffer.
  73878. * This is dynamic to allow compat with webgl 1 and 2.
  73879. * You will need to pass the name of the uniform as well as the value.
  73880. */
  73881. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73882. /**
  73883. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73884. * This is dynamic to allow compat with webgl 1 and 2.
  73885. * You will need to pass the name of the uniform as well as the value.
  73886. */
  73887. updateMatrix: (name: string, mat: Matrix) => void;
  73888. /**
  73889. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73890. * This is dynamic to allow compat with webgl 1 and 2.
  73891. * You will need to pass the name of the uniform as well as the value.
  73892. */
  73893. updateVector3: (name: string, vector: Vector3) => void;
  73894. /**
  73895. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73896. * This is dynamic to allow compat with webgl 1 and 2.
  73897. * You will need to pass the name of the uniform as well as the value.
  73898. */
  73899. updateVector4: (name: string, vector: Vector4) => void;
  73900. /**
  73901. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73902. * This is dynamic to allow compat with webgl 1 and 2.
  73903. * You will need to pass the name of the uniform as well as the value.
  73904. */
  73905. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73906. /**
  73907. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73908. * This is dynamic to allow compat with webgl 1 and 2.
  73909. * You will need to pass the name of the uniform as well as the value.
  73910. */
  73911. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73912. /**
  73913. * Instantiates a new Uniform buffer objects.
  73914. *
  73915. * Handles blocks of uniform on the GPU.
  73916. *
  73917. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73918. *
  73919. * For more information, please refer to :
  73920. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73921. * @param engine Define the engine the buffer is associated with
  73922. * @param data Define the data contained in the buffer
  73923. * @param dynamic Define if the buffer is updatable
  73924. */
  73925. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73926. /**
  73927. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73928. * or just falling back on setUniformXXX calls.
  73929. */
  73930. readonly useUbo: boolean;
  73931. /**
  73932. * Indicates if the WebGL underlying uniform buffer is in sync
  73933. * with the javascript cache data.
  73934. */
  73935. readonly isSync: boolean;
  73936. /**
  73937. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73938. * Also, a dynamic UniformBuffer will disable cache verification and always
  73939. * update the underlying WebGL uniform buffer to the GPU.
  73940. * @returns if Dynamic, otherwise false
  73941. */
  73942. isDynamic(): boolean;
  73943. /**
  73944. * The data cache on JS side.
  73945. * @returns the underlying data as a float array
  73946. */
  73947. getData(): Float32Array;
  73948. /**
  73949. * The underlying WebGL Uniform buffer.
  73950. * @returns the webgl buffer
  73951. */
  73952. getBuffer(): Nullable<DataBuffer>;
  73953. /**
  73954. * std140 layout specifies how to align data within an UBO structure.
  73955. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73956. * for specs.
  73957. */
  73958. private _fillAlignment;
  73959. /**
  73960. * Adds an uniform in the buffer.
  73961. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73962. * for the layout to be correct !
  73963. * @param name Name of the uniform, as used in the uniform block in the shader.
  73964. * @param size Data size, or data directly.
  73965. */
  73966. addUniform(name: string, size: number | number[]): void;
  73967. /**
  73968. * Adds a Matrix 4x4 to the uniform buffer.
  73969. * @param name Name of the uniform, as used in the uniform block in the shader.
  73970. * @param mat A 4x4 matrix.
  73971. */
  73972. addMatrix(name: string, mat: Matrix): void;
  73973. /**
  73974. * Adds a vec2 to the uniform buffer.
  73975. * @param name Name of the uniform, as used in the uniform block in the shader.
  73976. * @param x Define the x component value of the vec2
  73977. * @param y Define the y component value of the vec2
  73978. */
  73979. addFloat2(name: string, x: number, y: number): void;
  73980. /**
  73981. * Adds a vec3 to the uniform buffer.
  73982. * @param name Name of the uniform, as used in the uniform block in the shader.
  73983. * @param x Define the x component value of the vec3
  73984. * @param y Define the y component value of the vec3
  73985. * @param z Define the z component value of the vec3
  73986. */
  73987. addFloat3(name: string, x: number, y: number, z: number): void;
  73988. /**
  73989. * Adds a vec3 to the uniform buffer.
  73990. * @param name Name of the uniform, as used in the uniform block in the shader.
  73991. * @param color Define the vec3 from a Color
  73992. */
  73993. addColor3(name: string, color: Color3): void;
  73994. /**
  73995. * Adds a vec4 to the uniform buffer.
  73996. * @param name Name of the uniform, as used in the uniform block in the shader.
  73997. * @param color Define the rgb components from a Color
  73998. * @param alpha Define the a component of the vec4
  73999. */
  74000. addColor4(name: string, color: Color3, alpha: number): void;
  74001. /**
  74002. * Adds a vec3 to the uniform buffer.
  74003. * @param name Name of the uniform, as used in the uniform block in the shader.
  74004. * @param vector Define the vec3 components from a Vector
  74005. */
  74006. addVector3(name: string, vector: Vector3): void;
  74007. /**
  74008. * Adds a Matrix 3x3 to the uniform buffer.
  74009. * @param name Name of the uniform, as used in the uniform block in the shader.
  74010. */
  74011. addMatrix3x3(name: string): void;
  74012. /**
  74013. * Adds a Matrix 2x2 to the uniform buffer.
  74014. * @param name Name of the uniform, as used in the uniform block in the shader.
  74015. */
  74016. addMatrix2x2(name: string): void;
  74017. /**
  74018. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74019. */
  74020. create(): void;
  74021. /** @hidden */
  74022. _rebuild(): void;
  74023. /**
  74024. * Updates the WebGL Uniform Buffer on the GPU.
  74025. * If the `dynamic` flag is set to true, no cache comparison is done.
  74026. * Otherwise, the buffer will be updated only if the cache differs.
  74027. */
  74028. update(): void;
  74029. /**
  74030. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74031. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74032. * @param data Define the flattened data
  74033. * @param size Define the size of the data.
  74034. */
  74035. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74036. private _valueCache;
  74037. private _cacheMatrix;
  74038. private _updateMatrix3x3ForUniform;
  74039. private _updateMatrix3x3ForEffect;
  74040. private _updateMatrix2x2ForEffect;
  74041. private _updateMatrix2x2ForUniform;
  74042. private _updateFloatForEffect;
  74043. private _updateFloatForUniform;
  74044. private _updateFloat2ForEffect;
  74045. private _updateFloat2ForUniform;
  74046. private _updateFloat3ForEffect;
  74047. private _updateFloat3ForUniform;
  74048. private _updateFloat4ForEffect;
  74049. private _updateFloat4ForUniform;
  74050. private _updateMatrixForEffect;
  74051. private _updateMatrixForUniform;
  74052. private _updateVector3ForEffect;
  74053. private _updateVector3ForUniform;
  74054. private _updateVector4ForEffect;
  74055. private _updateVector4ForUniform;
  74056. private _updateColor3ForEffect;
  74057. private _updateColor3ForUniform;
  74058. private _updateColor4ForEffect;
  74059. private _updateColor4ForUniform;
  74060. /**
  74061. * Sets a sampler uniform on the effect.
  74062. * @param name Define the name of the sampler.
  74063. * @param texture Define the texture to set in the sampler
  74064. */
  74065. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74066. /**
  74067. * Directly updates the value of the uniform in the cache AND on the GPU.
  74068. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74069. * @param data Define the flattened data
  74070. */
  74071. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74072. /**
  74073. * Binds this uniform buffer to an effect.
  74074. * @param effect Define the effect to bind the buffer to
  74075. * @param name Name of the uniform block in the shader.
  74076. */
  74077. bindToEffect(effect: Effect, name: string): void;
  74078. /**
  74079. * Disposes the uniform buffer.
  74080. */
  74081. dispose(): void;
  74082. }
  74083. }
  74084. declare module BABYLON {
  74085. /**
  74086. * Enum that determines the text-wrapping mode to use.
  74087. */
  74088. export enum InspectableType {
  74089. /**
  74090. * Checkbox for booleans
  74091. */
  74092. Checkbox = 0,
  74093. /**
  74094. * Sliders for numbers
  74095. */
  74096. Slider = 1,
  74097. /**
  74098. * Vector3
  74099. */
  74100. Vector3 = 2,
  74101. /**
  74102. * Quaternions
  74103. */
  74104. Quaternion = 3,
  74105. /**
  74106. * Color3
  74107. */
  74108. Color3 = 4,
  74109. /**
  74110. * String
  74111. */
  74112. String = 5
  74113. }
  74114. /**
  74115. * Interface used to define custom inspectable properties.
  74116. * This interface is used by the inspector to display custom property grids
  74117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74118. */
  74119. export interface IInspectable {
  74120. /**
  74121. * Gets the label to display
  74122. */
  74123. label: string;
  74124. /**
  74125. * Gets the name of the property to edit
  74126. */
  74127. propertyName: string;
  74128. /**
  74129. * Gets the type of the editor to use
  74130. */
  74131. type: InspectableType;
  74132. /**
  74133. * Gets the minimum value of the property when using in "slider" mode
  74134. */
  74135. min?: number;
  74136. /**
  74137. * Gets the maximum value of the property when using in "slider" mode
  74138. */
  74139. max?: number;
  74140. /**
  74141. * Gets the setp to use when using in "slider" mode
  74142. */
  74143. step?: number;
  74144. }
  74145. }
  74146. declare module BABYLON {
  74147. /**
  74148. * Class used to provide helper for timing
  74149. */
  74150. export class TimingTools {
  74151. /**
  74152. * Polyfill for setImmediate
  74153. * @param action defines the action to execute after the current execution block
  74154. */
  74155. static SetImmediate(action: () => void): void;
  74156. }
  74157. }
  74158. declare module BABYLON {
  74159. /**
  74160. * Class used to enable instatition of objects by class name
  74161. */
  74162. export class InstantiationTools {
  74163. /**
  74164. * Use this object to register external classes like custom textures or material
  74165. * to allow the laoders to instantiate them
  74166. */
  74167. static RegisteredExternalClasses: {
  74168. [key: string]: Object;
  74169. };
  74170. /**
  74171. * Tries to instantiate a new object from a given class name
  74172. * @param className defines the class name to instantiate
  74173. * @returns the new object or null if the system was not able to do the instantiation
  74174. */
  74175. static Instantiate(className: string): any;
  74176. }
  74177. }
  74178. declare module BABYLON {
  74179. /**
  74180. * Define options used to create a depth texture
  74181. */
  74182. export class DepthTextureCreationOptions {
  74183. /** Specifies whether or not a stencil should be allocated in the texture */
  74184. generateStencil?: boolean;
  74185. /** Specifies whether or not bilinear filtering is enable on the texture */
  74186. bilinearFiltering?: boolean;
  74187. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74188. comparisonFunction?: number;
  74189. /** Specifies if the created texture is a cube texture */
  74190. isCube?: boolean;
  74191. }
  74192. }
  74193. declare module BABYLON {
  74194. interface ThinEngine {
  74195. /**
  74196. * Creates a depth stencil cube texture.
  74197. * This is only available in WebGL 2.
  74198. * @param size The size of face edge in the cube texture.
  74199. * @param options The options defining the cube texture.
  74200. * @returns The cube texture
  74201. */
  74202. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74203. /**
  74204. * Creates a cube texture
  74205. * @param rootUrl defines the url where the files to load is located
  74206. * @param scene defines the current scene
  74207. * @param files defines the list of files to load (1 per face)
  74208. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74209. * @param onLoad defines an optional callback raised when the texture is loaded
  74210. * @param onError defines an optional callback raised if there is an issue to load the texture
  74211. * @param format defines the format of the data
  74212. * @param forcedExtension defines the extension to use to pick the right loader
  74213. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74214. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74215. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74216. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74217. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74218. * @returns the cube texture as an InternalTexture
  74219. */
  74220. 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;
  74221. /**
  74222. * Creates a cube texture
  74223. * @param rootUrl defines the url where the files to load is located
  74224. * @param scene defines the current scene
  74225. * @param files defines the list of files to load (1 per face)
  74226. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74227. * @param onLoad defines an optional callback raised when the texture is loaded
  74228. * @param onError defines an optional callback raised if there is an issue to load the texture
  74229. * @param format defines the format of the data
  74230. * @param forcedExtension defines the extension to use to pick the right loader
  74231. * @returns the cube texture as an InternalTexture
  74232. */
  74233. 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;
  74234. /**
  74235. * Creates a cube texture
  74236. * @param rootUrl defines the url where the files to load is located
  74237. * @param scene defines the current scene
  74238. * @param files defines the list of files to load (1 per face)
  74239. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74240. * @param onLoad defines an optional callback raised when the texture is loaded
  74241. * @param onError defines an optional callback raised if there is an issue to load the texture
  74242. * @param format defines the format of the data
  74243. * @param forcedExtension defines the extension to use to pick the right loader
  74244. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74245. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74246. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74247. * @returns the cube texture as an InternalTexture
  74248. */
  74249. 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;
  74250. /** @hidden */
  74251. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74252. /** @hidden */
  74253. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74254. /** @hidden */
  74255. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74256. /** @hidden */
  74257. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74258. }
  74259. }
  74260. declare module BABYLON {
  74261. /**
  74262. * Class for creating a cube texture
  74263. */
  74264. export class CubeTexture extends BaseTexture {
  74265. private _delayedOnLoad;
  74266. /**
  74267. * The url of the texture
  74268. */
  74269. url: string;
  74270. /**
  74271. * Gets or sets the center of the bounding box associated with the cube texture.
  74272. * It must define where the camera used to render the texture was set
  74273. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74274. */
  74275. boundingBoxPosition: Vector3;
  74276. private _boundingBoxSize;
  74277. /**
  74278. * Gets or sets the size of the bounding box associated with the cube texture
  74279. * When defined, the cubemap will switch to local mode
  74280. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74281. * @example https://www.babylonjs-playground.com/#RNASML
  74282. */
  74283. /**
  74284. * Returns the bounding box size
  74285. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74286. */
  74287. boundingBoxSize: Vector3;
  74288. protected _rotationY: number;
  74289. /**
  74290. * Sets texture matrix rotation angle around Y axis in radians.
  74291. */
  74292. /**
  74293. * Gets texture matrix rotation angle around Y axis radians.
  74294. */
  74295. rotationY: number;
  74296. /**
  74297. * Are mip maps generated for this texture or not.
  74298. */
  74299. readonly noMipmap: boolean;
  74300. private _noMipmap;
  74301. private _files;
  74302. protected _forcedExtension: Nullable<string>;
  74303. private _extensions;
  74304. private _textureMatrix;
  74305. private _format;
  74306. private _createPolynomials;
  74307. /** @hidden */
  74308. _prefiltered: boolean;
  74309. /**
  74310. * Creates a cube texture from an array of image urls
  74311. * @param files defines an array of image urls
  74312. * @param scene defines the hosting scene
  74313. * @param noMipmap specifies if mip maps are not used
  74314. * @returns a cube texture
  74315. */
  74316. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74317. /**
  74318. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74319. * @param url defines the url of the prefiltered texture
  74320. * @param scene defines the scene the texture is attached to
  74321. * @param forcedExtension defines the extension of the file if different from the url
  74322. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74323. * @return the prefiltered texture
  74324. */
  74325. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74326. /**
  74327. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74328. * as prefiltered data.
  74329. * @param rootUrl defines the url of the texture or the root name of the six images
  74330. * @param scene defines the scene the texture is attached to
  74331. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74332. * @param noMipmap defines if mipmaps should be created or not
  74333. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74334. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74335. * @param onError defines a callback triggered in case of error during load
  74336. * @param format defines the internal format to use for the texture once loaded
  74337. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74338. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74339. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74340. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74341. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74342. * @return the cube texture
  74343. */
  74344. 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);
  74345. /**
  74346. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74347. */
  74348. readonly isPrefiltered: boolean;
  74349. /**
  74350. * Get the current class name of the texture useful for serialization or dynamic coding.
  74351. * @returns "CubeTexture"
  74352. */
  74353. getClassName(): string;
  74354. /**
  74355. * Update the url (and optional buffer) of this texture if url was null during construction.
  74356. * @param url the url of the texture
  74357. * @param forcedExtension defines the extension to use
  74358. * @param onLoad callback called when the texture is loaded (defaults to null)
  74359. */
  74360. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74361. /**
  74362. * Delays loading of the cube texture
  74363. * @param forcedExtension defines the extension to use
  74364. */
  74365. delayLoad(forcedExtension?: string): void;
  74366. /**
  74367. * Returns the reflection texture matrix
  74368. * @returns the reflection texture matrix
  74369. */
  74370. getReflectionTextureMatrix(): Matrix;
  74371. /**
  74372. * Sets the reflection texture matrix
  74373. * @param value Reflection texture matrix
  74374. */
  74375. setReflectionTextureMatrix(value: Matrix): void;
  74376. /**
  74377. * Parses text to create a cube texture
  74378. * @param parsedTexture define the serialized text to read from
  74379. * @param scene defines the hosting scene
  74380. * @param rootUrl defines the root url of the cube texture
  74381. * @returns a cube texture
  74382. */
  74383. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74384. /**
  74385. * Makes a clone, or deep copy, of the cube texture
  74386. * @returns a new cube texture
  74387. */
  74388. clone(): CubeTexture;
  74389. }
  74390. }
  74391. declare module BABYLON {
  74392. /**
  74393. * Manages the defines for the Material
  74394. */
  74395. export class MaterialDefines {
  74396. /** @hidden */
  74397. protected _keys: string[];
  74398. private _isDirty;
  74399. /** @hidden */
  74400. _renderId: number;
  74401. /** @hidden */
  74402. _areLightsDirty: boolean;
  74403. /** @hidden */
  74404. _areLightsDisposed: boolean;
  74405. /** @hidden */
  74406. _areAttributesDirty: boolean;
  74407. /** @hidden */
  74408. _areTexturesDirty: boolean;
  74409. /** @hidden */
  74410. _areFresnelDirty: boolean;
  74411. /** @hidden */
  74412. _areMiscDirty: boolean;
  74413. /** @hidden */
  74414. _areImageProcessingDirty: boolean;
  74415. /** @hidden */
  74416. _normals: boolean;
  74417. /** @hidden */
  74418. _uvs: boolean;
  74419. /** @hidden */
  74420. _needNormals: boolean;
  74421. /** @hidden */
  74422. _needUVs: boolean;
  74423. [id: string]: any;
  74424. /**
  74425. * Specifies if the material needs to be re-calculated
  74426. */
  74427. readonly isDirty: boolean;
  74428. /**
  74429. * Marks the material to indicate that it has been re-calculated
  74430. */
  74431. markAsProcessed(): void;
  74432. /**
  74433. * Marks the material to indicate that it needs to be re-calculated
  74434. */
  74435. markAsUnprocessed(): void;
  74436. /**
  74437. * Marks the material to indicate all of its defines need to be re-calculated
  74438. */
  74439. markAllAsDirty(): void;
  74440. /**
  74441. * Marks the material to indicate that image processing needs to be re-calculated
  74442. */
  74443. markAsImageProcessingDirty(): void;
  74444. /**
  74445. * Marks the material to indicate the lights need to be re-calculated
  74446. * @param disposed Defines whether the light is dirty due to dispose or not
  74447. */
  74448. markAsLightDirty(disposed?: boolean): void;
  74449. /**
  74450. * Marks the attribute state as changed
  74451. */
  74452. markAsAttributesDirty(): void;
  74453. /**
  74454. * Marks the texture state as changed
  74455. */
  74456. markAsTexturesDirty(): void;
  74457. /**
  74458. * Marks the fresnel state as changed
  74459. */
  74460. markAsFresnelDirty(): void;
  74461. /**
  74462. * Marks the misc state as changed
  74463. */
  74464. markAsMiscDirty(): void;
  74465. /**
  74466. * Rebuilds the material defines
  74467. */
  74468. rebuild(): void;
  74469. /**
  74470. * Specifies if two material defines are equal
  74471. * @param other - A material define instance to compare to
  74472. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74473. */
  74474. isEqual(other: MaterialDefines): boolean;
  74475. /**
  74476. * Clones this instance's defines to another instance
  74477. * @param other - material defines to clone values to
  74478. */
  74479. cloneTo(other: MaterialDefines): void;
  74480. /**
  74481. * Resets the material define values
  74482. */
  74483. reset(): void;
  74484. /**
  74485. * Converts the material define values to a string
  74486. * @returns - String of material define information
  74487. */
  74488. toString(): string;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /**
  74493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74495. * 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;
  74496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74497. */
  74498. export class ColorCurves {
  74499. private _dirty;
  74500. private _tempColor;
  74501. private _globalCurve;
  74502. private _highlightsCurve;
  74503. private _midtonesCurve;
  74504. private _shadowsCurve;
  74505. private _positiveCurve;
  74506. private _negativeCurve;
  74507. private _globalHue;
  74508. private _globalDensity;
  74509. private _globalSaturation;
  74510. private _globalExposure;
  74511. /**
  74512. * Gets the global Hue value.
  74513. * 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).
  74514. */
  74515. /**
  74516. * Sets the global Hue value.
  74517. * 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).
  74518. */
  74519. globalHue: number;
  74520. /**
  74521. * Gets the global Density value.
  74522. * 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.
  74523. * Values less than zero provide a filter of opposite hue.
  74524. */
  74525. /**
  74526. * Sets the global Density value.
  74527. * 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.
  74528. * Values less than zero provide a filter of opposite hue.
  74529. */
  74530. globalDensity: number;
  74531. /**
  74532. * Gets the global Saturation value.
  74533. * 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.
  74534. */
  74535. /**
  74536. * Sets the global Saturation value.
  74537. * 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.
  74538. */
  74539. globalSaturation: number;
  74540. /**
  74541. * Gets the global Exposure value.
  74542. * 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.
  74543. */
  74544. /**
  74545. * Sets the global Exposure value.
  74546. * 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.
  74547. */
  74548. globalExposure: number;
  74549. private _highlightsHue;
  74550. private _highlightsDensity;
  74551. private _highlightsSaturation;
  74552. private _highlightsExposure;
  74553. /**
  74554. * Gets the highlights Hue value.
  74555. * 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).
  74556. */
  74557. /**
  74558. * Sets the highlights Hue value.
  74559. * 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).
  74560. */
  74561. highlightsHue: number;
  74562. /**
  74563. * Gets the highlights Density value.
  74564. * 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.
  74565. * Values less than zero provide a filter of opposite hue.
  74566. */
  74567. /**
  74568. * Sets the highlights Density value.
  74569. * 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.
  74570. * Values less than zero provide a filter of opposite hue.
  74571. */
  74572. highlightsDensity: number;
  74573. /**
  74574. * Gets the highlights Saturation value.
  74575. * 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.
  74576. */
  74577. /**
  74578. * Sets the highlights Saturation value.
  74579. * 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.
  74580. */
  74581. highlightsSaturation: number;
  74582. /**
  74583. * Gets the highlights Exposure value.
  74584. * 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.
  74585. */
  74586. /**
  74587. * Sets the highlights Exposure value.
  74588. * 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.
  74589. */
  74590. highlightsExposure: number;
  74591. private _midtonesHue;
  74592. private _midtonesDensity;
  74593. private _midtonesSaturation;
  74594. private _midtonesExposure;
  74595. /**
  74596. * Gets the midtones Hue value.
  74597. * 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).
  74598. */
  74599. /**
  74600. * Sets the midtones Hue value.
  74601. * 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).
  74602. */
  74603. midtonesHue: number;
  74604. /**
  74605. * Gets the midtones Density value.
  74606. * 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.
  74607. * Values less than zero provide a filter of opposite hue.
  74608. */
  74609. /**
  74610. * Sets the midtones Density value.
  74611. * 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.
  74612. * Values less than zero provide a filter of opposite hue.
  74613. */
  74614. midtonesDensity: number;
  74615. /**
  74616. * Gets the midtones Saturation value.
  74617. * 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.
  74618. */
  74619. /**
  74620. * Sets the midtones Saturation value.
  74621. * 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.
  74622. */
  74623. midtonesSaturation: number;
  74624. /**
  74625. * Gets the midtones Exposure value.
  74626. * 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.
  74627. */
  74628. /**
  74629. * Sets the midtones Exposure value.
  74630. * 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.
  74631. */
  74632. midtonesExposure: number;
  74633. private _shadowsHue;
  74634. private _shadowsDensity;
  74635. private _shadowsSaturation;
  74636. private _shadowsExposure;
  74637. /**
  74638. * Gets the shadows Hue value.
  74639. * 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).
  74640. */
  74641. /**
  74642. * Sets the shadows Hue value.
  74643. * 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).
  74644. */
  74645. shadowsHue: number;
  74646. /**
  74647. * Gets the shadows Density value.
  74648. * 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.
  74649. * Values less than zero provide a filter of opposite hue.
  74650. */
  74651. /**
  74652. * Sets the shadows Density value.
  74653. * 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.
  74654. * Values less than zero provide a filter of opposite hue.
  74655. */
  74656. shadowsDensity: number;
  74657. /**
  74658. * Gets the shadows Saturation value.
  74659. * 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.
  74660. */
  74661. /**
  74662. * Sets the shadows Saturation value.
  74663. * 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.
  74664. */
  74665. shadowsSaturation: number;
  74666. /**
  74667. * Gets the shadows Exposure value.
  74668. * 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.
  74669. */
  74670. /**
  74671. * Sets the shadows Exposure value.
  74672. * 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.
  74673. */
  74674. shadowsExposure: number;
  74675. /**
  74676. * Returns the class name
  74677. * @returns The class name
  74678. */
  74679. getClassName(): string;
  74680. /**
  74681. * Binds the color curves to the shader.
  74682. * @param colorCurves The color curve to bind
  74683. * @param effect The effect to bind to
  74684. * @param positiveUniform The positive uniform shader parameter
  74685. * @param neutralUniform The neutral uniform shader parameter
  74686. * @param negativeUniform The negative uniform shader parameter
  74687. */
  74688. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74689. /**
  74690. * Prepare the list of uniforms associated with the ColorCurves effects.
  74691. * @param uniformsList The list of uniforms used in the effect
  74692. */
  74693. static PrepareUniforms(uniformsList: string[]): void;
  74694. /**
  74695. * Returns color grading data based on a hue, density, saturation and exposure value.
  74696. * @param filterHue The hue of the color filter.
  74697. * @param filterDensity The density of the color filter.
  74698. * @param saturation The saturation.
  74699. * @param exposure The exposure.
  74700. * @param result The result data container.
  74701. */
  74702. private getColorGradingDataToRef;
  74703. /**
  74704. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74705. * @param value The input slider value in range [-100,100].
  74706. * @returns Adjusted value.
  74707. */
  74708. private static applyColorGradingSliderNonlinear;
  74709. /**
  74710. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74711. * @param hue The hue (H) input.
  74712. * @param saturation The saturation (S) input.
  74713. * @param brightness The brightness (B) input.
  74714. * @result An RGBA color represented as Vector4.
  74715. */
  74716. private static fromHSBToRef;
  74717. /**
  74718. * Returns a value clamped between min and max
  74719. * @param value The value to clamp
  74720. * @param min The minimum of value
  74721. * @param max The maximum of value
  74722. * @returns The clamped value.
  74723. */
  74724. private static clamp;
  74725. /**
  74726. * Clones the current color curve instance.
  74727. * @return The cloned curves
  74728. */
  74729. clone(): ColorCurves;
  74730. /**
  74731. * Serializes the current color curve instance to a json representation.
  74732. * @return a JSON representation
  74733. */
  74734. serialize(): any;
  74735. /**
  74736. * Parses the color curve from a json representation.
  74737. * @param source the JSON source to parse
  74738. * @return The parsed curves
  74739. */
  74740. static Parse(source: any): ColorCurves;
  74741. }
  74742. }
  74743. declare module BABYLON {
  74744. /**
  74745. * Interface to follow in your material defines to integrate easily the
  74746. * Image proccessing functions.
  74747. * @hidden
  74748. */
  74749. export interface IImageProcessingConfigurationDefines {
  74750. IMAGEPROCESSING: boolean;
  74751. VIGNETTE: boolean;
  74752. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74753. VIGNETTEBLENDMODEOPAQUE: boolean;
  74754. TONEMAPPING: boolean;
  74755. TONEMAPPING_ACES: boolean;
  74756. CONTRAST: boolean;
  74757. EXPOSURE: boolean;
  74758. COLORCURVES: boolean;
  74759. COLORGRADING: boolean;
  74760. COLORGRADING3D: boolean;
  74761. SAMPLER3DGREENDEPTH: boolean;
  74762. SAMPLER3DBGRMAP: boolean;
  74763. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74764. }
  74765. /**
  74766. * @hidden
  74767. */
  74768. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74769. IMAGEPROCESSING: boolean;
  74770. VIGNETTE: boolean;
  74771. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74772. VIGNETTEBLENDMODEOPAQUE: boolean;
  74773. TONEMAPPING: boolean;
  74774. TONEMAPPING_ACES: boolean;
  74775. CONTRAST: boolean;
  74776. COLORCURVES: boolean;
  74777. COLORGRADING: boolean;
  74778. COLORGRADING3D: boolean;
  74779. SAMPLER3DGREENDEPTH: boolean;
  74780. SAMPLER3DBGRMAP: boolean;
  74781. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74782. EXPOSURE: boolean;
  74783. constructor();
  74784. }
  74785. /**
  74786. * This groups together the common properties used for image processing either in direct forward pass
  74787. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74788. * or not.
  74789. */
  74790. export class ImageProcessingConfiguration {
  74791. /**
  74792. * Default tone mapping applied in BabylonJS.
  74793. */
  74794. static readonly TONEMAPPING_STANDARD: number;
  74795. /**
  74796. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74797. * to other engines rendering to increase portability.
  74798. */
  74799. static readonly TONEMAPPING_ACES: number;
  74800. /**
  74801. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74802. */
  74803. colorCurves: Nullable<ColorCurves>;
  74804. private _colorCurvesEnabled;
  74805. /**
  74806. * Gets wether the color curves effect is enabled.
  74807. */
  74808. /**
  74809. * Sets wether the color curves effect is enabled.
  74810. */
  74811. colorCurvesEnabled: boolean;
  74812. private _colorGradingTexture;
  74813. /**
  74814. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74815. */
  74816. /**
  74817. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74818. */
  74819. colorGradingTexture: Nullable<BaseTexture>;
  74820. private _colorGradingEnabled;
  74821. /**
  74822. * Gets wether the color grading effect is enabled.
  74823. */
  74824. /**
  74825. * Sets wether the color grading effect is enabled.
  74826. */
  74827. colorGradingEnabled: boolean;
  74828. private _colorGradingWithGreenDepth;
  74829. /**
  74830. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74831. */
  74832. /**
  74833. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74834. */
  74835. colorGradingWithGreenDepth: boolean;
  74836. private _colorGradingBGR;
  74837. /**
  74838. * Gets wether the color grading texture contains BGR values.
  74839. */
  74840. /**
  74841. * Sets wether the color grading texture contains BGR values.
  74842. */
  74843. colorGradingBGR: boolean;
  74844. /** @hidden */
  74845. _exposure: number;
  74846. /**
  74847. * Gets the Exposure used in the effect.
  74848. */
  74849. /**
  74850. * Sets the Exposure used in the effect.
  74851. */
  74852. exposure: number;
  74853. private _toneMappingEnabled;
  74854. /**
  74855. * Gets wether the tone mapping effect is enabled.
  74856. */
  74857. /**
  74858. * Sets wether the tone mapping effect is enabled.
  74859. */
  74860. toneMappingEnabled: boolean;
  74861. private _toneMappingType;
  74862. /**
  74863. * Gets the type of tone mapping effect.
  74864. */
  74865. /**
  74866. * Sets the type of tone mapping effect used in BabylonJS.
  74867. */
  74868. toneMappingType: number;
  74869. protected _contrast: number;
  74870. /**
  74871. * Gets the contrast used in the effect.
  74872. */
  74873. /**
  74874. * Sets the contrast used in the effect.
  74875. */
  74876. contrast: number;
  74877. /**
  74878. * Vignette stretch size.
  74879. */
  74880. vignetteStretch: number;
  74881. /**
  74882. * Vignette centre X Offset.
  74883. */
  74884. vignetteCentreX: number;
  74885. /**
  74886. * Vignette centre Y Offset.
  74887. */
  74888. vignetteCentreY: number;
  74889. /**
  74890. * Vignette weight or intensity of the vignette effect.
  74891. */
  74892. vignetteWeight: number;
  74893. /**
  74894. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74895. * if vignetteEnabled is set to true.
  74896. */
  74897. vignetteColor: Color4;
  74898. /**
  74899. * Camera field of view used by the Vignette effect.
  74900. */
  74901. vignetteCameraFov: number;
  74902. private _vignetteBlendMode;
  74903. /**
  74904. * Gets the vignette blend mode allowing different kind of effect.
  74905. */
  74906. /**
  74907. * Sets the vignette blend mode allowing different kind of effect.
  74908. */
  74909. vignetteBlendMode: number;
  74910. private _vignetteEnabled;
  74911. /**
  74912. * Gets wether the vignette effect is enabled.
  74913. */
  74914. /**
  74915. * Sets wether the vignette effect is enabled.
  74916. */
  74917. vignetteEnabled: boolean;
  74918. private _applyByPostProcess;
  74919. /**
  74920. * Gets wether the image processing is applied through a post process or not.
  74921. */
  74922. /**
  74923. * Sets wether the image processing is applied through a post process or not.
  74924. */
  74925. applyByPostProcess: boolean;
  74926. private _isEnabled;
  74927. /**
  74928. * Gets wether the image processing is enabled or not.
  74929. */
  74930. /**
  74931. * Sets wether the image processing is enabled or not.
  74932. */
  74933. isEnabled: boolean;
  74934. /**
  74935. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74936. */
  74937. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74938. /**
  74939. * Method called each time the image processing information changes requires to recompile the effect.
  74940. */
  74941. protected _updateParameters(): void;
  74942. /**
  74943. * Gets the current class name.
  74944. * @return "ImageProcessingConfiguration"
  74945. */
  74946. getClassName(): string;
  74947. /**
  74948. * Prepare the list of uniforms associated with the Image Processing effects.
  74949. * @param uniforms The list of uniforms used in the effect
  74950. * @param defines the list of defines currently in use
  74951. */
  74952. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74953. /**
  74954. * Prepare the list of samplers associated with the Image Processing effects.
  74955. * @param samplersList The list of uniforms used in the effect
  74956. * @param defines the list of defines currently in use
  74957. */
  74958. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74959. /**
  74960. * Prepare the list of defines associated to the shader.
  74961. * @param defines the list of defines to complete
  74962. * @param forPostProcess Define if we are currently in post process mode or not
  74963. */
  74964. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74965. /**
  74966. * Returns true if all the image processing information are ready.
  74967. * @returns True if ready, otherwise, false
  74968. */
  74969. isReady(): boolean;
  74970. /**
  74971. * Binds the image processing to the shader.
  74972. * @param effect The effect to bind to
  74973. * @param aspectRatio Define the current aspect ratio of the effect
  74974. */
  74975. bind(effect: Effect, aspectRatio?: number): void;
  74976. /**
  74977. * Clones the current image processing instance.
  74978. * @return The cloned image processing
  74979. */
  74980. clone(): ImageProcessingConfiguration;
  74981. /**
  74982. * Serializes the current image processing instance to a json representation.
  74983. * @return a JSON representation
  74984. */
  74985. serialize(): any;
  74986. /**
  74987. * Parses the image processing from a json representation.
  74988. * @param source the JSON source to parse
  74989. * @return The parsed image processing
  74990. */
  74991. static Parse(source: any): ImageProcessingConfiguration;
  74992. private static _VIGNETTEMODE_MULTIPLY;
  74993. private static _VIGNETTEMODE_OPAQUE;
  74994. /**
  74995. * Used to apply the vignette as a mix with the pixel color.
  74996. */
  74997. static readonly VIGNETTEMODE_MULTIPLY: number;
  74998. /**
  74999. * Used to apply the vignette as a replacement of the pixel color.
  75000. */
  75001. static readonly VIGNETTEMODE_OPAQUE: number;
  75002. }
  75003. }
  75004. declare module BABYLON {
  75005. /** @hidden */
  75006. export var postprocessVertexShader: {
  75007. name: string;
  75008. shader: string;
  75009. };
  75010. }
  75011. declare module BABYLON {
  75012. interface ThinEngine {
  75013. /**
  75014. * Creates a new render target texture
  75015. * @param size defines the size of the texture
  75016. * @param options defines the options used to create the texture
  75017. * @returns a new render target texture stored in an InternalTexture
  75018. */
  75019. createRenderTargetTexture(size: number | {
  75020. width: number;
  75021. height: number;
  75022. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75023. }
  75024. }
  75025. declare module BABYLON {
  75026. /** Defines supported spaces */
  75027. export enum Space {
  75028. /** Local (object) space */
  75029. LOCAL = 0,
  75030. /** World space */
  75031. WORLD = 1,
  75032. /** Bone space */
  75033. BONE = 2
  75034. }
  75035. /** Defines the 3 main axes */
  75036. export class Axis {
  75037. /** X axis */
  75038. static X: Vector3;
  75039. /** Y axis */
  75040. static Y: Vector3;
  75041. /** Z axis */
  75042. static Z: Vector3;
  75043. }
  75044. }
  75045. declare module BABYLON {
  75046. /**
  75047. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75048. * This is the base of the follow, arc rotate cameras and Free camera
  75049. * @see http://doc.babylonjs.com/features/cameras
  75050. */
  75051. export class TargetCamera extends Camera {
  75052. private static _RigCamTransformMatrix;
  75053. private static _TargetTransformMatrix;
  75054. private static _TargetFocalPoint;
  75055. /**
  75056. * Define the current direction the camera is moving to
  75057. */
  75058. cameraDirection: Vector3;
  75059. /**
  75060. * Define the current rotation the camera is rotating to
  75061. */
  75062. cameraRotation: Vector2;
  75063. /**
  75064. * When set, the up vector of the camera will be updated by the rotation of the camera
  75065. */
  75066. updateUpVectorFromRotation: boolean;
  75067. private _tmpQuaternion;
  75068. /**
  75069. * Define the current rotation of the camera
  75070. */
  75071. rotation: Vector3;
  75072. /**
  75073. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75074. */
  75075. rotationQuaternion: Quaternion;
  75076. /**
  75077. * Define the current speed of the camera
  75078. */
  75079. speed: number;
  75080. /**
  75081. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75082. * around all axis.
  75083. */
  75084. noRotationConstraint: boolean;
  75085. /**
  75086. * Define the current target of the camera as an object or a position.
  75087. */
  75088. lockedTarget: any;
  75089. /** @hidden */
  75090. _currentTarget: Vector3;
  75091. /** @hidden */
  75092. _initialFocalDistance: number;
  75093. /** @hidden */
  75094. _viewMatrix: Matrix;
  75095. /** @hidden */
  75096. _camMatrix: Matrix;
  75097. /** @hidden */
  75098. _cameraTransformMatrix: Matrix;
  75099. /** @hidden */
  75100. _cameraRotationMatrix: Matrix;
  75101. /** @hidden */
  75102. _referencePoint: Vector3;
  75103. /** @hidden */
  75104. _transformedReferencePoint: Vector3;
  75105. protected _globalCurrentTarget: Vector3;
  75106. protected _globalCurrentUpVector: Vector3;
  75107. /** @hidden */
  75108. _reset: () => void;
  75109. private _defaultUp;
  75110. /**
  75111. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75112. * This is the base of the follow, arc rotate cameras and Free camera
  75113. * @see http://doc.babylonjs.com/features/cameras
  75114. * @param name Defines the name of the camera in the scene
  75115. * @param position Defines the start position of the camera in the scene
  75116. * @param scene Defines the scene the camera belongs to
  75117. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75118. */
  75119. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75120. /**
  75121. * Gets the position in front of the camera at a given distance.
  75122. * @param distance The distance from the camera we want the position to be
  75123. * @returns the position
  75124. */
  75125. getFrontPosition(distance: number): Vector3;
  75126. /** @hidden */
  75127. _getLockedTargetPosition(): Nullable<Vector3>;
  75128. private _storedPosition;
  75129. private _storedRotation;
  75130. private _storedRotationQuaternion;
  75131. /**
  75132. * Store current camera state of the camera (fov, position, rotation, etc..)
  75133. * @returns the camera
  75134. */
  75135. storeState(): Camera;
  75136. /**
  75137. * Restored camera state. You must call storeState() first
  75138. * @returns whether it was successful or not
  75139. * @hidden
  75140. */
  75141. _restoreStateValues(): boolean;
  75142. /** @hidden */
  75143. _initCache(): void;
  75144. /** @hidden */
  75145. _updateCache(ignoreParentClass?: boolean): void;
  75146. /** @hidden */
  75147. _isSynchronizedViewMatrix(): boolean;
  75148. /** @hidden */
  75149. _computeLocalCameraSpeed(): number;
  75150. /**
  75151. * Defines the target the camera should look at.
  75152. * @param target Defines the new target as a Vector or a mesh
  75153. */
  75154. setTarget(target: Vector3): void;
  75155. /**
  75156. * Return the current target position of the camera. This value is expressed in local space.
  75157. * @returns the target position
  75158. */
  75159. getTarget(): Vector3;
  75160. /** @hidden */
  75161. _decideIfNeedsToMove(): boolean;
  75162. /** @hidden */
  75163. _updatePosition(): void;
  75164. /** @hidden */
  75165. _checkInputs(): void;
  75166. protected _updateCameraRotationMatrix(): void;
  75167. /**
  75168. * 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)
  75169. * @returns the current camera
  75170. */
  75171. private _rotateUpVectorWithCameraRotationMatrix;
  75172. private _cachedRotationZ;
  75173. private _cachedQuaternionRotationZ;
  75174. /** @hidden */
  75175. _getViewMatrix(): Matrix;
  75176. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75177. /**
  75178. * @hidden
  75179. */
  75180. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75181. /**
  75182. * @hidden
  75183. */
  75184. _updateRigCameras(): void;
  75185. private _getRigCamPositionAndTarget;
  75186. /**
  75187. * Gets the current object class name.
  75188. * @return the class name
  75189. */
  75190. getClassName(): string;
  75191. }
  75192. }
  75193. declare module BABYLON {
  75194. /**
  75195. * Gather the list of keyboard event types as constants.
  75196. */
  75197. export class KeyboardEventTypes {
  75198. /**
  75199. * The keydown event is fired when a key becomes active (pressed).
  75200. */
  75201. static readonly KEYDOWN: number;
  75202. /**
  75203. * The keyup event is fired when a key has been released.
  75204. */
  75205. static readonly KEYUP: number;
  75206. }
  75207. /**
  75208. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75209. */
  75210. export class KeyboardInfo {
  75211. /**
  75212. * Defines the type of event (KeyboardEventTypes)
  75213. */
  75214. type: number;
  75215. /**
  75216. * Defines the related dom event
  75217. */
  75218. event: KeyboardEvent;
  75219. /**
  75220. * Instantiates a new keyboard info.
  75221. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75222. * @param type Defines the type of event (KeyboardEventTypes)
  75223. * @param event Defines the related dom event
  75224. */
  75225. constructor(
  75226. /**
  75227. * Defines the type of event (KeyboardEventTypes)
  75228. */
  75229. type: number,
  75230. /**
  75231. * Defines the related dom event
  75232. */
  75233. event: KeyboardEvent);
  75234. }
  75235. /**
  75236. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75237. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75238. */
  75239. export class KeyboardInfoPre extends KeyboardInfo {
  75240. /**
  75241. * Defines the type of event (KeyboardEventTypes)
  75242. */
  75243. type: number;
  75244. /**
  75245. * Defines the related dom event
  75246. */
  75247. event: KeyboardEvent;
  75248. /**
  75249. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75250. */
  75251. skipOnPointerObservable: boolean;
  75252. /**
  75253. * Instantiates a new keyboard pre info.
  75254. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75255. * @param type Defines the type of event (KeyboardEventTypes)
  75256. * @param event Defines the related dom event
  75257. */
  75258. constructor(
  75259. /**
  75260. * Defines the type of event (KeyboardEventTypes)
  75261. */
  75262. type: number,
  75263. /**
  75264. * Defines the related dom event
  75265. */
  75266. event: KeyboardEvent);
  75267. }
  75268. }
  75269. declare module BABYLON {
  75270. /**
  75271. * Manage the keyboard inputs to control the movement of a free camera.
  75272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75273. */
  75274. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75275. /**
  75276. * Defines the camera the input is attached to.
  75277. */
  75278. camera: FreeCamera;
  75279. /**
  75280. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75281. */
  75282. keysUp: number[];
  75283. /**
  75284. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75285. */
  75286. keysDown: number[];
  75287. /**
  75288. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75289. */
  75290. keysLeft: number[];
  75291. /**
  75292. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75293. */
  75294. keysRight: number[];
  75295. private _keys;
  75296. private _onCanvasBlurObserver;
  75297. private _onKeyboardObserver;
  75298. private _engine;
  75299. private _scene;
  75300. /**
  75301. * Attach the input controls to a specific dom element to get the input from.
  75302. * @param element Defines the element the controls should be listened from
  75303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75304. */
  75305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75306. /**
  75307. * Detach the current controls from the specified dom element.
  75308. * @param element Defines the element to stop listening the inputs from
  75309. */
  75310. detachControl(element: Nullable<HTMLElement>): void;
  75311. /**
  75312. * Update the current camera state depending on the inputs that have been used this frame.
  75313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75314. */
  75315. checkInputs(): void;
  75316. /**
  75317. * Gets the class name of the current intput.
  75318. * @returns the class name
  75319. */
  75320. getClassName(): string;
  75321. /** @hidden */
  75322. _onLostFocus(): void;
  75323. /**
  75324. * Get the friendly name associated with the input class.
  75325. * @returns the input friendly name
  75326. */
  75327. getSimpleName(): string;
  75328. }
  75329. }
  75330. declare module BABYLON {
  75331. /**
  75332. * Interface describing all the common properties and methods a shadow light needs to implement.
  75333. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75334. * as well as binding the different shadow properties to the effects.
  75335. */
  75336. export interface IShadowLight extends Light {
  75337. /**
  75338. * The light id in the scene (used in scene.findLighById for instance)
  75339. */
  75340. id: string;
  75341. /**
  75342. * The position the shdow will be casted from.
  75343. */
  75344. position: Vector3;
  75345. /**
  75346. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75347. */
  75348. direction: Vector3;
  75349. /**
  75350. * The transformed position. Position of the light in world space taking parenting in account.
  75351. */
  75352. transformedPosition: Vector3;
  75353. /**
  75354. * The transformed direction. Direction of the light in world space taking parenting in account.
  75355. */
  75356. transformedDirection: Vector3;
  75357. /**
  75358. * The friendly name of the light in the scene.
  75359. */
  75360. name: string;
  75361. /**
  75362. * Defines the shadow projection clipping minimum z value.
  75363. */
  75364. shadowMinZ: number;
  75365. /**
  75366. * Defines the shadow projection clipping maximum z value.
  75367. */
  75368. shadowMaxZ: number;
  75369. /**
  75370. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75371. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75372. */
  75373. computeTransformedInformation(): boolean;
  75374. /**
  75375. * Gets the scene the light belongs to.
  75376. * @returns The scene
  75377. */
  75378. getScene(): Scene;
  75379. /**
  75380. * Callback defining a custom Projection Matrix Builder.
  75381. * This can be used to override the default projection matrix computation.
  75382. */
  75383. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75384. /**
  75385. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75386. * @param matrix The materix to updated with the projection information
  75387. * @param viewMatrix The transform matrix of the light
  75388. * @param renderList The list of mesh to render in the map
  75389. * @returns The current light
  75390. */
  75391. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75392. /**
  75393. * Gets the current depth scale used in ESM.
  75394. * @returns The scale
  75395. */
  75396. getDepthScale(): number;
  75397. /**
  75398. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75399. * @returns true if a cube texture needs to be use
  75400. */
  75401. needCube(): boolean;
  75402. /**
  75403. * Detects if the projection matrix requires to be recomputed this frame.
  75404. * @returns true if it requires to be recomputed otherwise, false.
  75405. */
  75406. needProjectionMatrixCompute(): boolean;
  75407. /**
  75408. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75409. */
  75410. forceProjectionMatrixCompute(): void;
  75411. /**
  75412. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75413. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75414. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75415. */
  75416. getShadowDirection(faceIndex?: number): Vector3;
  75417. /**
  75418. * Gets the minZ used for shadow according to both the scene and the light.
  75419. * @param activeCamera The camera we are returning the min for
  75420. * @returns the depth min z
  75421. */
  75422. getDepthMinZ(activeCamera: Camera): number;
  75423. /**
  75424. * Gets the maxZ used for shadow according to both the scene and the light.
  75425. * @param activeCamera The camera we are returning the max for
  75426. * @returns the depth max z
  75427. */
  75428. getDepthMaxZ(activeCamera: Camera): number;
  75429. }
  75430. /**
  75431. * Base implementation IShadowLight
  75432. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75433. */
  75434. export abstract class ShadowLight extends Light implements IShadowLight {
  75435. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75436. protected _position: Vector3;
  75437. protected _setPosition(value: Vector3): void;
  75438. /**
  75439. * Sets the position the shadow will be casted from. Also use as the light position for both
  75440. * point and spot lights.
  75441. */
  75442. /**
  75443. * Sets the position the shadow will be casted from. Also use as the light position for both
  75444. * point and spot lights.
  75445. */
  75446. position: Vector3;
  75447. protected _direction: Vector3;
  75448. protected _setDirection(value: Vector3): void;
  75449. /**
  75450. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75451. * Also use as the light direction on spot and directional lights.
  75452. */
  75453. /**
  75454. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75455. * Also use as the light direction on spot and directional lights.
  75456. */
  75457. direction: Vector3;
  75458. private _shadowMinZ;
  75459. /**
  75460. * Gets the shadow projection clipping minimum z value.
  75461. */
  75462. /**
  75463. * Sets the shadow projection clipping minimum z value.
  75464. */
  75465. shadowMinZ: number;
  75466. private _shadowMaxZ;
  75467. /**
  75468. * Sets the shadow projection clipping maximum z value.
  75469. */
  75470. /**
  75471. * Gets the shadow projection clipping maximum z value.
  75472. */
  75473. shadowMaxZ: number;
  75474. /**
  75475. * Callback defining a custom Projection Matrix Builder.
  75476. * This can be used to override the default projection matrix computation.
  75477. */
  75478. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75479. /**
  75480. * The transformed position. Position of the light in world space taking parenting in account.
  75481. */
  75482. transformedPosition: Vector3;
  75483. /**
  75484. * The transformed direction. Direction of the light in world space taking parenting in account.
  75485. */
  75486. transformedDirection: Vector3;
  75487. private _needProjectionMatrixCompute;
  75488. /**
  75489. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75490. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75491. */
  75492. computeTransformedInformation(): boolean;
  75493. /**
  75494. * Return the depth scale used for the shadow map.
  75495. * @returns the depth scale.
  75496. */
  75497. getDepthScale(): number;
  75498. /**
  75499. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75500. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75501. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75502. */
  75503. getShadowDirection(faceIndex?: number): Vector3;
  75504. /**
  75505. * Returns the ShadowLight absolute position in the World.
  75506. * @returns the position vector in world space
  75507. */
  75508. getAbsolutePosition(): Vector3;
  75509. /**
  75510. * Sets the ShadowLight direction toward the passed target.
  75511. * @param target The point to target in local space
  75512. * @returns the updated ShadowLight direction
  75513. */
  75514. setDirectionToTarget(target: Vector3): Vector3;
  75515. /**
  75516. * Returns the light rotation in euler definition.
  75517. * @returns the x y z rotation in local space.
  75518. */
  75519. getRotation(): Vector3;
  75520. /**
  75521. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75522. * @returns true if a cube texture needs to be use
  75523. */
  75524. needCube(): boolean;
  75525. /**
  75526. * Detects if the projection matrix requires to be recomputed this frame.
  75527. * @returns true if it requires to be recomputed otherwise, false.
  75528. */
  75529. needProjectionMatrixCompute(): boolean;
  75530. /**
  75531. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75532. */
  75533. forceProjectionMatrixCompute(): void;
  75534. /** @hidden */
  75535. _initCache(): void;
  75536. /** @hidden */
  75537. _isSynchronized(): boolean;
  75538. /**
  75539. * Computes the world matrix of the node
  75540. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75541. * @returns the world matrix
  75542. */
  75543. computeWorldMatrix(force?: boolean): Matrix;
  75544. /**
  75545. * Gets the minZ used for shadow according to both the scene and the light.
  75546. * @param activeCamera The camera we are returning the min for
  75547. * @returns the depth min z
  75548. */
  75549. getDepthMinZ(activeCamera: Camera): number;
  75550. /**
  75551. * Gets the maxZ used for shadow according to both the scene and the light.
  75552. * @param activeCamera The camera we are returning the max for
  75553. * @returns the depth max z
  75554. */
  75555. getDepthMaxZ(activeCamera: Camera): number;
  75556. /**
  75557. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75558. * @param matrix The materix to updated with the projection information
  75559. * @param viewMatrix The transform matrix of the light
  75560. * @param renderList The list of mesh to render in the map
  75561. * @returns The current light
  75562. */
  75563. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75564. }
  75565. }
  75566. declare module BABYLON {
  75567. /**
  75568. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75569. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75570. */
  75571. export class EffectFallbacks implements IEffectFallbacks {
  75572. private _defines;
  75573. private _currentRank;
  75574. private _maxRank;
  75575. private _mesh;
  75576. /**
  75577. * Removes the fallback from the bound mesh.
  75578. */
  75579. unBindMesh(): void;
  75580. /**
  75581. * Adds a fallback on the specified property.
  75582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75583. * @param define The name of the define in the shader
  75584. */
  75585. addFallback(rank: number, define: string): void;
  75586. /**
  75587. * Sets the mesh to use CPU skinning when needing to fallback.
  75588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75589. * @param mesh The mesh to use the fallbacks.
  75590. */
  75591. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75592. /**
  75593. * Checks to see if more fallbacks are still availible.
  75594. */
  75595. readonly hasMoreFallbacks: boolean;
  75596. /**
  75597. * Removes the defines that should be removed when falling back.
  75598. * @param currentDefines defines the current define statements for the shader.
  75599. * @param effect defines the current effect we try to compile
  75600. * @returns The resulting defines with defines of the current rank removed.
  75601. */
  75602. reduce(currentDefines: string, effect: Effect): string;
  75603. }
  75604. }
  75605. declare module BABYLON {
  75606. /**
  75607. * "Static Class" containing the most commonly used helper while dealing with material for
  75608. * rendering purpose.
  75609. *
  75610. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75611. *
  75612. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75613. */
  75614. export class MaterialHelper {
  75615. /**
  75616. * Bind the current view position to an effect.
  75617. * @param effect The effect to be bound
  75618. * @param scene The scene the eyes position is used from
  75619. */
  75620. static BindEyePosition(effect: Effect, scene: Scene): void;
  75621. /**
  75622. * Helps preparing the defines values about the UVs in used in the effect.
  75623. * UVs are shared as much as we can accross channels in the shaders.
  75624. * @param texture The texture we are preparing the UVs for
  75625. * @param defines The defines to update
  75626. * @param key The channel key "diffuse", "specular"... used in the shader
  75627. */
  75628. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75629. /**
  75630. * Binds a texture matrix value to its corrsponding uniform
  75631. * @param texture The texture to bind the matrix for
  75632. * @param uniformBuffer The uniform buffer receivin the data
  75633. * @param key The channel key "diffuse", "specular"... used in the shader
  75634. */
  75635. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75636. /**
  75637. * Gets the current status of the fog (should it be enabled?)
  75638. * @param mesh defines the mesh to evaluate for fog support
  75639. * @param scene defines the hosting scene
  75640. * @returns true if fog must be enabled
  75641. */
  75642. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75643. /**
  75644. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75645. * @param mesh defines the current mesh
  75646. * @param scene defines the current scene
  75647. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75648. * @param pointsCloud defines if point cloud rendering has to be turned on
  75649. * @param fogEnabled defines if fog has to be turned on
  75650. * @param alphaTest defines if alpha testing has to be turned on
  75651. * @param defines defines the current list of defines
  75652. */
  75653. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75654. /**
  75655. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75656. * @param scene defines the current scene
  75657. * @param engine defines the current engine
  75658. * @param defines specifies the list of active defines
  75659. * @param useInstances defines if instances have to be turned on
  75660. * @param useClipPlane defines if clip plane have to be turned on
  75661. */
  75662. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75663. /**
  75664. * Prepares the defines for bones
  75665. * @param mesh The mesh containing the geometry data we will draw
  75666. * @param defines The defines to update
  75667. */
  75668. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75669. /**
  75670. * Prepares the defines for morph targets
  75671. * @param mesh The mesh containing the geometry data we will draw
  75672. * @param defines The defines to update
  75673. */
  75674. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75675. /**
  75676. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75677. * @param mesh The mesh containing the geometry data we will draw
  75678. * @param defines The defines to update
  75679. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75680. * @param useBones Precise whether bones should be used or not (override mesh info)
  75681. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75682. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75683. * @returns false if defines are considered not dirty and have not been checked
  75684. */
  75685. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75686. /**
  75687. * Prepares the defines related to multiview
  75688. * @param scene The scene we are intending to draw
  75689. * @param defines The defines to update
  75690. */
  75691. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75692. /**
  75693. * Prepares the defines related to the light information passed in parameter
  75694. * @param scene The scene we are intending to draw
  75695. * @param mesh The mesh the effect is compiling for
  75696. * @param light The light the effect is compiling for
  75697. * @param lightIndex The index of the light
  75698. * @param defines The defines to update
  75699. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75700. * @param state Defines the current state regarding what is needed (normals, etc...)
  75701. */
  75702. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75703. needNormals: boolean;
  75704. needRebuild: boolean;
  75705. shadowEnabled: boolean;
  75706. specularEnabled: boolean;
  75707. lightmapMode: boolean;
  75708. }): void;
  75709. /**
  75710. * Prepares the defines related to the light information passed in parameter
  75711. * @param scene The scene we are intending to draw
  75712. * @param mesh The mesh the effect is compiling for
  75713. * @param defines The defines to update
  75714. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75715. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75716. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75717. * @returns true if normals will be required for the rest of the effect
  75718. */
  75719. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75720. /**
  75721. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75722. * @param lightIndex defines the light index
  75723. * @param uniformsList The uniform list
  75724. * @param samplersList The sampler list
  75725. * @param projectedLightTexture defines if projected texture must be used
  75726. * @param uniformBuffersList defines an optional list of uniform buffers
  75727. */
  75728. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75729. /**
  75730. * Prepares the uniforms and samplers list to be used in the effect
  75731. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75732. * @param samplersList The sampler list
  75733. * @param defines The defines helping in the list generation
  75734. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75735. */
  75736. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75737. /**
  75738. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75739. * @param defines The defines to update while falling back
  75740. * @param fallbacks The authorized effect fallbacks
  75741. * @param maxSimultaneousLights The maximum number of lights allowed
  75742. * @param rank the current rank of the Effect
  75743. * @returns The newly affected rank
  75744. */
  75745. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75746. private static _TmpMorphInfluencers;
  75747. /**
  75748. * Prepares the list of attributes required for morph targets according to the effect defines.
  75749. * @param attribs The current list of supported attribs
  75750. * @param mesh The mesh to prepare the morph targets attributes for
  75751. * @param influencers The number of influencers
  75752. */
  75753. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75754. /**
  75755. * Prepares the list of attributes required for morph targets according to the effect defines.
  75756. * @param attribs The current list of supported attribs
  75757. * @param mesh The mesh to prepare the morph targets attributes for
  75758. * @param defines The current Defines of the effect
  75759. */
  75760. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75761. /**
  75762. * Prepares the list of attributes required for bones according to the effect defines.
  75763. * @param attribs The current list of supported attribs
  75764. * @param mesh The mesh to prepare the bones attributes for
  75765. * @param defines The current Defines of the effect
  75766. * @param fallbacks The current efffect fallback strategy
  75767. */
  75768. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75769. /**
  75770. * Check and prepare the list of attributes required for instances according to the effect defines.
  75771. * @param attribs The current list of supported attribs
  75772. * @param defines The current MaterialDefines of the effect
  75773. */
  75774. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75775. /**
  75776. * Add the list of attributes required for instances to the attribs array.
  75777. * @param attribs The current list of supported attribs
  75778. */
  75779. static PushAttributesForInstances(attribs: string[]): void;
  75780. /**
  75781. * Binds the light shadow information to the effect for the given mesh.
  75782. * @param light The light containing the generator
  75783. * @param scene The scene the lights belongs to
  75784. * @param mesh The mesh we are binding the information to render
  75785. * @param lightIndex The light index in the effect used to render the mesh
  75786. * @param effect The effect we are binding the data to
  75787. */
  75788. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75789. /**
  75790. * Binds the light information to the effect.
  75791. * @param light The light containing the generator
  75792. * @param effect The effect we are binding the data to
  75793. * @param lightIndex The light index in the effect used to render
  75794. */
  75795. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75796. /**
  75797. * Binds the lights information from the scene to the effect for the given mesh.
  75798. * @param light Light to bind
  75799. * @param lightIndex Light index
  75800. * @param scene The scene where the light belongs to
  75801. * @param mesh The mesh we are binding the information to render
  75802. * @param effect The effect we are binding the data to
  75803. * @param useSpecular Defines if specular is supported
  75804. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75805. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75806. */
  75807. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75808. /**
  75809. * Binds the lights information from the scene to the effect for the given mesh.
  75810. * @param scene The scene the lights belongs to
  75811. * @param mesh The mesh we are binding the information to render
  75812. * @param effect The effect we are binding the data to
  75813. * @param defines The generated defines for the effect
  75814. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75815. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75816. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75817. */
  75818. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75819. private static _tempFogColor;
  75820. /**
  75821. * Binds the fog information from the scene to the effect for the given mesh.
  75822. * @param scene The scene the lights belongs to
  75823. * @param mesh The mesh we are binding the information to render
  75824. * @param effect The effect we are binding the data to
  75825. * @param linearSpace Defines if the fog effect is applied in linear space
  75826. */
  75827. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75828. /**
  75829. * Binds the bones information from the mesh to the effect.
  75830. * @param mesh The mesh we are binding the information to render
  75831. * @param effect The effect we are binding the data to
  75832. */
  75833. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75834. /**
  75835. * Binds the morph targets information from the mesh to the effect.
  75836. * @param abstractMesh The mesh we are binding the information to render
  75837. * @param effect The effect we are binding the data to
  75838. */
  75839. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75840. /**
  75841. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75842. * @param defines The generated defines used in the effect
  75843. * @param effect The effect we are binding the data to
  75844. * @param scene The scene we are willing to render with logarithmic scale for
  75845. */
  75846. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75847. /**
  75848. * Binds the clip plane information from the scene to the effect.
  75849. * @param scene The scene the clip plane information are extracted from
  75850. * @param effect The effect we are binding the data to
  75851. */
  75852. static BindClipPlane(effect: Effect, scene: Scene): void;
  75853. }
  75854. }
  75855. declare module BABYLON {
  75856. /** @hidden */
  75857. export var packingFunctions: {
  75858. name: string;
  75859. shader: string;
  75860. };
  75861. }
  75862. declare module BABYLON {
  75863. /** @hidden */
  75864. export var shadowMapPixelShader: {
  75865. name: string;
  75866. shader: string;
  75867. };
  75868. }
  75869. declare module BABYLON {
  75870. /** @hidden */
  75871. export var bonesDeclaration: {
  75872. name: string;
  75873. shader: string;
  75874. };
  75875. }
  75876. declare module BABYLON {
  75877. /** @hidden */
  75878. export var morphTargetsVertexGlobalDeclaration: {
  75879. name: string;
  75880. shader: string;
  75881. };
  75882. }
  75883. declare module BABYLON {
  75884. /** @hidden */
  75885. export var morphTargetsVertexDeclaration: {
  75886. name: string;
  75887. shader: string;
  75888. };
  75889. }
  75890. declare module BABYLON {
  75891. /** @hidden */
  75892. export var instancesDeclaration: {
  75893. name: string;
  75894. shader: string;
  75895. };
  75896. }
  75897. declare module BABYLON {
  75898. /** @hidden */
  75899. export var helperFunctions: {
  75900. name: string;
  75901. shader: string;
  75902. };
  75903. }
  75904. declare module BABYLON {
  75905. /** @hidden */
  75906. export var morphTargetsVertex: {
  75907. name: string;
  75908. shader: string;
  75909. };
  75910. }
  75911. declare module BABYLON {
  75912. /** @hidden */
  75913. export var instancesVertex: {
  75914. name: string;
  75915. shader: string;
  75916. };
  75917. }
  75918. declare module BABYLON {
  75919. /** @hidden */
  75920. export var bonesVertex: {
  75921. name: string;
  75922. shader: string;
  75923. };
  75924. }
  75925. declare module BABYLON {
  75926. /** @hidden */
  75927. export var shadowMapVertexShader: {
  75928. name: string;
  75929. shader: string;
  75930. };
  75931. }
  75932. declare module BABYLON {
  75933. /** @hidden */
  75934. export var depthBoxBlurPixelShader: {
  75935. name: string;
  75936. shader: string;
  75937. };
  75938. }
  75939. declare module BABYLON {
  75940. /**
  75941. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75942. */
  75943. export interface ICustomShaderOptions {
  75944. /**
  75945. * Gets or sets the custom shader name to use
  75946. */
  75947. shaderName: string;
  75948. /**
  75949. * The list of attribute names used in the shader
  75950. */
  75951. attributes?: string[];
  75952. /**
  75953. * The list of unifrom names used in the shader
  75954. */
  75955. uniforms?: string[];
  75956. /**
  75957. * The list of sampler names used in the shader
  75958. */
  75959. samplers?: string[];
  75960. /**
  75961. * The list of defines used in the shader
  75962. */
  75963. defines?: string[];
  75964. }
  75965. /**
  75966. * Interface to implement to create a shadow generator compatible with BJS.
  75967. */
  75968. export interface IShadowGenerator {
  75969. /**
  75970. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75971. * @returns The render target texture if present otherwise, null
  75972. */
  75973. getShadowMap(): Nullable<RenderTargetTexture>;
  75974. /**
  75975. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75976. * @returns The render target texture if the shadow map is present otherwise, null
  75977. */
  75978. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75979. /**
  75980. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75981. * @param subMesh The submesh we want to render in the shadow map
  75982. * @param useInstances Defines wether will draw in the map using instances
  75983. * @returns true if ready otherwise, false
  75984. */
  75985. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75986. /**
  75987. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75988. * @param defines Defines of the material we want to update
  75989. * @param lightIndex Index of the light in the enabled light list of the material
  75990. */
  75991. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75992. /**
  75993. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75994. * defined in the generator but impacting the effect).
  75995. * It implies the unifroms available on the materials are the standard BJS ones.
  75996. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75997. * @param effect The effect we are binfing the information for
  75998. */
  75999. bindShadowLight(lightIndex: string, effect: Effect): void;
  76000. /**
  76001. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76002. * (eq to shadow prjection matrix * light transform matrix)
  76003. * @returns The transform matrix used to create the shadow map
  76004. */
  76005. getTransformMatrix(): Matrix;
  76006. /**
  76007. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76008. * Cube and 2D textures for instance.
  76009. */
  76010. recreateShadowMap(): void;
  76011. /**
  76012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76013. * @param onCompiled Callback triggered at the and of the effects compilation
  76014. * @param options Sets of optional options forcing the compilation with different modes
  76015. */
  76016. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76017. useInstances: boolean;
  76018. }>): void;
  76019. /**
  76020. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76021. * @param options Sets of optional options forcing the compilation with different modes
  76022. * @returns A promise that resolves when the compilation completes
  76023. */
  76024. forceCompilationAsync(options?: Partial<{
  76025. useInstances: boolean;
  76026. }>): Promise<void>;
  76027. /**
  76028. * Serializes the shadow generator setup to a json object.
  76029. * @returns The serialized JSON object
  76030. */
  76031. serialize(): any;
  76032. /**
  76033. * Disposes the Shadow map and related Textures and effects.
  76034. */
  76035. dispose(): void;
  76036. }
  76037. /**
  76038. * Default implementation IShadowGenerator.
  76039. * This is the main object responsible of generating shadows in the framework.
  76040. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76041. */
  76042. export class ShadowGenerator implements IShadowGenerator {
  76043. /**
  76044. * Shadow generator mode None: no filtering applied.
  76045. */
  76046. static readonly FILTER_NONE: number;
  76047. /**
  76048. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76049. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76050. */
  76051. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76052. /**
  76053. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76054. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76055. */
  76056. static readonly FILTER_POISSONSAMPLING: number;
  76057. /**
  76058. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76059. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76060. */
  76061. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76062. /**
  76063. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76064. * edge artifacts on steep falloff.
  76065. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76066. */
  76067. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76068. /**
  76069. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76070. * edge artifacts on steep falloff.
  76071. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76072. */
  76073. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76074. /**
  76075. * Shadow generator mode PCF: Percentage Closer Filtering
  76076. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76077. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76078. */
  76079. static readonly FILTER_PCF: number;
  76080. /**
  76081. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76082. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76083. * Contact Hardening
  76084. */
  76085. static readonly FILTER_PCSS: number;
  76086. /**
  76087. * Reserved for PCF and PCSS
  76088. * Highest Quality.
  76089. *
  76090. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76091. *
  76092. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76093. */
  76094. static readonly QUALITY_HIGH: number;
  76095. /**
  76096. * Reserved for PCF and PCSS
  76097. * Good tradeoff for quality/perf cross devices
  76098. *
  76099. * Execute PCF on a 3*3 kernel.
  76100. *
  76101. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76102. */
  76103. static readonly QUALITY_MEDIUM: number;
  76104. /**
  76105. * Reserved for PCF and PCSS
  76106. * The lowest quality but the fastest.
  76107. *
  76108. * Execute PCF on a 1*1 kernel.
  76109. *
  76110. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76111. */
  76112. static readonly QUALITY_LOW: number;
  76113. /** Gets or sets the custom shader name to use */
  76114. customShaderOptions: ICustomShaderOptions;
  76115. /**
  76116. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76117. */
  76118. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76119. /**
  76120. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76121. */
  76122. onAfterShadowMapRenderObservable: Observable<Effect>;
  76123. /**
  76124. * Observable triggered before a mesh is rendered in the shadow map.
  76125. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76126. */
  76127. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76128. /**
  76129. * Observable triggered after a mesh is rendered in the shadow map.
  76130. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76131. */
  76132. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76133. private _bias;
  76134. /**
  76135. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76136. */
  76137. /**
  76138. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76139. */
  76140. bias: number;
  76141. private _normalBias;
  76142. /**
  76143. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76144. */
  76145. /**
  76146. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76147. */
  76148. normalBias: number;
  76149. private _blurBoxOffset;
  76150. /**
  76151. * Gets the blur box offset: offset applied during the blur pass.
  76152. * Only useful if useKernelBlur = false
  76153. */
  76154. /**
  76155. * Sets the blur box offset: offset applied during the blur pass.
  76156. * Only useful if useKernelBlur = false
  76157. */
  76158. blurBoxOffset: number;
  76159. private _blurScale;
  76160. /**
  76161. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76162. * 2 means half of the size.
  76163. */
  76164. /**
  76165. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76166. * 2 means half of the size.
  76167. */
  76168. blurScale: number;
  76169. private _blurKernel;
  76170. /**
  76171. * Gets the blur kernel: kernel size of the blur pass.
  76172. * Only useful if useKernelBlur = true
  76173. */
  76174. /**
  76175. * Sets the blur kernel: kernel size of the blur pass.
  76176. * Only useful if useKernelBlur = true
  76177. */
  76178. blurKernel: number;
  76179. private _useKernelBlur;
  76180. /**
  76181. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76182. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76183. */
  76184. /**
  76185. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76186. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76187. */
  76188. useKernelBlur: boolean;
  76189. private _depthScale;
  76190. /**
  76191. * Gets the depth scale used in ESM mode.
  76192. */
  76193. /**
  76194. * Sets the depth scale used in ESM mode.
  76195. * This can override the scale stored on the light.
  76196. */
  76197. depthScale: number;
  76198. private _filter;
  76199. /**
  76200. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76201. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76202. */
  76203. /**
  76204. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76205. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76206. */
  76207. filter: number;
  76208. /**
  76209. * Gets if the current filter is set to Poisson Sampling.
  76210. */
  76211. /**
  76212. * Sets the current filter to Poisson Sampling.
  76213. */
  76214. usePoissonSampling: boolean;
  76215. /**
  76216. * Gets if the current filter is set to ESM.
  76217. */
  76218. /**
  76219. * Sets the current filter is to ESM.
  76220. */
  76221. useExponentialShadowMap: boolean;
  76222. /**
  76223. * Gets if the current filter is set to filtered ESM.
  76224. */
  76225. /**
  76226. * Gets if the current filter is set to filtered ESM.
  76227. */
  76228. useBlurExponentialShadowMap: boolean;
  76229. /**
  76230. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76231. * exponential to prevent steep falloff artifacts).
  76232. */
  76233. /**
  76234. * Sets the current filter to "close ESM" (using the inverse of the
  76235. * exponential to prevent steep falloff artifacts).
  76236. */
  76237. useCloseExponentialShadowMap: boolean;
  76238. /**
  76239. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76240. * exponential to prevent steep falloff artifacts).
  76241. */
  76242. /**
  76243. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76244. * exponential to prevent steep falloff artifacts).
  76245. */
  76246. useBlurCloseExponentialShadowMap: boolean;
  76247. /**
  76248. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76249. */
  76250. /**
  76251. * Sets the current filter to "PCF" (percentage closer filtering).
  76252. */
  76253. usePercentageCloserFiltering: boolean;
  76254. private _filteringQuality;
  76255. /**
  76256. * Gets the PCF or PCSS Quality.
  76257. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76258. */
  76259. /**
  76260. * Sets the PCF or PCSS Quality.
  76261. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76262. */
  76263. filteringQuality: number;
  76264. /**
  76265. * Gets if the current filter is set to "PCSS" (contact hardening).
  76266. */
  76267. /**
  76268. * Sets the current filter to "PCSS" (contact hardening).
  76269. */
  76270. useContactHardeningShadow: boolean;
  76271. private _contactHardeningLightSizeUVRatio;
  76272. /**
  76273. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76274. * Using a ratio helps keeping shape stability independently of the map size.
  76275. *
  76276. * It does not account for the light projection as it was having too much
  76277. * instability during the light setup or during light position changes.
  76278. *
  76279. * Only valid if useContactHardeningShadow is true.
  76280. */
  76281. /**
  76282. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76283. * Using a ratio helps keeping shape stability independently of the map size.
  76284. *
  76285. * It does not account for the light projection as it was having too much
  76286. * instability during the light setup or during light position changes.
  76287. *
  76288. * Only valid if useContactHardeningShadow is true.
  76289. */
  76290. contactHardeningLightSizeUVRatio: number;
  76291. private _darkness;
  76292. /** Gets or sets the actual darkness of a shadow */
  76293. darkness: number;
  76294. /**
  76295. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76296. * 0 means strongest and 1 would means no shadow.
  76297. * @returns the darkness.
  76298. */
  76299. getDarkness(): number;
  76300. /**
  76301. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76302. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76303. * @returns the shadow generator allowing fluent coding.
  76304. */
  76305. setDarkness(darkness: number): ShadowGenerator;
  76306. private _transparencyShadow;
  76307. /** Gets or sets the ability to have transparent shadow */
  76308. transparencyShadow: boolean;
  76309. /**
  76310. * Sets the ability to have transparent shadow (boolean).
  76311. * @param transparent True if transparent else False
  76312. * @returns the shadow generator allowing fluent coding
  76313. */
  76314. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76315. private _shadowMap;
  76316. private _shadowMap2;
  76317. /**
  76318. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76319. * @returns The render target texture if present otherwise, null
  76320. */
  76321. getShadowMap(): Nullable<RenderTargetTexture>;
  76322. /**
  76323. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76324. * @returns The render target texture if the shadow map is present otherwise, null
  76325. */
  76326. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76327. /**
  76328. * Gets the class name of that object
  76329. * @returns "ShadowGenerator"
  76330. */
  76331. getClassName(): string;
  76332. /**
  76333. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76334. * @param mesh Mesh to add
  76335. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76336. * @returns the Shadow Generator itself
  76337. */
  76338. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76339. /**
  76340. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76341. * @param mesh Mesh to remove
  76342. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76343. * @returns the Shadow Generator itself
  76344. */
  76345. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76346. /**
  76347. * Controls the extent to which the shadows fade out at the edge of the frustum
  76348. * Used only by directionals and spots
  76349. */
  76350. frustumEdgeFalloff: number;
  76351. private _light;
  76352. /**
  76353. * Returns the associated light object.
  76354. * @returns the light generating the shadow
  76355. */
  76356. getLight(): IShadowLight;
  76357. /**
  76358. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76359. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76360. * It might on the other hand introduce peter panning.
  76361. */
  76362. forceBackFacesOnly: boolean;
  76363. private _scene;
  76364. private _lightDirection;
  76365. private _effect;
  76366. private _viewMatrix;
  76367. private _projectionMatrix;
  76368. private _transformMatrix;
  76369. private _cachedPosition;
  76370. private _cachedDirection;
  76371. private _cachedDefines;
  76372. private _currentRenderID;
  76373. private _boxBlurPostprocess;
  76374. private _kernelBlurXPostprocess;
  76375. private _kernelBlurYPostprocess;
  76376. private _blurPostProcesses;
  76377. private _mapSize;
  76378. private _currentFaceIndex;
  76379. private _currentFaceIndexCache;
  76380. private _textureType;
  76381. private _defaultTextureMatrix;
  76382. private _storedUniqueId;
  76383. /** @hidden */
  76384. static _SceneComponentInitialization: (scene: Scene) => void;
  76385. /**
  76386. * Creates a ShadowGenerator object.
  76387. * A ShadowGenerator is the required tool to use the shadows.
  76388. * Each light casting shadows needs to use its own ShadowGenerator.
  76389. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76390. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76391. * @param light The light object generating the shadows.
  76392. * @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.
  76393. */
  76394. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76395. private _initializeGenerator;
  76396. private _initializeShadowMap;
  76397. private _initializeBlurRTTAndPostProcesses;
  76398. private _renderForShadowMap;
  76399. private _renderSubMeshForShadowMap;
  76400. private _applyFilterValues;
  76401. /**
  76402. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76403. * @param onCompiled Callback triggered at the and of the effects compilation
  76404. * @param options Sets of optional options forcing the compilation with different modes
  76405. */
  76406. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76407. useInstances: boolean;
  76408. }>): void;
  76409. /**
  76410. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76411. * @param options Sets of optional options forcing the compilation with different modes
  76412. * @returns A promise that resolves when the compilation completes
  76413. */
  76414. forceCompilationAsync(options?: Partial<{
  76415. useInstances: boolean;
  76416. }>): Promise<void>;
  76417. /**
  76418. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76419. * @param subMesh The submesh we want to render in the shadow map
  76420. * @param useInstances Defines wether will draw in the map using instances
  76421. * @returns true if ready otherwise, false
  76422. */
  76423. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76424. /**
  76425. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76426. * @param defines Defines of the material we want to update
  76427. * @param lightIndex Index of the light in the enabled light list of the material
  76428. */
  76429. prepareDefines(defines: any, lightIndex: number): void;
  76430. /**
  76431. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76432. * defined in the generator but impacting the effect).
  76433. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76434. * @param effect The effect we are binfing the information for
  76435. */
  76436. bindShadowLight(lightIndex: string, effect: Effect): void;
  76437. /**
  76438. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76439. * (eq to shadow prjection matrix * light transform matrix)
  76440. * @returns The transform matrix used to create the shadow map
  76441. */
  76442. getTransformMatrix(): Matrix;
  76443. /**
  76444. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76445. * Cube and 2D textures for instance.
  76446. */
  76447. recreateShadowMap(): void;
  76448. private _disposeBlurPostProcesses;
  76449. private _disposeRTTandPostProcesses;
  76450. /**
  76451. * Disposes the ShadowGenerator.
  76452. * Returns nothing.
  76453. */
  76454. dispose(): void;
  76455. /**
  76456. * Serializes the shadow generator setup to a json object.
  76457. * @returns The serialized JSON object
  76458. */
  76459. serialize(): any;
  76460. /**
  76461. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76462. * @param parsedShadowGenerator The JSON object to parse
  76463. * @param scene The scene to create the shadow map for
  76464. * @returns The parsed shadow generator
  76465. */
  76466. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76467. }
  76468. }
  76469. declare module BABYLON {
  76470. /**
  76471. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76472. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76473. * 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.
  76474. */
  76475. export abstract class Light extends Node {
  76476. /**
  76477. * Falloff Default: light is falling off following the material specification:
  76478. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76479. */
  76480. static readonly FALLOFF_DEFAULT: number;
  76481. /**
  76482. * Falloff Physical: light is falling off following the inverse squared distance law.
  76483. */
  76484. static readonly FALLOFF_PHYSICAL: number;
  76485. /**
  76486. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76487. * to enhance interoperability with other engines.
  76488. */
  76489. static readonly FALLOFF_GLTF: number;
  76490. /**
  76491. * Falloff Standard: light is falling off like in the standard material
  76492. * to enhance interoperability with other materials.
  76493. */
  76494. static readonly FALLOFF_STANDARD: number;
  76495. /**
  76496. * If every light affecting the material is in this lightmapMode,
  76497. * material.lightmapTexture adds or multiplies
  76498. * (depends on material.useLightmapAsShadowmap)
  76499. * after every other light calculations.
  76500. */
  76501. static readonly LIGHTMAP_DEFAULT: number;
  76502. /**
  76503. * material.lightmapTexture as only diffuse lighting from this light
  76504. * adds only specular lighting from this light
  76505. * adds dynamic shadows
  76506. */
  76507. static readonly LIGHTMAP_SPECULAR: number;
  76508. /**
  76509. * material.lightmapTexture as only lighting
  76510. * no light calculation from this light
  76511. * only adds dynamic shadows from this light
  76512. */
  76513. static readonly LIGHTMAP_SHADOWSONLY: number;
  76514. /**
  76515. * Each light type uses the default quantity according to its type:
  76516. * point/spot lights use luminous intensity
  76517. * directional lights use illuminance
  76518. */
  76519. static readonly INTENSITYMODE_AUTOMATIC: number;
  76520. /**
  76521. * lumen (lm)
  76522. */
  76523. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76524. /**
  76525. * candela (lm/sr)
  76526. */
  76527. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76528. /**
  76529. * lux (lm/m^2)
  76530. */
  76531. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76532. /**
  76533. * nit (cd/m^2)
  76534. */
  76535. static readonly INTENSITYMODE_LUMINANCE: number;
  76536. /**
  76537. * Light type const id of the point light.
  76538. */
  76539. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76540. /**
  76541. * Light type const id of the directional light.
  76542. */
  76543. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76544. /**
  76545. * Light type const id of the spot light.
  76546. */
  76547. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76548. /**
  76549. * Light type const id of the hemispheric light.
  76550. */
  76551. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76552. /**
  76553. * Diffuse gives the basic color to an object.
  76554. */
  76555. diffuse: Color3;
  76556. /**
  76557. * Specular produces a highlight color on an object.
  76558. * Note: This is note affecting PBR materials.
  76559. */
  76560. specular: Color3;
  76561. /**
  76562. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76563. * falling off base on range or angle.
  76564. * This can be set to any values in Light.FALLOFF_x.
  76565. *
  76566. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76567. * other types of materials.
  76568. */
  76569. falloffType: number;
  76570. /**
  76571. * Strength of the light.
  76572. * Note: By default it is define in the framework own unit.
  76573. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76574. */
  76575. intensity: number;
  76576. private _range;
  76577. protected _inverseSquaredRange: number;
  76578. /**
  76579. * Defines how far from the source the light is impacting in scene units.
  76580. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76581. */
  76582. /**
  76583. * Defines how far from the source the light is impacting in scene units.
  76584. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76585. */
  76586. range: number;
  76587. /**
  76588. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76589. * of light.
  76590. */
  76591. private _photometricScale;
  76592. private _intensityMode;
  76593. /**
  76594. * Gets the photometric scale used to interpret the intensity.
  76595. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76596. */
  76597. /**
  76598. * Sets the photometric scale used to interpret the intensity.
  76599. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76600. */
  76601. intensityMode: number;
  76602. private _radius;
  76603. /**
  76604. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76605. */
  76606. /**
  76607. * sets the light radius used by PBR Materials to simulate soft area lights.
  76608. */
  76609. radius: number;
  76610. private _renderPriority;
  76611. /**
  76612. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76613. * exceeding the number allowed of the materials.
  76614. */
  76615. renderPriority: number;
  76616. private _shadowEnabled;
  76617. /**
  76618. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76619. * the current shadow generator.
  76620. */
  76621. /**
  76622. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76623. * the current shadow generator.
  76624. */
  76625. shadowEnabled: boolean;
  76626. private _includedOnlyMeshes;
  76627. /**
  76628. * Gets the only meshes impacted by this light.
  76629. */
  76630. /**
  76631. * Sets the only meshes impacted by this light.
  76632. */
  76633. includedOnlyMeshes: AbstractMesh[];
  76634. private _excludedMeshes;
  76635. /**
  76636. * Gets the meshes not impacted by this light.
  76637. */
  76638. /**
  76639. * Sets the meshes not impacted by this light.
  76640. */
  76641. excludedMeshes: AbstractMesh[];
  76642. private _excludeWithLayerMask;
  76643. /**
  76644. * Gets the layer id use to find what meshes are not impacted by the light.
  76645. * Inactive if 0
  76646. */
  76647. /**
  76648. * Sets the layer id use to find what meshes are not impacted by the light.
  76649. * Inactive if 0
  76650. */
  76651. excludeWithLayerMask: number;
  76652. private _includeOnlyWithLayerMask;
  76653. /**
  76654. * Gets the layer id use to find what meshes are impacted by the light.
  76655. * Inactive if 0
  76656. */
  76657. /**
  76658. * Sets the layer id use to find what meshes are impacted by the light.
  76659. * Inactive if 0
  76660. */
  76661. includeOnlyWithLayerMask: number;
  76662. private _lightmapMode;
  76663. /**
  76664. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76665. */
  76666. /**
  76667. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76668. */
  76669. lightmapMode: number;
  76670. /**
  76671. * Shadow generator associted to the light.
  76672. * @hidden Internal use only.
  76673. */
  76674. _shadowGenerator: Nullable<IShadowGenerator>;
  76675. /**
  76676. * @hidden Internal use only.
  76677. */
  76678. _excludedMeshesIds: string[];
  76679. /**
  76680. * @hidden Internal use only.
  76681. */
  76682. _includedOnlyMeshesIds: string[];
  76683. /**
  76684. * The current light unifom buffer.
  76685. * @hidden Internal use only.
  76686. */
  76687. _uniformBuffer: UniformBuffer;
  76688. /**
  76689. * Creates a Light object in the scene.
  76690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76691. * @param name The firendly name of the light
  76692. * @param scene The scene the light belongs too
  76693. */
  76694. constructor(name: string, scene: Scene);
  76695. protected abstract _buildUniformLayout(): void;
  76696. /**
  76697. * Sets the passed Effect "effect" with the Light information.
  76698. * @param effect The effect to update
  76699. * @param lightIndex The index of the light in the effect to update
  76700. * @returns The light
  76701. */
  76702. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76703. /**
  76704. * Sets the passed Effect "effect" with the Light information.
  76705. * @param effect The effect to update
  76706. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76707. * @returns The light
  76708. */
  76709. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76710. /**
  76711. * Returns the string "Light".
  76712. * @returns the class name
  76713. */
  76714. getClassName(): string;
  76715. /** @hidden */
  76716. readonly _isLight: boolean;
  76717. /**
  76718. * Converts the light information to a readable string for debug purpose.
  76719. * @param fullDetails Supports for multiple levels of logging within scene loading
  76720. * @returns the human readable light info
  76721. */
  76722. toString(fullDetails?: boolean): string;
  76723. /** @hidden */
  76724. protected _syncParentEnabledState(): void;
  76725. /**
  76726. * Set the enabled state of this node.
  76727. * @param value - the new enabled state
  76728. */
  76729. setEnabled(value: boolean): void;
  76730. /**
  76731. * Returns the Light associated shadow generator if any.
  76732. * @return the associated shadow generator.
  76733. */
  76734. getShadowGenerator(): Nullable<IShadowGenerator>;
  76735. /**
  76736. * Returns a Vector3, the absolute light position in the World.
  76737. * @returns the world space position of the light
  76738. */
  76739. getAbsolutePosition(): Vector3;
  76740. /**
  76741. * Specifies if the light will affect the passed mesh.
  76742. * @param mesh The mesh to test against the light
  76743. * @return true the mesh is affected otherwise, false.
  76744. */
  76745. canAffectMesh(mesh: AbstractMesh): boolean;
  76746. /**
  76747. * Sort function to order lights for rendering.
  76748. * @param a First Light object to compare to second.
  76749. * @param b Second Light object to compare first.
  76750. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76751. */
  76752. static CompareLightsPriority(a: Light, b: Light): number;
  76753. /**
  76754. * Releases resources associated with this node.
  76755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76757. */
  76758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76759. /**
  76760. * Returns the light type ID (integer).
  76761. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76762. */
  76763. getTypeID(): number;
  76764. /**
  76765. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76766. * @returns the scaled intensity in intensity mode unit
  76767. */
  76768. getScaledIntensity(): number;
  76769. /**
  76770. * Returns a new Light object, named "name", from the current one.
  76771. * @param name The name of the cloned light
  76772. * @returns the new created light
  76773. */
  76774. clone(name: string): Nullable<Light>;
  76775. /**
  76776. * Serializes the current light into a Serialization object.
  76777. * @returns the serialized object.
  76778. */
  76779. serialize(): any;
  76780. /**
  76781. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76782. * This new light is named "name" and added to the passed scene.
  76783. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76784. * @param name The friendly name of the light
  76785. * @param scene The scene the new light will belong to
  76786. * @returns the constructor function
  76787. */
  76788. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76789. /**
  76790. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76791. * @param parsedLight The JSON representation of the light
  76792. * @param scene The scene to create the parsed light in
  76793. * @returns the created light after parsing
  76794. */
  76795. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76796. private _hookArrayForExcluded;
  76797. private _hookArrayForIncludedOnly;
  76798. private _resyncMeshes;
  76799. /**
  76800. * Forces the meshes to update their light related information in their rendering used effects
  76801. * @hidden Internal Use Only
  76802. */
  76803. _markMeshesAsLightDirty(): void;
  76804. /**
  76805. * Recomputes the cached photometric scale if needed.
  76806. */
  76807. private _computePhotometricScale;
  76808. /**
  76809. * Returns the Photometric Scale according to the light type and intensity mode.
  76810. */
  76811. private _getPhotometricScale;
  76812. /**
  76813. * Reorder the light in the scene according to their defined priority.
  76814. * @hidden Internal Use Only
  76815. */
  76816. _reorderLightsInScene(): void;
  76817. /**
  76818. * Prepares the list of defines specific to the light type.
  76819. * @param defines the list of defines
  76820. * @param lightIndex defines the index of the light for the effect
  76821. */
  76822. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76823. }
  76824. }
  76825. declare module BABYLON {
  76826. /**
  76827. * Interface used to define Action
  76828. */
  76829. export interface IAction {
  76830. /**
  76831. * Trigger for the action
  76832. */
  76833. trigger: number;
  76834. /** Options of the trigger */
  76835. triggerOptions: any;
  76836. /**
  76837. * Gets the trigger parameters
  76838. * @returns the trigger parameters
  76839. */
  76840. getTriggerParameter(): any;
  76841. /**
  76842. * Internal only - executes current action event
  76843. * @hidden
  76844. */
  76845. _executeCurrent(evt?: ActionEvent): void;
  76846. /**
  76847. * Serialize placeholder for child classes
  76848. * @param parent of child
  76849. * @returns the serialized object
  76850. */
  76851. serialize(parent: any): any;
  76852. /**
  76853. * Internal only
  76854. * @hidden
  76855. */
  76856. _prepare(): void;
  76857. /**
  76858. * Internal only - manager for action
  76859. * @hidden
  76860. */
  76861. _actionManager: AbstractActionManager;
  76862. /**
  76863. * Adds action to chain of actions, may be a DoNothingAction
  76864. * @param action defines the next action to execute
  76865. * @returns The action passed in
  76866. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76867. */
  76868. then(action: IAction): IAction;
  76869. }
  76870. /**
  76871. * The action to be carried out following a trigger
  76872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76873. */
  76874. export class Action implements IAction {
  76875. /** the trigger, with or without parameters, for the action */
  76876. triggerOptions: any;
  76877. /**
  76878. * Trigger for the action
  76879. */
  76880. trigger: number;
  76881. /**
  76882. * Internal only - manager for action
  76883. * @hidden
  76884. */
  76885. _actionManager: ActionManager;
  76886. private _nextActiveAction;
  76887. private _child;
  76888. private _condition?;
  76889. private _triggerParameter;
  76890. /**
  76891. * An event triggered prior to action being executed.
  76892. */
  76893. onBeforeExecuteObservable: Observable<Action>;
  76894. /**
  76895. * Creates a new Action
  76896. * @param triggerOptions the trigger, with or without parameters, for the action
  76897. * @param condition an optional determinant of action
  76898. */
  76899. constructor(
  76900. /** the trigger, with or without parameters, for the action */
  76901. triggerOptions: any, condition?: Condition);
  76902. /**
  76903. * Internal only
  76904. * @hidden
  76905. */
  76906. _prepare(): void;
  76907. /**
  76908. * Gets the trigger parameters
  76909. * @returns the trigger parameters
  76910. */
  76911. getTriggerParameter(): any;
  76912. /**
  76913. * Internal only - executes current action event
  76914. * @hidden
  76915. */
  76916. _executeCurrent(evt?: ActionEvent): void;
  76917. /**
  76918. * Execute placeholder for child classes
  76919. * @param evt optional action event
  76920. */
  76921. execute(evt?: ActionEvent): void;
  76922. /**
  76923. * Skips to next active action
  76924. */
  76925. skipToNextActiveAction(): void;
  76926. /**
  76927. * Adds action to chain of actions, may be a DoNothingAction
  76928. * @param action defines the next action to execute
  76929. * @returns The action passed in
  76930. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76931. */
  76932. then(action: Action): Action;
  76933. /**
  76934. * Internal only
  76935. * @hidden
  76936. */
  76937. _getProperty(propertyPath: string): string;
  76938. /**
  76939. * Internal only
  76940. * @hidden
  76941. */
  76942. _getEffectiveTarget(target: any, propertyPath: string): any;
  76943. /**
  76944. * Serialize placeholder for child classes
  76945. * @param parent of child
  76946. * @returns the serialized object
  76947. */
  76948. serialize(parent: any): any;
  76949. /**
  76950. * Internal only called by serialize
  76951. * @hidden
  76952. */
  76953. protected _serialize(serializedAction: any, parent?: any): any;
  76954. /**
  76955. * Internal only
  76956. * @hidden
  76957. */
  76958. static _SerializeValueAsString: (value: any) => string;
  76959. /**
  76960. * Internal only
  76961. * @hidden
  76962. */
  76963. static _GetTargetProperty: (target: Node | Scene) => {
  76964. name: string;
  76965. targetType: string;
  76966. value: string;
  76967. };
  76968. }
  76969. }
  76970. declare module BABYLON {
  76971. /**
  76972. * A Condition applied to an Action
  76973. */
  76974. export class Condition {
  76975. /**
  76976. * Internal only - manager for action
  76977. * @hidden
  76978. */
  76979. _actionManager: ActionManager;
  76980. /**
  76981. * Internal only
  76982. * @hidden
  76983. */
  76984. _evaluationId: number;
  76985. /**
  76986. * Internal only
  76987. * @hidden
  76988. */
  76989. _currentResult: boolean;
  76990. /**
  76991. * Creates a new Condition
  76992. * @param actionManager the manager of the action the condition is applied to
  76993. */
  76994. constructor(actionManager: ActionManager);
  76995. /**
  76996. * Check if the current condition is valid
  76997. * @returns a boolean
  76998. */
  76999. isValid(): boolean;
  77000. /**
  77001. * Internal only
  77002. * @hidden
  77003. */
  77004. _getProperty(propertyPath: string): string;
  77005. /**
  77006. * Internal only
  77007. * @hidden
  77008. */
  77009. _getEffectiveTarget(target: any, propertyPath: string): any;
  77010. /**
  77011. * Serialize placeholder for child classes
  77012. * @returns the serialized object
  77013. */
  77014. serialize(): any;
  77015. /**
  77016. * Internal only
  77017. * @hidden
  77018. */
  77019. protected _serialize(serializedCondition: any): any;
  77020. }
  77021. /**
  77022. * Defines specific conditional operators as extensions of Condition
  77023. */
  77024. export class ValueCondition extends Condition {
  77025. /** path to specify the property of the target the conditional operator uses */
  77026. propertyPath: string;
  77027. /** the value compared by the conditional operator against the current value of the property */
  77028. value: any;
  77029. /** the conditional operator, default ValueCondition.IsEqual */
  77030. operator: number;
  77031. /**
  77032. * Internal only
  77033. * @hidden
  77034. */
  77035. private static _IsEqual;
  77036. /**
  77037. * Internal only
  77038. * @hidden
  77039. */
  77040. private static _IsDifferent;
  77041. /**
  77042. * Internal only
  77043. * @hidden
  77044. */
  77045. private static _IsGreater;
  77046. /**
  77047. * Internal only
  77048. * @hidden
  77049. */
  77050. private static _IsLesser;
  77051. /**
  77052. * returns the number for IsEqual
  77053. */
  77054. static readonly IsEqual: number;
  77055. /**
  77056. * Returns the number for IsDifferent
  77057. */
  77058. static readonly IsDifferent: number;
  77059. /**
  77060. * Returns the number for IsGreater
  77061. */
  77062. static readonly IsGreater: number;
  77063. /**
  77064. * Returns the number for IsLesser
  77065. */
  77066. static readonly IsLesser: number;
  77067. /**
  77068. * Internal only The action manager for the condition
  77069. * @hidden
  77070. */
  77071. _actionManager: ActionManager;
  77072. /**
  77073. * Internal only
  77074. * @hidden
  77075. */
  77076. private _target;
  77077. /**
  77078. * Internal only
  77079. * @hidden
  77080. */
  77081. private _effectiveTarget;
  77082. /**
  77083. * Internal only
  77084. * @hidden
  77085. */
  77086. private _property;
  77087. /**
  77088. * Creates a new ValueCondition
  77089. * @param actionManager manager for the action the condition applies to
  77090. * @param target for the action
  77091. * @param propertyPath path to specify the property of the target the conditional operator uses
  77092. * @param value the value compared by the conditional operator against the current value of the property
  77093. * @param operator the conditional operator, default ValueCondition.IsEqual
  77094. */
  77095. constructor(actionManager: ActionManager, target: any,
  77096. /** path to specify the property of the target the conditional operator uses */
  77097. propertyPath: string,
  77098. /** the value compared by the conditional operator against the current value of the property */
  77099. value: any,
  77100. /** the conditional operator, default ValueCondition.IsEqual */
  77101. operator?: number);
  77102. /**
  77103. * Compares the given value with the property value for the specified conditional operator
  77104. * @returns the result of the comparison
  77105. */
  77106. isValid(): boolean;
  77107. /**
  77108. * Serialize the ValueCondition into a JSON compatible object
  77109. * @returns serialization object
  77110. */
  77111. serialize(): any;
  77112. /**
  77113. * Gets the name of the conditional operator for the ValueCondition
  77114. * @param operator the conditional operator
  77115. * @returns the name
  77116. */
  77117. static GetOperatorName(operator: number): string;
  77118. }
  77119. /**
  77120. * Defines a predicate condition as an extension of Condition
  77121. */
  77122. export class PredicateCondition extends Condition {
  77123. /** defines the predicate function used to validate the condition */
  77124. predicate: () => boolean;
  77125. /**
  77126. * Internal only - manager for action
  77127. * @hidden
  77128. */
  77129. _actionManager: ActionManager;
  77130. /**
  77131. * Creates a new PredicateCondition
  77132. * @param actionManager manager for the action the condition applies to
  77133. * @param predicate defines the predicate function used to validate the condition
  77134. */
  77135. constructor(actionManager: ActionManager,
  77136. /** defines the predicate function used to validate the condition */
  77137. predicate: () => boolean);
  77138. /**
  77139. * @returns the validity of the predicate condition
  77140. */
  77141. isValid(): boolean;
  77142. }
  77143. /**
  77144. * Defines a state condition as an extension of Condition
  77145. */
  77146. export class StateCondition extends Condition {
  77147. /** Value to compare with target state */
  77148. value: string;
  77149. /**
  77150. * Internal only - manager for action
  77151. * @hidden
  77152. */
  77153. _actionManager: ActionManager;
  77154. /**
  77155. * Internal only
  77156. * @hidden
  77157. */
  77158. private _target;
  77159. /**
  77160. * Creates a new StateCondition
  77161. * @param actionManager manager for the action the condition applies to
  77162. * @param target of the condition
  77163. * @param value to compare with target state
  77164. */
  77165. constructor(actionManager: ActionManager, target: any,
  77166. /** Value to compare with target state */
  77167. value: string);
  77168. /**
  77169. * Gets a boolean indicating if the current condition is met
  77170. * @returns the validity of the state
  77171. */
  77172. isValid(): boolean;
  77173. /**
  77174. * Serialize the StateCondition into a JSON compatible object
  77175. * @returns serialization object
  77176. */
  77177. serialize(): any;
  77178. }
  77179. }
  77180. declare module BABYLON {
  77181. /**
  77182. * This defines an action responsible to toggle a boolean once triggered.
  77183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77184. */
  77185. export class SwitchBooleanAction extends Action {
  77186. /**
  77187. * The path to the boolean property in the target object
  77188. */
  77189. propertyPath: string;
  77190. private _target;
  77191. private _effectiveTarget;
  77192. private _property;
  77193. /**
  77194. * Instantiate the action
  77195. * @param triggerOptions defines the trigger options
  77196. * @param target defines the object containing the boolean
  77197. * @param propertyPath defines the path to the boolean property in the target object
  77198. * @param condition defines the trigger related conditions
  77199. */
  77200. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77201. /** @hidden */
  77202. _prepare(): void;
  77203. /**
  77204. * Execute the action toggle the boolean value.
  77205. */
  77206. execute(): void;
  77207. /**
  77208. * Serializes the actions and its related information.
  77209. * @param parent defines the object to serialize in
  77210. * @returns the serialized object
  77211. */
  77212. serialize(parent: any): any;
  77213. }
  77214. /**
  77215. * This defines an action responsible to set a the state field of the target
  77216. * to a desired value once triggered.
  77217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77218. */
  77219. export class SetStateAction extends Action {
  77220. /**
  77221. * The value to store in the state field.
  77222. */
  77223. value: string;
  77224. private _target;
  77225. /**
  77226. * Instantiate the action
  77227. * @param triggerOptions defines the trigger options
  77228. * @param target defines the object containing the state property
  77229. * @param value defines the value to store in the state field
  77230. * @param condition defines the trigger related conditions
  77231. */
  77232. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77233. /**
  77234. * Execute the action and store the value on the target state property.
  77235. */
  77236. execute(): void;
  77237. /**
  77238. * Serializes the actions and its related information.
  77239. * @param parent defines the object to serialize in
  77240. * @returns the serialized object
  77241. */
  77242. serialize(parent: any): any;
  77243. }
  77244. /**
  77245. * This defines an action responsible to set a property of the target
  77246. * to a desired value once triggered.
  77247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77248. */
  77249. export class SetValueAction extends Action {
  77250. /**
  77251. * The path of the property to set in the target.
  77252. */
  77253. propertyPath: string;
  77254. /**
  77255. * The value to set in the property
  77256. */
  77257. value: any;
  77258. private _target;
  77259. private _effectiveTarget;
  77260. private _property;
  77261. /**
  77262. * Instantiate the action
  77263. * @param triggerOptions defines the trigger options
  77264. * @param target defines the object containing the property
  77265. * @param propertyPath defines the path of the property to set in the target
  77266. * @param value defines the value to set in the property
  77267. * @param condition defines the trigger related conditions
  77268. */
  77269. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77270. /** @hidden */
  77271. _prepare(): void;
  77272. /**
  77273. * Execute the action and set the targetted property to the desired value.
  77274. */
  77275. execute(): void;
  77276. /**
  77277. * Serializes the actions and its related information.
  77278. * @param parent defines the object to serialize in
  77279. * @returns the serialized object
  77280. */
  77281. serialize(parent: any): any;
  77282. }
  77283. /**
  77284. * This defines an action responsible to increment the target value
  77285. * to a desired value once triggered.
  77286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77287. */
  77288. export class IncrementValueAction extends Action {
  77289. /**
  77290. * The path of the property to increment in the target.
  77291. */
  77292. propertyPath: string;
  77293. /**
  77294. * The value we should increment the property by.
  77295. */
  77296. value: any;
  77297. private _target;
  77298. private _effectiveTarget;
  77299. private _property;
  77300. /**
  77301. * Instantiate the action
  77302. * @param triggerOptions defines the trigger options
  77303. * @param target defines the object containing the property
  77304. * @param propertyPath defines the path of the property to increment in the target
  77305. * @param value defines the value value we should increment the property by
  77306. * @param condition defines the trigger related conditions
  77307. */
  77308. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77309. /** @hidden */
  77310. _prepare(): void;
  77311. /**
  77312. * Execute the action and increment the target of the value amount.
  77313. */
  77314. execute(): void;
  77315. /**
  77316. * Serializes the actions and its related information.
  77317. * @param parent defines the object to serialize in
  77318. * @returns the serialized object
  77319. */
  77320. serialize(parent: any): any;
  77321. }
  77322. /**
  77323. * This defines an action responsible to start an animation once triggered.
  77324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77325. */
  77326. export class PlayAnimationAction extends Action {
  77327. /**
  77328. * Where the animation should start (animation frame)
  77329. */
  77330. from: number;
  77331. /**
  77332. * Where the animation should stop (animation frame)
  77333. */
  77334. to: number;
  77335. /**
  77336. * Define if the animation should loop or stop after the first play.
  77337. */
  77338. loop?: boolean;
  77339. private _target;
  77340. /**
  77341. * Instantiate the action
  77342. * @param triggerOptions defines the trigger options
  77343. * @param target defines the target animation or animation name
  77344. * @param from defines from where the animation should start (animation frame)
  77345. * @param end defines where the animation should stop (animation frame)
  77346. * @param loop defines if the animation should loop or stop after the first play
  77347. * @param condition defines the trigger related conditions
  77348. */
  77349. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77350. /** @hidden */
  77351. _prepare(): void;
  77352. /**
  77353. * Execute the action and play the animation.
  77354. */
  77355. execute(): void;
  77356. /**
  77357. * Serializes the actions and its related information.
  77358. * @param parent defines the object to serialize in
  77359. * @returns the serialized object
  77360. */
  77361. serialize(parent: any): any;
  77362. }
  77363. /**
  77364. * This defines an action responsible to stop an animation once triggered.
  77365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77366. */
  77367. export class StopAnimationAction extends Action {
  77368. private _target;
  77369. /**
  77370. * Instantiate the action
  77371. * @param triggerOptions defines the trigger options
  77372. * @param target defines the target animation or animation name
  77373. * @param condition defines the trigger related conditions
  77374. */
  77375. constructor(triggerOptions: any, target: any, condition?: Condition);
  77376. /** @hidden */
  77377. _prepare(): void;
  77378. /**
  77379. * Execute the action and stop the animation.
  77380. */
  77381. execute(): void;
  77382. /**
  77383. * Serializes the actions and its related information.
  77384. * @param parent defines the object to serialize in
  77385. * @returns the serialized object
  77386. */
  77387. serialize(parent: any): any;
  77388. }
  77389. /**
  77390. * This defines an action responsible that does nothing once triggered.
  77391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77392. */
  77393. export class DoNothingAction extends Action {
  77394. /**
  77395. * Instantiate the action
  77396. * @param triggerOptions defines the trigger options
  77397. * @param condition defines the trigger related conditions
  77398. */
  77399. constructor(triggerOptions?: any, condition?: Condition);
  77400. /**
  77401. * Execute the action and do nothing.
  77402. */
  77403. execute(): void;
  77404. /**
  77405. * Serializes the actions and its related information.
  77406. * @param parent defines the object to serialize in
  77407. * @returns the serialized object
  77408. */
  77409. serialize(parent: any): any;
  77410. }
  77411. /**
  77412. * This defines an action responsible to trigger several actions once triggered.
  77413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77414. */
  77415. export class CombineAction extends Action {
  77416. /**
  77417. * The list of aggregated animations to run.
  77418. */
  77419. children: Action[];
  77420. /**
  77421. * Instantiate the action
  77422. * @param triggerOptions defines the trigger options
  77423. * @param children defines the list of aggregated animations to run
  77424. * @param condition defines the trigger related conditions
  77425. */
  77426. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77427. /** @hidden */
  77428. _prepare(): void;
  77429. /**
  77430. * Execute the action and executes all the aggregated actions.
  77431. */
  77432. execute(evt: ActionEvent): void;
  77433. /**
  77434. * Serializes the actions and its related information.
  77435. * @param parent defines the object to serialize in
  77436. * @returns the serialized object
  77437. */
  77438. serialize(parent: any): any;
  77439. }
  77440. /**
  77441. * This defines an action responsible to run code (external event) once triggered.
  77442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77443. */
  77444. export class ExecuteCodeAction extends Action {
  77445. /**
  77446. * The callback function to run.
  77447. */
  77448. func: (evt: ActionEvent) => void;
  77449. /**
  77450. * Instantiate the action
  77451. * @param triggerOptions defines the trigger options
  77452. * @param func defines the callback function to run
  77453. * @param condition defines the trigger related conditions
  77454. */
  77455. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77456. /**
  77457. * Execute the action and run the attached code.
  77458. */
  77459. execute(evt: ActionEvent): void;
  77460. }
  77461. /**
  77462. * This defines an action responsible to set the parent property of the target once triggered.
  77463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77464. */
  77465. export class SetParentAction extends Action {
  77466. private _parent;
  77467. private _target;
  77468. /**
  77469. * Instantiate the action
  77470. * @param triggerOptions defines the trigger options
  77471. * @param target defines the target containing the parent property
  77472. * @param parent defines from where the animation should start (animation frame)
  77473. * @param condition defines the trigger related conditions
  77474. */
  77475. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77476. /** @hidden */
  77477. _prepare(): void;
  77478. /**
  77479. * Execute the action and set the parent property.
  77480. */
  77481. execute(): void;
  77482. /**
  77483. * Serializes the actions and its related information.
  77484. * @param parent defines the object to serialize in
  77485. * @returns the serialized object
  77486. */
  77487. serialize(parent: any): any;
  77488. }
  77489. }
  77490. declare module BABYLON {
  77491. /**
  77492. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77493. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77495. */
  77496. export class ActionManager extends AbstractActionManager {
  77497. /**
  77498. * Nothing
  77499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77500. */
  77501. static readonly NothingTrigger: number;
  77502. /**
  77503. * On pick
  77504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77505. */
  77506. static readonly OnPickTrigger: number;
  77507. /**
  77508. * On left pick
  77509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77510. */
  77511. static readonly OnLeftPickTrigger: number;
  77512. /**
  77513. * On right pick
  77514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77515. */
  77516. static readonly OnRightPickTrigger: number;
  77517. /**
  77518. * On center pick
  77519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77520. */
  77521. static readonly OnCenterPickTrigger: number;
  77522. /**
  77523. * On pick down
  77524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77525. */
  77526. static readonly OnPickDownTrigger: number;
  77527. /**
  77528. * On double pick
  77529. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77530. */
  77531. static readonly OnDoublePickTrigger: number;
  77532. /**
  77533. * On pick up
  77534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77535. */
  77536. static readonly OnPickUpTrigger: number;
  77537. /**
  77538. * On pick out.
  77539. * This trigger will only be raised if you also declared a OnPickDown
  77540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77541. */
  77542. static readonly OnPickOutTrigger: number;
  77543. /**
  77544. * On long press
  77545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77546. */
  77547. static readonly OnLongPressTrigger: number;
  77548. /**
  77549. * On pointer over
  77550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77551. */
  77552. static readonly OnPointerOverTrigger: number;
  77553. /**
  77554. * On pointer out
  77555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77556. */
  77557. static readonly OnPointerOutTrigger: number;
  77558. /**
  77559. * On every frame
  77560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77561. */
  77562. static readonly OnEveryFrameTrigger: number;
  77563. /**
  77564. * On intersection enter
  77565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77566. */
  77567. static readonly OnIntersectionEnterTrigger: number;
  77568. /**
  77569. * On intersection exit
  77570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77571. */
  77572. static readonly OnIntersectionExitTrigger: number;
  77573. /**
  77574. * On key down
  77575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77576. */
  77577. static readonly OnKeyDownTrigger: number;
  77578. /**
  77579. * On key up
  77580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77581. */
  77582. static readonly OnKeyUpTrigger: number;
  77583. private _scene;
  77584. /**
  77585. * Creates a new action manager
  77586. * @param scene defines the hosting scene
  77587. */
  77588. constructor(scene: Scene);
  77589. /**
  77590. * Releases all associated resources
  77591. */
  77592. dispose(): void;
  77593. /**
  77594. * Gets hosting scene
  77595. * @returns the hosting scene
  77596. */
  77597. getScene(): Scene;
  77598. /**
  77599. * Does this action manager handles actions of any of the given triggers
  77600. * @param triggers defines the triggers to be tested
  77601. * @return a boolean indicating whether one (or more) of the triggers is handled
  77602. */
  77603. hasSpecificTriggers(triggers: number[]): boolean;
  77604. /**
  77605. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77606. * speed.
  77607. * @param triggerA defines the trigger to be tested
  77608. * @param triggerB defines the trigger to be tested
  77609. * @return a boolean indicating whether one (or more) of the triggers is handled
  77610. */
  77611. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77612. /**
  77613. * Does this action manager handles actions of a given trigger
  77614. * @param trigger defines the trigger to be tested
  77615. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77616. * @return whether the trigger is handled
  77617. */
  77618. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77619. /**
  77620. * Does this action manager has pointer triggers
  77621. */
  77622. readonly hasPointerTriggers: boolean;
  77623. /**
  77624. * Does this action manager has pick triggers
  77625. */
  77626. readonly hasPickTriggers: boolean;
  77627. /**
  77628. * Registers an action to this action manager
  77629. * @param action defines the action to be registered
  77630. * @return the action amended (prepared) after registration
  77631. */
  77632. registerAction(action: IAction): Nullable<IAction>;
  77633. /**
  77634. * Unregisters an action to this action manager
  77635. * @param action defines the action to be unregistered
  77636. * @return a boolean indicating whether the action has been unregistered
  77637. */
  77638. unregisterAction(action: IAction): Boolean;
  77639. /**
  77640. * Process a specific trigger
  77641. * @param trigger defines the trigger to process
  77642. * @param evt defines the event details to be processed
  77643. */
  77644. processTrigger(trigger: number, evt?: IActionEvent): void;
  77645. /** @hidden */
  77646. _getEffectiveTarget(target: any, propertyPath: string): any;
  77647. /** @hidden */
  77648. _getProperty(propertyPath: string): string;
  77649. /**
  77650. * Serialize this manager to a JSON object
  77651. * @param name defines the property name to store this manager
  77652. * @returns a JSON representation of this manager
  77653. */
  77654. serialize(name: string): any;
  77655. /**
  77656. * Creates a new ActionManager from a JSON data
  77657. * @param parsedActions defines the JSON data to read from
  77658. * @param object defines the hosting mesh
  77659. * @param scene defines the hosting scene
  77660. */
  77661. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77662. /**
  77663. * Get a trigger name by index
  77664. * @param trigger defines the trigger index
  77665. * @returns a trigger name
  77666. */
  77667. static GetTriggerName(trigger: number): string;
  77668. }
  77669. }
  77670. declare module BABYLON {
  77671. /**
  77672. * Class representing a ray with position and direction
  77673. */
  77674. export class Ray {
  77675. /** origin point */
  77676. origin: Vector3;
  77677. /** direction */
  77678. direction: Vector3;
  77679. /** length of the ray */
  77680. length: number;
  77681. private static readonly TmpVector3;
  77682. private _tmpRay;
  77683. /**
  77684. * Creates a new ray
  77685. * @param origin origin point
  77686. * @param direction direction
  77687. * @param length length of the ray
  77688. */
  77689. constructor(
  77690. /** origin point */
  77691. origin: Vector3,
  77692. /** direction */
  77693. direction: Vector3,
  77694. /** length of the ray */
  77695. length?: number);
  77696. /**
  77697. * Checks if the ray intersects a box
  77698. * @param minimum bound of the box
  77699. * @param maximum bound of the box
  77700. * @param intersectionTreshold extra extend to be added to the box in all direction
  77701. * @returns if the box was hit
  77702. */
  77703. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77704. /**
  77705. * Checks if the ray intersects a box
  77706. * @param box the bounding box to check
  77707. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77708. * @returns if the box was hit
  77709. */
  77710. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77711. /**
  77712. * If the ray hits a sphere
  77713. * @param sphere the bounding sphere to check
  77714. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77715. * @returns true if it hits the sphere
  77716. */
  77717. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77718. /**
  77719. * If the ray hits a triange
  77720. * @param vertex0 triangle vertex
  77721. * @param vertex1 triangle vertex
  77722. * @param vertex2 triangle vertex
  77723. * @returns intersection information if hit
  77724. */
  77725. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77726. /**
  77727. * Checks if ray intersects a plane
  77728. * @param plane the plane to check
  77729. * @returns the distance away it was hit
  77730. */
  77731. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77732. /**
  77733. * Calculate the intercept of a ray on a given axis
  77734. * @param axis to check 'x' | 'y' | 'z'
  77735. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77736. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77737. */
  77738. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77739. /**
  77740. * Checks if ray intersects a mesh
  77741. * @param mesh the mesh to check
  77742. * @param fastCheck if only the bounding box should checked
  77743. * @returns picking info of the intersecton
  77744. */
  77745. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77746. /**
  77747. * Checks if ray intersects a mesh
  77748. * @param meshes the meshes to check
  77749. * @param fastCheck if only the bounding box should checked
  77750. * @param results array to store result in
  77751. * @returns Array of picking infos
  77752. */
  77753. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77754. private _comparePickingInfo;
  77755. private static smallnum;
  77756. private static rayl;
  77757. /**
  77758. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77759. * @param sega the first point of the segment to test the intersection against
  77760. * @param segb the second point of the segment to test the intersection against
  77761. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77762. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77763. */
  77764. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77765. /**
  77766. * Update the ray from viewport position
  77767. * @param x position
  77768. * @param y y position
  77769. * @param viewportWidth viewport width
  77770. * @param viewportHeight viewport height
  77771. * @param world world matrix
  77772. * @param view view matrix
  77773. * @param projection projection matrix
  77774. * @returns this ray updated
  77775. */
  77776. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77777. /**
  77778. * Creates a ray with origin and direction of 0,0,0
  77779. * @returns the new ray
  77780. */
  77781. static Zero(): Ray;
  77782. /**
  77783. * Creates a new ray from screen space and viewport
  77784. * @param x position
  77785. * @param y y position
  77786. * @param viewportWidth viewport width
  77787. * @param viewportHeight viewport height
  77788. * @param world world matrix
  77789. * @param view view matrix
  77790. * @param projection projection matrix
  77791. * @returns new ray
  77792. */
  77793. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77794. /**
  77795. * 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
  77796. * transformed to the given world matrix.
  77797. * @param origin The origin point
  77798. * @param end The end point
  77799. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77800. * @returns the new ray
  77801. */
  77802. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77803. /**
  77804. * Transforms a ray by a matrix
  77805. * @param ray ray to transform
  77806. * @param matrix matrix to apply
  77807. * @returns the resulting new ray
  77808. */
  77809. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77810. /**
  77811. * Transforms a ray by a matrix
  77812. * @param ray ray to transform
  77813. * @param matrix matrix to apply
  77814. * @param result ray to store result in
  77815. */
  77816. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77817. /**
  77818. * Unproject a ray from screen space to object space
  77819. * @param sourceX defines the screen space x coordinate to use
  77820. * @param sourceY defines the screen space y coordinate to use
  77821. * @param viewportWidth defines the current width of the viewport
  77822. * @param viewportHeight defines the current height of the viewport
  77823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77824. * @param view defines the view matrix to use
  77825. * @param projection defines the projection matrix to use
  77826. */
  77827. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77828. }
  77829. /**
  77830. * Type used to define predicate used to select faces when a mesh intersection is detected
  77831. */
  77832. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77833. interface Scene {
  77834. /** @hidden */
  77835. _tempPickingRay: Nullable<Ray>;
  77836. /** @hidden */
  77837. _cachedRayForTransform: Ray;
  77838. /** @hidden */
  77839. _pickWithRayInverseMatrix: Matrix;
  77840. /** @hidden */
  77841. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77842. /** @hidden */
  77843. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77844. }
  77845. }
  77846. declare module BABYLON {
  77847. /**
  77848. * Groups all the scene component constants in one place to ease maintenance.
  77849. * @hidden
  77850. */
  77851. export class SceneComponentConstants {
  77852. static readonly NAME_EFFECTLAYER: string;
  77853. static readonly NAME_LAYER: string;
  77854. static readonly NAME_LENSFLARESYSTEM: string;
  77855. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77856. static readonly NAME_PARTICLESYSTEM: string;
  77857. static readonly NAME_GAMEPAD: string;
  77858. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77859. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77860. static readonly NAME_DEPTHRENDERER: string;
  77861. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77862. static readonly NAME_SPRITE: string;
  77863. static readonly NAME_OUTLINERENDERER: string;
  77864. static readonly NAME_PROCEDURALTEXTURE: string;
  77865. static readonly NAME_SHADOWGENERATOR: string;
  77866. static readonly NAME_OCTREE: string;
  77867. static readonly NAME_PHYSICSENGINE: string;
  77868. static readonly NAME_AUDIO: string;
  77869. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77870. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77871. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77872. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77873. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77874. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77875. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77876. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77877. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77878. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77879. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77880. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77881. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77882. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77883. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77884. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77885. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77886. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77887. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77888. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77889. static readonly STEP_AFTERRENDER_AUDIO: number;
  77890. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77891. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77892. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77893. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77894. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77895. static readonly STEP_POINTERMOVE_SPRITE: number;
  77896. static readonly STEP_POINTERDOWN_SPRITE: number;
  77897. static readonly STEP_POINTERUP_SPRITE: number;
  77898. }
  77899. /**
  77900. * This represents a scene component.
  77901. *
  77902. * This is used to decouple the dependency the scene is having on the different workloads like
  77903. * layers, post processes...
  77904. */
  77905. export interface ISceneComponent {
  77906. /**
  77907. * The name of the component. Each component must have a unique name.
  77908. */
  77909. name: string;
  77910. /**
  77911. * The scene the component belongs to.
  77912. */
  77913. scene: Scene;
  77914. /**
  77915. * Register the component to one instance of a scene.
  77916. */
  77917. register(): void;
  77918. /**
  77919. * Rebuilds the elements related to this component in case of
  77920. * context lost for instance.
  77921. */
  77922. rebuild(): void;
  77923. /**
  77924. * Disposes the component and the associated ressources.
  77925. */
  77926. dispose(): void;
  77927. }
  77928. /**
  77929. * This represents a SERIALIZABLE scene component.
  77930. *
  77931. * This extends Scene Component to add Serialization methods on top.
  77932. */
  77933. export interface ISceneSerializableComponent extends ISceneComponent {
  77934. /**
  77935. * Adds all the elements from the container to the scene
  77936. * @param container the container holding the elements
  77937. */
  77938. addFromContainer(container: AbstractScene): void;
  77939. /**
  77940. * Removes all the elements in the container from the scene
  77941. * @param container contains the elements to remove
  77942. * @param dispose if the removed element should be disposed (default: false)
  77943. */
  77944. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77945. /**
  77946. * Serializes the component data to the specified json object
  77947. * @param serializationObject The object to serialize to
  77948. */
  77949. serialize(serializationObject: any): void;
  77950. }
  77951. /**
  77952. * Strong typing of a Mesh related stage step action
  77953. */
  77954. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77955. /**
  77956. * Strong typing of a Evaluate Sub Mesh related stage step action
  77957. */
  77958. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77959. /**
  77960. * Strong typing of a Active Mesh related stage step action
  77961. */
  77962. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77963. /**
  77964. * Strong typing of a Camera related stage step action
  77965. */
  77966. export type CameraStageAction = (camera: Camera) => void;
  77967. /**
  77968. * Strong typing of a Camera Frame buffer related stage step action
  77969. */
  77970. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77971. /**
  77972. * Strong typing of a Render Target related stage step action
  77973. */
  77974. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77975. /**
  77976. * Strong typing of a RenderingGroup related stage step action
  77977. */
  77978. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77979. /**
  77980. * Strong typing of a Mesh Render related stage step action
  77981. */
  77982. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77983. /**
  77984. * Strong typing of a simple stage step action
  77985. */
  77986. export type SimpleStageAction = () => void;
  77987. /**
  77988. * Strong typing of a render target action.
  77989. */
  77990. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77991. /**
  77992. * Strong typing of a pointer move action.
  77993. */
  77994. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77995. /**
  77996. * Strong typing of a pointer up/down action.
  77997. */
  77998. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77999. /**
  78000. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78001. * @hidden
  78002. */
  78003. export class Stage<T extends Function> extends Array<{
  78004. index: number;
  78005. component: ISceneComponent;
  78006. action: T;
  78007. }> {
  78008. /**
  78009. * Hide ctor from the rest of the world.
  78010. * @param items The items to add.
  78011. */
  78012. private constructor();
  78013. /**
  78014. * Creates a new Stage.
  78015. * @returns A new instance of a Stage
  78016. */
  78017. static Create<T extends Function>(): Stage<T>;
  78018. /**
  78019. * Registers a step in an ordered way in the targeted stage.
  78020. * @param index Defines the position to register the step in
  78021. * @param component Defines the component attached to the step
  78022. * @param action Defines the action to launch during the step
  78023. */
  78024. registerStep(index: number, component: ISceneComponent, action: T): void;
  78025. /**
  78026. * Clears all the steps from the stage.
  78027. */
  78028. clear(): void;
  78029. }
  78030. }
  78031. declare module BABYLON {
  78032. interface Scene {
  78033. /** @hidden */
  78034. _pointerOverSprite: Nullable<Sprite>;
  78035. /** @hidden */
  78036. _pickedDownSprite: Nullable<Sprite>;
  78037. /** @hidden */
  78038. _tempSpritePickingRay: Nullable<Ray>;
  78039. /**
  78040. * All of the sprite managers added to this scene
  78041. * @see http://doc.babylonjs.com/babylon101/sprites
  78042. */
  78043. spriteManagers: Array<ISpriteManager>;
  78044. /**
  78045. * An event triggered when sprites rendering is about to start
  78046. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78047. */
  78048. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78049. /**
  78050. * An event triggered when sprites rendering is done
  78051. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78052. */
  78053. onAfterSpritesRenderingObservable: Observable<Scene>;
  78054. /** @hidden */
  78055. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78056. /** Launch a ray to try to pick a sprite in the scene
  78057. * @param x position on screen
  78058. * @param y position on screen
  78059. * @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
  78060. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78061. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78062. * @returns a PickingInfo
  78063. */
  78064. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78065. /** Use the given ray to pick a sprite in the scene
  78066. * @param ray The ray (in world space) to use to pick meshes
  78067. * @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
  78068. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78069. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78070. * @returns a PickingInfo
  78071. */
  78072. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78073. /** @hidden */
  78074. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78075. /** Launch a ray to try to pick sprites in the scene
  78076. * @param x position on screen
  78077. * @param y position on screen
  78078. * @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
  78079. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78080. * @returns a PickingInfo array
  78081. */
  78082. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78083. /** Use the given ray to pick sprites in the scene
  78084. * @param ray The ray (in world space) to use to pick meshes
  78085. * @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
  78086. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78087. * @returns a PickingInfo array
  78088. */
  78089. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78090. /**
  78091. * Force the sprite under the pointer
  78092. * @param sprite defines the sprite to use
  78093. */
  78094. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78095. /**
  78096. * Gets the sprite under the pointer
  78097. * @returns a Sprite or null if no sprite is under the pointer
  78098. */
  78099. getPointerOverSprite(): Nullable<Sprite>;
  78100. }
  78101. /**
  78102. * Defines the sprite scene component responsible to manage sprites
  78103. * in a given scene.
  78104. */
  78105. export class SpriteSceneComponent implements ISceneComponent {
  78106. /**
  78107. * The component name helpfull to identify the component in the list of scene components.
  78108. */
  78109. readonly name: string;
  78110. /**
  78111. * The scene the component belongs to.
  78112. */
  78113. scene: Scene;
  78114. /** @hidden */
  78115. private _spritePredicate;
  78116. /**
  78117. * Creates a new instance of the component for the given scene
  78118. * @param scene Defines the scene to register the component in
  78119. */
  78120. constructor(scene: Scene);
  78121. /**
  78122. * Registers the component in a given scene
  78123. */
  78124. register(): void;
  78125. /**
  78126. * Rebuilds the elements related to this component in case of
  78127. * context lost for instance.
  78128. */
  78129. rebuild(): void;
  78130. /**
  78131. * Disposes the component and the associated ressources.
  78132. */
  78133. dispose(): void;
  78134. private _pickSpriteButKeepRay;
  78135. private _pointerMove;
  78136. private _pointerDown;
  78137. private _pointerUp;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. /** @hidden */
  78142. export var fogFragmentDeclaration: {
  78143. name: string;
  78144. shader: string;
  78145. };
  78146. }
  78147. declare module BABYLON {
  78148. /** @hidden */
  78149. export var fogFragment: {
  78150. name: string;
  78151. shader: string;
  78152. };
  78153. }
  78154. declare module BABYLON {
  78155. /** @hidden */
  78156. export var spritesPixelShader: {
  78157. name: string;
  78158. shader: string;
  78159. };
  78160. }
  78161. declare module BABYLON {
  78162. /** @hidden */
  78163. export var fogVertexDeclaration: {
  78164. name: string;
  78165. shader: string;
  78166. };
  78167. }
  78168. declare module BABYLON {
  78169. /** @hidden */
  78170. export var spritesVertexShader: {
  78171. name: string;
  78172. shader: string;
  78173. };
  78174. }
  78175. declare module BABYLON {
  78176. /**
  78177. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78178. */
  78179. export interface ISpriteManager extends IDisposable {
  78180. /**
  78181. * Restricts the camera to viewing objects with the same layerMask.
  78182. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78183. */
  78184. layerMask: number;
  78185. /**
  78186. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78187. */
  78188. isPickable: boolean;
  78189. /**
  78190. * Specifies the rendering group id for this mesh (0 by default)
  78191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78192. */
  78193. renderingGroupId: number;
  78194. /**
  78195. * Defines the list of sprites managed by the manager.
  78196. */
  78197. sprites: Array<Sprite>;
  78198. /**
  78199. * Tests the intersection of a sprite with a specific ray.
  78200. * @param ray The ray we are sending to test the collision
  78201. * @param camera The camera space we are sending rays in
  78202. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78203. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78204. * @returns picking info or null.
  78205. */
  78206. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78207. /**
  78208. * Intersects the sprites with a ray
  78209. * @param ray defines the ray to intersect with
  78210. * @param camera defines the current active camera
  78211. * @param predicate defines a predicate used to select candidate sprites
  78212. * @returns null if no hit or a PickingInfo array
  78213. */
  78214. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78215. /**
  78216. * Renders the list of sprites on screen.
  78217. */
  78218. render(): void;
  78219. }
  78220. /**
  78221. * Class used to manage multiple sprites on the same spritesheet
  78222. * @see http://doc.babylonjs.com/babylon101/sprites
  78223. */
  78224. export class SpriteManager implements ISpriteManager {
  78225. /** defines the manager's name */
  78226. name: string;
  78227. /** Gets the list of sprites */
  78228. sprites: Sprite[];
  78229. /** Gets or sets the rendering group id (0 by default) */
  78230. renderingGroupId: number;
  78231. /** Gets or sets camera layer mask */
  78232. layerMask: number;
  78233. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78234. fogEnabled: boolean;
  78235. /** Gets or sets a boolean indicating if the sprites are pickable */
  78236. isPickable: boolean;
  78237. /** Defines the default width of a cell in the spritesheet */
  78238. cellWidth: number;
  78239. /** Defines the default height of a cell in the spritesheet */
  78240. cellHeight: number;
  78241. /** Associative array from JSON sprite data file */
  78242. private _cellData;
  78243. /** Array of sprite names from JSON sprite data file */
  78244. private _spriteMap;
  78245. /** True when packed cell data from JSON file is ready*/
  78246. private _packedAndReady;
  78247. /**
  78248. * An event triggered when the manager is disposed.
  78249. */
  78250. onDisposeObservable: Observable<SpriteManager>;
  78251. private _onDisposeObserver;
  78252. /**
  78253. * Callback called when the manager is disposed
  78254. */
  78255. onDispose: () => void;
  78256. private _capacity;
  78257. private _fromPacked;
  78258. private _spriteTexture;
  78259. private _epsilon;
  78260. private _scene;
  78261. private _vertexData;
  78262. private _buffer;
  78263. private _vertexBuffers;
  78264. private _indexBuffer;
  78265. private _effectBase;
  78266. private _effectFog;
  78267. /**
  78268. * Gets or sets the spritesheet texture
  78269. */
  78270. texture: Texture;
  78271. /**
  78272. * Creates a new sprite manager
  78273. * @param name defines the manager's name
  78274. * @param imgUrl defines the sprite sheet url
  78275. * @param capacity defines the maximum allowed number of sprites
  78276. * @param cellSize defines the size of a sprite cell
  78277. * @param scene defines the hosting scene
  78278. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78279. * @param samplingMode defines the smapling mode to use with spritesheet
  78280. * @param fromPacked set to false; do not alter
  78281. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78282. */
  78283. constructor(
  78284. /** defines the manager's name */
  78285. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78286. private _makePacked;
  78287. private _appendSpriteVertex;
  78288. /**
  78289. * Intersects the sprites with a ray
  78290. * @param ray defines the ray to intersect with
  78291. * @param camera defines the current active camera
  78292. * @param predicate defines a predicate used to select candidate sprites
  78293. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78294. * @returns null if no hit or a PickingInfo
  78295. */
  78296. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78297. /**
  78298. * Intersects the sprites with a ray
  78299. * @param ray defines the ray to intersect with
  78300. * @param camera defines the current active camera
  78301. * @param predicate defines a predicate used to select candidate sprites
  78302. * @returns null if no hit or a PickingInfo array
  78303. */
  78304. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78305. /**
  78306. * Render all child sprites
  78307. */
  78308. render(): void;
  78309. /**
  78310. * Release associated resources
  78311. */
  78312. dispose(): void;
  78313. }
  78314. }
  78315. declare module BABYLON {
  78316. /**
  78317. * Class used to represent a sprite
  78318. * @see http://doc.babylonjs.com/babylon101/sprites
  78319. */
  78320. export class Sprite {
  78321. /** defines the name */
  78322. name: string;
  78323. /** Gets or sets the current world position */
  78324. position: Vector3;
  78325. /** Gets or sets the main color */
  78326. color: Color4;
  78327. /** Gets or sets the width */
  78328. width: number;
  78329. /** Gets or sets the height */
  78330. height: number;
  78331. /** Gets or sets rotation angle */
  78332. angle: number;
  78333. /** Gets or sets the cell index in the sprite sheet */
  78334. cellIndex: number;
  78335. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78336. cellRef: string;
  78337. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78338. invertU: number;
  78339. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78340. invertV: number;
  78341. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78342. disposeWhenFinishedAnimating: boolean;
  78343. /** Gets the list of attached animations */
  78344. animations: Animation[];
  78345. /** Gets or sets a boolean indicating if the sprite can be picked */
  78346. isPickable: boolean;
  78347. /**
  78348. * Gets or sets the associated action manager
  78349. */
  78350. actionManager: Nullable<ActionManager>;
  78351. private _animationStarted;
  78352. private _loopAnimation;
  78353. private _fromIndex;
  78354. private _toIndex;
  78355. private _delay;
  78356. private _direction;
  78357. private _manager;
  78358. private _time;
  78359. private _onAnimationEnd;
  78360. /**
  78361. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78362. */
  78363. isVisible: boolean;
  78364. /**
  78365. * Gets or sets the sprite size
  78366. */
  78367. size: number;
  78368. /**
  78369. * Creates a new Sprite
  78370. * @param name defines the name
  78371. * @param manager defines the manager
  78372. */
  78373. constructor(
  78374. /** defines the name */
  78375. name: string, manager: ISpriteManager);
  78376. /**
  78377. * Starts an animation
  78378. * @param from defines the initial key
  78379. * @param to defines the end key
  78380. * @param loop defines if the animation must loop
  78381. * @param delay defines the start delay (in ms)
  78382. * @param onAnimationEnd defines a callback to call when animation ends
  78383. */
  78384. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78385. /** Stops current animation (if any) */
  78386. stopAnimation(): void;
  78387. /** @hidden */
  78388. _animate(deltaTime: number): void;
  78389. /** Release associated resources */
  78390. dispose(): void;
  78391. }
  78392. }
  78393. declare module BABYLON {
  78394. /**
  78395. * Information about the result of picking within a scene
  78396. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78397. */
  78398. export class PickingInfo {
  78399. /** @hidden */
  78400. _pickingUnavailable: boolean;
  78401. /**
  78402. * If the pick collided with an object
  78403. */
  78404. hit: boolean;
  78405. /**
  78406. * Distance away where the pick collided
  78407. */
  78408. distance: number;
  78409. /**
  78410. * The location of pick collision
  78411. */
  78412. pickedPoint: Nullable<Vector3>;
  78413. /**
  78414. * The mesh corresponding the the pick collision
  78415. */
  78416. pickedMesh: Nullable<AbstractMesh>;
  78417. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78418. bu: number;
  78419. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78420. bv: number;
  78421. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78422. faceId: number;
  78423. /** Id of the the submesh that was picked */
  78424. subMeshId: number;
  78425. /** If a sprite was picked, this will be the sprite the pick collided with */
  78426. pickedSprite: Nullable<Sprite>;
  78427. /**
  78428. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78429. */
  78430. originMesh: Nullable<AbstractMesh>;
  78431. /**
  78432. * The ray that was used to perform the picking.
  78433. */
  78434. ray: Nullable<Ray>;
  78435. /**
  78436. * Gets the normal correspodning to the face the pick collided with
  78437. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78438. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78439. * @returns The normal correspodning to the face the pick collided with
  78440. */
  78441. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78442. /**
  78443. * Gets the texture coordinates of where the pick occured
  78444. * @returns the vector containing the coordnates of the texture
  78445. */
  78446. getTextureCoordinates(): Nullable<Vector2>;
  78447. }
  78448. }
  78449. declare module BABYLON {
  78450. /**
  78451. * Gather the list of pointer event types as constants.
  78452. */
  78453. export class PointerEventTypes {
  78454. /**
  78455. * 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.
  78456. */
  78457. static readonly POINTERDOWN: number;
  78458. /**
  78459. * The pointerup event is fired when a pointer is no longer active.
  78460. */
  78461. static readonly POINTERUP: number;
  78462. /**
  78463. * The pointermove event is fired when a pointer changes coordinates.
  78464. */
  78465. static readonly POINTERMOVE: number;
  78466. /**
  78467. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78468. */
  78469. static readonly POINTERWHEEL: number;
  78470. /**
  78471. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78472. */
  78473. static readonly POINTERPICK: number;
  78474. /**
  78475. * The pointertap event is fired when a the object has been touched and released without drag.
  78476. */
  78477. static readonly POINTERTAP: number;
  78478. /**
  78479. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78480. */
  78481. static readonly POINTERDOUBLETAP: number;
  78482. }
  78483. /**
  78484. * Base class of pointer info types.
  78485. */
  78486. export class PointerInfoBase {
  78487. /**
  78488. * Defines the type of event (PointerEventTypes)
  78489. */
  78490. type: number;
  78491. /**
  78492. * Defines the related dom event
  78493. */
  78494. event: PointerEvent | MouseWheelEvent;
  78495. /**
  78496. * Instantiates the base class of pointers info.
  78497. * @param type Defines the type of event (PointerEventTypes)
  78498. * @param event Defines the related dom event
  78499. */
  78500. constructor(
  78501. /**
  78502. * Defines the type of event (PointerEventTypes)
  78503. */
  78504. type: number,
  78505. /**
  78506. * Defines the related dom event
  78507. */
  78508. event: PointerEvent | MouseWheelEvent);
  78509. }
  78510. /**
  78511. * This class is used to store pointer related info for the onPrePointerObservable event.
  78512. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78513. */
  78514. export class PointerInfoPre extends PointerInfoBase {
  78515. /**
  78516. * Ray from a pointer if availible (eg. 6dof controller)
  78517. */
  78518. ray: Nullable<Ray>;
  78519. /**
  78520. * Defines the local position of the pointer on the canvas.
  78521. */
  78522. localPosition: Vector2;
  78523. /**
  78524. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78525. */
  78526. skipOnPointerObservable: boolean;
  78527. /**
  78528. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78529. * @param type Defines the type of event (PointerEventTypes)
  78530. * @param event Defines the related dom event
  78531. * @param localX Defines the local x coordinates of the pointer when the event occured
  78532. * @param localY Defines the local y coordinates of the pointer when the event occured
  78533. */
  78534. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78535. }
  78536. /**
  78537. * This type contains all the data related to a pointer event in Babylon.js.
  78538. * 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.
  78539. */
  78540. export class PointerInfo extends PointerInfoBase {
  78541. /**
  78542. * Defines the picking info associated to the info (if any)\
  78543. */
  78544. pickInfo: Nullable<PickingInfo>;
  78545. /**
  78546. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78547. * @param type Defines the type of event (PointerEventTypes)
  78548. * @param event Defines the related dom event
  78549. * @param pickInfo Defines the picking info associated to the info (if any)\
  78550. */
  78551. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78552. /**
  78553. * Defines the picking info associated to the info (if any)\
  78554. */
  78555. pickInfo: Nullable<PickingInfo>);
  78556. }
  78557. /**
  78558. * Data relating to a touch event on the screen.
  78559. */
  78560. export interface PointerTouch {
  78561. /**
  78562. * X coordinate of touch.
  78563. */
  78564. x: number;
  78565. /**
  78566. * Y coordinate of touch.
  78567. */
  78568. y: number;
  78569. /**
  78570. * Id of touch. Unique for each finger.
  78571. */
  78572. pointerId: number;
  78573. /**
  78574. * Event type passed from DOM.
  78575. */
  78576. type: any;
  78577. }
  78578. }
  78579. declare module BABYLON {
  78580. /**
  78581. * Manage the mouse inputs to control the movement of a free camera.
  78582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78583. */
  78584. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78585. /**
  78586. * Define if touch is enabled in the mouse input
  78587. */
  78588. touchEnabled: boolean;
  78589. /**
  78590. * Defines the camera the input is attached to.
  78591. */
  78592. camera: FreeCamera;
  78593. /**
  78594. * Defines the buttons associated with the input to handle camera move.
  78595. */
  78596. buttons: number[];
  78597. /**
  78598. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78599. */
  78600. angularSensibility: number;
  78601. private _pointerInput;
  78602. private _onMouseMove;
  78603. private _observer;
  78604. private previousPosition;
  78605. /**
  78606. * Observable for when a pointer move event occurs containing the move offset
  78607. */
  78608. onPointerMovedObservable: Observable<{
  78609. offsetX: number;
  78610. offsetY: number;
  78611. }>;
  78612. /**
  78613. * @hidden
  78614. * If the camera should be rotated automatically based on pointer movement
  78615. */
  78616. _allowCameraRotation: boolean;
  78617. /**
  78618. * Manage the mouse inputs to control the movement of a free camera.
  78619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78620. * @param touchEnabled Defines if touch is enabled or not
  78621. */
  78622. constructor(
  78623. /**
  78624. * Define if touch is enabled in the mouse input
  78625. */
  78626. touchEnabled?: boolean);
  78627. /**
  78628. * Attach the input controls to a specific dom element to get the input from.
  78629. * @param element Defines the element the controls should be listened from
  78630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78631. */
  78632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78633. /**
  78634. * Called on JS contextmenu event.
  78635. * Override this method to provide functionality.
  78636. */
  78637. protected onContextMenu(evt: PointerEvent): void;
  78638. /**
  78639. * Detach the current controls from the specified dom element.
  78640. * @param element Defines the element to stop listening the inputs from
  78641. */
  78642. detachControl(element: Nullable<HTMLElement>): void;
  78643. /**
  78644. * Gets the class name of the current intput.
  78645. * @returns the class name
  78646. */
  78647. getClassName(): string;
  78648. /**
  78649. * Get the friendly name associated with the input class.
  78650. * @returns the input friendly name
  78651. */
  78652. getSimpleName(): string;
  78653. }
  78654. }
  78655. declare module BABYLON {
  78656. /**
  78657. * Manage the touch inputs to control the movement of a free camera.
  78658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78659. */
  78660. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78661. /**
  78662. * Defines the camera the input is attached to.
  78663. */
  78664. camera: FreeCamera;
  78665. /**
  78666. * Defines the touch sensibility for rotation.
  78667. * The higher the faster.
  78668. */
  78669. touchAngularSensibility: number;
  78670. /**
  78671. * Defines the touch sensibility for move.
  78672. * The higher the faster.
  78673. */
  78674. touchMoveSensibility: number;
  78675. private _offsetX;
  78676. private _offsetY;
  78677. private _pointerPressed;
  78678. private _pointerInput;
  78679. private _observer;
  78680. private _onLostFocus;
  78681. /**
  78682. * Attach the input controls to a specific dom element to get the input from.
  78683. * @param element Defines the element the controls should be listened from
  78684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78685. */
  78686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78687. /**
  78688. * Detach the current controls from the specified dom element.
  78689. * @param element Defines the element to stop listening the inputs from
  78690. */
  78691. detachControl(element: Nullable<HTMLElement>): void;
  78692. /**
  78693. * Update the current camera state depending on the inputs that have been used this frame.
  78694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78695. */
  78696. checkInputs(): void;
  78697. /**
  78698. * Gets the class name of the current intput.
  78699. * @returns the class name
  78700. */
  78701. getClassName(): string;
  78702. /**
  78703. * Get the friendly name associated with the input class.
  78704. * @returns the input friendly name
  78705. */
  78706. getSimpleName(): string;
  78707. }
  78708. }
  78709. declare module BABYLON {
  78710. /**
  78711. * Default Inputs manager for the FreeCamera.
  78712. * It groups all the default supported inputs for ease of use.
  78713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78714. */
  78715. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78716. /**
  78717. * @hidden
  78718. */
  78719. _mouseInput: Nullable<FreeCameraMouseInput>;
  78720. /**
  78721. * Instantiates a new FreeCameraInputsManager.
  78722. * @param camera Defines the camera the inputs belong to
  78723. */
  78724. constructor(camera: FreeCamera);
  78725. /**
  78726. * Add keyboard input support to the input manager.
  78727. * @returns the current input manager
  78728. */
  78729. addKeyboard(): FreeCameraInputsManager;
  78730. /**
  78731. * Add mouse input support to the input manager.
  78732. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78733. * @returns the current input manager
  78734. */
  78735. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78736. /**
  78737. * Removes the mouse input support from the manager
  78738. * @returns the current input manager
  78739. */
  78740. removeMouse(): FreeCameraInputsManager;
  78741. /**
  78742. * Add touch input support to the input manager.
  78743. * @returns the current input manager
  78744. */
  78745. addTouch(): FreeCameraInputsManager;
  78746. /**
  78747. * Remove all attached input methods from a camera
  78748. */
  78749. clear(): void;
  78750. }
  78751. }
  78752. declare module BABYLON {
  78753. /**
  78754. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78755. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78757. */
  78758. export class FreeCamera extends TargetCamera {
  78759. /**
  78760. * Define the collision ellipsoid of the camera.
  78761. * This is helpful to simulate a camera body like the player body around the camera
  78762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78763. */
  78764. ellipsoid: Vector3;
  78765. /**
  78766. * Define an offset for the position of the ellipsoid around the camera.
  78767. * This can be helpful to determine the center of the body near the gravity center of the body
  78768. * instead of its head.
  78769. */
  78770. ellipsoidOffset: Vector3;
  78771. /**
  78772. * Enable or disable collisions of the camera with the rest of the scene objects.
  78773. */
  78774. checkCollisions: boolean;
  78775. /**
  78776. * Enable or disable gravity on the camera.
  78777. */
  78778. applyGravity: boolean;
  78779. /**
  78780. * Define the input manager associated to the camera.
  78781. */
  78782. inputs: FreeCameraInputsManager;
  78783. /**
  78784. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78785. * Higher values reduce sensitivity.
  78786. */
  78787. /**
  78788. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78789. * Higher values reduce sensitivity.
  78790. */
  78791. angularSensibility: number;
  78792. /**
  78793. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78794. */
  78795. keysUp: number[];
  78796. /**
  78797. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78798. */
  78799. keysDown: number[];
  78800. /**
  78801. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78802. */
  78803. keysLeft: number[];
  78804. /**
  78805. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78806. */
  78807. keysRight: number[];
  78808. /**
  78809. * Event raised when the camera collide with a mesh in the scene.
  78810. */
  78811. onCollide: (collidedMesh: AbstractMesh) => void;
  78812. private _collider;
  78813. private _needMoveForGravity;
  78814. private _oldPosition;
  78815. private _diffPosition;
  78816. private _newPosition;
  78817. /** @hidden */
  78818. _localDirection: Vector3;
  78819. /** @hidden */
  78820. _transformedDirection: Vector3;
  78821. /**
  78822. * Instantiates a Free Camera.
  78823. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78824. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78826. * @param name Define the name of the camera in the scene
  78827. * @param position Define the start position of the camera in the scene
  78828. * @param scene Define the scene the camera belongs to
  78829. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78830. */
  78831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78832. /**
  78833. * Attached controls to the current camera.
  78834. * @param element Defines the element the controls should be listened from
  78835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78836. */
  78837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78838. /**
  78839. * Detach the current controls from the camera.
  78840. * The camera will stop reacting to inputs.
  78841. * @param element Defines the element to stop listening the inputs from
  78842. */
  78843. detachControl(element: HTMLElement): void;
  78844. private _collisionMask;
  78845. /**
  78846. * Define a collision mask to limit the list of object the camera can collide with
  78847. */
  78848. collisionMask: number;
  78849. /** @hidden */
  78850. _collideWithWorld(displacement: Vector3): void;
  78851. private _onCollisionPositionChange;
  78852. /** @hidden */
  78853. _checkInputs(): void;
  78854. /** @hidden */
  78855. _decideIfNeedsToMove(): boolean;
  78856. /** @hidden */
  78857. _updatePosition(): void;
  78858. /**
  78859. * Destroy the camera and release the current resources hold by it.
  78860. */
  78861. dispose(): void;
  78862. /**
  78863. * Gets the current object class name.
  78864. * @return the class name
  78865. */
  78866. getClassName(): string;
  78867. }
  78868. }
  78869. declare module BABYLON {
  78870. /**
  78871. * Represents a gamepad control stick position
  78872. */
  78873. export class StickValues {
  78874. /**
  78875. * The x component of the control stick
  78876. */
  78877. x: number;
  78878. /**
  78879. * The y component of the control stick
  78880. */
  78881. y: number;
  78882. /**
  78883. * Initializes the gamepad x and y control stick values
  78884. * @param x The x component of the gamepad control stick value
  78885. * @param y The y component of the gamepad control stick value
  78886. */
  78887. constructor(
  78888. /**
  78889. * The x component of the control stick
  78890. */
  78891. x: number,
  78892. /**
  78893. * The y component of the control stick
  78894. */
  78895. y: number);
  78896. }
  78897. /**
  78898. * An interface which manages callbacks for gamepad button changes
  78899. */
  78900. export interface GamepadButtonChanges {
  78901. /**
  78902. * Called when a gamepad has been changed
  78903. */
  78904. changed: boolean;
  78905. /**
  78906. * Called when a gamepad press event has been triggered
  78907. */
  78908. pressChanged: boolean;
  78909. /**
  78910. * Called when a touch event has been triggered
  78911. */
  78912. touchChanged: boolean;
  78913. /**
  78914. * Called when a value has changed
  78915. */
  78916. valueChanged: boolean;
  78917. }
  78918. /**
  78919. * Represents a gamepad
  78920. */
  78921. export class Gamepad {
  78922. /**
  78923. * The id of the gamepad
  78924. */
  78925. id: string;
  78926. /**
  78927. * The index of the gamepad
  78928. */
  78929. index: number;
  78930. /**
  78931. * The browser gamepad
  78932. */
  78933. browserGamepad: any;
  78934. /**
  78935. * Specifies what type of gamepad this represents
  78936. */
  78937. type: number;
  78938. private _leftStick;
  78939. private _rightStick;
  78940. /** @hidden */
  78941. _isConnected: boolean;
  78942. private _leftStickAxisX;
  78943. private _leftStickAxisY;
  78944. private _rightStickAxisX;
  78945. private _rightStickAxisY;
  78946. /**
  78947. * Triggered when the left control stick has been changed
  78948. */
  78949. private _onleftstickchanged;
  78950. /**
  78951. * Triggered when the right control stick has been changed
  78952. */
  78953. private _onrightstickchanged;
  78954. /**
  78955. * Represents a gamepad controller
  78956. */
  78957. static GAMEPAD: number;
  78958. /**
  78959. * Represents a generic controller
  78960. */
  78961. static GENERIC: number;
  78962. /**
  78963. * Represents an XBox controller
  78964. */
  78965. static XBOX: number;
  78966. /**
  78967. * Represents a pose-enabled controller
  78968. */
  78969. static POSE_ENABLED: number;
  78970. /**
  78971. * Represents an Dual Shock controller
  78972. */
  78973. static DUALSHOCK: number;
  78974. /**
  78975. * Specifies whether the left control stick should be Y-inverted
  78976. */
  78977. protected _invertLeftStickY: boolean;
  78978. /**
  78979. * Specifies if the gamepad has been connected
  78980. */
  78981. readonly isConnected: boolean;
  78982. /**
  78983. * Initializes the gamepad
  78984. * @param id The id of the gamepad
  78985. * @param index The index of the gamepad
  78986. * @param browserGamepad The browser gamepad
  78987. * @param leftStickX The x component of the left joystick
  78988. * @param leftStickY The y component of the left joystick
  78989. * @param rightStickX The x component of the right joystick
  78990. * @param rightStickY The y component of the right joystick
  78991. */
  78992. constructor(
  78993. /**
  78994. * The id of the gamepad
  78995. */
  78996. id: string,
  78997. /**
  78998. * The index of the gamepad
  78999. */
  79000. index: number,
  79001. /**
  79002. * The browser gamepad
  79003. */
  79004. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79005. /**
  79006. * Callback triggered when the left joystick has changed
  79007. * @param callback
  79008. */
  79009. onleftstickchanged(callback: (values: StickValues) => void): void;
  79010. /**
  79011. * Callback triggered when the right joystick has changed
  79012. * @param callback
  79013. */
  79014. onrightstickchanged(callback: (values: StickValues) => void): void;
  79015. /**
  79016. * Gets the left joystick
  79017. */
  79018. /**
  79019. * Sets the left joystick values
  79020. */
  79021. leftStick: StickValues;
  79022. /**
  79023. * Gets the right joystick
  79024. */
  79025. /**
  79026. * Sets the right joystick value
  79027. */
  79028. rightStick: StickValues;
  79029. /**
  79030. * Updates the gamepad joystick positions
  79031. */
  79032. update(): void;
  79033. /**
  79034. * Disposes the gamepad
  79035. */
  79036. dispose(): void;
  79037. }
  79038. /**
  79039. * Represents a generic gamepad
  79040. */
  79041. export class GenericPad extends Gamepad {
  79042. private _buttons;
  79043. private _onbuttondown;
  79044. private _onbuttonup;
  79045. /**
  79046. * Observable triggered when a button has been pressed
  79047. */
  79048. onButtonDownObservable: Observable<number>;
  79049. /**
  79050. * Observable triggered when a button has been released
  79051. */
  79052. onButtonUpObservable: Observable<number>;
  79053. /**
  79054. * Callback triggered when a button has been pressed
  79055. * @param callback Called when a button has been pressed
  79056. */
  79057. onbuttondown(callback: (buttonPressed: number) => void): void;
  79058. /**
  79059. * Callback triggered when a button has been released
  79060. * @param callback Called when a button has been released
  79061. */
  79062. onbuttonup(callback: (buttonReleased: number) => void): void;
  79063. /**
  79064. * Initializes the generic gamepad
  79065. * @param id The id of the generic gamepad
  79066. * @param index The index of the generic gamepad
  79067. * @param browserGamepad The browser gamepad
  79068. */
  79069. constructor(id: string, index: number, browserGamepad: any);
  79070. private _setButtonValue;
  79071. /**
  79072. * Updates the generic gamepad
  79073. */
  79074. update(): void;
  79075. /**
  79076. * Disposes the generic gamepad
  79077. */
  79078. dispose(): void;
  79079. }
  79080. }
  79081. declare module BABYLON {
  79082. interface Engine {
  79083. /**
  79084. * Creates a raw texture
  79085. * @param data defines the data to store in the texture
  79086. * @param width defines the width of the texture
  79087. * @param height defines the height of the texture
  79088. * @param format defines the format of the data
  79089. * @param generateMipMaps defines if the engine should generate the mip levels
  79090. * @param invertY defines if data must be stored with Y axis inverted
  79091. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79092. * @param compression defines the compression used (null by default)
  79093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79094. * @returns the raw texture inside an InternalTexture
  79095. */
  79096. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79097. /**
  79098. * Update a raw texture
  79099. * @param texture defines the texture to update
  79100. * @param data defines the data to store in the texture
  79101. * @param format defines the format of the data
  79102. * @param invertY defines if data must be stored with Y axis inverted
  79103. */
  79104. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79105. /**
  79106. * Update a raw texture
  79107. * @param texture defines the texture to update
  79108. * @param data defines the data to store in the texture
  79109. * @param format defines the format of the data
  79110. * @param invertY defines if data must be stored with Y axis inverted
  79111. * @param compression defines the compression used (null by default)
  79112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79113. */
  79114. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79115. /**
  79116. * Creates a new raw cube texture
  79117. * @param data defines the array of data to use to create each face
  79118. * @param size defines the size of the textures
  79119. * @param format defines the format of the data
  79120. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79121. * @param generateMipMaps defines if the engine should generate the mip levels
  79122. * @param invertY defines if data must be stored with Y axis inverted
  79123. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79124. * @param compression defines the compression used (null by default)
  79125. * @returns the cube texture as an InternalTexture
  79126. */
  79127. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79128. /**
  79129. * Update a raw cube texture
  79130. * @param texture defines the texture to udpdate
  79131. * @param data defines the data to store
  79132. * @param format defines the data format
  79133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79134. * @param invertY defines if data must be stored with Y axis inverted
  79135. */
  79136. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79137. /**
  79138. * Update a raw cube texture
  79139. * @param texture defines the texture to udpdate
  79140. * @param data defines the data to store
  79141. * @param format defines the data format
  79142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79143. * @param invertY defines if data must be stored with Y axis inverted
  79144. * @param compression defines the compression used (null by default)
  79145. */
  79146. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79147. /**
  79148. * Update a raw cube texture
  79149. * @param texture defines the texture to udpdate
  79150. * @param data defines the data to store
  79151. * @param format defines the data format
  79152. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79153. * @param invertY defines if data must be stored with Y axis inverted
  79154. * @param compression defines the compression used (null by default)
  79155. * @param level defines which level of the texture to update
  79156. */
  79157. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79158. /**
  79159. * Creates a new raw cube texture from a specified url
  79160. * @param url defines the url where the data is located
  79161. * @param scene defines the current scene
  79162. * @param size defines the size of the textures
  79163. * @param format defines the format of the data
  79164. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79165. * @param noMipmap defines if the engine should avoid generating the mip levels
  79166. * @param callback defines a callback used to extract texture data from loaded data
  79167. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79168. * @param onLoad defines a callback called when texture is loaded
  79169. * @param onError defines a callback called if there is an error
  79170. * @returns the cube texture as an InternalTexture
  79171. */
  79172. 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;
  79173. /**
  79174. * Creates a new raw cube texture from a specified url
  79175. * @param url defines the url where the data is located
  79176. * @param scene defines the current scene
  79177. * @param size defines the size of the textures
  79178. * @param format defines the format of the data
  79179. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79180. * @param noMipmap defines if the engine should avoid generating the mip levels
  79181. * @param callback defines a callback used to extract texture data from loaded data
  79182. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79183. * @param onLoad defines a callback called when texture is loaded
  79184. * @param onError defines a callback called if there is an error
  79185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79186. * @param invertY defines if data must be stored with Y axis inverted
  79187. * @returns the cube texture as an InternalTexture
  79188. */
  79189. 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;
  79190. /**
  79191. * Creates a new raw 3D texture
  79192. * @param data defines the data used to create the texture
  79193. * @param width defines the width of the texture
  79194. * @param height defines the height of the texture
  79195. * @param depth defines the depth of the texture
  79196. * @param format defines the format of the texture
  79197. * @param generateMipMaps defines if the engine must generate mip levels
  79198. * @param invertY defines if data must be stored with Y axis inverted
  79199. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79200. * @param compression defines the compressed used (can be null)
  79201. * @param textureType defines the compressed used (can be null)
  79202. * @returns a new raw 3D texture (stored in an InternalTexture)
  79203. */
  79204. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79205. /**
  79206. * Update a raw 3D texture
  79207. * @param texture defines the texture to update
  79208. * @param data defines the data to store
  79209. * @param format defines the data format
  79210. * @param invertY defines if data must be stored with Y axis inverted
  79211. */
  79212. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79213. /**
  79214. * Update a raw 3D texture
  79215. * @param texture defines the texture to update
  79216. * @param data defines the data to store
  79217. * @param format defines the data format
  79218. * @param invertY defines if data must be stored with Y axis inverted
  79219. * @param compression defines the used compression (can be null)
  79220. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79221. */
  79222. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79223. }
  79224. }
  79225. declare module BABYLON {
  79226. /**
  79227. * Raw texture can help creating a texture directly from an array of data.
  79228. * This can be super useful if you either get the data from an uncompressed source or
  79229. * if you wish to create your texture pixel by pixel.
  79230. */
  79231. export class RawTexture extends Texture {
  79232. /**
  79233. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79234. */
  79235. format: number;
  79236. private _engine;
  79237. /**
  79238. * Instantiates a new RawTexture.
  79239. * Raw texture can help creating a texture directly from an array of data.
  79240. * This can be super useful if you either get the data from an uncompressed source or
  79241. * if you wish to create your texture pixel by pixel.
  79242. * @param data define the array of data to use to create the texture
  79243. * @param width define the width of the texture
  79244. * @param height define the height of the texture
  79245. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79246. * @param scene define the scene the texture belongs to
  79247. * @param generateMipMaps define whether mip maps should be generated or not
  79248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79250. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79251. */
  79252. constructor(data: ArrayBufferView, width: number, height: number,
  79253. /**
  79254. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79255. */
  79256. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79257. /**
  79258. * Updates the texture underlying data.
  79259. * @param data Define the new data of the texture
  79260. */
  79261. update(data: ArrayBufferView): void;
  79262. /**
  79263. * Creates a luminance texture from some data.
  79264. * @param data Define the texture data
  79265. * @param width Define the width of the texture
  79266. * @param height Define the height of the texture
  79267. * @param scene Define the scene the texture belongs to
  79268. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79269. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79270. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79271. * @returns the luminance texture
  79272. */
  79273. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79274. /**
  79275. * Creates a luminance alpha texture from some data.
  79276. * @param data Define the texture data
  79277. * @param width Define the width of the texture
  79278. * @param height Define the height of the texture
  79279. * @param scene Define the scene the texture belongs to
  79280. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79283. * @returns the luminance alpha texture
  79284. */
  79285. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79286. /**
  79287. * Creates an alpha texture from some data.
  79288. * @param data Define the texture data
  79289. * @param width Define the width of the texture
  79290. * @param height Define the height of the texture
  79291. * @param scene Define the scene the texture belongs to
  79292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79295. * @returns the alpha texture
  79296. */
  79297. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79298. /**
  79299. * Creates a RGB texture from some data.
  79300. * @param data Define the texture data
  79301. * @param width Define the width of the texture
  79302. * @param height Define the height of the texture
  79303. * @param scene Define the scene the texture belongs to
  79304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79307. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79308. * @returns the RGB alpha texture
  79309. */
  79310. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79311. /**
  79312. * Creates a RGBA texture from some data.
  79313. * @param data Define the texture data
  79314. * @param width Define the width of the texture
  79315. * @param height Define the height of the texture
  79316. * @param scene Define the scene the texture belongs to
  79317. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79318. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79319. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79320. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79321. * @returns the RGBA texture
  79322. */
  79323. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79324. /**
  79325. * Creates a R texture from some data.
  79326. * @param data Define the texture data
  79327. * @param width Define the width of the texture
  79328. * @param height Define the height of the texture
  79329. * @param scene Define the scene the texture belongs to
  79330. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79331. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79332. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79333. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79334. * @returns the R texture
  79335. */
  79336. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79337. }
  79338. }
  79339. declare module BABYLON {
  79340. /**
  79341. * Interface for the size containing width and height
  79342. */
  79343. export interface ISize {
  79344. /**
  79345. * Width
  79346. */
  79347. width: number;
  79348. /**
  79349. * Heighht
  79350. */
  79351. height: number;
  79352. }
  79353. /**
  79354. * Size containing widht and height
  79355. */
  79356. export class Size implements ISize {
  79357. /**
  79358. * Width
  79359. */
  79360. width: number;
  79361. /**
  79362. * Height
  79363. */
  79364. height: number;
  79365. /**
  79366. * Creates a Size object from the given width and height (floats).
  79367. * @param width width of the new size
  79368. * @param height height of the new size
  79369. */
  79370. constructor(width: number, height: number);
  79371. /**
  79372. * Returns a string with the Size width and height
  79373. * @returns a string with the Size width and height
  79374. */
  79375. toString(): string;
  79376. /**
  79377. * "Size"
  79378. * @returns the string "Size"
  79379. */
  79380. getClassName(): string;
  79381. /**
  79382. * Returns the Size hash code.
  79383. * @returns a hash code for a unique width and height
  79384. */
  79385. getHashCode(): number;
  79386. /**
  79387. * Updates the current size from the given one.
  79388. * @param src the given size
  79389. */
  79390. copyFrom(src: Size): void;
  79391. /**
  79392. * Updates in place the current Size from the given floats.
  79393. * @param width width of the new size
  79394. * @param height height of the new size
  79395. * @returns the updated Size.
  79396. */
  79397. copyFromFloats(width: number, height: number): Size;
  79398. /**
  79399. * Updates in place the current Size from the given floats.
  79400. * @param width width to set
  79401. * @param height height to set
  79402. * @returns the updated Size.
  79403. */
  79404. set(width: number, height: number): Size;
  79405. /**
  79406. * Multiplies the width and height by numbers
  79407. * @param w factor to multiple the width by
  79408. * @param h factor to multiple the height by
  79409. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79410. */
  79411. multiplyByFloats(w: number, h: number): Size;
  79412. /**
  79413. * Clones the size
  79414. * @returns a new Size copied from the given one.
  79415. */
  79416. clone(): Size;
  79417. /**
  79418. * True if the current Size and the given one width and height are strictly equal.
  79419. * @param other the other size to compare against
  79420. * @returns True if the current Size and the given one width and height are strictly equal.
  79421. */
  79422. equals(other: Size): boolean;
  79423. /**
  79424. * The surface of the Size : width * height (float).
  79425. */
  79426. readonly surface: number;
  79427. /**
  79428. * Create a new size of zero
  79429. * @returns a new Size set to (0.0, 0.0)
  79430. */
  79431. static Zero(): Size;
  79432. /**
  79433. * Sums the width and height of two sizes
  79434. * @param otherSize size to add to this size
  79435. * @returns a new Size set as the addition result of the current Size and the given one.
  79436. */
  79437. add(otherSize: Size): Size;
  79438. /**
  79439. * Subtracts the width and height of two
  79440. * @param otherSize size to subtract to this size
  79441. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79442. */
  79443. subtract(otherSize: Size): Size;
  79444. /**
  79445. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79446. * @param start starting size to lerp between
  79447. * @param end end size to lerp between
  79448. * @param amount amount to lerp between the start and end values
  79449. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79450. */
  79451. static Lerp(start: Size, end: Size, amount: number): Size;
  79452. }
  79453. }
  79454. declare module BABYLON {
  79455. /**
  79456. * Defines a runtime animation
  79457. */
  79458. export class RuntimeAnimation {
  79459. private _events;
  79460. /**
  79461. * The current frame of the runtime animation
  79462. */
  79463. private _currentFrame;
  79464. /**
  79465. * The animation used by the runtime animation
  79466. */
  79467. private _animation;
  79468. /**
  79469. * The target of the runtime animation
  79470. */
  79471. private _target;
  79472. /**
  79473. * The initiating animatable
  79474. */
  79475. private _host;
  79476. /**
  79477. * The original value of the runtime animation
  79478. */
  79479. private _originalValue;
  79480. /**
  79481. * The original blend value of the runtime animation
  79482. */
  79483. private _originalBlendValue;
  79484. /**
  79485. * The offsets cache of the runtime animation
  79486. */
  79487. private _offsetsCache;
  79488. /**
  79489. * The high limits cache of the runtime animation
  79490. */
  79491. private _highLimitsCache;
  79492. /**
  79493. * Specifies if the runtime animation has been stopped
  79494. */
  79495. private _stopped;
  79496. /**
  79497. * The blending factor of the runtime animation
  79498. */
  79499. private _blendingFactor;
  79500. /**
  79501. * The BabylonJS scene
  79502. */
  79503. private _scene;
  79504. /**
  79505. * The current value of the runtime animation
  79506. */
  79507. private _currentValue;
  79508. /** @hidden */
  79509. _animationState: _IAnimationState;
  79510. /**
  79511. * The active target of the runtime animation
  79512. */
  79513. private _activeTargets;
  79514. private _currentActiveTarget;
  79515. private _directTarget;
  79516. /**
  79517. * The target path of the runtime animation
  79518. */
  79519. private _targetPath;
  79520. /**
  79521. * The weight of the runtime animation
  79522. */
  79523. private _weight;
  79524. /**
  79525. * The ratio offset of the runtime animation
  79526. */
  79527. private _ratioOffset;
  79528. /**
  79529. * The previous delay of the runtime animation
  79530. */
  79531. private _previousDelay;
  79532. /**
  79533. * The previous ratio of the runtime animation
  79534. */
  79535. private _previousRatio;
  79536. private _enableBlending;
  79537. private _keys;
  79538. private _minFrame;
  79539. private _maxFrame;
  79540. private _minValue;
  79541. private _maxValue;
  79542. private _targetIsArray;
  79543. /**
  79544. * Gets the current frame of the runtime animation
  79545. */
  79546. readonly currentFrame: number;
  79547. /**
  79548. * Gets the weight of the runtime animation
  79549. */
  79550. readonly weight: number;
  79551. /**
  79552. * Gets the current value of the runtime animation
  79553. */
  79554. readonly currentValue: any;
  79555. /**
  79556. * Gets the target path of the runtime animation
  79557. */
  79558. readonly targetPath: string;
  79559. /**
  79560. * Gets the actual target of the runtime animation
  79561. */
  79562. readonly target: any;
  79563. /** @hidden */
  79564. _onLoop: () => void;
  79565. /**
  79566. * Create a new RuntimeAnimation object
  79567. * @param target defines the target of the animation
  79568. * @param animation defines the source animation object
  79569. * @param scene defines the hosting scene
  79570. * @param host defines the initiating Animatable
  79571. */
  79572. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79573. private _preparePath;
  79574. /**
  79575. * Gets the animation from the runtime animation
  79576. */
  79577. readonly animation: Animation;
  79578. /**
  79579. * Resets the runtime animation to the beginning
  79580. * @param restoreOriginal defines whether to restore the target property to the original value
  79581. */
  79582. reset(restoreOriginal?: boolean): void;
  79583. /**
  79584. * Specifies if the runtime animation is stopped
  79585. * @returns Boolean specifying if the runtime animation is stopped
  79586. */
  79587. isStopped(): boolean;
  79588. /**
  79589. * Disposes of the runtime animation
  79590. */
  79591. dispose(): void;
  79592. /**
  79593. * Apply the interpolated value to the target
  79594. * @param currentValue defines the value computed by the animation
  79595. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79596. */
  79597. setValue(currentValue: any, weight: number): void;
  79598. private _getOriginalValues;
  79599. private _setValue;
  79600. /**
  79601. * Gets the loop pmode of the runtime animation
  79602. * @returns Loop Mode
  79603. */
  79604. private _getCorrectLoopMode;
  79605. /**
  79606. * Move the current animation to a given frame
  79607. * @param frame defines the frame to move to
  79608. */
  79609. goToFrame(frame: number): void;
  79610. /**
  79611. * @hidden Internal use only
  79612. */
  79613. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79614. /**
  79615. * Execute the current animation
  79616. * @param delay defines the delay to add to the current frame
  79617. * @param from defines the lower bound of the animation range
  79618. * @param to defines the upper bound of the animation range
  79619. * @param loop defines if the current animation must loop
  79620. * @param speedRatio defines the current speed ratio
  79621. * @param weight defines the weight of the animation (default is -1 so no weight)
  79622. * @param onLoop optional callback called when animation loops
  79623. * @returns a boolean indicating if the animation is running
  79624. */
  79625. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79626. }
  79627. }
  79628. declare module BABYLON {
  79629. /**
  79630. * Class used to store an actual running animation
  79631. */
  79632. export class Animatable {
  79633. /** defines the target object */
  79634. target: any;
  79635. /** defines the starting frame number (default is 0) */
  79636. fromFrame: number;
  79637. /** defines the ending frame number (default is 100) */
  79638. toFrame: number;
  79639. /** defines if the animation must loop (default is false) */
  79640. loopAnimation: boolean;
  79641. /** defines a callback to call when animation ends if it is not looping */
  79642. onAnimationEnd?: (() => void) | null | undefined;
  79643. /** defines a callback to call when animation loops */
  79644. onAnimationLoop?: (() => void) | null | undefined;
  79645. private _localDelayOffset;
  79646. private _pausedDelay;
  79647. private _runtimeAnimations;
  79648. private _paused;
  79649. private _scene;
  79650. private _speedRatio;
  79651. private _weight;
  79652. private _syncRoot;
  79653. /**
  79654. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79655. * This will only apply for non looping animation (default is true)
  79656. */
  79657. disposeOnEnd: boolean;
  79658. /**
  79659. * Gets a boolean indicating if the animation has started
  79660. */
  79661. animationStarted: boolean;
  79662. /**
  79663. * Observer raised when the animation ends
  79664. */
  79665. onAnimationEndObservable: Observable<Animatable>;
  79666. /**
  79667. * Observer raised when the animation loops
  79668. */
  79669. onAnimationLoopObservable: Observable<Animatable>;
  79670. /**
  79671. * Gets the root Animatable used to synchronize and normalize animations
  79672. */
  79673. readonly syncRoot: Nullable<Animatable>;
  79674. /**
  79675. * Gets the current frame of the first RuntimeAnimation
  79676. * Used to synchronize Animatables
  79677. */
  79678. readonly masterFrame: number;
  79679. /**
  79680. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79681. */
  79682. weight: number;
  79683. /**
  79684. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79685. */
  79686. speedRatio: number;
  79687. /**
  79688. * Creates a new Animatable
  79689. * @param scene defines the hosting scene
  79690. * @param target defines the target object
  79691. * @param fromFrame defines the starting frame number (default is 0)
  79692. * @param toFrame defines the ending frame number (default is 100)
  79693. * @param loopAnimation defines if the animation must loop (default is false)
  79694. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79695. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79696. * @param animations defines a group of animation to add to the new Animatable
  79697. * @param onAnimationLoop defines a callback to call when animation loops
  79698. */
  79699. constructor(scene: Scene,
  79700. /** defines the target object */
  79701. target: any,
  79702. /** defines the starting frame number (default is 0) */
  79703. fromFrame?: number,
  79704. /** defines the ending frame number (default is 100) */
  79705. toFrame?: number,
  79706. /** defines if the animation must loop (default is false) */
  79707. loopAnimation?: boolean, speedRatio?: number,
  79708. /** defines a callback to call when animation ends if it is not looping */
  79709. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79710. /** defines a callback to call when animation loops */
  79711. onAnimationLoop?: (() => void) | null | undefined);
  79712. /**
  79713. * Synchronize and normalize current Animatable with a source Animatable
  79714. * This is useful when using animation weights and when animations are not of the same length
  79715. * @param root defines the root Animatable to synchronize with
  79716. * @returns the current Animatable
  79717. */
  79718. syncWith(root: Animatable): Animatable;
  79719. /**
  79720. * Gets the list of runtime animations
  79721. * @returns an array of RuntimeAnimation
  79722. */
  79723. getAnimations(): RuntimeAnimation[];
  79724. /**
  79725. * Adds more animations to the current animatable
  79726. * @param target defines the target of the animations
  79727. * @param animations defines the new animations to add
  79728. */
  79729. appendAnimations(target: any, animations: Animation[]): void;
  79730. /**
  79731. * Gets the source animation for a specific property
  79732. * @param property defines the propertyu to look for
  79733. * @returns null or the source animation for the given property
  79734. */
  79735. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79736. /**
  79737. * Gets the runtime animation for a specific property
  79738. * @param property defines the propertyu to look for
  79739. * @returns null or the runtime animation for the given property
  79740. */
  79741. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79742. /**
  79743. * Resets the animatable to its original state
  79744. */
  79745. reset(): void;
  79746. /**
  79747. * Allows the animatable to blend with current running animations
  79748. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79749. * @param blendingSpeed defines the blending speed to use
  79750. */
  79751. enableBlending(blendingSpeed: number): void;
  79752. /**
  79753. * Disable animation blending
  79754. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79755. */
  79756. disableBlending(): void;
  79757. /**
  79758. * Jump directly to a given frame
  79759. * @param frame defines the frame to jump to
  79760. */
  79761. goToFrame(frame: number): void;
  79762. /**
  79763. * Pause the animation
  79764. */
  79765. pause(): void;
  79766. /**
  79767. * Restart the animation
  79768. */
  79769. restart(): void;
  79770. private _raiseOnAnimationEnd;
  79771. /**
  79772. * Stop and delete the current animation
  79773. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79774. * @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)
  79775. */
  79776. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79777. /**
  79778. * Wait asynchronously for the animation to end
  79779. * @returns a promise which will be fullfilled when the animation ends
  79780. */
  79781. waitAsync(): Promise<Animatable>;
  79782. /** @hidden */
  79783. _animate(delay: number): boolean;
  79784. }
  79785. interface Scene {
  79786. /** @hidden */
  79787. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79788. /** @hidden */
  79789. _processLateAnimationBindingsForMatrices(holder: {
  79790. totalWeight: number;
  79791. animations: RuntimeAnimation[];
  79792. originalValue: Matrix;
  79793. }): any;
  79794. /** @hidden */
  79795. _processLateAnimationBindingsForQuaternions(holder: {
  79796. totalWeight: number;
  79797. animations: RuntimeAnimation[];
  79798. originalValue: Quaternion;
  79799. }, refQuaternion: Quaternion): Quaternion;
  79800. /** @hidden */
  79801. _processLateAnimationBindings(): void;
  79802. /**
  79803. * Will start the animation sequence of a given target
  79804. * @param target defines the target
  79805. * @param from defines from which frame should animation start
  79806. * @param to defines until which frame should animation run.
  79807. * @param weight defines the weight to apply to the animation (1.0 by default)
  79808. * @param loop defines if the animation loops
  79809. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79810. * @param onAnimationEnd defines the function to be executed when the animation ends
  79811. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79812. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79813. * @param onAnimationLoop defines the callback to call when an animation loops
  79814. * @returns the animatable object created for this animation
  79815. */
  79816. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79817. /**
  79818. * Will start the animation sequence of a given target
  79819. * @param target defines the target
  79820. * @param from defines from which frame should animation start
  79821. * @param to defines until which frame should animation run.
  79822. * @param loop defines if the animation loops
  79823. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79824. * @param onAnimationEnd defines the function to be executed when the animation ends
  79825. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79826. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79827. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79828. * @param onAnimationLoop defines the callback to call when an animation loops
  79829. * @returns the animatable object created for this animation
  79830. */
  79831. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79832. /**
  79833. * Will start the animation sequence of a given target and its hierarchy
  79834. * @param target defines the target
  79835. * @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.
  79836. * @param from defines from which frame should animation start
  79837. * @param to defines until which frame should animation run.
  79838. * @param loop defines if the animation loops
  79839. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79840. * @param onAnimationEnd defines the function to be executed when the animation ends
  79841. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79842. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79843. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79844. * @param onAnimationLoop defines the callback to call when an animation loops
  79845. * @returns the list of created animatables
  79846. */
  79847. 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[];
  79848. /**
  79849. * Begin a new animation on a given node
  79850. * @param target defines the target where the animation will take place
  79851. * @param animations defines the list of animations to start
  79852. * @param from defines the initial value
  79853. * @param to defines the final value
  79854. * @param loop defines if you want animation to loop (off by default)
  79855. * @param speedRatio defines the speed ratio to apply to all animations
  79856. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79857. * @param onAnimationLoop defines the callback to call when an animation loops
  79858. * @returns the list of created animatables
  79859. */
  79860. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79861. /**
  79862. * Begin a new animation on a given node and its hierarchy
  79863. * @param target defines the root node where the animation will take place
  79864. * @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.
  79865. * @param animations defines the list of animations to start
  79866. * @param from defines the initial value
  79867. * @param to defines the final value
  79868. * @param loop defines if you want animation to loop (off by default)
  79869. * @param speedRatio defines the speed ratio to apply to all animations
  79870. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79871. * @param onAnimationLoop defines the callback to call when an animation loops
  79872. * @returns the list of animatables created for all nodes
  79873. */
  79874. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79875. /**
  79876. * Gets the animatable associated with a specific target
  79877. * @param target defines the target of the animatable
  79878. * @returns the required animatable if found
  79879. */
  79880. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79881. /**
  79882. * Gets all animatables associated with a given target
  79883. * @param target defines the target to look animatables for
  79884. * @returns an array of Animatables
  79885. */
  79886. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79887. /**
  79888. * Stops and removes all animations that have been applied to the scene
  79889. */
  79890. stopAllAnimations(): void;
  79891. /**
  79892. * Gets the current delta time used by animation engine
  79893. */
  79894. deltaTime: number;
  79895. }
  79896. interface Bone {
  79897. /**
  79898. * Copy an animation range from another bone
  79899. * @param source defines the source bone
  79900. * @param rangeName defines the range name to copy
  79901. * @param frameOffset defines the frame offset
  79902. * @param rescaleAsRequired defines if rescaling must be applied if required
  79903. * @param skelDimensionsRatio defines the scaling ratio
  79904. * @returns true if operation was successful
  79905. */
  79906. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79907. }
  79908. }
  79909. declare module BABYLON {
  79910. /**
  79911. * Class used to override all child animations of a given target
  79912. */
  79913. export class AnimationPropertiesOverride {
  79914. /**
  79915. * Gets or sets a value indicating if animation blending must be used
  79916. */
  79917. enableBlending: boolean;
  79918. /**
  79919. * Gets or sets the blending speed to use when enableBlending is true
  79920. */
  79921. blendingSpeed: number;
  79922. /**
  79923. * Gets or sets the default loop mode to use
  79924. */
  79925. loopMode: number;
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /**
  79930. * Class used to handle skinning animations
  79931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79932. */
  79933. export class Skeleton implements IAnimatable {
  79934. /** defines the skeleton name */
  79935. name: string;
  79936. /** defines the skeleton Id */
  79937. id: string;
  79938. /**
  79939. * Defines the list of child bones
  79940. */
  79941. bones: Bone[];
  79942. /**
  79943. * Defines an estimate of the dimension of the skeleton at rest
  79944. */
  79945. dimensionsAtRest: Vector3;
  79946. /**
  79947. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79948. */
  79949. needInitialSkinMatrix: boolean;
  79950. /**
  79951. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79952. */
  79953. overrideMesh: Nullable<AbstractMesh>;
  79954. /**
  79955. * Gets the list of animations attached to this skeleton
  79956. */
  79957. animations: Array<Animation>;
  79958. private _scene;
  79959. private _isDirty;
  79960. private _transformMatrices;
  79961. private _transformMatrixTexture;
  79962. private _meshesWithPoseMatrix;
  79963. private _animatables;
  79964. private _identity;
  79965. private _synchronizedWithMesh;
  79966. private _ranges;
  79967. private _lastAbsoluteTransformsUpdateId;
  79968. private _canUseTextureForBones;
  79969. private _uniqueId;
  79970. /** @hidden */
  79971. _numBonesWithLinkedTransformNode: number;
  79972. /** @hidden */
  79973. _hasWaitingData: Nullable<boolean>;
  79974. /**
  79975. * Specifies if the skeleton should be serialized
  79976. */
  79977. doNotSerialize: boolean;
  79978. private _useTextureToStoreBoneMatrices;
  79979. /**
  79980. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79981. * Please note that this option is not available if the hardware does not support it
  79982. */
  79983. useTextureToStoreBoneMatrices: boolean;
  79984. private _animationPropertiesOverride;
  79985. /**
  79986. * Gets or sets the animation properties override
  79987. */
  79988. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79989. /**
  79990. * List of inspectable custom properties (used by the Inspector)
  79991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79992. */
  79993. inspectableCustomProperties: IInspectable[];
  79994. /**
  79995. * An observable triggered before computing the skeleton's matrices
  79996. */
  79997. onBeforeComputeObservable: Observable<Skeleton>;
  79998. /**
  79999. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80000. */
  80001. readonly isUsingTextureForMatrices: boolean;
  80002. /**
  80003. * Gets the unique ID of this skeleton
  80004. */
  80005. readonly uniqueId: number;
  80006. /**
  80007. * Creates a new skeleton
  80008. * @param name defines the skeleton name
  80009. * @param id defines the skeleton Id
  80010. * @param scene defines the hosting scene
  80011. */
  80012. constructor(
  80013. /** defines the skeleton name */
  80014. name: string,
  80015. /** defines the skeleton Id */
  80016. id: string, scene: Scene);
  80017. /**
  80018. * Gets the current object class name.
  80019. * @return the class name
  80020. */
  80021. getClassName(): string;
  80022. /**
  80023. * Returns an array containing the root bones
  80024. * @returns an array containing the root bones
  80025. */
  80026. getChildren(): Array<Bone>;
  80027. /**
  80028. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80029. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80030. * @returns a Float32Array containing matrices data
  80031. */
  80032. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80033. /**
  80034. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80035. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80036. * @returns a raw texture containing the data
  80037. */
  80038. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80039. /**
  80040. * Gets the current hosting scene
  80041. * @returns a scene object
  80042. */
  80043. getScene(): Scene;
  80044. /**
  80045. * Gets a string representing the current skeleton data
  80046. * @param fullDetails defines a boolean indicating if we want a verbose version
  80047. * @returns a string representing the current skeleton data
  80048. */
  80049. toString(fullDetails?: boolean): string;
  80050. /**
  80051. * Get bone's index searching by name
  80052. * @param name defines bone's name to search for
  80053. * @return the indice of the bone. Returns -1 if not found
  80054. */
  80055. getBoneIndexByName(name: string): number;
  80056. /**
  80057. * Creater a new animation range
  80058. * @param name defines the name of the range
  80059. * @param from defines the start key
  80060. * @param to defines the end key
  80061. */
  80062. createAnimationRange(name: string, from: number, to: number): void;
  80063. /**
  80064. * Delete a specific animation range
  80065. * @param name defines the name of the range
  80066. * @param deleteFrames defines if frames must be removed as well
  80067. */
  80068. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80069. /**
  80070. * Gets a specific animation range
  80071. * @param name defines the name of the range to look for
  80072. * @returns the requested animation range or null if not found
  80073. */
  80074. getAnimationRange(name: string): Nullable<AnimationRange>;
  80075. /**
  80076. * Gets the list of all animation ranges defined on this skeleton
  80077. * @returns an array
  80078. */
  80079. getAnimationRanges(): Nullable<AnimationRange>[];
  80080. /**
  80081. * Copy animation range from a source skeleton.
  80082. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80083. * @param source defines the source skeleton
  80084. * @param name defines the name of the range to copy
  80085. * @param rescaleAsRequired defines if rescaling must be applied if required
  80086. * @returns true if operation was successful
  80087. */
  80088. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80089. /**
  80090. * Forces the skeleton to go to rest pose
  80091. */
  80092. returnToRest(): void;
  80093. private _getHighestAnimationFrame;
  80094. /**
  80095. * Begin a specific animation range
  80096. * @param name defines the name of the range to start
  80097. * @param loop defines if looping must be turned on (false by default)
  80098. * @param speedRatio defines the speed ratio to apply (1 by default)
  80099. * @param onAnimationEnd defines a callback which will be called when animation will end
  80100. * @returns a new animatable
  80101. */
  80102. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80103. /** @hidden */
  80104. _markAsDirty(): void;
  80105. /** @hidden */
  80106. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80107. /** @hidden */
  80108. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80109. private _computeTransformMatrices;
  80110. /**
  80111. * Build all resources required to render a skeleton
  80112. */
  80113. prepare(): void;
  80114. /**
  80115. * Gets the list of animatables currently running for this skeleton
  80116. * @returns an array of animatables
  80117. */
  80118. getAnimatables(): IAnimatable[];
  80119. /**
  80120. * Clone the current skeleton
  80121. * @param name defines the name of the new skeleton
  80122. * @param id defines the id of the new skeleton
  80123. * @returns the new skeleton
  80124. */
  80125. clone(name: string, id: string): Skeleton;
  80126. /**
  80127. * Enable animation blending for this skeleton
  80128. * @param blendingSpeed defines the blending speed to apply
  80129. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80130. */
  80131. enableBlending(blendingSpeed?: number): void;
  80132. /**
  80133. * Releases all resources associated with the current skeleton
  80134. */
  80135. dispose(): void;
  80136. /**
  80137. * Serialize the skeleton in a JSON object
  80138. * @returns a JSON object
  80139. */
  80140. serialize(): any;
  80141. /**
  80142. * Creates a new skeleton from serialized data
  80143. * @param parsedSkeleton defines the serialized data
  80144. * @param scene defines the hosting scene
  80145. * @returns a new skeleton
  80146. */
  80147. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80148. /**
  80149. * Compute all node absolute transforms
  80150. * @param forceUpdate defines if computation must be done even if cache is up to date
  80151. */
  80152. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80153. /**
  80154. * Gets the root pose matrix
  80155. * @returns a matrix
  80156. */
  80157. getPoseMatrix(): Nullable<Matrix>;
  80158. /**
  80159. * Sorts bones per internal index
  80160. */
  80161. sortBones(): void;
  80162. private _sortBones;
  80163. }
  80164. }
  80165. declare module BABYLON {
  80166. /**
  80167. * Class used to store bone information
  80168. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80169. */
  80170. export class Bone extends Node {
  80171. /**
  80172. * defines the bone name
  80173. */
  80174. name: string;
  80175. private static _tmpVecs;
  80176. private static _tmpQuat;
  80177. private static _tmpMats;
  80178. /**
  80179. * Gets the list of child bones
  80180. */
  80181. children: Bone[];
  80182. /** Gets the animations associated with this bone */
  80183. animations: Animation[];
  80184. /**
  80185. * Gets or sets bone length
  80186. */
  80187. length: number;
  80188. /**
  80189. * @hidden Internal only
  80190. * Set this value to map this bone to a different index in the transform matrices
  80191. * Set this value to -1 to exclude the bone from the transform matrices
  80192. */
  80193. _index: Nullable<number>;
  80194. private _skeleton;
  80195. private _localMatrix;
  80196. private _restPose;
  80197. private _baseMatrix;
  80198. private _absoluteTransform;
  80199. private _invertedAbsoluteTransform;
  80200. private _parent;
  80201. private _scalingDeterminant;
  80202. private _worldTransform;
  80203. private _localScaling;
  80204. private _localRotation;
  80205. private _localPosition;
  80206. private _needToDecompose;
  80207. private _needToCompose;
  80208. /** @hidden */
  80209. _linkedTransformNode: Nullable<TransformNode>;
  80210. /** @hidden */
  80211. _waitingTransformNodeId: Nullable<string>;
  80212. /** @hidden */
  80213. /** @hidden */
  80214. _matrix: Matrix;
  80215. /**
  80216. * Create a new bone
  80217. * @param name defines the bone name
  80218. * @param skeleton defines the parent skeleton
  80219. * @param parentBone defines the parent (can be null if the bone is the root)
  80220. * @param localMatrix defines the local matrix
  80221. * @param restPose defines the rest pose matrix
  80222. * @param baseMatrix defines the base matrix
  80223. * @param index defines index of the bone in the hiearchy
  80224. */
  80225. constructor(
  80226. /**
  80227. * defines the bone name
  80228. */
  80229. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80230. /**
  80231. * Gets the current object class name.
  80232. * @return the class name
  80233. */
  80234. getClassName(): string;
  80235. /**
  80236. * Gets the parent skeleton
  80237. * @returns a skeleton
  80238. */
  80239. getSkeleton(): Skeleton;
  80240. /**
  80241. * Gets parent bone
  80242. * @returns a bone or null if the bone is the root of the bone hierarchy
  80243. */
  80244. getParent(): Nullable<Bone>;
  80245. /**
  80246. * Returns an array containing the root bones
  80247. * @returns an array containing the root bones
  80248. */
  80249. getChildren(): Array<Bone>;
  80250. /**
  80251. * Sets the parent bone
  80252. * @param parent defines the parent (can be null if the bone is the root)
  80253. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80254. */
  80255. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80256. /**
  80257. * Gets the local matrix
  80258. * @returns a matrix
  80259. */
  80260. getLocalMatrix(): Matrix;
  80261. /**
  80262. * Gets the base matrix (initial matrix which remains unchanged)
  80263. * @returns a matrix
  80264. */
  80265. getBaseMatrix(): Matrix;
  80266. /**
  80267. * Gets the rest pose matrix
  80268. * @returns a matrix
  80269. */
  80270. getRestPose(): Matrix;
  80271. /**
  80272. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80273. */
  80274. getWorldMatrix(): Matrix;
  80275. /**
  80276. * Sets the local matrix to rest pose matrix
  80277. */
  80278. returnToRest(): void;
  80279. /**
  80280. * Gets the inverse of the absolute transform matrix.
  80281. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80282. * @returns a matrix
  80283. */
  80284. getInvertedAbsoluteTransform(): Matrix;
  80285. /**
  80286. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80287. * @returns a matrix
  80288. */
  80289. getAbsoluteTransform(): Matrix;
  80290. /**
  80291. * Links with the given transform node.
  80292. * The local matrix of this bone is copied from the transform node every frame.
  80293. * @param transformNode defines the transform node to link to
  80294. */
  80295. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80296. /**
  80297. * Gets the node used to drive the bone's transformation
  80298. * @returns a transform node or null
  80299. */
  80300. getTransformNode(): Nullable<TransformNode>;
  80301. /** Gets or sets current position (in local space) */
  80302. position: Vector3;
  80303. /** Gets or sets current rotation (in local space) */
  80304. rotation: Vector3;
  80305. /** Gets or sets current rotation quaternion (in local space) */
  80306. rotationQuaternion: Quaternion;
  80307. /** Gets or sets current scaling (in local space) */
  80308. scaling: Vector3;
  80309. /**
  80310. * Gets the animation properties override
  80311. */
  80312. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80313. private _decompose;
  80314. private _compose;
  80315. /**
  80316. * Update the base and local matrices
  80317. * @param matrix defines the new base or local matrix
  80318. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80319. * @param updateLocalMatrix defines if the local matrix should be updated
  80320. */
  80321. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80322. /** @hidden */
  80323. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80324. /**
  80325. * Flag the bone as dirty (Forcing it to update everything)
  80326. */
  80327. markAsDirty(): void;
  80328. /** @hidden */
  80329. _markAsDirtyAndCompose(): void;
  80330. private _markAsDirtyAndDecompose;
  80331. /**
  80332. * Translate the bone in local or world space
  80333. * @param vec The amount to translate the bone
  80334. * @param space The space that the translation is in
  80335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80336. */
  80337. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80338. /**
  80339. * Set the postion of the bone in local or world space
  80340. * @param position The position to set the bone
  80341. * @param space The space that the position is in
  80342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80343. */
  80344. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80345. /**
  80346. * Set the absolute position of the bone (world space)
  80347. * @param position The position to set the bone
  80348. * @param mesh The mesh that this bone is attached to
  80349. */
  80350. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80351. /**
  80352. * Scale the bone on the x, y and z axes (in local space)
  80353. * @param x The amount to scale the bone on the x axis
  80354. * @param y The amount to scale the bone on the y axis
  80355. * @param z The amount to scale the bone on the z axis
  80356. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80357. */
  80358. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80359. /**
  80360. * Set the bone scaling in local space
  80361. * @param scale defines the scaling vector
  80362. */
  80363. setScale(scale: Vector3): void;
  80364. /**
  80365. * Gets the current scaling in local space
  80366. * @returns the current scaling vector
  80367. */
  80368. getScale(): Vector3;
  80369. /**
  80370. * Gets the current scaling in local space and stores it in a target vector
  80371. * @param result defines the target vector
  80372. */
  80373. getScaleToRef(result: Vector3): void;
  80374. /**
  80375. * Set the yaw, pitch, and roll of the bone in local or world space
  80376. * @param yaw The rotation of the bone on the y axis
  80377. * @param pitch The rotation of the bone on the x axis
  80378. * @param roll The rotation of the bone on the z axis
  80379. * @param space The space that the axes of rotation are in
  80380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80381. */
  80382. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80383. /**
  80384. * Add a rotation to the bone on an axis in local or world space
  80385. * @param axis The axis to rotate the bone on
  80386. * @param amount The amount to rotate the bone
  80387. * @param space The space that the axis is in
  80388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80389. */
  80390. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80391. /**
  80392. * Set the rotation of the bone to a particular axis angle in local or world space
  80393. * @param axis The axis to rotate the bone on
  80394. * @param angle The angle that the bone should be rotated to
  80395. * @param space The space that the axis is in
  80396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80397. */
  80398. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80399. /**
  80400. * Set the euler rotation of the bone in local of world space
  80401. * @param rotation The euler rotation that the bone should be set to
  80402. * @param space The space that the rotation is in
  80403. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80404. */
  80405. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80406. /**
  80407. * Set the quaternion rotation of the bone in local of world space
  80408. * @param quat The quaternion rotation that the bone should be set to
  80409. * @param space The space that the rotation is in
  80410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80411. */
  80412. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80413. /**
  80414. * Set the rotation matrix of the bone in local of world space
  80415. * @param rotMat The rotation matrix that the bone should be set to
  80416. * @param space The space that the rotation is in
  80417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80418. */
  80419. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80420. private _rotateWithMatrix;
  80421. private _getNegativeRotationToRef;
  80422. /**
  80423. * Get the position of the bone in local or world space
  80424. * @param space The space that the returned position is in
  80425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80426. * @returns The position of the bone
  80427. */
  80428. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80429. /**
  80430. * Copy the position of the bone to a vector3 in local or world space
  80431. * @param space The space that the returned position is in
  80432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80433. * @param result The vector3 to copy the position to
  80434. */
  80435. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80436. /**
  80437. * Get the absolute position of the bone (world space)
  80438. * @param mesh The mesh that this bone is attached to
  80439. * @returns The absolute position of the bone
  80440. */
  80441. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80442. /**
  80443. * Copy the absolute position of the bone (world space) to the result param
  80444. * @param mesh The mesh that this bone is attached to
  80445. * @param result The vector3 to copy the absolute position to
  80446. */
  80447. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80448. /**
  80449. * Compute the absolute transforms of this bone and its children
  80450. */
  80451. computeAbsoluteTransforms(): void;
  80452. /**
  80453. * Get the world direction from an axis that is in the local space of the bone
  80454. * @param localAxis The local direction that is used to compute the world direction
  80455. * @param mesh The mesh that this bone is attached to
  80456. * @returns The world direction
  80457. */
  80458. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80459. /**
  80460. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80461. * @param localAxis The local direction that is used to compute the world direction
  80462. * @param mesh The mesh that this bone is attached to
  80463. * @param result The vector3 that the world direction will be copied to
  80464. */
  80465. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80466. /**
  80467. * Get the euler rotation of the bone in local or world space
  80468. * @param space The space that the rotation should be in
  80469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80470. * @returns The euler rotation
  80471. */
  80472. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80473. /**
  80474. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80475. * @param space The space that the rotation should be in
  80476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80477. * @param result The vector3 that the rotation should be copied to
  80478. */
  80479. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80480. /**
  80481. * Get the quaternion rotation of the bone in either local or world space
  80482. * @param space The space that the rotation should be in
  80483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80484. * @returns The quaternion rotation
  80485. */
  80486. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80487. /**
  80488. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80489. * @param space The space that the rotation should be in
  80490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80491. * @param result The quaternion that the rotation should be copied to
  80492. */
  80493. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80494. /**
  80495. * Get the rotation matrix of the bone in local or world space
  80496. * @param space The space that the rotation should be in
  80497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80498. * @returns The rotation matrix
  80499. */
  80500. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80501. /**
  80502. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80503. * @param space The space that the rotation should be in
  80504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80505. * @param result The quaternion that the rotation should be copied to
  80506. */
  80507. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80508. /**
  80509. * Get the world position of a point that is in the local space of the bone
  80510. * @param position The local position
  80511. * @param mesh The mesh that this bone is attached to
  80512. * @returns The world position
  80513. */
  80514. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80515. /**
  80516. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80517. * @param position The local position
  80518. * @param mesh The mesh that this bone is attached to
  80519. * @param result The vector3 that the world position should be copied to
  80520. */
  80521. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80522. /**
  80523. * Get the local position of a point that is in world space
  80524. * @param position The world position
  80525. * @param mesh The mesh that this bone is attached to
  80526. * @returns The local position
  80527. */
  80528. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80529. /**
  80530. * Get the local position of a point that is in world space and copy it to the result param
  80531. * @param position The world position
  80532. * @param mesh The mesh that this bone is attached to
  80533. * @param result The vector3 that the local position should be copied to
  80534. */
  80535. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80536. }
  80537. }
  80538. declare module BABYLON {
  80539. /**
  80540. * 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.
  80541. * @see https://doc.babylonjs.com/how_to/transformnode
  80542. */
  80543. export class TransformNode extends Node {
  80544. /**
  80545. * Object will not rotate to face the camera
  80546. */
  80547. static BILLBOARDMODE_NONE: number;
  80548. /**
  80549. * Object will rotate to face the camera but only on the x axis
  80550. */
  80551. static BILLBOARDMODE_X: number;
  80552. /**
  80553. * Object will rotate to face the camera but only on the y axis
  80554. */
  80555. static BILLBOARDMODE_Y: number;
  80556. /**
  80557. * Object will rotate to face the camera but only on the z axis
  80558. */
  80559. static BILLBOARDMODE_Z: number;
  80560. /**
  80561. * Object will rotate to face the camera
  80562. */
  80563. static BILLBOARDMODE_ALL: number;
  80564. /**
  80565. * Object will rotate to face the camera's position instead of orientation
  80566. */
  80567. static BILLBOARDMODE_USE_POSITION: number;
  80568. private _forward;
  80569. private _forwardInverted;
  80570. private _up;
  80571. private _right;
  80572. private _rightInverted;
  80573. private _position;
  80574. private _rotation;
  80575. private _rotationQuaternion;
  80576. protected _scaling: Vector3;
  80577. protected _isDirty: boolean;
  80578. private _transformToBoneReferal;
  80579. private _isAbsoluteSynced;
  80580. private _billboardMode;
  80581. /**
  80582. * Gets or sets the billboard mode. Default is 0.
  80583. *
  80584. * | Value | Type | Description |
  80585. * | --- | --- | --- |
  80586. * | 0 | BILLBOARDMODE_NONE | |
  80587. * | 1 | BILLBOARDMODE_X | |
  80588. * | 2 | BILLBOARDMODE_Y | |
  80589. * | 4 | BILLBOARDMODE_Z | |
  80590. * | 7 | BILLBOARDMODE_ALL | |
  80591. *
  80592. */
  80593. billboardMode: number;
  80594. private _preserveParentRotationForBillboard;
  80595. /**
  80596. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80597. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80598. */
  80599. preserveParentRotationForBillboard: boolean;
  80600. /**
  80601. * 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
  80602. */
  80603. scalingDeterminant: number;
  80604. private _infiniteDistance;
  80605. /**
  80606. * Gets or sets the distance of the object to max, often used by skybox
  80607. */
  80608. infiniteDistance: boolean;
  80609. /**
  80610. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80611. * By default the system will update normals to compensate
  80612. */
  80613. ignoreNonUniformScaling: boolean;
  80614. /**
  80615. * 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
  80616. */
  80617. reIntegrateRotationIntoRotationQuaternion: boolean;
  80618. /** @hidden */
  80619. _poseMatrix: Nullable<Matrix>;
  80620. /** @hidden */
  80621. _localMatrix: Matrix;
  80622. private _usePivotMatrix;
  80623. private _absolutePosition;
  80624. private _absoluteScaling;
  80625. private _absoluteRotationQuaternion;
  80626. private _pivotMatrix;
  80627. private _pivotMatrixInverse;
  80628. protected _postMultiplyPivotMatrix: boolean;
  80629. protected _isWorldMatrixFrozen: boolean;
  80630. /** @hidden */
  80631. _indexInSceneTransformNodesArray: number;
  80632. /**
  80633. * An event triggered after the world matrix is updated
  80634. */
  80635. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80636. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80637. /**
  80638. * Gets a string identifying the name of the class
  80639. * @returns "TransformNode" string
  80640. */
  80641. getClassName(): string;
  80642. /**
  80643. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80644. */
  80645. position: Vector3;
  80646. /**
  80647. * 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)).
  80648. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80649. */
  80650. rotation: Vector3;
  80651. /**
  80652. * 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)).
  80653. */
  80654. scaling: Vector3;
  80655. /**
  80656. * 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).
  80657. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80658. */
  80659. rotationQuaternion: Nullable<Quaternion>;
  80660. /**
  80661. * The forward direction of that transform in world space.
  80662. */
  80663. readonly forward: Vector3;
  80664. /**
  80665. * The up direction of that transform in world space.
  80666. */
  80667. readonly up: Vector3;
  80668. /**
  80669. * The right direction of that transform in world space.
  80670. */
  80671. readonly right: Vector3;
  80672. /**
  80673. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80674. * @param matrix the matrix to copy the pose from
  80675. * @returns this TransformNode.
  80676. */
  80677. updatePoseMatrix(matrix: Matrix): TransformNode;
  80678. /**
  80679. * Returns the mesh Pose matrix.
  80680. * @returns the pose matrix
  80681. */
  80682. getPoseMatrix(): Matrix;
  80683. /** @hidden */
  80684. _isSynchronized(): boolean;
  80685. /** @hidden */
  80686. _initCache(): void;
  80687. /**
  80688. * Flag the transform node as dirty (Forcing it to update everything)
  80689. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80690. * @returns this transform node
  80691. */
  80692. markAsDirty(property: string): TransformNode;
  80693. /**
  80694. * Returns the current mesh absolute position.
  80695. * Returns a Vector3.
  80696. */
  80697. readonly absolutePosition: Vector3;
  80698. /**
  80699. * Returns the current mesh absolute scaling.
  80700. * Returns a Vector3.
  80701. */
  80702. readonly absoluteScaling: Vector3;
  80703. /**
  80704. * Returns the current mesh absolute rotation.
  80705. * Returns a Quaternion.
  80706. */
  80707. readonly absoluteRotationQuaternion: Quaternion;
  80708. /**
  80709. * Sets a new matrix to apply before all other transformation
  80710. * @param matrix defines the transform matrix
  80711. * @returns the current TransformNode
  80712. */
  80713. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80714. /**
  80715. * Sets a new pivot matrix to the current node
  80716. * @param matrix defines the new pivot matrix to use
  80717. * @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
  80718. * @returns the current TransformNode
  80719. */
  80720. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80721. /**
  80722. * Returns the mesh pivot matrix.
  80723. * Default : Identity.
  80724. * @returns the matrix
  80725. */
  80726. getPivotMatrix(): Matrix;
  80727. /**
  80728. * Instantiate (when possible) or clone that node with its hierarchy
  80729. * @param newParent defines the new parent to use for the instance (or clone)
  80730. * @returns an instance (or a clone) of the current node with its hiearchy
  80731. */
  80732. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80733. /**
  80734. * Prevents the World matrix to be computed any longer
  80735. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80736. * @returns the TransformNode.
  80737. */
  80738. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80739. /**
  80740. * Allows back the World matrix computation.
  80741. * @returns the TransformNode.
  80742. */
  80743. unfreezeWorldMatrix(): this;
  80744. /**
  80745. * True if the World matrix has been frozen.
  80746. */
  80747. readonly isWorldMatrixFrozen: boolean;
  80748. /**
  80749. * Retuns the mesh absolute position in the World.
  80750. * @returns a Vector3.
  80751. */
  80752. getAbsolutePosition(): Vector3;
  80753. /**
  80754. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80755. * @param absolutePosition the absolute position to set
  80756. * @returns the TransformNode.
  80757. */
  80758. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80759. /**
  80760. * Sets the mesh position in its local space.
  80761. * @param vector3 the position to set in localspace
  80762. * @returns the TransformNode.
  80763. */
  80764. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80765. /**
  80766. * Returns the mesh position in the local space from the current World matrix values.
  80767. * @returns a new Vector3.
  80768. */
  80769. getPositionExpressedInLocalSpace(): Vector3;
  80770. /**
  80771. * Translates the mesh along the passed Vector3 in its local space.
  80772. * @param vector3 the distance to translate in localspace
  80773. * @returns the TransformNode.
  80774. */
  80775. locallyTranslate(vector3: Vector3): TransformNode;
  80776. private static _lookAtVectorCache;
  80777. /**
  80778. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80779. * @param targetPoint the position (must be in same space as current mesh) to look at
  80780. * @param yawCor optional yaw (y-axis) correction in radians
  80781. * @param pitchCor optional pitch (x-axis) correction in radians
  80782. * @param rollCor optional roll (z-axis) correction in radians
  80783. * @param space the choosen space of the target
  80784. * @returns the TransformNode.
  80785. */
  80786. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80787. /**
  80788. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80789. * This Vector3 is expressed in the World space.
  80790. * @param localAxis axis to rotate
  80791. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80792. */
  80793. getDirection(localAxis: Vector3): Vector3;
  80794. /**
  80795. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80796. * localAxis is expressed in the mesh local space.
  80797. * result is computed in the Wordl space from the mesh World matrix.
  80798. * @param localAxis axis to rotate
  80799. * @param result the resulting transformnode
  80800. * @returns this TransformNode.
  80801. */
  80802. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80803. /**
  80804. * Sets this transform node rotation to the given local axis.
  80805. * @param localAxis the axis in local space
  80806. * @param yawCor optional yaw (y-axis) correction in radians
  80807. * @param pitchCor optional pitch (x-axis) correction in radians
  80808. * @param rollCor optional roll (z-axis) correction in radians
  80809. * @returns this TransformNode
  80810. */
  80811. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80812. /**
  80813. * Sets a new pivot point to the current node
  80814. * @param point defines the new pivot point to use
  80815. * @param space defines if the point is in world or local space (local by default)
  80816. * @returns the current TransformNode
  80817. */
  80818. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80819. /**
  80820. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80821. * @returns the pivot point
  80822. */
  80823. getPivotPoint(): Vector3;
  80824. /**
  80825. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80826. * @param result the vector3 to store the result
  80827. * @returns this TransformNode.
  80828. */
  80829. getPivotPointToRef(result: Vector3): TransformNode;
  80830. /**
  80831. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80832. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80833. */
  80834. getAbsolutePivotPoint(): Vector3;
  80835. /**
  80836. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80837. * @param result vector3 to store the result
  80838. * @returns this TransformNode.
  80839. */
  80840. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80841. /**
  80842. * Defines the passed node as the parent of the current node.
  80843. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80844. * @see https://doc.babylonjs.com/how_to/parenting
  80845. * @param node the node ot set as the parent
  80846. * @returns this TransformNode.
  80847. */
  80848. setParent(node: Nullable<Node>): TransformNode;
  80849. private _nonUniformScaling;
  80850. /**
  80851. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80852. */
  80853. readonly nonUniformScaling: boolean;
  80854. /** @hidden */
  80855. _updateNonUniformScalingState(value: boolean): boolean;
  80856. /**
  80857. * Attach the current TransformNode to another TransformNode associated with a bone
  80858. * @param bone Bone affecting the TransformNode
  80859. * @param affectedTransformNode TransformNode associated with the bone
  80860. * @returns this object
  80861. */
  80862. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80863. /**
  80864. * Detach the transform node if its associated with a bone
  80865. * @returns this object
  80866. */
  80867. detachFromBone(): TransformNode;
  80868. private static _rotationAxisCache;
  80869. /**
  80870. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80871. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80872. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80873. * The passed axis is also normalized.
  80874. * @param axis the axis to rotate around
  80875. * @param amount the amount to rotate in radians
  80876. * @param space Space to rotate in (Default: local)
  80877. * @returns the TransformNode.
  80878. */
  80879. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80880. /**
  80881. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80882. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80883. * The passed axis is also normalized. .
  80884. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80885. * @param point the point to rotate around
  80886. * @param axis the axis to rotate around
  80887. * @param amount the amount to rotate in radians
  80888. * @returns the TransformNode
  80889. */
  80890. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80891. /**
  80892. * Translates the mesh along the axis vector for the passed distance in the given space.
  80893. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80894. * @param axis the axis to translate in
  80895. * @param distance the distance to translate
  80896. * @param space Space to rotate in (Default: local)
  80897. * @returns the TransformNode.
  80898. */
  80899. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80900. /**
  80901. * Adds a rotation step to the mesh current rotation.
  80902. * x, y, z are Euler angles expressed in radians.
  80903. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80904. * This means this rotation is made in the mesh local space only.
  80905. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80906. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80907. * ```javascript
  80908. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80909. * ```
  80910. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80911. * 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.
  80912. * @param x Rotation to add
  80913. * @param y Rotation to add
  80914. * @param z Rotation to add
  80915. * @returns the TransformNode.
  80916. */
  80917. addRotation(x: number, y: number, z: number): TransformNode;
  80918. /**
  80919. * @hidden
  80920. */
  80921. protected _getEffectiveParent(): Nullable<Node>;
  80922. /**
  80923. * Computes the world matrix of the node
  80924. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80925. * @returns the world matrix
  80926. */
  80927. computeWorldMatrix(force?: boolean): Matrix;
  80928. protected _afterComputeWorldMatrix(): void;
  80929. /**
  80930. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80931. * @param func callback function to add
  80932. *
  80933. * @returns the TransformNode.
  80934. */
  80935. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80936. /**
  80937. * Removes a registered callback function.
  80938. * @param func callback function to remove
  80939. * @returns the TransformNode.
  80940. */
  80941. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80942. /**
  80943. * Gets the position of the current mesh in camera space
  80944. * @param camera defines the camera to use
  80945. * @returns a position
  80946. */
  80947. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80948. /**
  80949. * Returns the distance from the mesh to the active camera
  80950. * @param camera defines the camera to use
  80951. * @returns the distance
  80952. */
  80953. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80954. /**
  80955. * Clone the current transform node
  80956. * @param name Name of the new clone
  80957. * @param newParent New parent for the clone
  80958. * @param doNotCloneChildren Do not clone children hierarchy
  80959. * @returns the new transform node
  80960. */
  80961. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80962. /**
  80963. * Serializes the objects information.
  80964. * @param currentSerializationObject defines the object to serialize in
  80965. * @returns the serialized object
  80966. */
  80967. serialize(currentSerializationObject?: any): any;
  80968. /**
  80969. * Returns a new TransformNode object parsed from the source provided.
  80970. * @param parsedTransformNode is the source.
  80971. * @param scene the scne the object belongs to
  80972. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80973. * @returns a new TransformNode object parsed from the source provided.
  80974. */
  80975. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80976. /**
  80977. * Get all child-transformNodes of this node
  80978. * @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
  80979. * @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
  80980. * @returns an array of TransformNode
  80981. */
  80982. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80983. /**
  80984. * Releases resources associated with this transform node.
  80985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80987. */
  80988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80989. /**
  80990. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80991. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80992. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80993. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80994. * @returns the current mesh
  80995. */
  80996. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80997. private _syncAbsoluteScalingAndRotation;
  80998. }
  80999. }
  81000. declare module BABYLON {
  81001. /**
  81002. * Defines the types of pose enabled controllers that are supported
  81003. */
  81004. export enum PoseEnabledControllerType {
  81005. /**
  81006. * HTC Vive
  81007. */
  81008. VIVE = 0,
  81009. /**
  81010. * Oculus Rift
  81011. */
  81012. OCULUS = 1,
  81013. /**
  81014. * Windows mixed reality
  81015. */
  81016. WINDOWS = 2,
  81017. /**
  81018. * Samsung gear VR
  81019. */
  81020. GEAR_VR = 3,
  81021. /**
  81022. * Google Daydream
  81023. */
  81024. DAYDREAM = 4,
  81025. /**
  81026. * Generic
  81027. */
  81028. GENERIC = 5
  81029. }
  81030. /**
  81031. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81032. */
  81033. export interface MutableGamepadButton {
  81034. /**
  81035. * Value of the button/trigger
  81036. */
  81037. value: number;
  81038. /**
  81039. * If the button/trigger is currently touched
  81040. */
  81041. touched: boolean;
  81042. /**
  81043. * If the button/trigger is currently pressed
  81044. */
  81045. pressed: boolean;
  81046. }
  81047. /**
  81048. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81049. * @hidden
  81050. */
  81051. export interface ExtendedGamepadButton extends GamepadButton {
  81052. /**
  81053. * If the button/trigger is currently pressed
  81054. */
  81055. readonly pressed: boolean;
  81056. /**
  81057. * If the button/trigger is currently touched
  81058. */
  81059. readonly touched: boolean;
  81060. /**
  81061. * Value of the button/trigger
  81062. */
  81063. readonly value: number;
  81064. }
  81065. /** @hidden */
  81066. export interface _GamePadFactory {
  81067. /**
  81068. * Returns wether or not the current gamepad can be created for this type of controller.
  81069. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81070. * @returns true if it can be created, otherwise false
  81071. */
  81072. canCreate(gamepadInfo: any): boolean;
  81073. /**
  81074. * Creates a new instance of the Gamepad.
  81075. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81076. * @returns the new gamepad instance
  81077. */
  81078. create(gamepadInfo: any): Gamepad;
  81079. }
  81080. /**
  81081. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81082. */
  81083. export class PoseEnabledControllerHelper {
  81084. /** @hidden */
  81085. static _ControllerFactories: _GamePadFactory[];
  81086. /** @hidden */
  81087. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81088. /**
  81089. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81090. * @param vrGamepad the gamepad to initialized
  81091. * @returns a vr controller of the type the gamepad identified as
  81092. */
  81093. static InitiateController(vrGamepad: any): Gamepad;
  81094. }
  81095. /**
  81096. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81097. */
  81098. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81099. /**
  81100. * If the controller is used in a webXR session
  81101. */
  81102. isXR: boolean;
  81103. private _deviceRoomPosition;
  81104. private _deviceRoomRotationQuaternion;
  81105. /**
  81106. * The device position in babylon space
  81107. */
  81108. devicePosition: Vector3;
  81109. /**
  81110. * The device rotation in babylon space
  81111. */
  81112. deviceRotationQuaternion: Quaternion;
  81113. /**
  81114. * The scale factor of the device in babylon space
  81115. */
  81116. deviceScaleFactor: number;
  81117. /**
  81118. * (Likely devicePosition should be used instead) The device position in its room space
  81119. */
  81120. position: Vector3;
  81121. /**
  81122. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81123. */
  81124. rotationQuaternion: Quaternion;
  81125. /**
  81126. * The type of controller (Eg. Windows mixed reality)
  81127. */
  81128. controllerType: PoseEnabledControllerType;
  81129. protected _calculatedPosition: Vector3;
  81130. private _calculatedRotation;
  81131. /**
  81132. * The raw pose from the device
  81133. */
  81134. rawPose: DevicePose;
  81135. private _trackPosition;
  81136. private _maxRotationDistFromHeadset;
  81137. private _draggedRoomRotation;
  81138. /**
  81139. * @hidden
  81140. */
  81141. _disableTrackPosition(fixedPosition: Vector3): void;
  81142. /**
  81143. * Internal, the mesh attached to the controller
  81144. * @hidden
  81145. */
  81146. _mesh: Nullable<AbstractMesh>;
  81147. private _poseControlledCamera;
  81148. private _leftHandSystemQuaternion;
  81149. /**
  81150. * Internal, matrix used to convert room space to babylon space
  81151. * @hidden
  81152. */
  81153. _deviceToWorld: Matrix;
  81154. /**
  81155. * Node to be used when casting a ray from the controller
  81156. * @hidden
  81157. */
  81158. _pointingPoseNode: Nullable<TransformNode>;
  81159. /**
  81160. * Name of the child mesh that can be used to cast a ray from the controller
  81161. */
  81162. static readonly POINTING_POSE: string;
  81163. /**
  81164. * Creates a new PoseEnabledController from a gamepad
  81165. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81166. */
  81167. constructor(browserGamepad: any);
  81168. private _workingMatrix;
  81169. /**
  81170. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81171. */
  81172. update(): void;
  81173. /**
  81174. * Updates only the pose device and mesh without doing any button event checking
  81175. */
  81176. protected _updatePoseAndMesh(): void;
  81177. /**
  81178. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81179. * @param poseData raw pose fromthe device
  81180. */
  81181. updateFromDevice(poseData: DevicePose): void;
  81182. /**
  81183. * @hidden
  81184. */
  81185. _meshAttachedObservable: Observable<AbstractMesh>;
  81186. /**
  81187. * Attaches a mesh to the controller
  81188. * @param mesh the mesh to be attached
  81189. */
  81190. attachToMesh(mesh: AbstractMesh): void;
  81191. /**
  81192. * Attaches the controllers mesh to a camera
  81193. * @param camera the camera the mesh should be attached to
  81194. */
  81195. attachToPoseControlledCamera(camera: TargetCamera): void;
  81196. /**
  81197. * Disposes of the controller
  81198. */
  81199. dispose(): void;
  81200. /**
  81201. * The mesh that is attached to the controller
  81202. */
  81203. readonly mesh: Nullable<AbstractMesh>;
  81204. /**
  81205. * Gets the ray of the controller in the direction the controller is pointing
  81206. * @param length the length the resulting ray should be
  81207. * @returns a ray in the direction the controller is pointing
  81208. */
  81209. getForwardRay(length?: number): Ray;
  81210. }
  81211. }
  81212. declare module BABYLON {
  81213. /**
  81214. * Defines the WebVRController object that represents controllers tracked in 3D space
  81215. */
  81216. export abstract class WebVRController extends PoseEnabledController {
  81217. /**
  81218. * Internal, the default controller model for the controller
  81219. */
  81220. protected _defaultModel: Nullable<AbstractMesh>;
  81221. /**
  81222. * Fired when the trigger state has changed
  81223. */
  81224. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81225. /**
  81226. * Fired when the main button state has changed
  81227. */
  81228. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81229. /**
  81230. * Fired when the secondary button state has changed
  81231. */
  81232. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81233. /**
  81234. * Fired when the pad state has changed
  81235. */
  81236. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81237. /**
  81238. * Fired when controllers stick values have changed
  81239. */
  81240. onPadValuesChangedObservable: Observable<StickValues>;
  81241. /**
  81242. * Array of button availible on the controller
  81243. */
  81244. protected _buttons: Array<MutableGamepadButton>;
  81245. private _onButtonStateChange;
  81246. /**
  81247. * Fired when a controller button's state has changed
  81248. * @param callback the callback containing the button that was modified
  81249. */
  81250. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81251. /**
  81252. * X and Y axis corresponding to the controllers joystick
  81253. */
  81254. pad: StickValues;
  81255. /**
  81256. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81257. */
  81258. hand: string;
  81259. /**
  81260. * The default controller model for the controller
  81261. */
  81262. readonly defaultModel: Nullable<AbstractMesh>;
  81263. /**
  81264. * Creates a new WebVRController from a gamepad
  81265. * @param vrGamepad the gamepad that the WebVRController should be created from
  81266. */
  81267. constructor(vrGamepad: any);
  81268. /**
  81269. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81270. */
  81271. update(): void;
  81272. /**
  81273. * Function to be called when a button is modified
  81274. */
  81275. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81276. /**
  81277. * Loads a mesh and attaches it to the controller
  81278. * @param scene the scene the mesh should be added to
  81279. * @param meshLoaded callback for when the mesh has been loaded
  81280. */
  81281. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81282. private _setButtonValue;
  81283. private _changes;
  81284. private _checkChanges;
  81285. /**
  81286. * Disposes of th webVRCOntroller
  81287. */
  81288. dispose(): void;
  81289. }
  81290. }
  81291. declare module BABYLON {
  81292. /**
  81293. * The HemisphericLight simulates the ambient environment light,
  81294. * so the passed direction is the light reflection direction, not the incoming direction.
  81295. */
  81296. export class HemisphericLight extends Light {
  81297. /**
  81298. * The groundColor is the light in the opposite direction to the one specified during creation.
  81299. * 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.
  81300. */
  81301. groundColor: Color3;
  81302. /**
  81303. * The light reflection direction, not the incoming direction.
  81304. */
  81305. direction: Vector3;
  81306. /**
  81307. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81308. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81309. * The HemisphericLight can't cast shadows.
  81310. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81311. * @param name The friendly name of the light
  81312. * @param direction The direction of the light reflection
  81313. * @param scene The scene the light belongs to
  81314. */
  81315. constructor(name: string, direction: Vector3, scene: Scene);
  81316. protected _buildUniformLayout(): void;
  81317. /**
  81318. * Returns the string "HemisphericLight".
  81319. * @return The class name
  81320. */
  81321. getClassName(): string;
  81322. /**
  81323. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81324. * Returns the updated direction.
  81325. * @param target The target the direction should point to
  81326. * @return The computed direction
  81327. */
  81328. setDirectionToTarget(target: Vector3): Vector3;
  81329. /**
  81330. * Returns the shadow generator associated to the light.
  81331. * @returns Always null for hemispheric lights because it does not support shadows.
  81332. */
  81333. getShadowGenerator(): Nullable<IShadowGenerator>;
  81334. /**
  81335. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81336. * @param effect The effect to update
  81337. * @param lightIndex The index of the light in the effect to update
  81338. * @returns The hemispheric light
  81339. */
  81340. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81341. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81342. /**
  81343. * Computes the world matrix of the node
  81344. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81345. * @param useWasUpdatedFlag defines a reserved property
  81346. * @returns the world matrix
  81347. */
  81348. computeWorldMatrix(): Matrix;
  81349. /**
  81350. * Returns the integer 3.
  81351. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81352. */
  81353. getTypeID(): number;
  81354. /**
  81355. * Prepares the list of defines specific to the light type.
  81356. * @param defines the list of defines
  81357. * @param lightIndex defines the index of the light for the effect
  81358. */
  81359. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81360. }
  81361. }
  81362. declare module BABYLON {
  81363. /** @hidden */
  81364. export var vrMultiviewToSingleviewPixelShader: {
  81365. name: string;
  81366. shader: string;
  81367. };
  81368. }
  81369. declare module BABYLON {
  81370. /**
  81371. * Renders to multiple views with a single draw call
  81372. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81373. */
  81374. export class MultiviewRenderTarget extends RenderTargetTexture {
  81375. /**
  81376. * Creates a multiview render target
  81377. * @param scene scene used with the render target
  81378. * @param size the size of the render target (used for each view)
  81379. */
  81380. constructor(scene: Scene, size?: number | {
  81381. width: number;
  81382. height: number;
  81383. } | {
  81384. ratio: number;
  81385. });
  81386. /**
  81387. * @hidden
  81388. * @param faceIndex the face index, if its a cube texture
  81389. */
  81390. _bindFrameBuffer(faceIndex?: number): void;
  81391. /**
  81392. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81393. * @returns the view count
  81394. */
  81395. getViewCount(): number;
  81396. }
  81397. }
  81398. declare module BABYLON {
  81399. /**
  81400. * Represents a camera frustum
  81401. */
  81402. export class Frustum {
  81403. /**
  81404. * Gets the planes representing the frustum
  81405. * @param transform matrix to be applied to the returned planes
  81406. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81407. */
  81408. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81409. /**
  81410. * Gets the near frustum plane transformed by the transform matrix
  81411. * @param transform transformation matrix to be applied to the resulting frustum plane
  81412. * @param frustumPlane the resuling frustum plane
  81413. */
  81414. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81415. /**
  81416. * Gets the far frustum plane transformed by the transform matrix
  81417. * @param transform transformation matrix to be applied to the resulting frustum plane
  81418. * @param frustumPlane the resuling frustum plane
  81419. */
  81420. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81421. /**
  81422. * Gets the left frustum plane transformed by the transform matrix
  81423. * @param transform transformation matrix to be applied to the resulting frustum plane
  81424. * @param frustumPlane the resuling frustum plane
  81425. */
  81426. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81427. /**
  81428. * Gets the right frustum plane transformed by the transform matrix
  81429. * @param transform transformation matrix to be applied to the resulting frustum plane
  81430. * @param frustumPlane the resuling frustum plane
  81431. */
  81432. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81433. /**
  81434. * Gets the top frustum plane transformed by the transform matrix
  81435. * @param transform transformation matrix to be applied to the resulting frustum plane
  81436. * @param frustumPlane the resuling frustum plane
  81437. */
  81438. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81439. /**
  81440. * Gets the bottom frustum plane transformed by the transform matrix
  81441. * @param transform transformation matrix to be applied to the resulting frustum plane
  81442. * @param frustumPlane the resuling frustum plane
  81443. */
  81444. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81445. /**
  81446. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81447. * @param transform transformation matrix to be applied to the resulting frustum planes
  81448. * @param frustumPlanes the resuling frustum planes
  81449. */
  81450. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81451. }
  81452. }
  81453. declare module BABYLON {
  81454. interface Engine {
  81455. /**
  81456. * Creates a new multiview render target
  81457. * @param width defines the width of the texture
  81458. * @param height defines the height of the texture
  81459. * @returns the created multiview texture
  81460. */
  81461. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81462. /**
  81463. * Binds a multiview framebuffer to be drawn to
  81464. * @param multiviewTexture texture to bind
  81465. */
  81466. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81467. }
  81468. interface Camera {
  81469. /**
  81470. * @hidden
  81471. * 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)
  81472. */
  81473. _useMultiviewToSingleView: boolean;
  81474. /**
  81475. * @hidden
  81476. * 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)
  81477. */
  81478. _multiviewTexture: Nullable<RenderTargetTexture>;
  81479. /**
  81480. * @hidden
  81481. * ensures the multiview texture of the camera exists and has the specified width/height
  81482. * @param width height to set on the multiview texture
  81483. * @param height width to set on the multiview texture
  81484. */
  81485. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81486. }
  81487. interface Scene {
  81488. /** @hidden */
  81489. _transformMatrixR: Matrix;
  81490. /** @hidden */
  81491. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81492. /** @hidden */
  81493. _createMultiviewUbo(): void;
  81494. /** @hidden */
  81495. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81496. /** @hidden */
  81497. _renderMultiviewToSingleView(camera: Camera): void;
  81498. }
  81499. }
  81500. declare module BABYLON {
  81501. /**
  81502. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81503. * This will not be used for webXR as it supports displaying texture arrays directly
  81504. */
  81505. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81506. /**
  81507. * Initializes a VRMultiviewToSingleview
  81508. * @param name name of the post process
  81509. * @param camera camera to be applied to
  81510. * @param scaleFactor scaling factor to the size of the output texture
  81511. */
  81512. constructor(name: string, camera: Camera, scaleFactor: number);
  81513. }
  81514. }
  81515. declare module BABYLON {
  81516. interface Engine {
  81517. /** @hidden */
  81518. _vrDisplay: any;
  81519. /** @hidden */
  81520. _vrSupported: boolean;
  81521. /** @hidden */
  81522. _oldSize: Size;
  81523. /** @hidden */
  81524. _oldHardwareScaleFactor: number;
  81525. /** @hidden */
  81526. _vrExclusivePointerMode: boolean;
  81527. /** @hidden */
  81528. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81529. /** @hidden */
  81530. _onVRDisplayPointerRestricted: () => void;
  81531. /** @hidden */
  81532. _onVRDisplayPointerUnrestricted: () => void;
  81533. /** @hidden */
  81534. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81535. /** @hidden */
  81536. _onVrDisplayDisconnect: Nullable<() => void>;
  81537. /** @hidden */
  81538. _onVrDisplayPresentChange: Nullable<() => void>;
  81539. /**
  81540. * Observable signaled when VR display mode changes
  81541. */
  81542. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81543. /**
  81544. * Observable signaled when VR request present is complete
  81545. */
  81546. onVRRequestPresentComplete: Observable<boolean>;
  81547. /**
  81548. * Observable signaled when VR request present starts
  81549. */
  81550. onVRRequestPresentStart: Observable<Engine>;
  81551. /**
  81552. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81553. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81554. */
  81555. isInVRExclusivePointerMode: boolean;
  81556. /**
  81557. * Gets a boolean indicating if a webVR device was detected
  81558. * @returns true if a webVR device was detected
  81559. */
  81560. isVRDevicePresent(): boolean;
  81561. /**
  81562. * Gets the current webVR device
  81563. * @returns the current webVR device (or null)
  81564. */
  81565. getVRDevice(): any;
  81566. /**
  81567. * Initializes a webVR display and starts listening to display change events
  81568. * The onVRDisplayChangedObservable will be notified upon these changes
  81569. * @returns A promise containing a VRDisplay and if vr is supported
  81570. */
  81571. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81572. /** @hidden */
  81573. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81574. /**
  81575. * Call this function to switch to webVR mode
  81576. * Will do nothing if webVR is not supported or if there is no webVR device
  81577. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81578. */
  81579. enableVR(): void;
  81580. /** @hidden */
  81581. _onVRFullScreenTriggered(): void;
  81582. }
  81583. }
  81584. declare module BABYLON {
  81585. /**
  81586. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81587. * IMPORTANT!! The data is right-hand data.
  81588. * @export
  81589. * @interface DevicePose
  81590. */
  81591. export interface DevicePose {
  81592. /**
  81593. * The position of the device, values in array are [x,y,z].
  81594. */
  81595. readonly position: Nullable<Float32Array>;
  81596. /**
  81597. * The linearVelocity of the device, values in array are [x,y,z].
  81598. */
  81599. readonly linearVelocity: Nullable<Float32Array>;
  81600. /**
  81601. * The linearAcceleration of the device, values in array are [x,y,z].
  81602. */
  81603. readonly linearAcceleration: Nullable<Float32Array>;
  81604. /**
  81605. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81606. */
  81607. readonly orientation: Nullable<Float32Array>;
  81608. /**
  81609. * The angularVelocity of the device, values in array are [x,y,z].
  81610. */
  81611. readonly angularVelocity: Nullable<Float32Array>;
  81612. /**
  81613. * The angularAcceleration of the device, values in array are [x,y,z].
  81614. */
  81615. readonly angularAcceleration: Nullable<Float32Array>;
  81616. }
  81617. /**
  81618. * Interface representing a pose controlled object in Babylon.
  81619. * A pose controlled object has both regular pose values as well as pose values
  81620. * from an external device such as a VR head mounted display
  81621. */
  81622. export interface PoseControlled {
  81623. /**
  81624. * The position of the object in babylon space.
  81625. */
  81626. position: Vector3;
  81627. /**
  81628. * The rotation quaternion of the object in babylon space.
  81629. */
  81630. rotationQuaternion: Quaternion;
  81631. /**
  81632. * The position of the device in babylon space.
  81633. */
  81634. devicePosition?: Vector3;
  81635. /**
  81636. * The rotation quaternion of the device in babylon space.
  81637. */
  81638. deviceRotationQuaternion: Quaternion;
  81639. /**
  81640. * The raw pose coming from the device.
  81641. */
  81642. rawPose: Nullable<DevicePose>;
  81643. /**
  81644. * The scale of the device to be used when translating from device space to babylon space.
  81645. */
  81646. deviceScaleFactor: number;
  81647. /**
  81648. * Updates the poseControlled values based on the input device pose.
  81649. * @param poseData the pose data to update the object with
  81650. */
  81651. updateFromDevice(poseData: DevicePose): void;
  81652. }
  81653. /**
  81654. * Set of options to customize the webVRCamera
  81655. */
  81656. export interface WebVROptions {
  81657. /**
  81658. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81659. */
  81660. trackPosition?: boolean;
  81661. /**
  81662. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81663. */
  81664. positionScale?: number;
  81665. /**
  81666. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81667. */
  81668. displayName?: string;
  81669. /**
  81670. * Should the native controller meshes be initialized. (default: true)
  81671. */
  81672. controllerMeshes?: boolean;
  81673. /**
  81674. * Creating a default HemiLight only on controllers. (default: true)
  81675. */
  81676. defaultLightingOnControllers?: boolean;
  81677. /**
  81678. * If you don't want to use the default VR button of the helper. (default: false)
  81679. */
  81680. useCustomVRButton?: boolean;
  81681. /**
  81682. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81683. */
  81684. customVRButton?: HTMLButtonElement;
  81685. /**
  81686. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81687. */
  81688. rayLength?: number;
  81689. /**
  81690. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81691. */
  81692. defaultHeight?: number;
  81693. /**
  81694. * If multiview should be used if availible (default: false)
  81695. */
  81696. useMultiview?: boolean;
  81697. }
  81698. /**
  81699. * This represents a WebVR camera.
  81700. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81701. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81702. */
  81703. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81704. private webVROptions;
  81705. /**
  81706. * @hidden
  81707. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81708. */
  81709. _vrDevice: any;
  81710. /**
  81711. * The rawPose of the vrDevice.
  81712. */
  81713. rawPose: Nullable<DevicePose>;
  81714. private _onVREnabled;
  81715. private _specsVersion;
  81716. private _attached;
  81717. private _frameData;
  81718. protected _descendants: Array<Node>;
  81719. private _deviceRoomPosition;
  81720. /** @hidden */
  81721. _deviceRoomRotationQuaternion: Quaternion;
  81722. private _standingMatrix;
  81723. /**
  81724. * Represents device position in babylon space.
  81725. */
  81726. devicePosition: Vector3;
  81727. /**
  81728. * Represents device rotation in babylon space.
  81729. */
  81730. deviceRotationQuaternion: Quaternion;
  81731. /**
  81732. * The scale of the device to be used when translating from device space to babylon space.
  81733. */
  81734. deviceScaleFactor: number;
  81735. private _deviceToWorld;
  81736. private _worldToDevice;
  81737. /**
  81738. * References to the webVR controllers for the vrDevice.
  81739. */
  81740. controllers: Array<WebVRController>;
  81741. /**
  81742. * Emits an event when a controller is attached.
  81743. */
  81744. onControllersAttachedObservable: Observable<WebVRController[]>;
  81745. /**
  81746. * Emits an event when a controller's mesh has been loaded;
  81747. */
  81748. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81749. /**
  81750. * Emits an event when the HMD's pose has been updated.
  81751. */
  81752. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81753. private _poseSet;
  81754. /**
  81755. * If the rig cameras be used as parent instead of this camera.
  81756. */
  81757. rigParenting: boolean;
  81758. private _lightOnControllers;
  81759. private _defaultHeight?;
  81760. /**
  81761. * Instantiates a WebVRFreeCamera.
  81762. * @param name The name of the WebVRFreeCamera
  81763. * @param position The starting anchor position for the camera
  81764. * @param scene The scene the camera belongs to
  81765. * @param webVROptions a set of customizable options for the webVRCamera
  81766. */
  81767. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81768. /**
  81769. * Gets the device distance from the ground in meters.
  81770. * @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.
  81771. */
  81772. deviceDistanceToRoomGround(): number;
  81773. /**
  81774. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81775. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81776. */
  81777. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81778. /**
  81779. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81780. * @returns A promise with a boolean set to if the standing matrix is supported.
  81781. */
  81782. useStandingMatrixAsync(): Promise<boolean>;
  81783. /**
  81784. * Disposes the camera
  81785. */
  81786. dispose(): void;
  81787. /**
  81788. * Gets a vrController by name.
  81789. * @param name The name of the controller to retreive
  81790. * @returns the controller matching the name specified or null if not found
  81791. */
  81792. getControllerByName(name: string): Nullable<WebVRController>;
  81793. private _leftController;
  81794. /**
  81795. * The controller corresponding to the users left hand.
  81796. */
  81797. readonly leftController: Nullable<WebVRController>;
  81798. private _rightController;
  81799. /**
  81800. * The controller corresponding to the users right hand.
  81801. */
  81802. readonly rightController: Nullable<WebVRController>;
  81803. /**
  81804. * Casts a ray forward from the vrCamera's gaze.
  81805. * @param length Length of the ray (default: 100)
  81806. * @returns the ray corresponding to the gaze
  81807. */
  81808. getForwardRay(length?: number): Ray;
  81809. /**
  81810. * @hidden
  81811. * Updates the camera based on device's frame data
  81812. */
  81813. _checkInputs(): void;
  81814. /**
  81815. * Updates the poseControlled values based on the input device pose.
  81816. * @param poseData Pose coming from the device
  81817. */
  81818. updateFromDevice(poseData: DevicePose): void;
  81819. private _htmlElementAttached;
  81820. private _detachIfAttached;
  81821. /**
  81822. * WebVR's attach control will start broadcasting frames to the device.
  81823. * Note that in certain browsers (chrome for example) this function must be called
  81824. * within a user-interaction callback. Example:
  81825. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81826. *
  81827. * @param element html element to attach the vrDevice to
  81828. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81829. */
  81830. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81831. /**
  81832. * Detaches the camera from the html element and disables VR
  81833. *
  81834. * @param element html element to detach from
  81835. */
  81836. detachControl(element: HTMLElement): void;
  81837. /**
  81838. * @returns the name of this class
  81839. */
  81840. getClassName(): string;
  81841. /**
  81842. * Calls resetPose on the vrDisplay
  81843. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81844. */
  81845. resetToCurrentRotation(): void;
  81846. /**
  81847. * @hidden
  81848. * Updates the rig cameras (left and right eye)
  81849. */
  81850. _updateRigCameras(): void;
  81851. private _workingVector;
  81852. private _oneVector;
  81853. private _workingMatrix;
  81854. private updateCacheCalled;
  81855. private _correctPositionIfNotTrackPosition;
  81856. /**
  81857. * @hidden
  81858. * Updates the cached values of the camera
  81859. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81860. */
  81861. _updateCache(ignoreParentClass?: boolean): void;
  81862. /**
  81863. * @hidden
  81864. * Get current device position in babylon world
  81865. */
  81866. _computeDevicePosition(): void;
  81867. /**
  81868. * Updates the current device position and rotation in the babylon world
  81869. */
  81870. update(): void;
  81871. /**
  81872. * @hidden
  81873. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81874. * @returns an identity matrix
  81875. */
  81876. _getViewMatrix(): Matrix;
  81877. private _tmpMatrix;
  81878. /**
  81879. * This function is called by the two RIG cameras.
  81880. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81881. * @hidden
  81882. */
  81883. _getWebVRViewMatrix(): Matrix;
  81884. /** @hidden */
  81885. _getWebVRProjectionMatrix(): Matrix;
  81886. private _onGamepadConnectedObserver;
  81887. private _onGamepadDisconnectedObserver;
  81888. private _updateCacheWhenTrackingDisabledObserver;
  81889. /**
  81890. * Initializes the controllers and their meshes
  81891. */
  81892. initControllers(): void;
  81893. }
  81894. }
  81895. declare module BABYLON {
  81896. /**
  81897. * Size options for a post process
  81898. */
  81899. export type PostProcessOptions = {
  81900. width: number;
  81901. height: number;
  81902. };
  81903. /**
  81904. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81905. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81906. */
  81907. export class PostProcess {
  81908. /** Name of the PostProcess. */
  81909. name: string;
  81910. /**
  81911. * Gets or sets the unique id of the post process
  81912. */
  81913. uniqueId: number;
  81914. /**
  81915. * Width of the texture to apply the post process on
  81916. */
  81917. width: number;
  81918. /**
  81919. * Height of the texture to apply the post process on
  81920. */
  81921. height: number;
  81922. /**
  81923. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81924. * @hidden
  81925. */
  81926. _outputTexture: Nullable<InternalTexture>;
  81927. /**
  81928. * Sampling mode used by the shader
  81929. * See https://doc.babylonjs.com/classes/3.1/texture
  81930. */
  81931. renderTargetSamplingMode: number;
  81932. /**
  81933. * Clear color to use when screen clearing
  81934. */
  81935. clearColor: Color4;
  81936. /**
  81937. * If the buffer needs to be cleared before applying the post process. (default: true)
  81938. * Should be set to false if shader will overwrite all previous pixels.
  81939. */
  81940. autoClear: boolean;
  81941. /**
  81942. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81943. */
  81944. alphaMode: number;
  81945. /**
  81946. * Sets the setAlphaBlendConstants of the babylon engine
  81947. */
  81948. alphaConstants: Color4;
  81949. /**
  81950. * Animations to be used for the post processing
  81951. */
  81952. animations: Animation[];
  81953. /**
  81954. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81955. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81956. */
  81957. enablePixelPerfectMode: boolean;
  81958. /**
  81959. * Force the postprocess to be applied without taking in account viewport
  81960. */
  81961. forceFullscreenViewport: boolean;
  81962. /**
  81963. * List of inspectable custom properties (used by the Inspector)
  81964. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81965. */
  81966. inspectableCustomProperties: IInspectable[];
  81967. /**
  81968. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81969. *
  81970. * | Value | Type | Description |
  81971. * | ----- | ----------------------------------- | ----------- |
  81972. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81973. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81974. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81975. *
  81976. */
  81977. scaleMode: number;
  81978. /**
  81979. * Force textures to be a power of two (default: false)
  81980. */
  81981. alwaysForcePOT: boolean;
  81982. private _samples;
  81983. /**
  81984. * Number of sample textures (default: 1)
  81985. */
  81986. samples: number;
  81987. /**
  81988. * Modify the scale of the post process to be the same as the viewport (default: false)
  81989. */
  81990. adaptScaleToCurrentViewport: boolean;
  81991. private _camera;
  81992. private _scene;
  81993. private _engine;
  81994. private _options;
  81995. private _reusable;
  81996. private _textureType;
  81997. /**
  81998. * Smart array of input and output textures for the post process.
  81999. * @hidden
  82000. */
  82001. _textures: SmartArray<InternalTexture>;
  82002. /**
  82003. * The index in _textures that corresponds to the output texture.
  82004. * @hidden
  82005. */
  82006. _currentRenderTextureInd: number;
  82007. private _effect;
  82008. private _samplers;
  82009. private _fragmentUrl;
  82010. private _vertexUrl;
  82011. private _parameters;
  82012. private _scaleRatio;
  82013. protected _indexParameters: any;
  82014. private _shareOutputWithPostProcess;
  82015. private _texelSize;
  82016. private _forcedOutputTexture;
  82017. /**
  82018. * Returns the fragment url or shader name used in the post process.
  82019. * @returns the fragment url or name in the shader store.
  82020. */
  82021. getEffectName(): string;
  82022. /**
  82023. * An event triggered when the postprocess is activated.
  82024. */
  82025. onActivateObservable: Observable<Camera>;
  82026. private _onActivateObserver;
  82027. /**
  82028. * A function that is added to the onActivateObservable
  82029. */
  82030. onActivate: Nullable<(camera: Camera) => void>;
  82031. /**
  82032. * An event triggered when the postprocess changes its size.
  82033. */
  82034. onSizeChangedObservable: Observable<PostProcess>;
  82035. private _onSizeChangedObserver;
  82036. /**
  82037. * A function that is added to the onSizeChangedObservable
  82038. */
  82039. onSizeChanged: (postProcess: PostProcess) => void;
  82040. /**
  82041. * An event triggered when the postprocess applies its effect.
  82042. */
  82043. onApplyObservable: Observable<Effect>;
  82044. private _onApplyObserver;
  82045. /**
  82046. * A function that is added to the onApplyObservable
  82047. */
  82048. onApply: (effect: Effect) => void;
  82049. /**
  82050. * An event triggered before rendering the postprocess
  82051. */
  82052. onBeforeRenderObservable: Observable<Effect>;
  82053. private _onBeforeRenderObserver;
  82054. /**
  82055. * A function that is added to the onBeforeRenderObservable
  82056. */
  82057. onBeforeRender: (effect: Effect) => void;
  82058. /**
  82059. * An event triggered after rendering the postprocess
  82060. */
  82061. onAfterRenderObservable: Observable<Effect>;
  82062. private _onAfterRenderObserver;
  82063. /**
  82064. * A function that is added to the onAfterRenderObservable
  82065. */
  82066. onAfterRender: (efect: Effect) => void;
  82067. /**
  82068. * 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
  82069. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82070. */
  82071. inputTexture: InternalTexture;
  82072. /**
  82073. * Gets the camera which post process is applied to.
  82074. * @returns The camera the post process is applied to.
  82075. */
  82076. getCamera(): Camera;
  82077. /**
  82078. * Gets the texel size of the postprocess.
  82079. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82080. */
  82081. readonly texelSize: Vector2;
  82082. /**
  82083. * Creates a new instance PostProcess
  82084. * @param name The name of the PostProcess.
  82085. * @param fragmentUrl The url of the fragment shader to be used.
  82086. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82087. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82088. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82089. * @param camera The camera to apply the render pass to.
  82090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82091. * @param engine The engine which the post process will be applied. (default: current engine)
  82092. * @param reusable If the post process can be reused on the same frame. (default: false)
  82093. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82094. * @param textureType Type of textures used when performing the post process. (default: 0)
  82095. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82096. * @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
  82097. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82098. */
  82099. constructor(
  82100. /** Name of the PostProcess. */
  82101. 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);
  82102. /**
  82103. * Gets a string idenfifying the name of the class
  82104. * @returns "PostProcess" string
  82105. */
  82106. getClassName(): string;
  82107. /**
  82108. * Gets the engine which this post process belongs to.
  82109. * @returns The engine the post process was enabled with.
  82110. */
  82111. getEngine(): Engine;
  82112. /**
  82113. * The effect that is created when initializing the post process.
  82114. * @returns The created effect corresponding the the postprocess.
  82115. */
  82116. getEffect(): Effect;
  82117. /**
  82118. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82119. * @param postProcess The post process to share the output with.
  82120. * @returns This post process.
  82121. */
  82122. shareOutputWith(postProcess: PostProcess): PostProcess;
  82123. /**
  82124. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82125. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82126. */
  82127. useOwnOutput(): void;
  82128. /**
  82129. * Updates the effect with the current post process compile time values and recompiles the shader.
  82130. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82131. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82132. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82133. * @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
  82134. * @param onCompiled Called when the shader has been compiled.
  82135. * @param onError Called if there is an error when compiling a shader.
  82136. */
  82137. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82138. /**
  82139. * The post process is reusable if it can be used multiple times within one frame.
  82140. * @returns If the post process is reusable
  82141. */
  82142. isReusable(): boolean;
  82143. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82144. markTextureDirty(): void;
  82145. /**
  82146. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82147. * 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.
  82148. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82149. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82150. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82151. * @returns The target texture that was bound to be written to.
  82152. */
  82153. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82154. /**
  82155. * If the post process is supported.
  82156. */
  82157. readonly isSupported: boolean;
  82158. /**
  82159. * The aspect ratio of the output texture.
  82160. */
  82161. readonly aspectRatio: number;
  82162. /**
  82163. * Get a value indicating if the post-process is ready to be used
  82164. * @returns true if the post-process is ready (shader is compiled)
  82165. */
  82166. isReady(): boolean;
  82167. /**
  82168. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82169. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82170. */
  82171. apply(): Nullable<Effect>;
  82172. private _disposeTextures;
  82173. /**
  82174. * Disposes the post process.
  82175. * @param camera The camera to dispose the post process on.
  82176. */
  82177. dispose(camera?: Camera): void;
  82178. }
  82179. }
  82180. declare module BABYLON {
  82181. /** @hidden */
  82182. export var kernelBlurVaryingDeclaration: {
  82183. name: string;
  82184. shader: string;
  82185. };
  82186. }
  82187. declare module BABYLON {
  82188. /** @hidden */
  82189. export var kernelBlurFragment: {
  82190. name: string;
  82191. shader: string;
  82192. };
  82193. }
  82194. declare module BABYLON {
  82195. /** @hidden */
  82196. export var kernelBlurFragment2: {
  82197. name: string;
  82198. shader: string;
  82199. };
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var kernelBlurPixelShader: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var kernelBlurVertex: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. /** @hidden */
  82217. export var kernelBlurVertexShader: {
  82218. name: string;
  82219. shader: string;
  82220. };
  82221. }
  82222. declare module BABYLON {
  82223. /**
  82224. * The Blur Post Process which blurs an image based on a kernel and direction.
  82225. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82226. */
  82227. export class BlurPostProcess extends PostProcess {
  82228. /** The direction in which to blur the image. */
  82229. direction: Vector2;
  82230. private blockCompilation;
  82231. protected _kernel: number;
  82232. protected _idealKernel: number;
  82233. protected _packedFloat: boolean;
  82234. private _staticDefines;
  82235. /**
  82236. * Sets the length in pixels of the blur sample region
  82237. */
  82238. /**
  82239. * Gets the length in pixels of the blur sample region
  82240. */
  82241. kernel: number;
  82242. /**
  82243. * Sets wether or not the blur needs to unpack/repack floats
  82244. */
  82245. /**
  82246. * Gets wether or not the blur is unpacking/repacking floats
  82247. */
  82248. packedFloat: boolean;
  82249. /**
  82250. * Creates a new instance BlurPostProcess
  82251. * @param name The name of the effect.
  82252. * @param direction The direction in which to blur the image.
  82253. * @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.
  82254. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82255. * @param camera The camera to apply the render pass to.
  82256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82257. * @param engine The engine which the post process will be applied. (default: current engine)
  82258. * @param reusable If the post process can be reused on the same frame. (default: false)
  82259. * @param textureType Type of textures used when performing the post process. (default: 0)
  82260. * @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)
  82261. */
  82262. constructor(name: string,
  82263. /** The direction in which to blur the image. */
  82264. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82265. /**
  82266. * Updates the effect with the current post process compile time values and recompiles the shader.
  82267. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82268. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82269. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82270. * @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
  82271. * @param onCompiled Called when the shader has been compiled.
  82272. * @param onError Called if there is an error when compiling a shader.
  82273. */
  82274. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82275. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82276. /**
  82277. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82278. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82279. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82280. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82281. * The gaps between physical kernels are compensated for in the weighting of the samples
  82282. * @param idealKernel Ideal blur kernel.
  82283. * @return Nearest best kernel.
  82284. */
  82285. protected _nearestBestKernel(idealKernel: number): number;
  82286. /**
  82287. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82288. * @param x The point on the Gaussian distribution to sample.
  82289. * @return the value of the Gaussian function at x.
  82290. */
  82291. protected _gaussianWeight(x: number): number;
  82292. /**
  82293. * Generates a string that can be used as a floating point number in GLSL.
  82294. * @param x Value to print.
  82295. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82296. * @return GLSL float string.
  82297. */
  82298. protected _glslFloat(x: number, decimalFigures?: number): string;
  82299. }
  82300. }
  82301. declare module BABYLON {
  82302. /**
  82303. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82304. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82305. * You can then easily use it as a reflectionTexture on a flat surface.
  82306. * In case the surface is not a plane, please consider relying on reflection probes.
  82307. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82308. */
  82309. export class MirrorTexture extends RenderTargetTexture {
  82310. private scene;
  82311. /**
  82312. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82313. * 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.
  82314. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82315. */
  82316. mirrorPlane: Plane;
  82317. /**
  82318. * Define the blur ratio used to blur the reflection if needed.
  82319. */
  82320. blurRatio: number;
  82321. /**
  82322. * Define the adaptive blur kernel used to blur the reflection if needed.
  82323. * This will autocompute the closest best match for the `blurKernel`
  82324. */
  82325. adaptiveBlurKernel: number;
  82326. /**
  82327. * Define the blur kernel used to blur the reflection if needed.
  82328. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82329. */
  82330. blurKernel: number;
  82331. /**
  82332. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82333. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82334. */
  82335. blurKernelX: number;
  82336. /**
  82337. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82338. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82339. */
  82340. blurKernelY: number;
  82341. private _autoComputeBlurKernel;
  82342. protected _onRatioRescale(): void;
  82343. private _updateGammaSpace;
  82344. private _imageProcessingConfigChangeObserver;
  82345. private _transformMatrix;
  82346. private _mirrorMatrix;
  82347. private _savedViewMatrix;
  82348. private _blurX;
  82349. private _blurY;
  82350. private _adaptiveBlurKernel;
  82351. private _blurKernelX;
  82352. private _blurKernelY;
  82353. private _blurRatio;
  82354. /**
  82355. * Instantiates a Mirror Texture.
  82356. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82357. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82358. * You can then easily use it as a reflectionTexture on a flat surface.
  82359. * In case the surface is not a plane, please consider relying on reflection probes.
  82360. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82361. * @param name
  82362. * @param size
  82363. * @param scene
  82364. * @param generateMipMaps
  82365. * @param type
  82366. * @param samplingMode
  82367. * @param generateDepthBuffer
  82368. */
  82369. constructor(name: string, size: number | {
  82370. width: number;
  82371. height: number;
  82372. } | {
  82373. ratio: number;
  82374. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82375. private _preparePostProcesses;
  82376. /**
  82377. * Clone the mirror texture.
  82378. * @returns the cloned texture
  82379. */
  82380. clone(): MirrorTexture;
  82381. /**
  82382. * Serialize the texture to a JSON representation you could use in Parse later on
  82383. * @returns the serialized JSON representation
  82384. */
  82385. serialize(): any;
  82386. /**
  82387. * Dispose the texture and release its associated resources.
  82388. */
  82389. dispose(): void;
  82390. }
  82391. }
  82392. declare module BABYLON {
  82393. /**
  82394. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82395. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82396. */
  82397. export class Texture extends BaseTexture {
  82398. /**
  82399. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82400. */
  82401. static SerializeBuffers: boolean;
  82402. /** @hidden */
  82403. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82404. /** @hidden */
  82405. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82406. /** @hidden */
  82407. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82408. /** nearest is mag = nearest and min = nearest and mip = linear */
  82409. static readonly NEAREST_SAMPLINGMODE: number;
  82410. /** nearest is mag = nearest and min = nearest and mip = linear */
  82411. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82412. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82413. static readonly BILINEAR_SAMPLINGMODE: number;
  82414. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82415. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82416. /** Trilinear is mag = linear and min = linear and mip = linear */
  82417. static readonly TRILINEAR_SAMPLINGMODE: number;
  82418. /** Trilinear is mag = linear and min = linear and mip = linear */
  82419. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82420. /** mag = nearest and min = nearest and mip = nearest */
  82421. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82422. /** mag = nearest and min = linear and mip = nearest */
  82423. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82424. /** mag = nearest and min = linear and mip = linear */
  82425. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82426. /** mag = nearest and min = linear and mip = none */
  82427. static readonly NEAREST_LINEAR: number;
  82428. /** mag = nearest and min = nearest and mip = none */
  82429. static readonly NEAREST_NEAREST: number;
  82430. /** mag = linear and min = nearest and mip = nearest */
  82431. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82432. /** mag = linear and min = nearest and mip = linear */
  82433. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82434. /** mag = linear and min = linear and mip = none */
  82435. static readonly LINEAR_LINEAR: number;
  82436. /** mag = linear and min = nearest and mip = none */
  82437. static readonly LINEAR_NEAREST: number;
  82438. /** Explicit coordinates mode */
  82439. static readonly EXPLICIT_MODE: number;
  82440. /** Spherical coordinates mode */
  82441. static readonly SPHERICAL_MODE: number;
  82442. /** Planar coordinates mode */
  82443. static readonly PLANAR_MODE: number;
  82444. /** Cubic coordinates mode */
  82445. static readonly CUBIC_MODE: number;
  82446. /** Projection coordinates mode */
  82447. static readonly PROJECTION_MODE: number;
  82448. /** Inverse Cubic coordinates mode */
  82449. static readonly SKYBOX_MODE: number;
  82450. /** Inverse Cubic coordinates mode */
  82451. static readonly INVCUBIC_MODE: number;
  82452. /** Equirectangular coordinates mode */
  82453. static readonly EQUIRECTANGULAR_MODE: number;
  82454. /** Equirectangular Fixed coordinates mode */
  82455. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82456. /** Equirectangular Fixed Mirrored coordinates mode */
  82457. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82458. /** Texture is not repeating outside of 0..1 UVs */
  82459. static readonly CLAMP_ADDRESSMODE: number;
  82460. /** Texture is repeating outside of 0..1 UVs */
  82461. static readonly WRAP_ADDRESSMODE: number;
  82462. /** Texture is repeating and mirrored */
  82463. static readonly MIRROR_ADDRESSMODE: number;
  82464. /**
  82465. * 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
  82466. */
  82467. static UseSerializedUrlIfAny: boolean;
  82468. /**
  82469. * Define the url of the texture.
  82470. */
  82471. url: Nullable<string>;
  82472. /**
  82473. * Define an offset on the texture to offset the u coordinates of the UVs
  82474. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82475. */
  82476. uOffset: number;
  82477. /**
  82478. * Define an offset on the texture to offset the v coordinates of the UVs
  82479. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82480. */
  82481. vOffset: number;
  82482. /**
  82483. * Define an offset on the texture to scale the u coordinates of the UVs
  82484. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82485. */
  82486. uScale: number;
  82487. /**
  82488. * Define an offset on the texture to scale the v coordinates of the UVs
  82489. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82490. */
  82491. vScale: number;
  82492. /**
  82493. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82494. * @see http://doc.babylonjs.com/how_to/more_materials
  82495. */
  82496. uAng: number;
  82497. /**
  82498. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82499. * @see http://doc.babylonjs.com/how_to/more_materials
  82500. */
  82501. vAng: number;
  82502. /**
  82503. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82504. * @see http://doc.babylonjs.com/how_to/more_materials
  82505. */
  82506. wAng: number;
  82507. /**
  82508. * Defines the center of rotation (U)
  82509. */
  82510. uRotationCenter: number;
  82511. /**
  82512. * Defines the center of rotation (V)
  82513. */
  82514. vRotationCenter: number;
  82515. /**
  82516. * Defines the center of rotation (W)
  82517. */
  82518. wRotationCenter: number;
  82519. /**
  82520. * Are mip maps generated for this texture or not.
  82521. */
  82522. readonly noMipmap: boolean;
  82523. /**
  82524. * List of inspectable custom properties (used by the Inspector)
  82525. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82526. */
  82527. inspectableCustomProperties: Nullable<IInspectable[]>;
  82528. private _noMipmap;
  82529. /** @hidden */
  82530. _invertY: boolean;
  82531. private _rowGenerationMatrix;
  82532. private _cachedTextureMatrix;
  82533. private _projectionModeMatrix;
  82534. private _t0;
  82535. private _t1;
  82536. private _t2;
  82537. private _cachedUOffset;
  82538. private _cachedVOffset;
  82539. private _cachedUScale;
  82540. private _cachedVScale;
  82541. private _cachedUAng;
  82542. private _cachedVAng;
  82543. private _cachedWAng;
  82544. private _cachedProjectionMatrixId;
  82545. private _cachedCoordinatesMode;
  82546. /** @hidden */
  82547. protected _initialSamplingMode: number;
  82548. /** @hidden */
  82549. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82550. private _deleteBuffer;
  82551. protected _format: Nullable<number>;
  82552. private _delayedOnLoad;
  82553. private _delayedOnError;
  82554. /**
  82555. * Observable triggered once the texture has been loaded.
  82556. */
  82557. onLoadObservable: Observable<Texture>;
  82558. protected _isBlocking: boolean;
  82559. /**
  82560. * Is the texture preventing material to render while loading.
  82561. * If false, a default texture will be used instead of the loading one during the preparation step.
  82562. */
  82563. isBlocking: boolean;
  82564. /**
  82565. * Get the current sampling mode associated with the texture.
  82566. */
  82567. readonly samplingMode: number;
  82568. /**
  82569. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82570. */
  82571. readonly invertY: boolean;
  82572. /**
  82573. * Instantiates a new texture.
  82574. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82575. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82576. * @param url define the url of the picture to load as a texture
  82577. * @param scene define the scene or engine the texture will belong to
  82578. * @param noMipmap define if the texture will require mip maps or not
  82579. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82580. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82581. * @param onLoad define a callback triggered when the texture has been loaded
  82582. * @param onError define a callback triggered when an error occurred during the loading session
  82583. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82584. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82585. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82586. */
  82587. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82588. /**
  82589. * Update the url (and optional buffer) of this texture if url was null during construction.
  82590. * @param url the url of the texture
  82591. * @param buffer the buffer of the texture (defaults to null)
  82592. * @param onLoad callback called when the texture is loaded (defaults to null)
  82593. */
  82594. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82595. /**
  82596. * Finish the loading sequence of a texture flagged as delayed load.
  82597. * @hidden
  82598. */
  82599. delayLoad(): void;
  82600. private _prepareRowForTextureGeneration;
  82601. /**
  82602. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82603. * @returns the transform matrix of the texture.
  82604. */
  82605. getTextureMatrix(): Matrix;
  82606. /**
  82607. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82608. * @returns The reflection texture transform
  82609. */
  82610. getReflectionTextureMatrix(): Matrix;
  82611. /**
  82612. * Clones the texture.
  82613. * @returns the cloned texture
  82614. */
  82615. clone(): Texture;
  82616. /**
  82617. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82618. * @returns The JSON representation of the texture
  82619. */
  82620. serialize(): any;
  82621. /**
  82622. * Get the current class name of the texture useful for serialization or dynamic coding.
  82623. * @returns "Texture"
  82624. */
  82625. getClassName(): string;
  82626. /**
  82627. * Dispose the texture and release its associated resources.
  82628. */
  82629. dispose(): void;
  82630. /**
  82631. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82632. * @param parsedTexture Define the JSON representation of the texture
  82633. * @param scene Define the scene the parsed texture should be instantiated in
  82634. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82635. * @returns The parsed texture if successful
  82636. */
  82637. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82638. /**
  82639. * Creates a texture from its base 64 representation.
  82640. * @param data Define the base64 payload without the data: prefix
  82641. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82642. * @param scene Define the scene the texture should belong to
  82643. * @param noMipmap Forces the texture to not create mip map information if true
  82644. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82645. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82646. * @param onLoad define a callback triggered when the texture has been loaded
  82647. * @param onError define a callback triggered when an error occurred during the loading session
  82648. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82649. * @returns the created texture
  82650. */
  82651. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82652. /**
  82653. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82654. * @param data Define the base64 payload without the data: prefix
  82655. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82656. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82657. * @param scene Define the scene the texture should belong to
  82658. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82659. * @param noMipmap Forces the texture to not create mip map information if true
  82660. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82661. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82662. * @param onLoad define a callback triggered when the texture has been loaded
  82663. * @param onError define a callback triggered when an error occurred during the loading session
  82664. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82665. * @returns the created texture
  82666. */
  82667. static 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;
  82668. }
  82669. }
  82670. declare module BABYLON {
  82671. /**
  82672. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82673. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82674. */
  82675. export class PostProcessManager {
  82676. private _scene;
  82677. private _indexBuffer;
  82678. private _vertexBuffers;
  82679. /**
  82680. * Creates a new instance PostProcess
  82681. * @param scene The scene that the post process is associated with.
  82682. */
  82683. constructor(scene: Scene);
  82684. private _prepareBuffers;
  82685. private _buildIndexBuffer;
  82686. /**
  82687. * Rebuilds the vertex buffers of the manager.
  82688. * @hidden
  82689. */
  82690. _rebuild(): void;
  82691. /**
  82692. * Prepares a frame to be run through a post process.
  82693. * @param sourceTexture The input texture to the post procesess. (default: null)
  82694. * @param postProcesses An array of post processes to be run. (default: null)
  82695. * @returns True if the post processes were able to be run.
  82696. * @hidden
  82697. */
  82698. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82699. /**
  82700. * Manually render a set of post processes to a texture.
  82701. * @param postProcesses An array of post processes to be run.
  82702. * @param targetTexture The target texture to render to.
  82703. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82704. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82705. * @param lodLevel defines which lod of the texture to render to
  82706. */
  82707. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82708. /**
  82709. * Finalize the result of the output of the postprocesses.
  82710. * @param doNotPresent If true the result will not be displayed to the screen.
  82711. * @param targetTexture The target texture to render to.
  82712. * @param faceIndex The index of the face to bind the target texture to.
  82713. * @param postProcesses The array of post processes to render.
  82714. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82715. * @hidden
  82716. */
  82717. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82718. /**
  82719. * Disposes of the post process manager.
  82720. */
  82721. dispose(): void;
  82722. }
  82723. }
  82724. declare module BABYLON {
  82725. /** Interface used by value gradients (color, factor, ...) */
  82726. export interface IValueGradient {
  82727. /**
  82728. * Gets or sets the gradient value (between 0 and 1)
  82729. */
  82730. gradient: number;
  82731. }
  82732. /** Class used to store color4 gradient */
  82733. export class ColorGradient implements IValueGradient {
  82734. /**
  82735. * Gets or sets the gradient value (between 0 and 1)
  82736. */
  82737. gradient: number;
  82738. /**
  82739. * Gets or sets first associated color
  82740. */
  82741. color1: Color4;
  82742. /**
  82743. * Gets or sets second associated color
  82744. */
  82745. color2?: Color4;
  82746. /**
  82747. * Will get a color picked randomly between color1 and color2.
  82748. * If color2 is undefined then color1 will be used
  82749. * @param result defines the target Color4 to store the result in
  82750. */
  82751. getColorToRef(result: Color4): void;
  82752. }
  82753. /** Class used to store color 3 gradient */
  82754. export class Color3Gradient implements IValueGradient {
  82755. /**
  82756. * Gets or sets the gradient value (between 0 and 1)
  82757. */
  82758. gradient: number;
  82759. /**
  82760. * Gets or sets the associated color
  82761. */
  82762. color: Color3;
  82763. }
  82764. /** Class used to store factor gradient */
  82765. export class FactorGradient implements IValueGradient {
  82766. /**
  82767. * Gets or sets the gradient value (between 0 and 1)
  82768. */
  82769. gradient: number;
  82770. /**
  82771. * Gets or sets first associated factor
  82772. */
  82773. factor1: number;
  82774. /**
  82775. * Gets or sets second associated factor
  82776. */
  82777. factor2?: number;
  82778. /**
  82779. * Will get a number picked randomly between factor1 and factor2.
  82780. * If factor2 is undefined then factor1 will be used
  82781. * @returns the picked number
  82782. */
  82783. getFactor(): number;
  82784. }
  82785. /**
  82786. * Helper used to simplify some generic gradient tasks
  82787. */
  82788. export class GradientHelper {
  82789. /**
  82790. * Gets the current gradient from an array of IValueGradient
  82791. * @param ratio defines the current ratio to get
  82792. * @param gradients defines the array of IValueGradient
  82793. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82794. */
  82795. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82796. }
  82797. }
  82798. declare module BABYLON {
  82799. interface ThinEngine {
  82800. /**
  82801. * Creates a dynamic texture
  82802. * @param width defines the width of the texture
  82803. * @param height defines the height of the texture
  82804. * @param generateMipMaps defines if the engine should generate the mip levels
  82805. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82806. * @returns the dynamic texture inside an InternalTexture
  82807. */
  82808. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82809. /**
  82810. * Update the content of a dynamic texture
  82811. * @param texture defines the texture to update
  82812. * @param canvas defines the canvas containing the source
  82813. * @param invertY defines if data must be stored with Y axis inverted
  82814. * @param premulAlpha defines if alpha is stored as premultiplied
  82815. * @param format defines the format of the data
  82816. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82817. */
  82818. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82819. }
  82820. }
  82821. declare module BABYLON {
  82822. /**
  82823. * A class extending Texture allowing drawing on a texture
  82824. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82825. */
  82826. export class DynamicTexture extends Texture {
  82827. private _generateMipMaps;
  82828. private _canvas;
  82829. private _context;
  82830. private _engine;
  82831. /**
  82832. * Creates a DynamicTexture
  82833. * @param name defines the name of the texture
  82834. * @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
  82835. * @param scene defines the scene where you want the texture
  82836. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82837. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82838. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82839. */
  82840. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82841. /**
  82842. * Get the current class name of the texture useful for serialization or dynamic coding.
  82843. * @returns "DynamicTexture"
  82844. */
  82845. getClassName(): string;
  82846. /**
  82847. * Gets the current state of canRescale
  82848. */
  82849. readonly canRescale: boolean;
  82850. private _recreate;
  82851. /**
  82852. * Scales the texture
  82853. * @param ratio the scale factor to apply to both width and height
  82854. */
  82855. scale(ratio: number): void;
  82856. /**
  82857. * Resizes the texture
  82858. * @param width the new width
  82859. * @param height the new height
  82860. */
  82861. scaleTo(width: number, height: number): void;
  82862. /**
  82863. * Gets the context of the canvas used by the texture
  82864. * @returns the canvas context of the dynamic texture
  82865. */
  82866. getContext(): CanvasRenderingContext2D;
  82867. /**
  82868. * Clears the texture
  82869. */
  82870. clear(): void;
  82871. /**
  82872. * Updates the texture
  82873. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82874. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82875. */
  82876. update(invertY?: boolean, premulAlpha?: boolean): void;
  82877. /**
  82878. * Draws text onto the texture
  82879. * @param text defines the text to be drawn
  82880. * @param x defines the placement of the text from the left
  82881. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82882. * @param font defines the font to be used with font-style, font-size, font-name
  82883. * @param color defines the color used for the text
  82884. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82885. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82886. * @param update defines whether texture is immediately update (default is true)
  82887. */
  82888. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82889. /**
  82890. * Clones the texture
  82891. * @returns the clone of the texture.
  82892. */
  82893. clone(): DynamicTexture;
  82894. /**
  82895. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82896. * @returns a serialized dynamic texture object
  82897. */
  82898. serialize(): any;
  82899. /** @hidden */
  82900. _rebuild(): void;
  82901. }
  82902. }
  82903. declare module BABYLON {
  82904. interface AbstractScene {
  82905. /**
  82906. * The list of procedural textures added to the scene
  82907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82908. */
  82909. proceduralTextures: Array<ProceduralTexture>;
  82910. }
  82911. /**
  82912. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82913. * in a given scene.
  82914. */
  82915. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82916. /**
  82917. * The component name helpfull to identify the component in the list of scene components.
  82918. */
  82919. readonly name: string;
  82920. /**
  82921. * The scene the component belongs to.
  82922. */
  82923. scene: Scene;
  82924. /**
  82925. * Creates a new instance of the component for the given scene
  82926. * @param scene Defines the scene to register the component in
  82927. */
  82928. constructor(scene: Scene);
  82929. /**
  82930. * Registers the component in a given scene
  82931. */
  82932. register(): void;
  82933. /**
  82934. * Rebuilds the elements related to this component in case of
  82935. * context lost for instance.
  82936. */
  82937. rebuild(): void;
  82938. /**
  82939. * Disposes the component and the associated ressources.
  82940. */
  82941. dispose(): void;
  82942. private _beforeClear;
  82943. }
  82944. }
  82945. declare module BABYLON {
  82946. interface ThinEngine {
  82947. /**
  82948. * Creates a new render target cube texture
  82949. * @param size defines the size of the texture
  82950. * @param options defines the options used to create the texture
  82951. * @returns a new render target cube texture stored in an InternalTexture
  82952. */
  82953. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82954. }
  82955. }
  82956. declare module BABYLON {
  82957. /** @hidden */
  82958. export var proceduralVertexShader: {
  82959. name: string;
  82960. shader: string;
  82961. };
  82962. }
  82963. declare module BABYLON {
  82964. /**
  82965. * 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.
  82966. * This is the base class of any Procedural texture and contains most of the shareable code.
  82967. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82968. */
  82969. export class ProceduralTexture extends Texture {
  82970. isCube: boolean;
  82971. /**
  82972. * Define if the texture is enabled or not (disabled texture will not render)
  82973. */
  82974. isEnabled: boolean;
  82975. /**
  82976. * Define if the texture must be cleared before rendering (default is true)
  82977. */
  82978. autoClear: boolean;
  82979. /**
  82980. * Callback called when the texture is generated
  82981. */
  82982. onGenerated: () => void;
  82983. /**
  82984. * Event raised when the texture is generated
  82985. */
  82986. onGeneratedObservable: Observable<ProceduralTexture>;
  82987. /** @hidden */
  82988. _generateMipMaps: boolean;
  82989. /** @hidden **/
  82990. _effect: Effect;
  82991. /** @hidden */
  82992. _textures: {
  82993. [key: string]: Texture;
  82994. };
  82995. private _size;
  82996. private _currentRefreshId;
  82997. private _refreshRate;
  82998. private _vertexBuffers;
  82999. private _indexBuffer;
  83000. private _uniforms;
  83001. private _samplers;
  83002. private _fragment;
  83003. private _floats;
  83004. private _ints;
  83005. private _floatsArrays;
  83006. private _colors3;
  83007. private _colors4;
  83008. private _vectors2;
  83009. private _vectors3;
  83010. private _matrices;
  83011. private _fallbackTexture;
  83012. private _fallbackTextureUsed;
  83013. private _engine;
  83014. private _cachedDefines;
  83015. private _contentUpdateId;
  83016. private _contentData;
  83017. /**
  83018. * Instantiates a new procedural texture.
  83019. * 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.
  83020. * This is the base class of any Procedural texture and contains most of the shareable code.
  83021. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83022. * @param name Define the name of the texture
  83023. * @param size Define the size of the texture to create
  83024. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83025. * @param scene Define the scene the texture belongs to
  83026. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83027. * @param generateMipMaps Define if the texture should creates mip maps or not
  83028. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83029. */
  83030. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83031. /**
  83032. * The effect that is created when initializing the post process.
  83033. * @returns The created effect corresponding the the postprocess.
  83034. */
  83035. getEffect(): Effect;
  83036. /**
  83037. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83038. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83039. */
  83040. getContent(): Nullable<ArrayBufferView>;
  83041. private _createIndexBuffer;
  83042. /** @hidden */
  83043. _rebuild(): void;
  83044. /**
  83045. * Resets the texture in order to recreate its associated resources.
  83046. * This can be called in case of context loss
  83047. */
  83048. reset(): void;
  83049. protected _getDefines(): string;
  83050. /**
  83051. * Is the texture ready to be used ? (rendered at least once)
  83052. * @returns true if ready, otherwise, false.
  83053. */
  83054. isReady(): boolean;
  83055. /**
  83056. * Resets the refresh counter of the texture and start bak from scratch.
  83057. * Could be useful to regenerate the texture if it is setup to render only once.
  83058. */
  83059. resetRefreshCounter(): void;
  83060. /**
  83061. * Set the fragment shader to use in order to render the texture.
  83062. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83063. */
  83064. setFragment(fragment: any): void;
  83065. /**
  83066. * Define the refresh rate of the texture or the rendering frequency.
  83067. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83068. */
  83069. refreshRate: number;
  83070. /** @hidden */
  83071. _shouldRender(): boolean;
  83072. /**
  83073. * Get the size the texture is rendering at.
  83074. * @returns the size (texture is always squared)
  83075. */
  83076. getRenderSize(): number;
  83077. /**
  83078. * Resize the texture to new value.
  83079. * @param size Define the new size the texture should have
  83080. * @param generateMipMaps Define whether the new texture should create mip maps
  83081. */
  83082. resize(size: number, generateMipMaps: boolean): void;
  83083. private _checkUniform;
  83084. /**
  83085. * Set a texture in the shader program used to render.
  83086. * @param name Define the name of the uniform samplers as defined in the shader
  83087. * @param texture Define the texture to bind to this sampler
  83088. * @return the texture itself allowing "fluent" like uniform updates
  83089. */
  83090. setTexture(name: string, texture: Texture): ProceduralTexture;
  83091. /**
  83092. * Set a float in the shader.
  83093. * @param name Define the name of the uniform as defined in the shader
  83094. * @param value Define the value to give to the uniform
  83095. * @return the texture itself allowing "fluent" like uniform updates
  83096. */
  83097. setFloat(name: string, value: number): ProceduralTexture;
  83098. /**
  83099. * Set a int in the shader.
  83100. * @param name Define the name of the uniform as defined in the shader
  83101. * @param value Define the value to give to the uniform
  83102. * @return the texture itself allowing "fluent" like uniform updates
  83103. */
  83104. setInt(name: string, value: number): ProceduralTexture;
  83105. /**
  83106. * Set an array of floats in the shader.
  83107. * @param name Define the name of the uniform as defined in the shader
  83108. * @param value Define the value to give to the uniform
  83109. * @return the texture itself allowing "fluent" like uniform updates
  83110. */
  83111. setFloats(name: string, value: number[]): ProceduralTexture;
  83112. /**
  83113. * Set a vec3 in the shader from a Color3.
  83114. * @param name Define the name of the uniform as defined in the shader
  83115. * @param value Define the value to give to the uniform
  83116. * @return the texture itself allowing "fluent" like uniform updates
  83117. */
  83118. setColor3(name: string, value: Color3): ProceduralTexture;
  83119. /**
  83120. * Set a vec4 in the shader from a Color4.
  83121. * @param name Define the name of the uniform as defined in the shader
  83122. * @param value Define the value to give to the uniform
  83123. * @return the texture itself allowing "fluent" like uniform updates
  83124. */
  83125. setColor4(name: string, value: Color4): ProceduralTexture;
  83126. /**
  83127. * Set a vec2 in the shader from a Vector2.
  83128. * @param name Define the name of the uniform as defined in the shader
  83129. * @param value Define the value to give to the uniform
  83130. * @return the texture itself allowing "fluent" like uniform updates
  83131. */
  83132. setVector2(name: string, value: Vector2): ProceduralTexture;
  83133. /**
  83134. * Set a vec3 in the shader from a Vector3.
  83135. * @param name Define the name of the uniform as defined in the shader
  83136. * @param value Define the value to give to the uniform
  83137. * @return the texture itself allowing "fluent" like uniform updates
  83138. */
  83139. setVector3(name: string, value: Vector3): ProceduralTexture;
  83140. /**
  83141. * Set a mat4 in the shader from a MAtrix.
  83142. * @param name Define the name of the uniform as defined in the shader
  83143. * @param value Define the value to give to the uniform
  83144. * @return the texture itself allowing "fluent" like uniform updates
  83145. */
  83146. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83147. /**
  83148. * Render the texture to its associated render target.
  83149. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83150. */
  83151. render(useCameraPostProcess?: boolean): void;
  83152. /**
  83153. * Clone the texture.
  83154. * @returns the cloned texture
  83155. */
  83156. clone(): ProceduralTexture;
  83157. /**
  83158. * Dispose the texture and release its asoociated resources.
  83159. */
  83160. dispose(): void;
  83161. }
  83162. }
  83163. declare module BABYLON {
  83164. /**
  83165. * This represents the base class for particle system in Babylon.
  83166. * 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.
  83167. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83168. * @example https://doc.babylonjs.com/babylon101/particles
  83169. */
  83170. export class BaseParticleSystem {
  83171. /**
  83172. * Source color is added to the destination color without alpha affecting the result
  83173. */
  83174. static BLENDMODE_ONEONE: number;
  83175. /**
  83176. * Blend current color and particle color using particle’s alpha
  83177. */
  83178. static BLENDMODE_STANDARD: number;
  83179. /**
  83180. * Add current color and particle color multiplied by particle’s alpha
  83181. */
  83182. static BLENDMODE_ADD: number;
  83183. /**
  83184. * Multiply current color with particle color
  83185. */
  83186. static BLENDMODE_MULTIPLY: number;
  83187. /**
  83188. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83189. */
  83190. static BLENDMODE_MULTIPLYADD: number;
  83191. /**
  83192. * List of animations used by the particle system.
  83193. */
  83194. animations: Animation[];
  83195. /**
  83196. * The id of the Particle system.
  83197. */
  83198. id: string;
  83199. /**
  83200. * The friendly name of the Particle system.
  83201. */
  83202. name: string;
  83203. /**
  83204. * The rendering group used by the Particle system to chose when to render.
  83205. */
  83206. renderingGroupId: number;
  83207. /**
  83208. * The emitter represents the Mesh or position we are attaching the particle system to.
  83209. */
  83210. emitter: Nullable<AbstractMesh | Vector3>;
  83211. /**
  83212. * The maximum number of particles to emit per frame
  83213. */
  83214. emitRate: number;
  83215. /**
  83216. * If you want to launch only a few particles at once, that can be done, as well.
  83217. */
  83218. manualEmitCount: number;
  83219. /**
  83220. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83221. */
  83222. updateSpeed: number;
  83223. /**
  83224. * The amount of time the particle system is running (depends of the overall update speed).
  83225. */
  83226. targetStopDuration: number;
  83227. /**
  83228. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83229. */
  83230. disposeOnStop: boolean;
  83231. /**
  83232. * Minimum power of emitting particles.
  83233. */
  83234. minEmitPower: number;
  83235. /**
  83236. * Maximum power of emitting particles.
  83237. */
  83238. maxEmitPower: number;
  83239. /**
  83240. * Minimum life time of emitting particles.
  83241. */
  83242. minLifeTime: number;
  83243. /**
  83244. * Maximum life time of emitting particles.
  83245. */
  83246. maxLifeTime: number;
  83247. /**
  83248. * Minimum Size of emitting particles.
  83249. */
  83250. minSize: number;
  83251. /**
  83252. * Maximum Size of emitting particles.
  83253. */
  83254. maxSize: number;
  83255. /**
  83256. * Minimum scale of emitting particles on X axis.
  83257. */
  83258. minScaleX: number;
  83259. /**
  83260. * Maximum scale of emitting particles on X axis.
  83261. */
  83262. maxScaleX: number;
  83263. /**
  83264. * Minimum scale of emitting particles on Y axis.
  83265. */
  83266. minScaleY: number;
  83267. /**
  83268. * Maximum scale of emitting particles on Y axis.
  83269. */
  83270. maxScaleY: number;
  83271. /**
  83272. * Gets or sets the minimal initial rotation in radians.
  83273. */
  83274. minInitialRotation: number;
  83275. /**
  83276. * Gets or sets the maximal initial rotation in radians.
  83277. */
  83278. maxInitialRotation: number;
  83279. /**
  83280. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83281. */
  83282. minAngularSpeed: number;
  83283. /**
  83284. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83285. */
  83286. maxAngularSpeed: number;
  83287. /**
  83288. * The texture used to render each particle. (this can be a spritesheet)
  83289. */
  83290. particleTexture: Nullable<Texture>;
  83291. /**
  83292. * The layer mask we are rendering the particles through.
  83293. */
  83294. layerMask: number;
  83295. /**
  83296. * This can help using your own shader to render the particle system.
  83297. * The according effect will be created
  83298. */
  83299. customShader: any;
  83300. /**
  83301. * By default particle system starts as soon as they are created. This prevents the
  83302. * automatic start to happen and let you decide when to start emitting particles.
  83303. */
  83304. preventAutoStart: boolean;
  83305. private _noiseTexture;
  83306. /**
  83307. * Gets or sets a texture used to add random noise to particle positions
  83308. */
  83309. noiseTexture: Nullable<ProceduralTexture>;
  83310. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83311. noiseStrength: Vector3;
  83312. /**
  83313. * Callback triggered when the particle animation is ending.
  83314. */
  83315. onAnimationEnd: Nullable<() => void>;
  83316. /**
  83317. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83318. */
  83319. blendMode: number;
  83320. /**
  83321. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83322. * to override the particles.
  83323. */
  83324. forceDepthWrite: boolean;
  83325. /** 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 */
  83326. preWarmCycles: number;
  83327. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83328. preWarmStepOffset: number;
  83329. /**
  83330. * 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)
  83331. */
  83332. spriteCellChangeSpeed: number;
  83333. /**
  83334. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83335. */
  83336. startSpriteCellID: number;
  83337. /**
  83338. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83339. */
  83340. endSpriteCellID: number;
  83341. /**
  83342. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83343. */
  83344. spriteCellWidth: number;
  83345. /**
  83346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83347. */
  83348. spriteCellHeight: number;
  83349. /**
  83350. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83351. */
  83352. spriteRandomStartCell: boolean;
  83353. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83354. translationPivot: Vector2;
  83355. /** @hidden */
  83356. protected _isAnimationSheetEnabled: boolean;
  83357. /**
  83358. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83359. */
  83360. beginAnimationOnStart: boolean;
  83361. /**
  83362. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83363. */
  83364. beginAnimationFrom: number;
  83365. /**
  83366. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83367. */
  83368. beginAnimationTo: number;
  83369. /**
  83370. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83371. */
  83372. beginAnimationLoop: boolean;
  83373. /**
  83374. * Gets or sets a world offset applied to all particles
  83375. */
  83376. worldOffset: Vector3;
  83377. /**
  83378. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83379. */
  83380. isAnimationSheetEnabled: boolean;
  83381. /**
  83382. * Get hosting scene
  83383. * @returns the scene
  83384. */
  83385. getScene(): Scene;
  83386. /**
  83387. * You can use gravity if you want to give an orientation to your particles.
  83388. */
  83389. gravity: Vector3;
  83390. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83391. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83392. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83393. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83394. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83395. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83396. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83397. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83398. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83399. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83400. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83401. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83402. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83403. /**
  83404. * Defines the delay in milliseconds before starting the system (0 by default)
  83405. */
  83406. startDelay: number;
  83407. /**
  83408. * Gets the current list of drag gradients.
  83409. * You must use addDragGradient and removeDragGradient to udpate this list
  83410. * @returns the list of drag gradients
  83411. */
  83412. getDragGradients(): Nullable<Array<FactorGradient>>;
  83413. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83414. limitVelocityDamping: number;
  83415. /**
  83416. * Gets the current list of limit velocity gradients.
  83417. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83418. * @returns the list of limit velocity gradients
  83419. */
  83420. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83421. /**
  83422. * Gets the current list of color gradients.
  83423. * You must use addColorGradient and removeColorGradient to udpate this list
  83424. * @returns the list of color gradients
  83425. */
  83426. getColorGradients(): Nullable<Array<ColorGradient>>;
  83427. /**
  83428. * Gets the current list of size gradients.
  83429. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83430. * @returns the list of size gradients
  83431. */
  83432. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83433. /**
  83434. * Gets the current list of color remap gradients.
  83435. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83436. * @returns the list of color remap gradients
  83437. */
  83438. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83439. /**
  83440. * Gets the current list of alpha remap gradients.
  83441. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83442. * @returns the list of alpha remap gradients
  83443. */
  83444. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83445. /**
  83446. * Gets the current list of life time gradients.
  83447. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83448. * @returns the list of life time gradients
  83449. */
  83450. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83451. /**
  83452. * Gets the current list of angular speed gradients.
  83453. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83454. * @returns the list of angular speed gradients
  83455. */
  83456. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83457. /**
  83458. * Gets the current list of velocity gradients.
  83459. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83460. * @returns the list of velocity gradients
  83461. */
  83462. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83463. /**
  83464. * Gets the current list of start size gradients.
  83465. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83466. * @returns the list of start size gradients
  83467. */
  83468. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83469. /**
  83470. * Gets the current list of emit rate gradients.
  83471. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83472. * @returns the list of emit rate gradients
  83473. */
  83474. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83475. /**
  83476. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83477. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83478. */
  83479. direction1: Vector3;
  83480. /**
  83481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83483. */
  83484. direction2: Vector3;
  83485. /**
  83486. * 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.
  83487. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83488. */
  83489. minEmitBox: Vector3;
  83490. /**
  83491. * 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.
  83492. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83493. */
  83494. maxEmitBox: Vector3;
  83495. /**
  83496. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83497. */
  83498. color1: Color4;
  83499. /**
  83500. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83501. */
  83502. color2: Color4;
  83503. /**
  83504. * Color the particle will have at the end of its lifetime
  83505. */
  83506. colorDead: Color4;
  83507. /**
  83508. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83509. */
  83510. textureMask: Color4;
  83511. /**
  83512. * The particle emitter type defines the emitter used by the particle system.
  83513. * It can be for example box, sphere, or cone...
  83514. */
  83515. particleEmitterType: IParticleEmitterType;
  83516. /** @hidden */
  83517. _isSubEmitter: boolean;
  83518. /**
  83519. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83520. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83521. */
  83522. billboardMode: number;
  83523. protected _isBillboardBased: boolean;
  83524. /**
  83525. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83526. */
  83527. isBillboardBased: boolean;
  83528. /**
  83529. * The scene the particle system belongs to.
  83530. */
  83531. protected _scene: Scene;
  83532. /**
  83533. * Local cache of defines for image processing.
  83534. */
  83535. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83536. /**
  83537. * Default configuration related to image processing available in the standard Material.
  83538. */
  83539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83540. /**
  83541. * Gets the image processing configuration used either in this material.
  83542. */
  83543. /**
  83544. * Sets the Default image processing configuration used either in the this material.
  83545. *
  83546. * If sets to null, the scene one is in use.
  83547. */
  83548. imageProcessingConfiguration: ImageProcessingConfiguration;
  83549. /**
  83550. * Attaches a new image processing configuration to the Standard Material.
  83551. * @param configuration
  83552. */
  83553. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83554. /** @hidden */
  83555. protected _reset(): void;
  83556. /** @hidden */
  83557. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83558. /**
  83559. * Instantiates a particle system.
  83560. * 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.
  83561. * @param name The name of the particle system
  83562. */
  83563. constructor(name: string);
  83564. /**
  83565. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83568. * @returns the emitter
  83569. */
  83570. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83571. /**
  83572. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83573. * @param radius The radius of the hemisphere to emit from
  83574. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83575. * @returns the emitter
  83576. */
  83577. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83578. /**
  83579. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83580. * @param radius The radius of the sphere to emit from
  83581. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83582. * @returns the emitter
  83583. */
  83584. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83585. /**
  83586. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83587. * @param radius The radius of the sphere to emit from
  83588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83590. * @returns the emitter
  83591. */
  83592. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83593. /**
  83594. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83595. * @param radius The radius of the emission cylinder
  83596. * @param height The height of the emission cylinder
  83597. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83598. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83599. * @returns the emitter
  83600. */
  83601. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83602. /**
  83603. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83604. * @param radius The radius of the cylinder to emit from
  83605. * @param height The height of the emission cylinder
  83606. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83607. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83608. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83609. * @returns the emitter
  83610. */
  83611. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83612. /**
  83613. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83614. * @param radius The radius of the cone to emit from
  83615. * @param angle The base angle of the cone
  83616. * @returns the emitter
  83617. */
  83618. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83619. /**
  83620. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83623. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83624. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83625. * @returns the emitter
  83626. */
  83627. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83628. }
  83629. }
  83630. declare module BABYLON {
  83631. /**
  83632. * Type of sub emitter
  83633. */
  83634. export enum SubEmitterType {
  83635. /**
  83636. * Attached to the particle over it's lifetime
  83637. */
  83638. ATTACHED = 0,
  83639. /**
  83640. * Created when the particle dies
  83641. */
  83642. END = 1
  83643. }
  83644. /**
  83645. * Sub emitter class used to emit particles from an existing particle
  83646. */
  83647. export class SubEmitter {
  83648. /**
  83649. * the particle system to be used by the sub emitter
  83650. */
  83651. particleSystem: ParticleSystem;
  83652. /**
  83653. * Type of the submitter (Default: END)
  83654. */
  83655. type: SubEmitterType;
  83656. /**
  83657. * 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)
  83658. * Note: This only is supported when using an emitter of type Mesh
  83659. */
  83660. inheritDirection: boolean;
  83661. /**
  83662. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83663. */
  83664. inheritedVelocityAmount: number;
  83665. /**
  83666. * Creates a sub emitter
  83667. * @param particleSystem the particle system to be used by the sub emitter
  83668. */
  83669. constructor(
  83670. /**
  83671. * the particle system to be used by the sub emitter
  83672. */
  83673. particleSystem: ParticleSystem);
  83674. /**
  83675. * Clones the sub emitter
  83676. * @returns the cloned sub emitter
  83677. */
  83678. clone(): SubEmitter;
  83679. /**
  83680. * Serialize current object to a JSON object
  83681. * @returns the serialized object
  83682. */
  83683. serialize(): any;
  83684. /** @hidden */
  83685. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83686. /**
  83687. * Creates a new SubEmitter from a serialized JSON version
  83688. * @param serializationObject defines the JSON object to read from
  83689. * @param scene defines the hosting scene
  83690. * @param rootUrl defines the rootUrl for data loading
  83691. * @returns a new SubEmitter
  83692. */
  83693. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83694. /** Release associated resources */
  83695. dispose(): void;
  83696. }
  83697. }
  83698. declare module BABYLON {
  83699. /** @hidden */
  83700. export var clipPlaneFragmentDeclaration: {
  83701. name: string;
  83702. shader: string;
  83703. };
  83704. }
  83705. declare module BABYLON {
  83706. /** @hidden */
  83707. export var imageProcessingDeclaration: {
  83708. name: string;
  83709. shader: string;
  83710. };
  83711. }
  83712. declare module BABYLON {
  83713. /** @hidden */
  83714. export var imageProcessingFunctions: {
  83715. name: string;
  83716. shader: string;
  83717. };
  83718. }
  83719. declare module BABYLON {
  83720. /** @hidden */
  83721. export var clipPlaneFragment: {
  83722. name: string;
  83723. shader: string;
  83724. };
  83725. }
  83726. declare module BABYLON {
  83727. /** @hidden */
  83728. export var particlesPixelShader: {
  83729. name: string;
  83730. shader: string;
  83731. };
  83732. }
  83733. declare module BABYLON {
  83734. /** @hidden */
  83735. export var clipPlaneVertexDeclaration: {
  83736. name: string;
  83737. shader: string;
  83738. };
  83739. }
  83740. declare module BABYLON {
  83741. /** @hidden */
  83742. export var clipPlaneVertex: {
  83743. name: string;
  83744. shader: string;
  83745. };
  83746. }
  83747. declare module BABYLON {
  83748. /** @hidden */
  83749. export var particlesVertexShader: {
  83750. name: string;
  83751. shader: string;
  83752. };
  83753. }
  83754. declare module BABYLON {
  83755. /**
  83756. * This represents a particle system in Babylon.
  83757. * 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.
  83758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83759. * @example https://doc.babylonjs.com/babylon101/particles
  83760. */
  83761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83762. /**
  83763. * Billboard mode will only apply to Y axis
  83764. */
  83765. static readonly BILLBOARDMODE_Y: number;
  83766. /**
  83767. * Billboard mode will apply to all axes
  83768. */
  83769. static readonly BILLBOARDMODE_ALL: number;
  83770. /**
  83771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83772. */
  83773. static readonly BILLBOARDMODE_STRETCHED: number;
  83774. /**
  83775. * This function can be defined to provide custom update for active particles.
  83776. * This function will be called instead of regular update (age, position, color, etc.).
  83777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83778. */
  83779. updateFunction: (particles: Particle[]) => void;
  83780. private _emitterWorldMatrix;
  83781. /**
  83782. * This function can be defined to specify initial direction for every new particle.
  83783. * It by default use the emitterType defined function
  83784. */
  83785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83786. /**
  83787. * This function can be defined to specify initial position for every new particle.
  83788. * It by default use the emitterType defined function
  83789. */
  83790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83791. /**
  83792. * @hidden
  83793. */
  83794. _inheritedVelocityOffset: Vector3;
  83795. /**
  83796. * An event triggered when the system is disposed
  83797. */
  83798. onDisposeObservable: Observable<ParticleSystem>;
  83799. private _onDisposeObserver;
  83800. /**
  83801. * Sets a callback that will be triggered when the system is disposed
  83802. */
  83803. onDispose: () => void;
  83804. private _particles;
  83805. private _epsilon;
  83806. private _capacity;
  83807. private _stockParticles;
  83808. private _newPartsExcess;
  83809. private _vertexData;
  83810. private _vertexBuffer;
  83811. private _vertexBuffers;
  83812. private _spriteBuffer;
  83813. private _indexBuffer;
  83814. private _effect;
  83815. private _customEffect;
  83816. private _cachedDefines;
  83817. private _scaledColorStep;
  83818. private _colorDiff;
  83819. private _scaledDirection;
  83820. private _scaledGravity;
  83821. private _currentRenderId;
  83822. private _alive;
  83823. private _useInstancing;
  83824. private _started;
  83825. private _stopped;
  83826. private _actualFrame;
  83827. private _scaledUpdateSpeed;
  83828. private _vertexBufferSize;
  83829. /** @hidden */
  83830. _currentEmitRateGradient: Nullable<FactorGradient>;
  83831. /** @hidden */
  83832. _currentEmitRate1: number;
  83833. /** @hidden */
  83834. _currentEmitRate2: number;
  83835. /** @hidden */
  83836. _currentStartSizeGradient: Nullable<FactorGradient>;
  83837. /** @hidden */
  83838. _currentStartSize1: number;
  83839. /** @hidden */
  83840. _currentStartSize2: number;
  83841. private readonly _rawTextureWidth;
  83842. private _rampGradientsTexture;
  83843. private _useRampGradients;
  83844. /** Gets or sets a boolean indicating that ramp gradients must be used
  83845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83846. */
  83847. useRampGradients: boolean;
  83848. /**
  83849. * 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.
  83850. * 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: [])
  83851. */
  83852. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83853. private _subEmitters;
  83854. /**
  83855. * @hidden
  83856. * If the particle systems emitter should be disposed when the particle system is disposed
  83857. */
  83858. _disposeEmitterOnDispose: boolean;
  83859. /**
  83860. * The current active Sub-systems, this property is used by the root particle system only.
  83861. */
  83862. activeSubSystems: Array<ParticleSystem>;
  83863. private _rootParticleSystem;
  83864. /**
  83865. * Gets the current list of active particles
  83866. */
  83867. readonly particles: Particle[];
  83868. /**
  83869. * Returns the string "ParticleSystem"
  83870. * @returns a string containing the class name
  83871. */
  83872. getClassName(): string;
  83873. /**
  83874. * Instantiates a particle system.
  83875. * 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.
  83876. * @param name The name of the particle system
  83877. * @param capacity The max number of particles alive at the same time
  83878. * @param scene The scene the particle system belongs to
  83879. * @param customEffect a custom effect used to change the way particles are rendered by default
  83880. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83881. * @param epsilon Offset used to render the particles
  83882. */
  83883. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83884. private _addFactorGradient;
  83885. private _removeFactorGradient;
  83886. /**
  83887. * Adds a new life time gradient
  83888. * @param gradient defines the gradient to use (between 0 and 1)
  83889. * @param factor defines the life time factor to affect to the specified gradient
  83890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83891. * @returns the current particle system
  83892. */
  83893. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83894. /**
  83895. * Remove a specific life time gradient
  83896. * @param gradient defines the gradient to remove
  83897. * @returns the current particle system
  83898. */
  83899. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83900. /**
  83901. * Adds a new size gradient
  83902. * @param gradient defines the gradient to use (between 0 and 1)
  83903. * @param factor defines the size factor to affect to the specified gradient
  83904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83905. * @returns the current particle system
  83906. */
  83907. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83908. /**
  83909. * Remove a specific size gradient
  83910. * @param gradient defines the gradient to remove
  83911. * @returns the current particle system
  83912. */
  83913. removeSizeGradient(gradient: number): IParticleSystem;
  83914. /**
  83915. * Adds a new color remap gradient
  83916. * @param gradient defines the gradient to use (between 0 and 1)
  83917. * @param min defines the color remap minimal range
  83918. * @param max defines the color remap maximal range
  83919. * @returns the current particle system
  83920. */
  83921. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83922. /**
  83923. * Remove a specific color remap gradient
  83924. * @param gradient defines the gradient to remove
  83925. * @returns the current particle system
  83926. */
  83927. removeColorRemapGradient(gradient: number): IParticleSystem;
  83928. /**
  83929. * Adds a new alpha remap gradient
  83930. * @param gradient defines the gradient to use (between 0 and 1)
  83931. * @param min defines the alpha remap minimal range
  83932. * @param max defines the alpha remap maximal range
  83933. * @returns the current particle system
  83934. */
  83935. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83936. /**
  83937. * Remove a specific alpha remap gradient
  83938. * @param gradient defines the gradient to remove
  83939. * @returns the current particle system
  83940. */
  83941. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83942. /**
  83943. * Adds a new angular speed gradient
  83944. * @param gradient defines the gradient to use (between 0 and 1)
  83945. * @param factor defines the angular speed to affect to the specified gradient
  83946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83947. * @returns the current particle system
  83948. */
  83949. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83950. /**
  83951. * Remove a specific angular speed gradient
  83952. * @param gradient defines the gradient to remove
  83953. * @returns the current particle system
  83954. */
  83955. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83956. /**
  83957. * Adds a new velocity gradient
  83958. * @param gradient defines the gradient to use (between 0 and 1)
  83959. * @param factor defines the velocity to affect to the specified gradient
  83960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83961. * @returns the current particle system
  83962. */
  83963. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83964. /**
  83965. * Remove a specific velocity gradient
  83966. * @param gradient defines the gradient to remove
  83967. * @returns the current particle system
  83968. */
  83969. removeVelocityGradient(gradient: number): IParticleSystem;
  83970. /**
  83971. * Adds a new limit velocity gradient
  83972. * @param gradient defines the gradient to use (between 0 and 1)
  83973. * @param factor defines the limit velocity value to affect to the specified gradient
  83974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83975. * @returns the current particle system
  83976. */
  83977. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83978. /**
  83979. * Remove a specific limit velocity gradient
  83980. * @param gradient defines the gradient to remove
  83981. * @returns the current particle system
  83982. */
  83983. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83984. /**
  83985. * Adds a new drag gradient
  83986. * @param gradient defines the gradient to use (between 0 and 1)
  83987. * @param factor defines the drag value to affect to the specified gradient
  83988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83989. * @returns the current particle system
  83990. */
  83991. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83992. /**
  83993. * Remove a specific drag gradient
  83994. * @param gradient defines the gradient to remove
  83995. * @returns the current particle system
  83996. */
  83997. removeDragGradient(gradient: number): IParticleSystem;
  83998. /**
  83999. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84000. * @param gradient defines the gradient to use (between 0 and 1)
  84001. * @param factor defines the emit rate value to affect to the specified gradient
  84002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84003. * @returns the current particle system
  84004. */
  84005. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84006. /**
  84007. * Remove a specific emit rate gradient
  84008. * @param gradient defines the gradient to remove
  84009. * @returns the current particle system
  84010. */
  84011. removeEmitRateGradient(gradient: number): IParticleSystem;
  84012. /**
  84013. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84014. * @param gradient defines the gradient to use (between 0 and 1)
  84015. * @param factor defines the start size value to affect to the specified gradient
  84016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84017. * @returns the current particle system
  84018. */
  84019. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84020. /**
  84021. * Remove a specific start size gradient
  84022. * @param gradient defines the gradient to remove
  84023. * @returns the current particle system
  84024. */
  84025. removeStartSizeGradient(gradient: number): IParticleSystem;
  84026. private _createRampGradientTexture;
  84027. /**
  84028. * Gets the current list of ramp gradients.
  84029. * You must use addRampGradient and removeRampGradient to udpate this list
  84030. * @returns the list of ramp gradients
  84031. */
  84032. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84033. /**
  84034. * Adds a new ramp gradient used to remap particle colors
  84035. * @param gradient defines the gradient to use (between 0 and 1)
  84036. * @param color defines the color to affect to the specified gradient
  84037. * @returns the current particle system
  84038. */
  84039. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84040. /**
  84041. * Remove a specific ramp gradient
  84042. * @param gradient defines the gradient to remove
  84043. * @returns the current particle system
  84044. */
  84045. removeRampGradient(gradient: number): ParticleSystem;
  84046. /**
  84047. * Adds a new color gradient
  84048. * @param gradient defines the gradient to use (between 0 and 1)
  84049. * @param color1 defines the color to affect to the specified gradient
  84050. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84051. * @returns this particle system
  84052. */
  84053. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84054. /**
  84055. * Remove a specific color gradient
  84056. * @param gradient defines the gradient to remove
  84057. * @returns this particle system
  84058. */
  84059. removeColorGradient(gradient: number): IParticleSystem;
  84060. private _fetchR;
  84061. protected _reset(): void;
  84062. private _resetEffect;
  84063. private _createVertexBuffers;
  84064. private _createIndexBuffer;
  84065. /**
  84066. * Gets the maximum number of particles active at the same time.
  84067. * @returns The max number of active particles.
  84068. */
  84069. getCapacity(): number;
  84070. /**
  84071. * Gets whether there are still active particles in the system.
  84072. * @returns True if it is alive, otherwise false.
  84073. */
  84074. isAlive(): boolean;
  84075. /**
  84076. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84077. * @returns True if it has been started, otherwise false.
  84078. */
  84079. isStarted(): boolean;
  84080. private _prepareSubEmitterInternalArray;
  84081. /**
  84082. * Starts the particle system and begins to emit
  84083. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84084. */
  84085. start(delay?: number): void;
  84086. /**
  84087. * Stops the particle system.
  84088. * @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.
  84089. */
  84090. stop(stopSubEmitters?: boolean): void;
  84091. /**
  84092. * Remove all active particles
  84093. */
  84094. reset(): void;
  84095. /**
  84096. * @hidden (for internal use only)
  84097. */
  84098. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84099. /**
  84100. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84101. * Its lifetime will start back at 0.
  84102. */
  84103. recycleParticle: (particle: Particle) => void;
  84104. private _stopSubEmitters;
  84105. private _createParticle;
  84106. private _removeFromRoot;
  84107. private _emitFromParticle;
  84108. private _update;
  84109. /** @hidden */
  84110. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84111. /** @hidden */
  84112. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84113. /** @hidden */
  84114. private _getEffect;
  84115. /**
  84116. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84117. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84118. */
  84119. animate(preWarmOnly?: boolean): void;
  84120. private _appendParticleVertices;
  84121. /**
  84122. * Rebuilds the particle system.
  84123. */
  84124. rebuild(): void;
  84125. /**
  84126. * Is this system ready to be used/rendered
  84127. * @return true if the system is ready
  84128. */
  84129. isReady(): boolean;
  84130. private _render;
  84131. /**
  84132. * Renders the particle system in its current state.
  84133. * @returns the current number of particles
  84134. */
  84135. render(): number;
  84136. /**
  84137. * Disposes the particle system and free the associated resources
  84138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84139. */
  84140. dispose(disposeTexture?: boolean): void;
  84141. /**
  84142. * Clones the particle system.
  84143. * @param name The name of the cloned object
  84144. * @param newEmitter The new emitter to use
  84145. * @returns the cloned particle system
  84146. */
  84147. clone(name: string, newEmitter: any): ParticleSystem;
  84148. /**
  84149. * Serializes the particle system to a JSON object.
  84150. * @returns the JSON object
  84151. */
  84152. serialize(): any;
  84153. /** @hidden */
  84154. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84155. /** @hidden */
  84156. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84157. /**
  84158. * Parses a JSON object to create a particle system.
  84159. * @param parsedParticleSystem The JSON object to parse
  84160. * @param scene The scene to create the particle system in
  84161. * @param rootUrl The root url to use to load external dependencies like texture
  84162. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84163. * @returns the Parsed particle system
  84164. */
  84165. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84166. }
  84167. }
  84168. declare module BABYLON {
  84169. /**
  84170. * A particle represents one of the element emitted by a particle system.
  84171. * This is mainly define by its coordinates, direction, velocity and age.
  84172. */
  84173. export class Particle {
  84174. /**
  84175. * The particle system the particle belongs to.
  84176. */
  84177. particleSystem: ParticleSystem;
  84178. private static _Count;
  84179. /**
  84180. * Unique ID of the particle
  84181. */
  84182. id: number;
  84183. /**
  84184. * The world position of the particle in the scene.
  84185. */
  84186. position: Vector3;
  84187. /**
  84188. * The world direction of the particle in the scene.
  84189. */
  84190. direction: Vector3;
  84191. /**
  84192. * The color of the particle.
  84193. */
  84194. color: Color4;
  84195. /**
  84196. * The color change of the particle per step.
  84197. */
  84198. colorStep: Color4;
  84199. /**
  84200. * Defines how long will the life of the particle be.
  84201. */
  84202. lifeTime: number;
  84203. /**
  84204. * The current age of the particle.
  84205. */
  84206. age: number;
  84207. /**
  84208. * The current size of the particle.
  84209. */
  84210. size: number;
  84211. /**
  84212. * The current scale of the particle.
  84213. */
  84214. scale: Vector2;
  84215. /**
  84216. * The current angle of the particle.
  84217. */
  84218. angle: number;
  84219. /**
  84220. * Defines how fast is the angle changing.
  84221. */
  84222. angularSpeed: number;
  84223. /**
  84224. * Defines the cell index used by the particle to be rendered from a sprite.
  84225. */
  84226. cellIndex: number;
  84227. /**
  84228. * The information required to support color remapping
  84229. */
  84230. remapData: Vector4;
  84231. /** @hidden */
  84232. _randomCellOffset?: number;
  84233. /** @hidden */
  84234. _initialDirection: Nullable<Vector3>;
  84235. /** @hidden */
  84236. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84237. /** @hidden */
  84238. _initialStartSpriteCellID: number;
  84239. /** @hidden */
  84240. _initialEndSpriteCellID: number;
  84241. /** @hidden */
  84242. _currentColorGradient: Nullable<ColorGradient>;
  84243. /** @hidden */
  84244. _currentColor1: Color4;
  84245. /** @hidden */
  84246. _currentColor2: Color4;
  84247. /** @hidden */
  84248. _currentSizeGradient: Nullable<FactorGradient>;
  84249. /** @hidden */
  84250. _currentSize1: number;
  84251. /** @hidden */
  84252. _currentSize2: number;
  84253. /** @hidden */
  84254. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84255. /** @hidden */
  84256. _currentAngularSpeed1: number;
  84257. /** @hidden */
  84258. _currentAngularSpeed2: number;
  84259. /** @hidden */
  84260. _currentVelocityGradient: Nullable<FactorGradient>;
  84261. /** @hidden */
  84262. _currentVelocity1: number;
  84263. /** @hidden */
  84264. _currentVelocity2: number;
  84265. /** @hidden */
  84266. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84267. /** @hidden */
  84268. _currentLimitVelocity1: number;
  84269. /** @hidden */
  84270. _currentLimitVelocity2: number;
  84271. /** @hidden */
  84272. _currentDragGradient: Nullable<FactorGradient>;
  84273. /** @hidden */
  84274. _currentDrag1: number;
  84275. /** @hidden */
  84276. _currentDrag2: number;
  84277. /** @hidden */
  84278. _randomNoiseCoordinates1: Vector3;
  84279. /** @hidden */
  84280. _randomNoiseCoordinates2: Vector3;
  84281. /**
  84282. * Creates a new instance Particle
  84283. * @param particleSystem the particle system the particle belongs to
  84284. */
  84285. constructor(
  84286. /**
  84287. * The particle system the particle belongs to.
  84288. */
  84289. particleSystem: ParticleSystem);
  84290. private updateCellInfoFromSystem;
  84291. /**
  84292. * Defines how the sprite cell index is updated for the particle
  84293. */
  84294. updateCellIndex(): void;
  84295. /** @hidden */
  84296. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84297. /** @hidden */
  84298. _inheritParticleInfoToSubEmitters(): void;
  84299. /** @hidden */
  84300. _reset(): void;
  84301. /**
  84302. * Copy the properties of particle to another one.
  84303. * @param other the particle to copy the information to.
  84304. */
  84305. copyTo(other: Particle): void;
  84306. }
  84307. }
  84308. declare module BABYLON {
  84309. /**
  84310. * Particle emitter represents a volume emitting particles.
  84311. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84312. */
  84313. export interface IParticleEmitterType {
  84314. /**
  84315. * Called by the particle System when the direction is computed for the created particle.
  84316. * @param worldMatrix is the world matrix of the particle system
  84317. * @param directionToUpdate is the direction vector to update with the result
  84318. * @param particle is the particle we are computed the direction for
  84319. */
  84320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84321. /**
  84322. * Called by the particle System when the position is computed for the created particle.
  84323. * @param worldMatrix is the world matrix of the particle system
  84324. * @param positionToUpdate is the position vector to update with the result
  84325. * @param particle is the particle we are computed the position for
  84326. */
  84327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84328. /**
  84329. * Clones the current emitter and returns a copy of it
  84330. * @returns the new emitter
  84331. */
  84332. clone(): IParticleEmitterType;
  84333. /**
  84334. * Called by the GPUParticleSystem to setup the update shader
  84335. * @param effect defines the update shader
  84336. */
  84337. applyToShader(effect: Effect): void;
  84338. /**
  84339. * Returns a string to use to update the GPU particles update shader
  84340. * @returns the effect defines string
  84341. */
  84342. getEffectDefines(): string;
  84343. /**
  84344. * Returns a string representing the class name
  84345. * @returns a string containing the class name
  84346. */
  84347. getClassName(): string;
  84348. /**
  84349. * Serializes the particle system to a JSON object.
  84350. * @returns the JSON object
  84351. */
  84352. serialize(): any;
  84353. /**
  84354. * Parse properties from a JSON object
  84355. * @param serializationObject defines the JSON object
  84356. */
  84357. parse(serializationObject: any): void;
  84358. }
  84359. }
  84360. declare module BABYLON {
  84361. /**
  84362. * Particle emitter emitting particles from the inside of a box.
  84363. * It emits the particles randomly between 2 given directions.
  84364. */
  84365. export class BoxParticleEmitter implements IParticleEmitterType {
  84366. /**
  84367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84368. */
  84369. direction1: Vector3;
  84370. /**
  84371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84372. */
  84373. direction2: Vector3;
  84374. /**
  84375. * 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.
  84376. */
  84377. minEmitBox: Vector3;
  84378. /**
  84379. * 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.
  84380. */
  84381. maxEmitBox: Vector3;
  84382. /**
  84383. * Creates a new instance BoxParticleEmitter
  84384. */
  84385. constructor();
  84386. /**
  84387. * Called by the particle System when the direction is computed for the created particle.
  84388. * @param worldMatrix is the world matrix of the particle system
  84389. * @param directionToUpdate is the direction vector to update with the result
  84390. * @param particle is the particle we are computed the direction for
  84391. */
  84392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84393. /**
  84394. * Called by the particle System when the position is computed for the created particle.
  84395. * @param worldMatrix is the world matrix of the particle system
  84396. * @param positionToUpdate is the position vector to update with the result
  84397. * @param particle is the particle we are computed the position for
  84398. */
  84399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84400. /**
  84401. * Clones the current emitter and returns a copy of it
  84402. * @returns the new emitter
  84403. */
  84404. clone(): BoxParticleEmitter;
  84405. /**
  84406. * Called by the GPUParticleSystem to setup the update shader
  84407. * @param effect defines the update shader
  84408. */
  84409. applyToShader(effect: Effect): void;
  84410. /**
  84411. * Returns a string to use to update the GPU particles update shader
  84412. * @returns a string containng the defines string
  84413. */
  84414. getEffectDefines(): string;
  84415. /**
  84416. * Returns the string "BoxParticleEmitter"
  84417. * @returns a string containing the class name
  84418. */
  84419. getClassName(): string;
  84420. /**
  84421. * Serializes the particle system to a JSON object.
  84422. * @returns the JSON object
  84423. */
  84424. serialize(): any;
  84425. /**
  84426. * Parse properties from a JSON object
  84427. * @param serializationObject defines the JSON object
  84428. */
  84429. parse(serializationObject: any): void;
  84430. }
  84431. }
  84432. declare module BABYLON {
  84433. /**
  84434. * Particle emitter emitting particles from the inside of a cone.
  84435. * It emits the particles alongside the cone volume from the base to the particle.
  84436. * The emission direction might be randomized.
  84437. */
  84438. export class ConeParticleEmitter implements IParticleEmitterType {
  84439. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84440. directionRandomizer: number;
  84441. private _radius;
  84442. private _angle;
  84443. private _height;
  84444. /**
  84445. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84446. */
  84447. radiusRange: number;
  84448. /**
  84449. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84450. */
  84451. heightRange: number;
  84452. /**
  84453. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84454. */
  84455. emitFromSpawnPointOnly: boolean;
  84456. /**
  84457. * Gets or sets the radius of the emission cone
  84458. */
  84459. radius: number;
  84460. /**
  84461. * Gets or sets the angle of the emission cone
  84462. */
  84463. angle: number;
  84464. private _buildHeight;
  84465. /**
  84466. * Creates a new instance ConeParticleEmitter
  84467. * @param radius the radius of the emission cone (1 by default)
  84468. * @param angle the cone base angle (PI by default)
  84469. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84470. */
  84471. constructor(radius?: number, angle?: number,
  84472. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84473. directionRandomizer?: number);
  84474. /**
  84475. * Called by the particle System when the direction is computed for the created particle.
  84476. * @param worldMatrix is the world matrix of the particle system
  84477. * @param directionToUpdate is the direction vector to update with the result
  84478. * @param particle is the particle we are computed the direction for
  84479. */
  84480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84481. /**
  84482. * Called by the particle System when the position is computed for the created particle.
  84483. * @param worldMatrix is the world matrix of the particle system
  84484. * @param positionToUpdate is the position vector to update with the result
  84485. * @param particle is the particle we are computed the position for
  84486. */
  84487. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84488. /**
  84489. * Clones the current emitter and returns a copy of it
  84490. * @returns the new emitter
  84491. */
  84492. clone(): ConeParticleEmitter;
  84493. /**
  84494. * Called by the GPUParticleSystem to setup the update shader
  84495. * @param effect defines the update shader
  84496. */
  84497. applyToShader(effect: Effect): void;
  84498. /**
  84499. * Returns a string to use to update the GPU particles update shader
  84500. * @returns a string containng the defines string
  84501. */
  84502. getEffectDefines(): string;
  84503. /**
  84504. * Returns the string "ConeParticleEmitter"
  84505. * @returns a string containing the class name
  84506. */
  84507. getClassName(): string;
  84508. /**
  84509. * Serializes the particle system to a JSON object.
  84510. * @returns the JSON object
  84511. */
  84512. serialize(): any;
  84513. /**
  84514. * Parse properties from a JSON object
  84515. * @param serializationObject defines the JSON object
  84516. */
  84517. parse(serializationObject: any): void;
  84518. }
  84519. }
  84520. declare module BABYLON {
  84521. /**
  84522. * Particle emitter emitting particles from the inside of a cylinder.
  84523. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84524. */
  84525. export class CylinderParticleEmitter implements IParticleEmitterType {
  84526. /**
  84527. * The radius of the emission cylinder.
  84528. */
  84529. radius: number;
  84530. /**
  84531. * The height of the emission cylinder.
  84532. */
  84533. height: number;
  84534. /**
  84535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84536. */
  84537. radiusRange: number;
  84538. /**
  84539. * How much to randomize the particle direction [0-1].
  84540. */
  84541. directionRandomizer: number;
  84542. /**
  84543. * Creates a new instance CylinderParticleEmitter
  84544. * @param radius the radius of the emission cylinder (1 by default)
  84545. * @param height the height of the emission cylinder (1 by default)
  84546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84547. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84548. */
  84549. constructor(
  84550. /**
  84551. * The radius of the emission cylinder.
  84552. */
  84553. radius?: number,
  84554. /**
  84555. * The height of the emission cylinder.
  84556. */
  84557. height?: number,
  84558. /**
  84559. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84560. */
  84561. radiusRange?: number,
  84562. /**
  84563. * How much to randomize the particle direction [0-1].
  84564. */
  84565. directionRandomizer?: number);
  84566. /**
  84567. * Called by the particle System when the direction is computed for the created particle.
  84568. * @param worldMatrix is the world matrix of the particle system
  84569. * @param directionToUpdate is the direction vector to update with the result
  84570. * @param particle is the particle we are computed the direction for
  84571. */
  84572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84573. /**
  84574. * Called by the particle System when the position is computed for the created particle.
  84575. * @param worldMatrix is the world matrix of the particle system
  84576. * @param positionToUpdate is the position vector to update with the result
  84577. * @param particle is the particle we are computed the position for
  84578. */
  84579. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84580. /**
  84581. * Clones the current emitter and returns a copy of it
  84582. * @returns the new emitter
  84583. */
  84584. clone(): CylinderParticleEmitter;
  84585. /**
  84586. * Called by the GPUParticleSystem to setup the update shader
  84587. * @param effect defines the update shader
  84588. */
  84589. applyToShader(effect: Effect): void;
  84590. /**
  84591. * Returns a string to use to update the GPU particles update shader
  84592. * @returns a string containng the defines string
  84593. */
  84594. getEffectDefines(): string;
  84595. /**
  84596. * Returns the string "CylinderParticleEmitter"
  84597. * @returns a string containing the class name
  84598. */
  84599. getClassName(): string;
  84600. /**
  84601. * Serializes the particle system to a JSON object.
  84602. * @returns the JSON object
  84603. */
  84604. serialize(): any;
  84605. /**
  84606. * Parse properties from a JSON object
  84607. * @param serializationObject defines the JSON object
  84608. */
  84609. parse(serializationObject: any): void;
  84610. }
  84611. /**
  84612. * Particle emitter emitting particles from the inside of a cylinder.
  84613. * It emits the particles randomly between two vectors.
  84614. */
  84615. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84616. /**
  84617. * The min limit of the emission direction.
  84618. */
  84619. direction1: Vector3;
  84620. /**
  84621. * The max limit of the emission direction.
  84622. */
  84623. direction2: Vector3;
  84624. /**
  84625. * Creates a new instance CylinderDirectedParticleEmitter
  84626. * @param radius the radius of the emission cylinder (1 by default)
  84627. * @param height the height of the emission cylinder (1 by default)
  84628. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84629. * @param direction1 the min limit of the emission direction (up vector by default)
  84630. * @param direction2 the max limit of the emission direction (up vector by default)
  84631. */
  84632. constructor(radius?: number, height?: number, radiusRange?: number,
  84633. /**
  84634. * The min limit of the emission direction.
  84635. */
  84636. direction1?: Vector3,
  84637. /**
  84638. * The max limit of the emission direction.
  84639. */
  84640. direction2?: Vector3);
  84641. /**
  84642. * Called by the particle System when the direction is computed for the created particle.
  84643. * @param worldMatrix is the world matrix of the particle system
  84644. * @param directionToUpdate is the direction vector to update with the result
  84645. * @param particle is the particle we are computed the direction for
  84646. */
  84647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84648. /**
  84649. * Clones the current emitter and returns a copy of it
  84650. * @returns the new emitter
  84651. */
  84652. clone(): CylinderDirectedParticleEmitter;
  84653. /**
  84654. * Called by the GPUParticleSystem to setup the update shader
  84655. * @param effect defines the update shader
  84656. */
  84657. applyToShader(effect: Effect): void;
  84658. /**
  84659. * Returns a string to use to update the GPU particles update shader
  84660. * @returns a string containng the defines string
  84661. */
  84662. getEffectDefines(): string;
  84663. /**
  84664. * Returns the string "CylinderDirectedParticleEmitter"
  84665. * @returns a string containing the class name
  84666. */
  84667. getClassName(): string;
  84668. /**
  84669. * Serializes the particle system to a JSON object.
  84670. * @returns the JSON object
  84671. */
  84672. serialize(): any;
  84673. /**
  84674. * Parse properties from a JSON object
  84675. * @param serializationObject defines the JSON object
  84676. */
  84677. parse(serializationObject: any): void;
  84678. }
  84679. }
  84680. declare module BABYLON {
  84681. /**
  84682. * Particle emitter emitting particles from the inside of a hemisphere.
  84683. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84684. */
  84685. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84686. /**
  84687. * The radius of the emission hemisphere.
  84688. */
  84689. radius: number;
  84690. /**
  84691. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84692. */
  84693. radiusRange: number;
  84694. /**
  84695. * How much to randomize the particle direction [0-1].
  84696. */
  84697. directionRandomizer: number;
  84698. /**
  84699. * Creates a new instance HemisphericParticleEmitter
  84700. * @param radius the radius of the emission hemisphere (1 by default)
  84701. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84702. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84703. */
  84704. constructor(
  84705. /**
  84706. * The radius of the emission hemisphere.
  84707. */
  84708. radius?: number,
  84709. /**
  84710. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84711. */
  84712. radiusRange?: number,
  84713. /**
  84714. * How much to randomize the particle direction [0-1].
  84715. */
  84716. directionRandomizer?: number);
  84717. /**
  84718. * Called by the particle System when the direction is computed for the created particle.
  84719. * @param worldMatrix is the world matrix of the particle system
  84720. * @param directionToUpdate is the direction vector to update with the result
  84721. * @param particle is the particle we are computed the direction for
  84722. */
  84723. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84724. /**
  84725. * Called by the particle System when the position is computed for the created particle.
  84726. * @param worldMatrix is the world matrix of the particle system
  84727. * @param positionToUpdate is the position vector to update with the result
  84728. * @param particle is the particle we are computed the position for
  84729. */
  84730. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84731. /**
  84732. * Clones the current emitter and returns a copy of it
  84733. * @returns the new emitter
  84734. */
  84735. clone(): HemisphericParticleEmitter;
  84736. /**
  84737. * Called by the GPUParticleSystem to setup the update shader
  84738. * @param effect defines the update shader
  84739. */
  84740. applyToShader(effect: Effect): void;
  84741. /**
  84742. * Returns a string to use to update the GPU particles update shader
  84743. * @returns a string containng the defines string
  84744. */
  84745. getEffectDefines(): string;
  84746. /**
  84747. * Returns the string "HemisphericParticleEmitter"
  84748. * @returns a string containing the class name
  84749. */
  84750. getClassName(): string;
  84751. /**
  84752. * Serializes the particle system to a JSON object.
  84753. * @returns the JSON object
  84754. */
  84755. serialize(): any;
  84756. /**
  84757. * Parse properties from a JSON object
  84758. * @param serializationObject defines the JSON object
  84759. */
  84760. parse(serializationObject: any): void;
  84761. }
  84762. }
  84763. declare module BABYLON {
  84764. /**
  84765. * Particle emitter emitting particles from a point.
  84766. * It emits the particles randomly between 2 given directions.
  84767. */
  84768. export class PointParticleEmitter implements IParticleEmitterType {
  84769. /**
  84770. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84771. */
  84772. direction1: Vector3;
  84773. /**
  84774. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84775. */
  84776. direction2: Vector3;
  84777. /**
  84778. * Creates a new instance PointParticleEmitter
  84779. */
  84780. constructor();
  84781. /**
  84782. * Called by the particle System when the direction is computed for the created particle.
  84783. * @param worldMatrix is the world matrix of the particle system
  84784. * @param directionToUpdate is the direction vector to update with the result
  84785. * @param particle is the particle we are computed the direction for
  84786. */
  84787. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84788. /**
  84789. * Called by the particle System when the position is computed for the created particle.
  84790. * @param worldMatrix is the world matrix of the particle system
  84791. * @param positionToUpdate is the position vector to update with the result
  84792. * @param particle is the particle we are computed the position for
  84793. */
  84794. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84795. /**
  84796. * Clones the current emitter and returns a copy of it
  84797. * @returns the new emitter
  84798. */
  84799. clone(): PointParticleEmitter;
  84800. /**
  84801. * Called by the GPUParticleSystem to setup the update shader
  84802. * @param effect defines the update shader
  84803. */
  84804. applyToShader(effect: Effect): void;
  84805. /**
  84806. * Returns a string to use to update the GPU particles update shader
  84807. * @returns a string containng the defines string
  84808. */
  84809. getEffectDefines(): string;
  84810. /**
  84811. * Returns the string "PointParticleEmitter"
  84812. * @returns a string containing the class name
  84813. */
  84814. getClassName(): string;
  84815. /**
  84816. * Serializes the particle system to a JSON object.
  84817. * @returns the JSON object
  84818. */
  84819. serialize(): any;
  84820. /**
  84821. * Parse properties from a JSON object
  84822. * @param serializationObject defines the JSON object
  84823. */
  84824. parse(serializationObject: any): void;
  84825. }
  84826. }
  84827. declare module BABYLON {
  84828. /**
  84829. * Particle emitter emitting particles from the inside of a sphere.
  84830. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84831. */
  84832. export class SphereParticleEmitter implements IParticleEmitterType {
  84833. /**
  84834. * The radius of the emission sphere.
  84835. */
  84836. radius: number;
  84837. /**
  84838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84839. */
  84840. radiusRange: number;
  84841. /**
  84842. * How much to randomize the particle direction [0-1].
  84843. */
  84844. directionRandomizer: number;
  84845. /**
  84846. * Creates a new instance SphereParticleEmitter
  84847. * @param radius the radius of the emission sphere (1 by default)
  84848. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84849. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84850. */
  84851. constructor(
  84852. /**
  84853. * The radius of the emission sphere.
  84854. */
  84855. radius?: number,
  84856. /**
  84857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84858. */
  84859. radiusRange?: number,
  84860. /**
  84861. * How much to randomize the particle direction [0-1].
  84862. */
  84863. directionRandomizer?: number);
  84864. /**
  84865. * Called by the particle System when the direction is computed for the created particle.
  84866. * @param worldMatrix is the world matrix of the particle system
  84867. * @param directionToUpdate is the direction vector to update with the result
  84868. * @param particle is the particle we are computed the direction for
  84869. */
  84870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84871. /**
  84872. * Called by the particle System when the position is computed for the created particle.
  84873. * @param worldMatrix is the world matrix of the particle system
  84874. * @param positionToUpdate is the position vector to update with the result
  84875. * @param particle is the particle we are computed the position for
  84876. */
  84877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84878. /**
  84879. * Clones the current emitter and returns a copy of it
  84880. * @returns the new emitter
  84881. */
  84882. clone(): SphereParticleEmitter;
  84883. /**
  84884. * Called by the GPUParticleSystem to setup the update shader
  84885. * @param effect defines the update shader
  84886. */
  84887. applyToShader(effect: Effect): void;
  84888. /**
  84889. * Returns a string to use to update the GPU particles update shader
  84890. * @returns a string containng the defines string
  84891. */
  84892. getEffectDefines(): string;
  84893. /**
  84894. * Returns the string "SphereParticleEmitter"
  84895. * @returns a string containing the class name
  84896. */
  84897. getClassName(): string;
  84898. /**
  84899. * Serializes the particle system to a JSON object.
  84900. * @returns the JSON object
  84901. */
  84902. serialize(): any;
  84903. /**
  84904. * Parse properties from a JSON object
  84905. * @param serializationObject defines the JSON object
  84906. */
  84907. parse(serializationObject: any): void;
  84908. }
  84909. /**
  84910. * Particle emitter emitting particles from the inside of a sphere.
  84911. * It emits the particles randomly between two vectors.
  84912. */
  84913. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84914. /**
  84915. * The min limit of the emission direction.
  84916. */
  84917. direction1: Vector3;
  84918. /**
  84919. * The max limit of the emission direction.
  84920. */
  84921. direction2: Vector3;
  84922. /**
  84923. * Creates a new instance SphereDirectedParticleEmitter
  84924. * @param radius the radius of the emission sphere (1 by default)
  84925. * @param direction1 the min limit of the emission direction (up vector by default)
  84926. * @param direction2 the max limit of the emission direction (up vector by default)
  84927. */
  84928. constructor(radius?: number,
  84929. /**
  84930. * The min limit of the emission direction.
  84931. */
  84932. direction1?: Vector3,
  84933. /**
  84934. * The max limit of the emission direction.
  84935. */
  84936. direction2?: Vector3);
  84937. /**
  84938. * Called by the particle System when the direction is computed for the created particle.
  84939. * @param worldMatrix is the world matrix of the particle system
  84940. * @param directionToUpdate is the direction vector to update with the result
  84941. * @param particle is the particle we are computed the direction for
  84942. */
  84943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84944. /**
  84945. * Clones the current emitter and returns a copy of it
  84946. * @returns the new emitter
  84947. */
  84948. clone(): SphereDirectedParticleEmitter;
  84949. /**
  84950. * Called by the GPUParticleSystem to setup the update shader
  84951. * @param effect defines the update shader
  84952. */
  84953. applyToShader(effect: Effect): void;
  84954. /**
  84955. * Returns a string to use to update the GPU particles update shader
  84956. * @returns a string containng the defines string
  84957. */
  84958. getEffectDefines(): string;
  84959. /**
  84960. * Returns the string "SphereDirectedParticleEmitter"
  84961. * @returns a string containing the class name
  84962. */
  84963. getClassName(): string;
  84964. /**
  84965. * Serializes the particle system to a JSON object.
  84966. * @returns the JSON object
  84967. */
  84968. serialize(): any;
  84969. /**
  84970. * Parse properties from a JSON object
  84971. * @param serializationObject defines the JSON object
  84972. */
  84973. parse(serializationObject: any): void;
  84974. }
  84975. }
  84976. declare module BABYLON {
  84977. /**
  84978. * Interface representing a particle system in Babylon.js.
  84979. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84980. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84981. */
  84982. export interface IParticleSystem {
  84983. /**
  84984. * List of animations used by the particle system.
  84985. */
  84986. animations: Animation[];
  84987. /**
  84988. * The id of the Particle system.
  84989. */
  84990. id: string;
  84991. /**
  84992. * The name of the Particle system.
  84993. */
  84994. name: string;
  84995. /**
  84996. * The emitter represents the Mesh or position we are attaching the particle system to.
  84997. */
  84998. emitter: Nullable<AbstractMesh | Vector3>;
  84999. /**
  85000. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85001. */
  85002. isBillboardBased: boolean;
  85003. /**
  85004. * The rendering group used by the Particle system to chose when to render.
  85005. */
  85006. renderingGroupId: number;
  85007. /**
  85008. * The layer mask we are rendering the particles through.
  85009. */
  85010. layerMask: number;
  85011. /**
  85012. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85013. */
  85014. updateSpeed: number;
  85015. /**
  85016. * The amount of time the particle system is running (depends of the overall update speed).
  85017. */
  85018. targetStopDuration: number;
  85019. /**
  85020. * The texture used to render each particle. (this can be a spritesheet)
  85021. */
  85022. particleTexture: Nullable<Texture>;
  85023. /**
  85024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85025. */
  85026. blendMode: number;
  85027. /**
  85028. * Minimum life time of emitting particles.
  85029. */
  85030. minLifeTime: number;
  85031. /**
  85032. * Maximum life time of emitting particles.
  85033. */
  85034. maxLifeTime: number;
  85035. /**
  85036. * Minimum Size of emitting particles.
  85037. */
  85038. minSize: number;
  85039. /**
  85040. * Maximum Size of emitting particles.
  85041. */
  85042. maxSize: number;
  85043. /**
  85044. * Minimum scale of emitting particles on X axis.
  85045. */
  85046. minScaleX: number;
  85047. /**
  85048. * Maximum scale of emitting particles on X axis.
  85049. */
  85050. maxScaleX: number;
  85051. /**
  85052. * Minimum scale of emitting particles on Y axis.
  85053. */
  85054. minScaleY: number;
  85055. /**
  85056. * Maximum scale of emitting particles on Y axis.
  85057. */
  85058. maxScaleY: number;
  85059. /**
  85060. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85061. */
  85062. color1: Color4;
  85063. /**
  85064. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85065. */
  85066. color2: Color4;
  85067. /**
  85068. * Color the particle will have at the end of its lifetime.
  85069. */
  85070. colorDead: Color4;
  85071. /**
  85072. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85073. */
  85074. emitRate: number;
  85075. /**
  85076. * You can use gravity if you want to give an orientation to your particles.
  85077. */
  85078. gravity: Vector3;
  85079. /**
  85080. * Minimum power of emitting particles.
  85081. */
  85082. minEmitPower: number;
  85083. /**
  85084. * Maximum power of emitting particles.
  85085. */
  85086. maxEmitPower: number;
  85087. /**
  85088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85089. */
  85090. minAngularSpeed: number;
  85091. /**
  85092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85093. */
  85094. maxAngularSpeed: number;
  85095. /**
  85096. * Gets or sets the minimal initial rotation in radians.
  85097. */
  85098. minInitialRotation: number;
  85099. /**
  85100. * Gets or sets the maximal initial rotation in radians.
  85101. */
  85102. maxInitialRotation: number;
  85103. /**
  85104. * The particle emitter type defines the emitter used by the particle system.
  85105. * It can be for example box, sphere, or cone...
  85106. */
  85107. particleEmitterType: Nullable<IParticleEmitterType>;
  85108. /**
  85109. * Defines the delay in milliseconds before starting the system (0 by default)
  85110. */
  85111. startDelay: number;
  85112. /**
  85113. * 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
  85114. */
  85115. preWarmCycles: number;
  85116. /**
  85117. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85118. */
  85119. preWarmStepOffset: number;
  85120. /**
  85121. * 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)
  85122. */
  85123. spriteCellChangeSpeed: number;
  85124. /**
  85125. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85126. */
  85127. startSpriteCellID: number;
  85128. /**
  85129. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85130. */
  85131. endSpriteCellID: number;
  85132. /**
  85133. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85134. */
  85135. spriteCellWidth: number;
  85136. /**
  85137. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85138. */
  85139. spriteCellHeight: number;
  85140. /**
  85141. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85142. */
  85143. spriteRandomStartCell: boolean;
  85144. /**
  85145. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85146. */
  85147. isAnimationSheetEnabled: boolean;
  85148. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85149. translationPivot: Vector2;
  85150. /**
  85151. * Gets or sets a texture used to add random noise to particle positions
  85152. */
  85153. noiseTexture: Nullable<BaseTexture>;
  85154. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85155. noiseStrength: Vector3;
  85156. /**
  85157. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85158. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85159. */
  85160. billboardMode: number;
  85161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85162. limitVelocityDamping: number;
  85163. /**
  85164. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85165. */
  85166. beginAnimationOnStart: boolean;
  85167. /**
  85168. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85169. */
  85170. beginAnimationFrom: number;
  85171. /**
  85172. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85173. */
  85174. beginAnimationTo: number;
  85175. /**
  85176. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85177. */
  85178. beginAnimationLoop: boolean;
  85179. /**
  85180. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85181. */
  85182. disposeOnStop: boolean;
  85183. /**
  85184. * Gets the maximum number of particles active at the same time.
  85185. * @returns The max number of active particles.
  85186. */
  85187. getCapacity(): number;
  85188. /**
  85189. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85190. * @returns True if it has been started, otherwise false.
  85191. */
  85192. isStarted(): boolean;
  85193. /**
  85194. * Animates the particle system for this frame.
  85195. */
  85196. animate(): void;
  85197. /**
  85198. * Renders the particle system in its current state.
  85199. * @returns the current number of particles
  85200. */
  85201. render(): number;
  85202. /**
  85203. * Dispose the particle system and frees its associated resources.
  85204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85205. */
  85206. dispose(disposeTexture?: boolean): void;
  85207. /**
  85208. * Clones the particle system.
  85209. * @param name The name of the cloned object
  85210. * @param newEmitter The new emitter to use
  85211. * @returns the cloned particle system
  85212. */
  85213. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85214. /**
  85215. * Serializes the particle system to a JSON object.
  85216. * @returns the JSON object
  85217. */
  85218. serialize(): any;
  85219. /**
  85220. * Rebuild the particle system
  85221. */
  85222. rebuild(): void;
  85223. /**
  85224. * Starts the particle system and begins to emit
  85225. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85226. */
  85227. start(delay?: number): void;
  85228. /**
  85229. * Stops the particle system.
  85230. */
  85231. stop(): void;
  85232. /**
  85233. * Remove all active particles
  85234. */
  85235. reset(): void;
  85236. /**
  85237. * Is this system ready to be used/rendered
  85238. * @return true if the system is ready
  85239. */
  85240. isReady(): boolean;
  85241. /**
  85242. * Adds a new color gradient
  85243. * @param gradient defines the gradient to use (between 0 and 1)
  85244. * @param color1 defines the color to affect to the specified gradient
  85245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85246. * @returns the current particle system
  85247. */
  85248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85249. /**
  85250. * Remove a specific color gradient
  85251. * @param gradient defines the gradient to remove
  85252. * @returns the current particle system
  85253. */
  85254. removeColorGradient(gradient: number): IParticleSystem;
  85255. /**
  85256. * Adds a new size gradient
  85257. * @param gradient defines the gradient to use (between 0 and 1)
  85258. * @param factor defines the size factor to affect to the specified gradient
  85259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85260. * @returns the current particle system
  85261. */
  85262. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85263. /**
  85264. * Remove a specific size gradient
  85265. * @param gradient defines the gradient to remove
  85266. * @returns the current particle system
  85267. */
  85268. removeSizeGradient(gradient: number): IParticleSystem;
  85269. /**
  85270. * Gets the current list of color gradients.
  85271. * You must use addColorGradient and removeColorGradient to udpate this list
  85272. * @returns the list of color gradients
  85273. */
  85274. getColorGradients(): Nullable<Array<ColorGradient>>;
  85275. /**
  85276. * Gets the current list of size gradients.
  85277. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85278. * @returns the list of size gradients
  85279. */
  85280. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85281. /**
  85282. * Gets the current list of angular speed gradients.
  85283. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85284. * @returns the list of angular speed gradients
  85285. */
  85286. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85287. /**
  85288. * Adds a new angular speed gradient
  85289. * @param gradient defines the gradient to use (between 0 and 1)
  85290. * @param factor defines the angular speed to affect to the specified gradient
  85291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85292. * @returns the current particle system
  85293. */
  85294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85295. /**
  85296. * Remove a specific angular speed gradient
  85297. * @param gradient defines the gradient to remove
  85298. * @returns the current particle system
  85299. */
  85300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85301. /**
  85302. * Gets the current list of velocity gradients.
  85303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85304. * @returns the list of velocity gradients
  85305. */
  85306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85307. /**
  85308. * Adds a new velocity gradient
  85309. * @param gradient defines the gradient to use (between 0 and 1)
  85310. * @param factor defines the velocity to affect to the specified gradient
  85311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85312. * @returns the current particle system
  85313. */
  85314. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85315. /**
  85316. * Remove a specific velocity gradient
  85317. * @param gradient defines the gradient to remove
  85318. * @returns the current particle system
  85319. */
  85320. removeVelocityGradient(gradient: number): IParticleSystem;
  85321. /**
  85322. * Gets the current list of limit velocity gradients.
  85323. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85324. * @returns the list of limit velocity gradients
  85325. */
  85326. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85327. /**
  85328. * Adds a new limit velocity gradient
  85329. * @param gradient defines the gradient to use (between 0 and 1)
  85330. * @param factor defines the limit velocity to affect to the specified gradient
  85331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85332. * @returns the current particle system
  85333. */
  85334. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85335. /**
  85336. * Remove a specific limit velocity gradient
  85337. * @param gradient defines the gradient to remove
  85338. * @returns the current particle system
  85339. */
  85340. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85341. /**
  85342. * Adds a new drag gradient
  85343. * @param gradient defines the gradient to use (between 0 and 1)
  85344. * @param factor defines the drag to affect to the specified gradient
  85345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85346. * @returns the current particle system
  85347. */
  85348. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85349. /**
  85350. * Remove a specific drag gradient
  85351. * @param gradient defines the gradient to remove
  85352. * @returns the current particle system
  85353. */
  85354. removeDragGradient(gradient: number): IParticleSystem;
  85355. /**
  85356. * Gets the current list of drag gradients.
  85357. * You must use addDragGradient and removeDragGradient to udpate this list
  85358. * @returns the list of drag gradients
  85359. */
  85360. getDragGradients(): Nullable<Array<FactorGradient>>;
  85361. /**
  85362. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85363. * @param gradient defines the gradient to use (between 0 and 1)
  85364. * @param factor defines the emit rate to affect to the specified gradient
  85365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85366. * @returns the current particle system
  85367. */
  85368. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85369. /**
  85370. * Remove a specific emit rate gradient
  85371. * @param gradient defines the gradient to remove
  85372. * @returns the current particle system
  85373. */
  85374. removeEmitRateGradient(gradient: number): IParticleSystem;
  85375. /**
  85376. * Gets the current list of emit rate gradients.
  85377. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85378. * @returns the list of emit rate gradients
  85379. */
  85380. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85381. /**
  85382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85383. * @param gradient defines the gradient to use (between 0 and 1)
  85384. * @param factor defines the start size to affect to the specified gradient
  85385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85386. * @returns the current particle system
  85387. */
  85388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85389. /**
  85390. * Remove a specific start size gradient
  85391. * @param gradient defines the gradient to remove
  85392. * @returns the current particle system
  85393. */
  85394. removeStartSizeGradient(gradient: number): IParticleSystem;
  85395. /**
  85396. * Gets the current list of start size gradients.
  85397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85398. * @returns the list of start size gradients
  85399. */
  85400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85401. /**
  85402. * Adds a new life time gradient
  85403. * @param gradient defines the gradient to use (between 0 and 1)
  85404. * @param factor defines the life time factor to affect to the specified gradient
  85405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85406. * @returns the current particle system
  85407. */
  85408. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85409. /**
  85410. * Remove a specific life time gradient
  85411. * @param gradient defines the gradient to remove
  85412. * @returns the current particle system
  85413. */
  85414. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85415. /**
  85416. * Gets the current list of life time gradients.
  85417. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85418. * @returns the list of life time gradients
  85419. */
  85420. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85421. /**
  85422. * Gets the current list of color gradients.
  85423. * You must use addColorGradient and removeColorGradient to udpate this list
  85424. * @returns the list of color gradients
  85425. */
  85426. getColorGradients(): Nullable<Array<ColorGradient>>;
  85427. /**
  85428. * Adds a new ramp gradient used to remap particle colors
  85429. * @param gradient defines the gradient to use (between 0 and 1)
  85430. * @param color defines the color to affect to the specified gradient
  85431. * @returns the current particle system
  85432. */
  85433. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85434. /**
  85435. * Gets the current list of ramp gradients.
  85436. * You must use addRampGradient and removeRampGradient to udpate this list
  85437. * @returns the list of ramp gradients
  85438. */
  85439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85440. /** Gets or sets a boolean indicating that ramp gradients must be used
  85441. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85442. */
  85443. useRampGradients: boolean;
  85444. /**
  85445. * Adds a new color remap gradient
  85446. * @param gradient defines the gradient to use (between 0 and 1)
  85447. * @param min defines the color remap minimal range
  85448. * @param max defines the color remap maximal range
  85449. * @returns the current particle system
  85450. */
  85451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85452. /**
  85453. * Gets the current list of color remap gradients.
  85454. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85455. * @returns the list of color remap gradients
  85456. */
  85457. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85458. /**
  85459. * Adds a new alpha remap gradient
  85460. * @param gradient defines the gradient to use (between 0 and 1)
  85461. * @param min defines the alpha remap minimal range
  85462. * @param max defines the alpha remap maximal range
  85463. * @returns the current particle system
  85464. */
  85465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85466. /**
  85467. * Gets the current list of alpha remap gradients.
  85468. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85469. * @returns the list of alpha remap gradients
  85470. */
  85471. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85472. /**
  85473. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85476. * @returns the emitter
  85477. */
  85478. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85479. /**
  85480. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85481. * @param radius The radius of the hemisphere to emit from
  85482. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85483. * @returns the emitter
  85484. */
  85485. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85486. /**
  85487. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85488. * @param radius The radius of the sphere to emit from
  85489. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85490. * @returns the emitter
  85491. */
  85492. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85493. /**
  85494. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85495. * @param radius The radius of the sphere to emit from
  85496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85498. * @returns the emitter
  85499. */
  85500. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85501. /**
  85502. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85503. * @param radius The radius of the emission cylinder
  85504. * @param height The height of the emission cylinder
  85505. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85506. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85507. * @returns the emitter
  85508. */
  85509. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85510. /**
  85511. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85512. * @param radius The radius of the cylinder to emit from
  85513. * @param height The height of the emission cylinder
  85514. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85517. * @returns the emitter
  85518. */
  85519. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85520. /**
  85521. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85522. * @param radius The radius of the cone to emit from
  85523. * @param angle The base angle of the cone
  85524. * @returns the emitter
  85525. */
  85526. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85527. /**
  85528. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85531. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85532. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85533. * @returns the emitter
  85534. */
  85535. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85536. /**
  85537. * Get hosting scene
  85538. * @returns the scene
  85539. */
  85540. getScene(): Scene;
  85541. }
  85542. }
  85543. declare module BABYLON {
  85544. /**
  85545. * Creates an instance based on a source mesh.
  85546. */
  85547. export class InstancedMesh extends AbstractMesh {
  85548. private _sourceMesh;
  85549. private _currentLOD;
  85550. /** @hidden */
  85551. _indexInSourceMeshInstanceArray: number;
  85552. constructor(name: string, source: Mesh);
  85553. /**
  85554. * Returns the string "InstancedMesh".
  85555. */
  85556. getClassName(): string;
  85557. /** Gets the list of lights affecting that mesh */
  85558. readonly lightSources: Light[];
  85559. _resyncLightSources(): void;
  85560. _resyncLighSource(light: Light): void;
  85561. _removeLightSource(light: Light, dispose: boolean): void;
  85562. /**
  85563. * If the source mesh receives shadows
  85564. */
  85565. readonly receiveShadows: boolean;
  85566. /**
  85567. * The material of the source mesh
  85568. */
  85569. readonly material: Nullable<Material>;
  85570. /**
  85571. * Visibility of the source mesh
  85572. */
  85573. readonly visibility: number;
  85574. /**
  85575. * Skeleton of the source mesh
  85576. */
  85577. readonly skeleton: Nullable<Skeleton>;
  85578. /**
  85579. * Rendering ground id of the source mesh
  85580. */
  85581. renderingGroupId: number;
  85582. /**
  85583. * Returns the total number of vertices (integer).
  85584. */
  85585. getTotalVertices(): number;
  85586. /**
  85587. * Returns a positive integer : the total number of indices in this mesh geometry.
  85588. * @returns the numner of indices or zero if the mesh has no geometry.
  85589. */
  85590. getTotalIndices(): number;
  85591. /**
  85592. * The source mesh of the instance
  85593. */
  85594. readonly sourceMesh: Mesh;
  85595. /**
  85596. * Is this node ready to be used/rendered
  85597. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85598. * @return {boolean} is it ready
  85599. */
  85600. isReady(completeCheck?: boolean): boolean;
  85601. /**
  85602. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85603. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85604. * @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.
  85605. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85606. */
  85607. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85608. /**
  85609. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85610. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85611. * The `data` are either a numeric array either a Float32Array.
  85612. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85613. * 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).
  85614. * Note that a new underlying VertexBuffer object is created each call.
  85615. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85616. *
  85617. * Possible `kind` values :
  85618. * - VertexBuffer.PositionKind
  85619. * - VertexBuffer.UVKind
  85620. * - VertexBuffer.UV2Kind
  85621. * - VertexBuffer.UV3Kind
  85622. * - VertexBuffer.UV4Kind
  85623. * - VertexBuffer.UV5Kind
  85624. * - VertexBuffer.UV6Kind
  85625. * - VertexBuffer.ColorKind
  85626. * - VertexBuffer.MatricesIndicesKind
  85627. * - VertexBuffer.MatricesIndicesExtraKind
  85628. * - VertexBuffer.MatricesWeightsKind
  85629. * - VertexBuffer.MatricesWeightsExtraKind
  85630. *
  85631. * Returns the Mesh.
  85632. */
  85633. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85634. /**
  85635. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85636. * If the mesh has no geometry, it is simply returned as it is.
  85637. * The `data` are either a numeric array either a Float32Array.
  85638. * No new underlying VertexBuffer object is created.
  85639. * 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.
  85640. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85641. *
  85642. * Possible `kind` values :
  85643. * - VertexBuffer.PositionKind
  85644. * - VertexBuffer.UVKind
  85645. * - VertexBuffer.UV2Kind
  85646. * - VertexBuffer.UV3Kind
  85647. * - VertexBuffer.UV4Kind
  85648. * - VertexBuffer.UV5Kind
  85649. * - VertexBuffer.UV6Kind
  85650. * - VertexBuffer.ColorKind
  85651. * - VertexBuffer.MatricesIndicesKind
  85652. * - VertexBuffer.MatricesIndicesExtraKind
  85653. * - VertexBuffer.MatricesWeightsKind
  85654. * - VertexBuffer.MatricesWeightsExtraKind
  85655. *
  85656. * Returns the Mesh.
  85657. */
  85658. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85659. /**
  85660. * Sets the mesh indices.
  85661. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85663. * This method creates a new index buffer each call.
  85664. * Returns the Mesh.
  85665. */
  85666. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85667. /**
  85668. * Boolean : True if the mesh owns the requested kind of data.
  85669. */
  85670. isVerticesDataPresent(kind: string): boolean;
  85671. /**
  85672. * Returns an array of indices (IndicesArray).
  85673. */
  85674. getIndices(): Nullable<IndicesArray>;
  85675. readonly _positions: Nullable<Vector3[]>;
  85676. /**
  85677. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85678. * This means the mesh underlying bounding box and sphere are recomputed.
  85679. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85680. * @returns the current mesh
  85681. */
  85682. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85683. /** @hidden */
  85684. _preActivate(): InstancedMesh;
  85685. /** @hidden */
  85686. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85687. /** @hidden */
  85688. _postActivate(): void;
  85689. getWorldMatrix(): Matrix;
  85690. readonly isAnInstance: boolean;
  85691. /**
  85692. * Returns the current associated LOD AbstractMesh.
  85693. */
  85694. getLOD(camera: Camera): AbstractMesh;
  85695. /** @hidden */
  85696. _syncSubMeshes(): InstancedMesh;
  85697. /** @hidden */
  85698. _generatePointsArray(): boolean;
  85699. /**
  85700. * Creates a new InstancedMesh from the current mesh.
  85701. * - name (string) : the cloned mesh name
  85702. * - newParent (optional Node) : the optional Node to parent the clone to.
  85703. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85704. *
  85705. * Returns the clone.
  85706. */
  85707. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85708. /**
  85709. * Disposes the InstancedMesh.
  85710. * Returns nothing.
  85711. */
  85712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85713. }
  85714. }
  85715. declare module BABYLON {
  85716. /**
  85717. * Defines the options associated with the creation of a shader material.
  85718. */
  85719. export interface IShaderMaterialOptions {
  85720. /**
  85721. * Does the material work in alpha blend mode
  85722. */
  85723. needAlphaBlending: boolean;
  85724. /**
  85725. * Does the material work in alpha test mode
  85726. */
  85727. needAlphaTesting: boolean;
  85728. /**
  85729. * The list of attribute names used in the shader
  85730. */
  85731. attributes: string[];
  85732. /**
  85733. * The list of unifrom names used in the shader
  85734. */
  85735. uniforms: string[];
  85736. /**
  85737. * The list of UBO names used in the shader
  85738. */
  85739. uniformBuffers: string[];
  85740. /**
  85741. * The list of sampler names used in the shader
  85742. */
  85743. samplers: string[];
  85744. /**
  85745. * The list of defines used in the shader
  85746. */
  85747. defines: string[];
  85748. }
  85749. /**
  85750. * 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.
  85751. *
  85752. * This returned material effects how the mesh will look based on the code in the shaders.
  85753. *
  85754. * @see http://doc.babylonjs.com/how_to/shader_material
  85755. */
  85756. export class ShaderMaterial extends Material {
  85757. private _shaderPath;
  85758. private _options;
  85759. private _textures;
  85760. private _textureArrays;
  85761. private _floats;
  85762. private _ints;
  85763. private _floatsArrays;
  85764. private _colors3;
  85765. private _colors3Arrays;
  85766. private _colors4;
  85767. private _colors4Arrays;
  85768. private _vectors2;
  85769. private _vectors3;
  85770. private _vectors4;
  85771. private _matrices;
  85772. private _matrices3x3;
  85773. private _matrices2x2;
  85774. private _vectors2Arrays;
  85775. private _vectors3Arrays;
  85776. private _vectors4Arrays;
  85777. private _cachedWorldViewMatrix;
  85778. private _cachedWorldViewProjectionMatrix;
  85779. private _renderId;
  85780. /**
  85781. * Instantiate a new shader material.
  85782. * 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.
  85783. * This returned material effects how the mesh will look based on the code in the shaders.
  85784. * @see http://doc.babylonjs.com/how_to/shader_material
  85785. * @param name Define the name of the material in the scene
  85786. * @param scene Define the scene the material belongs to
  85787. * @param shaderPath Defines the route to the shader code in one of three ways:
  85788. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85789. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85790. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85791. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85792. * @param options Define the options used to create the shader
  85793. */
  85794. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85795. /**
  85796. * Gets the options used to compile the shader.
  85797. * They can be modified to trigger a new compilation
  85798. */
  85799. readonly options: IShaderMaterialOptions;
  85800. /**
  85801. * Gets the current class name of the material e.g. "ShaderMaterial"
  85802. * Mainly use in serialization.
  85803. * @returns the class name
  85804. */
  85805. getClassName(): string;
  85806. /**
  85807. * Specifies if the material will require alpha blending
  85808. * @returns a boolean specifying if alpha blending is needed
  85809. */
  85810. needAlphaBlending(): boolean;
  85811. /**
  85812. * Specifies if this material should be rendered in alpha test mode
  85813. * @returns a boolean specifying if an alpha test is needed.
  85814. */
  85815. needAlphaTesting(): boolean;
  85816. private _checkUniform;
  85817. /**
  85818. * Set a texture in the shader.
  85819. * @param name Define the name of the uniform samplers as defined in the shader
  85820. * @param texture Define the texture to bind to this sampler
  85821. * @return the material itself allowing "fluent" like uniform updates
  85822. */
  85823. setTexture(name: string, texture: Texture): ShaderMaterial;
  85824. /**
  85825. * Set a texture array in the shader.
  85826. * @param name Define the name of the uniform sampler array as defined in the shader
  85827. * @param textures Define the list of textures to bind to this sampler
  85828. * @return the material itself allowing "fluent" like uniform updates
  85829. */
  85830. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85831. /**
  85832. * Set a float in the shader.
  85833. * @param name Define the name of the uniform as defined in the shader
  85834. * @param value Define the value to give to the uniform
  85835. * @return the material itself allowing "fluent" like uniform updates
  85836. */
  85837. setFloat(name: string, value: number): ShaderMaterial;
  85838. /**
  85839. * Set a int in the shader.
  85840. * @param name Define the name of the uniform as defined in the shader
  85841. * @param value Define the value to give to the uniform
  85842. * @return the material itself allowing "fluent" like uniform updates
  85843. */
  85844. setInt(name: string, value: number): ShaderMaterial;
  85845. /**
  85846. * Set an array of floats in the shader.
  85847. * @param name Define the name of the uniform as defined in the shader
  85848. * @param value Define the value to give to the uniform
  85849. * @return the material itself allowing "fluent" like uniform updates
  85850. */
  85851. setFloats(name: string, value: number[]): ShaderMaterial;
  85852. /**
  85853. * Set a vec3 in the shader from a Color3.
  85854. * @param name Define the name of the uniform as defined in the shader
  85855. * @param value Define the value to give to the uniform
  85856. * @return the material itself allowing "fluent" like uniform updates
  85857. */
  85858. setColor3(name: string, value: Color3): ShaderMaterial;
  85859. /**
  85860. * Set a vec3 array in the shader from a Color3 array.
  85861. * @param name Define the name of the uniform as defined in the shader
  85862. * @param value Define the value to give to the uniform
  85863. * @return the material itself allowing "fluent" like uniform updates
  85864. */
  85865. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85866. /**
  85867. * Set a vec4 in the shader from a Color4.
  85868. * @param name Define the name of the uniform as defined in the shader
  85869. * @param value Define the value to give to the uniform
  85870. * @return the material itself allowing "fluent" like uniform updates
  85871. */
  85872. setColor4(name: string, value: Color4): ShaderMaterial;
  85873. /**
  85874. * Set a vec4 array in the shader from a Color4 array.
  85875. * @param name Define the name of the uniform as defined in the shader
  85876. * @param value Define the value to give to the uniform
  85877. * @return the material itself allowing "fluent" like uniform updates
  85878. */
  85879. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85880. /**
  85881. * Set a vec2 in the shader from a Vector2.
  85882. * @param name Define the name of the uniform as defined in the shader
  85883. * @param value Define the value to give to the uniform
  85884. * @return the material itself allowing "fluent" like uniform updates
  85885. */
  85886. setVector2(name: string, value: Vector2): ShaderMaterial;
  85887. /**
  85888. * Set a vec3 in the shader from a Vector3.
  85889. * @param name Define the name of the uniform as defined in the shader
  85890. * @param value Define the value to give to the uniform
  85891. * @return the material itself allowing "fluent" like uniform updates
  85892. */
  85893. setVector3(name: string, value: Vector3): ShaderMaterial;
  85894. /**
  85895. * Set a vec4 in the shader from a Vector4.
  85896. * @param name Define the name of the uniform as defined in the shader
  85897. * @param value Define the value to give to the uniform
  85898. * @return the material itself allowing "fluent" like uniform updates
  85899. */
  85900. setVector4(name: string, value: Vector4): ShaderMaterial;
  85901. /**
  85902. * Set a mat4 in the shader from a Matrix.
  85903. * @param name Define the name of the uniform as defined in the shader
  85904. * @param value Define the value to give to the uniform
  85905. * @return the material itself allowing "fluent" like uniform updates
  85906. */
  85907. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85908. /**
  85909. * Set a mat3 in the shader from a Float32Array.
  85910. * @param name Define the name of the uniform as defined in the shader
  85911. * @param value Define the value to give to the uniform
  85912. * @return the material itself allowing "fluent" like uniform updates
  85913. */
  85914. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85915. /**
  85916. * Set a mat2 in the shader from a Float32Array.
  85917. * @param name Define the name of the uniform as defined in the shader
  85918. * @param value Define the value to give to the uniform
  85919. * @return the material itself allowing "fluent" like uniform updates
  85920. */
  85921. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85922. /**
  85923. * Set a vec2 array in the shader from a number array.
  85924. * @param name Define the name of the uniform as defined in the shader
  85925. * @param value Define the value to give to the uniform
  85926. * @return the material itself allowing "fluent" like uniform updates
  85927. */
  85928. setArray2(name: string, value: number[]): ShaderMaterial;
  85929. /**
  85930. * Set a vec3 array in the shader from a number array.
  85931. * @param name Define the name of the uniform as defined in the shader
  85932. * @param value Define the value to give to the uniform
  85933. * @return the material itself allowing "fluent" like uniform updates
  85934. */
  85935. setArray3(name: string, value: number[]): ShaderMaterial;
  85936. /**
  85937. * Set a vec4 array in the shader from a number array.
  85938. * @param name Define the name of the uniform as defined in the shader
  85939. * @param value Define the value to give to the uniform
  85940. * @return the material itself allowing "fluent" like uniform updates
  85941. */
  85942. setArray4(name: string, value: number[]): ShaderMaterial;
  85943. private _checkCache;
  85944. /**
  85945. * Specifies that the submesh is ready to be used
  85946. * @param mesh defines the mesh to check
  85947. * @param subMesh defines which submesh to check
  85948. * @param useInstances specifies that instances should be used
  85949. * @returns a boolean indicating that the submesh is ready or not
  85950. */
  85951. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85952. /**
  85953. * Checks if the material is ready to render the requested mesh
  85954. * @param mesh Define the mesh to render
  85955. * @param useInstances Define whether or not the material is used with instances
  85956. * @returns true if ready, otherwise false
  85957. */
  85958. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85959. /**
  85960. * Binds the world matrix to the material
  85961. * @param world defines the world transformation matrix
  85962. */
  85963. bindOnlyWorldMatrix(world: Matrix): void;
  85964. /**
  85965. * Binds the material to the mesh
  85966. * @param world defines the world transformation matrix
  85967. * @param mesh defines the mesh to bind the material to
  85968. */
  85969. bind(world: Matrix, mesh?: Mesh): void;
  85970. /**
  85971. * Gets the active textures from the material
  85972. * @returns an array of textures
  85973. */
  85974. getActiveTextures(): BaseTexture[];
  85975. /**
  85976. * Specifies if the material uses a texture
  85977. * @param texture defines the texture to check against the material
  85978. * @returns a boolean specifying if the material uses the texture
  85979. */
  85980. hasTexture(texture: BaseTexture): boolean;
  85981. /**
  85982. * Makes a duplicate of the material, and gives it a new name
  85983. * @param name defines the new name for the duplicated material
  85984. * @returns the cloned material
  85985. */
  85986. clone(name: string): ShaderMaterial;
  85987. /**
  85988. * Disposes the material
  85989. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85990. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85991. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85992. */
  85993. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85994. /**
  85995. * Serializes this material in a JSON representation
  85996. * @returns the serialized material object
  85997. */
  85998. serialize(): any;
  85999. /**
  86000. * Creates a shader material from parsed shader material data
  86001. * @param source defines the JSON represnetation of the material
  86002. * @param scene defines the hosting scene
  86003. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86004. * @returns a new material
  86005. */
  86006. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86007. }
  86008. }
  86009. declare module BABYLON {
  86010. /** @hidden */
  86011. export var colorPixelShader: {
  86012. name: string;
  86013. shader: string;
  86014. };
  86015. }
  86016. declare module BABYLON {
  86017. /** @hidden */
  86018. export var colorVertexShader: {
  86019. name: string;
  86020. shader: string;
  86021. };
  86022. }
  86023. declare module BABYLON {
  86024. /**
  86025. * Line mesh
  86026. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86027. */
  86028. export class LinesMesh extends Mesh {
  86029. /**
  86030. * If vertex color should be applied to the mesh
  86031. */
  86032. readonly useVertexColor?: boolean | undefined;
  86033. /**
  86034. * If vertex alpha should be applied to the mesh
  86035. */
  86036. readonly useVertexAlpha?: boolean | undefined;
  86037. /**
  86038. * Color of the line (Default: White)
  86039. */
  86040. color: Color3;
  86041. /**
  86042. * Alpha of the line (Default: 1)
  86043. */
  86044. alpha: number;
  86045. /**
  86046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86047. * This margin is expressed in world space coordinates, so its value may vary.
  86048. * Default value is 0.1
  86049. */
  86050. intersectionThreshold: number;
  86051. private _colorShader;
  86052. private color4;
  86053. /**
  86054. * Creates a new LinesMesh
  86055. * @param name defines the name
  86056. * @param scene defines the hosting scene
  86057. * @param parent defines the parent mesh if any
  86058. * @param source defines the optional source LinesMesh used to clone data from
  86059. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86060. * When false, achieved by calling a clone(), also passing False.
  86061. * This will make creation of children, recursive.
  86062. * @param useVertexColor defines if this LinesMesh supports vertex color
  86063. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86064. */
  86065. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86066. /**
  86067. * If vertex color should be applied to the mesh
  86068. */
  86069. useVertexColor?: boolean | undefined,
  86070. /**
  86071. * If vertex alpha should be applied to the mesh
  86072. */
  86073. useVertexAlpha?: boolean | undefined);
  86074. private _addClipPlaneDefine;
  86075. private _removeClipPlaneDefine;
  86076. isReady(): boolean;
  86077. /**
  86078. * Returns the string "LineMesh"
  86079. */
  86080. getClassName(): string;
  86081. /**
  86082. * @hidden
  86083. */
  86084. /**
  86085. * @hidden
  86086. */
  86087. material: Material;
  86088. /**
  86089. * @hidden
  86090. */
  86091. readonly checkCollisions: boolean;
  86092. /** @hidden */
  86093. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86094. /** @hidden */
  86095. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86096. /**
  86097. * Disposes of the line mesh
  86098. * @param doNotRecurse If children should be disposed
  86099. */
  86100. dispose(doNotRecurse?: boolean): void;
  86101. /**
  86102. * Returns a new LineMesh object cloned from the current one.
  86103. */
  86104. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86105. /**
  86106. * Creates a new InstancedLinesMesh object from the mesh model.
  86107. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86108. * @param name defines the name of the new instance
  86109. * @returns a new InstancedLinesMesh
  86110. */
  86111. createInstance(name: string): InstancedLinesMesh;
  86112. }
  86113. /**
  86114. * Creates an instance based on a source LinesMesh
  86115. */
  86116. export class InstancedLinesMesh extends InstancedMesh {
  86117. /**
  86118. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86119. * This margin is expressed in world space coordinates, so its value may vary.
  86120. * Initilized with the intersectionThreshold value of the source LinesMesh
  86121. */
  86122. intersectionThreshold: number;
  86123. constructor(name: string, source: LinesMesh);
  86124. /**
  86125. * Returns the string "InstancedLinesMesh".
  86126. */
  86127. getClassName(): string;
  86128. }
  86129. }
  86130. declare module BABYLON {
  86131. /** @hidden */
  86132. export var linePixelShader: {
  86133. name: string;
  86134. shader: string;
  86135. };
  86136. }
  86137. declare module BABYLON {
  86138. /** @hidden */
  86139. export var lineVertexShader: {
  86140. name: string;
  86141. shader: string;
  86142. };
  86143. }
  86144. declare module BABYLON {
  86145. interface AbstractMesh {
  86146. /**
  86147. * Gets the edgesRenderer associated with the mesh
  86148. */
  86149. edgesRenderer: Nullable<EdgesRenderer>;
  86150. }
  86151. interface LinesMesh {
  86152. /**
  86153. * Enables the edge rendering mode on the mesh.
  86154. * This mode makes the mesh edges visible
  86155. * @param epsilon defines the maximal distance between two angles to detect a face
  86156. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86157. * @returns the currentAbstractMesh
  86158. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86159. */
  86160. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86161. }
  86162. interface InstancedLinesMesh {
  86163. /**
  86164. * Enables the edge rendering mode on the mesh.
  86165. * This mode makes the mesh edges visible
  86166. * @param epsilon defines the maximal distance between two angles to detect a face
  86167. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86168. * @returns the current InstancedLinesMesh
  86169. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86170. */
  86171. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86172. }
  86173. /**
  86174. * Defines the minimum contract an Edges renderer should follow.
  86175. */
  86176. export interface IEdgesRenderer extends IDisposable {
  86177. /**
  86178. * Gets or sets a boolean indicating if the edgesRenderer is active
  86179. */
  86180. isEnabled: boolean;
  86181. /**
  86182. * Renders the edges of the attached mesh,
  86183. */
  86184. render(): void;
  86185. /**
  86186. * Checks wether or not the edges renderer is ready to render.
  86187. * @return true if ready, otherwise false.
  86188. */
  86189. isReady(): boolean;
  86190. }
  86191. /**
  86192. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86193. */
  86194. export class EdgesRenderer implements IEdgesRenderer {
  86195. /**
  86196. * Define the size of the edges with an orthographic camera
  86197. */
  86198. edgesWidthScalerForOrthographic: number;
  86199. /**
  86200. * Define the size of the edges with a perspective camera
  86201. */
  86202. edgesWidthScalerForPerspective: number;
  86203. protected _source: AbstractMesh;
  86204. protected _linesPositions: number[];
  86205. protected _linesNormals: number[];
  86206. protected _linesIndices: number[];
  86207. protected _epsilon: number;
  86208. protected _indicesCount: number;
  86209. protected _lineShader: ShaderMaterial;
  86210. protected _ib: DataBuffer;
  86211. protected _buffers: {
  86212. [key: string]: Nullable<VertexBuffer>;
  86213. };
  86214. protected _checkVerticesInsteadOfIndices: boolean;
  86215. private _meshRebuildObserver;
  86216. private _meshDisposeObserver;
  86217. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86218. isEnabled: boolean;
  86219. /**
  86220. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86221. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86222. * @param source Mesh used to create edges
  86223. * @param epsilon sum of angles in adjacency to check for edge
  86224. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86225. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86226. */
  86227. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86228. protected _prepareRessources(): void;
  86229. /** @hidden */
  86230. _rebuild(): void;
  86231. /**
  86232. * Releases the required resources for the edges renderer
  86233. */
  86234. dispose(): void;
  86235. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86236. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86237. /**
  86238. * Checks if the pair of p0 and p1 is en edge
  86239. * @param faceIndex
  86240. * @param edge
  86241. * @param faceNormals
  86242. * @param p0
  86243. * @param p1
  86244. * @private
  86245. */
  86246. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86247. /**
  86248. * push line into the position, normal and index buffer
  86249. * @protected
  86250. */
  86251. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86252. /**
  86253. * Generates lines edges from adjacencjes
  86254. * @private
  86255. */
  86256. _generateEdgesLines(): void;
  86257. /**
  86258. * Checks wether or not the edges renderer is ready to render.
  86259. * @return true if ready, otherwise false.
  86260. */
  86261. isReady(): boolean;
  86262. /**
  86263. * Renders the edges of the attached mesh,
  86264. */
  86265. render(): void;
  86266. }
  86267. /**
  86268. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86269. */
  86270. export class LineEdgesRenderer extends EdgesRenderer {
  86271. /**
  86272. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86273. * @param source LineMesh used to generate edges
  86274. * @param epsilon not important (specified angle for edge detection)
  86275. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86276. */
  86277. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86278. /**
  86279. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86280. */
  86281. _generateEdgesLines(): void;
  86282. }
  86283. }
  86284. declare module BABYLON {
  86285. /**
  86286. * This represents the object necessary to create a rendering group.
  86287. * This is exclusively used and created by the rendering manager.
  86288. * To modify the behavior, you use the available helpers in your scene or meshes.
  86289. * @hidden
  86290. */
  86291. export class RenderingGroup {
  86292. index: number;
  86293. private static _zeroVector;
  86294. private _scene;
  86295. private _opaqueSubMeshes;
  86296. private _transparentSubMeshes;
  86297. private _alphaTestSubMeshes;
  86298. private _depthOnlySubMeshes;
  86299. private _particleSystems;
  86300. private _spriteManagers;
  86301. private _opaqueSortCompareFn;
  86302. private _alphaTestSortCompareFn;
  86303. private _transparentSortCompareFn;
  86304. private _renderOpaque;
  86305. private _renderAlphaTest;
  86306. private _renderTransparent;
  86307. /** @hidden */
  86308. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86309. onBeforeTransparentRendering: () => void;
  86310. /**
  86311. * Set the opaque sort comparison function.
  86312. * If null the sub meshes will be render in the order they were created
  86313. */
  86314. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86315. /**
  86316. * Set the alpha test sort comparison function.
  86317. * If null the sub meshes will be render in the order they were created
  86318. */
  86319. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86320. /**
  86321. * Set the transparent sort comparison function.
  86322. * If null the sub meshes will be render in the order they were created
  86323. */
  86324. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86325. /**
  86326. * Creates a new rendering group.
  86327. * @param index The rendering group index
  86328. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86329. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86330. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86331. */
  86332. 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>);
  86333. /**
  86334. * Render all the sub meshes contained in the group.
  86335. * @param customRenderFunction Used to override the default render behaviour of the group.
  86336. * @returns true if rendered some submeshes.
  86337. */
  86338. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86339. /**
  86340. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86341. * @param subMeshes The submeshes to render
  86342. */
  86343. private renderOpaqueSorted;
  86344. /**
  86345. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86346. * @param subMeshes The submeshes to render
  86347. */
  86348. private renderAlphaTestSorted;
  86349. /**
  86350. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86351. * @param subMeshes The submeshes to render
  86352. */
  86353. private renderTransparentSorted;
  86354. /**
  86355. * Renders the submeshes in a specified order.
  86356. * @param subMeshes The submeshes to sort before render
  86357. * @param sortCompareFn The comparison function use to sort
  86358. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86359. * @param transparent Specifies to activate blending if true
  86360. */
  86361. private static renderSorted;
  86362. /**
  86363. * Renders the submeshes in the order they were dispatched (no sort applied).
  86364. * @param subMeshes The submeshes to render
  86365. */
  86366. private static renderUnsorted;
  86367. /**
  86368. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86369. * are rendered back to front if in the same alpha index.
  86370. *
  86371. * @param a The first submesh
  86372. * @param b The second submesh
  86373. * @returns The result of the comparison
  86374. */
  86375. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86376. /**
  86377. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86378. * are rendered back to front.
  86379. *
  86380. * @param a The first submesh
  86381. * @param b The second submesh
  86382. * @returns The result of the comparison
  86383. */
  86384. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86385. /**
  86386. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86387. * are rendered front to back (prevent overdraw).
  86388. *
  86389. * @param a The first submesh
  86390. * @param b The second submesh
  86391. * @returns The result of the comparison
  86392. */
  86393. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86394. /**
  86395. * Resets the different lists of submeshes to prepare a new frame.
  86396. */
  86397. prepare(): void;
  86398. dispose(): void;
  86399. /**
  86400. * Inserts the submesh in its correct queue depending on its material.
  86401. * @param subMesh The submesh to dispatch
  86402. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86403. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86404. */
  86405. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86406. dispatchSprites(spriteManager: ISpriteManager): void;
  86407. dispatchParticles(particleSystem: IParticleSystem): void;
  86408. private _renderParticles;
  86409. private _renderSprites;
  86410. }
  86411. }
  86412. declare module BABYLON {
  86413. /**
  86414. * Interface describing the different options available in the rendering manager
  86415. * regarding Auto Clear between groups.
  86416. */
  86417. export interface IRenderingManagerAutoClearSetup {
  86418. /**
  86419. * Defines whether or not autoclear is enable.
  86420. */
  86421. autoClear: boolean;
  86422. /**
  86423. * Defines whether or not to autoclear the depth buffer.
  86424. */
  86425. depth: boolean;
  86426. /**
  86427. * Defines whether or not to autoclear the stencil buffer.
  86428. */
  86429. stencil: boolean;
  86430. }
  86431. /**
  86432. * This class is used by the onRenderingGroupObservable
  86433. */
  86434. export class RenderingGroupInfo {
  86435. /**
  86436. * The Scene that being rendered
  86437. */
  86438. scene: Scene;
  86439. /**
  86440. * The camera currently used for the rendering pass
  86441. */
  86442. camera: Nullable<Camera>;
  86443. /**
  86444. * The ID of the renderingGroup being processed
  86445. */
  86446. renderingGroupId: number;
  86447. }
  86448. /**
  86449. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86450. * It is enable to manage the different groups as well as the different necessary sort functions.
  86451. * This should not be used directly aside of the few static configurations
  86452. */
  86453. export class RenderingManager {
  86454. /**
  86455. * The max id used for rendering groups (not included)
  86456. */
  86457. static MAX_RENDERINGGROUPS: number;
  86458. /**
  86459. * The min id used for rendering groups (included)
  86460. */
  86461. static MIN_RENDERINGGROUPS: number;
  86462. /**
  86463. * Used to globally prevent autoclearing scenes.
  86464. */
  86465. static AUTOCLEAR: boolean;
  86466. /**
  86467. * @hidden
  86468. */
  86469. _useSceneAutoClearSetup: boolean;
  86470. private _scene;
  86471. private _renderingGroups;
  86472. private _depthStencilBufferAlreadyCleaned;
  86473. private _autoClearDepthStencil;
  86474. private _customOpaqueSortCompareFn;
  86475. private _customAlphaTestSortCompareFn;
  86476. private _customTransparentSortCompareFn;
  86477. private _renderingGroupInfo;
  86478. /**
  86479. * Instantiates a new rendering group for a particular scene
  86480. * @param scene Defines the scene the groups belongs to
  86481. */
  86482. constructor(scene: Scene);
  86483. private _clearDepthStencilBuffer;
  86484. /**
  86485. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86486. * @hidden
  86487. */
  86488. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86489. /**
  86490. * Resets the different information of the group to prepare a new frame
  86491. * @hidden
  86492. */
  86493. reset(): void;
  86494. /**
  86495. * Dispose and release the group and its associated resources.
  86496. * @hidden
  86497. */
  86498. dispose(): void;
  86499. /**
  86500. * Clear the info related to rendering groups preventing retention points during dispose.
  86501. */
  86502. freeRenderingGroups(): void;
  86503. private _prepareRenderingGroup;
  86504. /**
  86505. * Add a sprite manager to the rendering manager in order to render it this frame.
  86506. * @param spriteManager Define the sprite manager to render
  86507. */
  86508. dispatchSprites(spriteManager: ISpriteManager): void;
  86509. /**
  86510. * Add a particle system to the rendering manager in order to render it this frame.
  86511. * @param particleSystem Define the particle system to render
  86512. */
  86513. dispatchParticles(particleSystem: IParticleSystem): void;
  86514. /**
  86515. * Add a submesh to the manager in order to render it this frame
  86516. * @param subMesh The submesh to dispatch
  86517. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86518. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86519. */
  86520. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86521. /**
  86522. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86523. * This allowed control for front to back rendering or reversly depending of the special needs.
  86524. *
  86525. * @param renderingGroupId The rendering group id corresponding to its index
  86526. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86527. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86528. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86529. */
  86530. 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;
  86531. /**
  86532. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86533. *
  86534. * @param renderingGroupId The rendering group id corresponding to its index
  86535. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86536. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86537. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86538. */
  86539. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86540. /**
  86541. * Gets the current auto clear configuration for one rendering group of the rendering
  86542. * manager.
  86543. * @param index the rendering group index to get the information for
  86544. * @returns The auto clear setup for the requested rendering group
  86545. */
  86546. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /**
  86551. * This Helps creating a texture that will be created from a camera in your scene.
  86552. * It is basically a dynamic texture that could be used to create special effects for instance.
  86553. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86554. */
  86555. export class RenderTargetTexture extends Texture {
  86556. isCube: boolean;
  86557. /**
  86558. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86559. */
  86560. static readonly REFRESHRATE_RENDER_ONCE: number;
  86561. /**
  86562. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86563. */
  86564. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86565. /**
  86566. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86567. * the central point of your effect and can save a lot of performances.
  86568. */
  86569. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86570. /**
  86571. * Use this predicate to dynamically define the list of mesh you want to render.
  86572. * If set, the renderList property will be overwritten.
  86573. */
  86574. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86575. private _renderList;
  86576. /**
  86577. * Use this list to define the list of mesh you want to render.
  86578. */
  86579. renderList: Nullable<Array<AbstractMesh>>;
  86580. private _hookArray;
  86581. /**
  86582. * Define if particles should be rendered in your texture.
  86583. */
  86584. renderParticles: boolean;
  86585. /**
  86586. * Define if sprites should be rendered in your texture.
  86587. */
  86588. renderSprites: boolean;
  86589. /**
  86590. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86591. */
  86592. coordinatesMode: number;
  86593. /**
  86594. * Define the camera used to render the texture.
  86595. */
  86596. activeCamera: Nullable<Camera>;
  86597. /**
  86598. * Override the render function of the texture with your own one.
  86599. */
  86600. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86601. /**
  86602. * Define if camera post processes should be use while rendering the texture.
  86603. */
  86604. useCameraPostProcesses: boolean;
  86605. /**
  86606. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86607. */
  86608. ignoreCameraViewport: boolean;
  86609. private _postProcessManager;
  86610. private _postProcesses;
  86611. private _resizeObserver;
  86612. /**
  86613. * An event triggered when the texture is unbind.
  86614. */
  86615. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86616. /**
  86617. * An event triggered when the texture is unbind.
  86618. */
  86619. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86620. private _onAfterUnbindObserver;
  86621. /**
  86622. * Set a after unbind callback in the texture.
  86623. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86624. */
  86625. onAfterUnbind: () => void;
  86626. /**
  86627. * An event triggered before rendering the texture
  86628. */
  86629. onBeforeRenderObservable: Observable<number>;
  86630. private _onBeforeRenderObserver;
  86631. /**
  86632. * Set a before render callback in the texture.
  86633. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86634. */
  86635. onBeforeRender: (faceIndex: number) => void;
  86636. /**
  86637. * An event triggered after rendering the texture
  86638. */
  86639. onAfterRenderObservable: Observable<number>;
  86640. private _onAfterRenderObserver;
  86641. /**
  86642. * Set a after render callback in the texture.
  86643. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86644. */
  86645. onAfterRender: (faceIndex: number) => void;
  86646. /**
  86647. * An event triggered after the texture clear
  86648. */
  86649. onClearObservable: Observable<Engine>;
  86650. private _onClearObserver;
  86651. /**
  86652. * Set a clear callback in the texture.
  86653. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86654. */
  86655. onClear: (Engine: Engine) => void;
  86656. /**
  86657. * An event triggered when the texture is resized.
  86658. */
  86659. onResizeObservable: Observable<RenderTargetTexture>;
  86660. /**
  86661. * Define the clear color of the Render Target if it should be different from the scene.
  86662. */
  86663. clearColor: Color4;
  86664. protected _size: number | {
  86665. width: number;
  86666. height: number;
  86667. };
  86668. protected _initialSizeParameter: number | {
  86669. width: number;
  86670. height: number;
  86671. } | {
  86672. ratio: number;
  86673. };
  86674. protected _sizeRatio: Nullable<number>;
  86675. /** @hidden */
  86676. _generateMipMaps: boolean;
  86677. protected _renderingManager: RenderingManager;
  86678. /** @hidden */
  86679. _waitingRenderList: string[];
  86680. protected _doNotChangeAspectRatio: boolean;
  86681. protected _currentRefreshId: number;
  86682. protected _refreshRate: number;
  86683. protected _textureMatrix: Matrix;
  86684. protected _samples: number;
  86685. protected _renderTargetOptions: RenderTargetCreationOptions;
  86686. /**
  86687. * Gets render target creation options that were used.
  86688. */
  86689. readonly renderTargetOptions: RenderTargetCreationOptions;
  86690. protected _engine: Engine;
  86691. protected _onRatioRescale(): void;
  86692. /**
  86693. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86694. * It must define where the camera used to render the texture is set
  86695. */
  86696. boundingBoxPosition: Vector3;
  86697. private _boundingBoxSize;
  86698. /**
  86699. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86700. * When defined, the cubemap will switch to local mode
  86701. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86702. * @example https://www.babylonjs-playground.com/#RNASML
  86703. */
  86704. boundingBoxSize: Vector3;
  86705. /**
  86706. * In case the RTT has been created with a depth texture, get the associated
  86707. * depth texture.
  86708. * Otherwise, return null.
  86709. */
  86710. depthStencilTexture: Nullable<InternalTexture>;
  86711. /**
  86712. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86713. * or used a shadow, depth texture...
  86714. * @param name The friendly name of the texture
  86715. * @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)
  86716. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86717. * @param generateMipMaps True if mip maps need to be generated after render.
  86718. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86719. * @param type The type of the buffer in the RTT (int, half float, float...)
  86720. * @param isCube True if a cube texture needs to be created
  86721. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86722. * @param generateDepthBuffer True to generate a depth buffer
  86723. * @param generateStencilBuffer True to generate a stencil buffer
  86724. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86725. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86726. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86727. */
  86728. constructor(name: string, size: number | {
  86729. width: number;
  86730. height: number;
  86731. } | {
  86732. ratio: number;
  86733. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86734. /**
  86735. * Creates a depth stencil texture.
  86736. * This is only available in WebGL 2 or with the depth texture extension available.
  86737. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86738. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86739. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86740. */
  86741. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86742. private _processSizeParameter;
  86743. /**
  86744. * Define the number of samples to use in case of MSAA.
  86745. * It defaults to one meaning no MSAA has been enabled.
  86746. */
  86747. samples: number;
  86748. /**
  86749. * Resets the refresh counter of the texture and start bak from scratch.
  86750. * Could be useful to regenerate the texture if it is setup to render only once.
  86751. */
  86752. resetRefreshCounter(): void;
  86753. /**
  86754. * Define the refresh rate of the texture or the rendering frequency.
  86755. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86756. */
  86757. refreshRate: number;
  86758. /**
  86759. * Adds a post process to the render target rendering passes.
  86760. * @param postProcess define the post process to add
  86761. */
  86762. addPostProcess(postProcess: PostProcess): void;
  86763. /**
  86764. * Clear all the post processes attached to the render target
  86765. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86766. */
  86767. clearPostProcesses(dispose?: boolean): void;
  86768. /**
  86769. * Remove one of the post process from the list of attached post processes to the texture
  86770. * @param postProcess define the post process to remove from the list
  86771. */
  86772. removePostProcess(postProcess: PostProcess): void;
  86773. /** @hidden */
  86774. _shouldRender(): boolean;
  86775. /**
  86776. * Gets the actual render size of the texture.
  86777. * @returns the width of the render size
  86778. */
  86779. getRenderSize(): number;
  86780. /**
  86781. * Gets the actual render width of the texture.
  86782. * @returns the width of the render size
  86783. */
  86784. getRenderWidth(): number;
  86785. /**
  86786. * Gets the actual render height of the texture.
  86787. * @returns the height of the render size
  86788. */
  86789. getRenderHeight(): number;
  86790. /**
  86791. * Get if the texture can be rescaled or not.
  86792. */
  86793. readonly canRescale: boolean;
  86794. /**
  86795. * Resize the texture using a ratio.
  86796. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86797. */
  86798. scale(ratio: number): void;
  86799. /**
  86800. * Get the texture reflection matrix used to rotate/transform the reflection.
  86801. * @returns the reflection matrix
  86802. */
  86803. getReflectionTextureMatrix(): Matrix;
  86804. /**
  86805. * Resize the texture to a new desired size.
  86806. * Be carrefull as it will recreate all the data in the new texture.
  86807. * @param size Define the new size. It can be:
  86808. * - a number for squared texture,
  86809. * - an object containing { width: number, height: number }
  86810. * - or an object containing a ratio { ratio: number }
  86811. */
  86812. resize(size: number | {
  86813. width: number;
  86814. height: number;
  86815. } | {
  86816. ratio: number;
  86817. }): void;
  86818. /**
  86819. * Renders all the objects from the render list into the texture.
  86820. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86821. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86822. */
  86823. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86824. private _bestReflectionRenderTargetDimension;
  86825. /**
  86826. * @hidden
  86827. * @param faceIndex face index to bind to if this is a cubetexture
  86828. */
  86829. _bindFrameBuffer(faceIndex?: number): void;
  86830. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86831. private renderToTarget;
  86832. /**
  86833. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86834. * This allowed control for front to back rendering or reversly depending of the special needs.
  86835. *
  86836. * @param renderingGroupId The rendering group id corresponding to its index
  86837. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86838. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86839. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86840. */
  86841. 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;
  86842. /**
  86843. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86844. *
  86845. * @param renderingGroupId The rendering group id corresponding to its index
  86846. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86847. */
  86848. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86849. /**
  86850. * Clones the texture.
  86851. * @returns the cloned texture
  86852. */
  86853. clone(): RenderTargetTexture;
  86854. /**
  86855. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86856. * @returns The JSON representation of the texture
  86857. */
  86858. serialize(): any;
  86859. /**
  86860. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86861. */
  86862. disposeFramebufferObjects(): void;
  86863. /**
  86864. * Dispose the texture and release its associated resources.
  86865. */
  86866. dispose(): void;
  86867. /** @hidden */
  86868. _rebuild(): void;
  86869. /**
  86870. * Clear the info related to rendering groups preventing retention point in material dispose.
  86871. */
  86872. freeRenderingGroups(): void;
  86873. /**
  86874. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86875. * @returns the view count
  86876. */
  86877. getViewCount(): number;
  86878. }
  86879. }
  86880. declare module BABYLON {
  86881. /**
  86882. * Base class for the main features of a material in Babylon.js
  86883. */
  86884. export class Material implements IAnimatable {
  86885. /**
  86886. * Returns the triangle fill mode
  86887. */
  86888. static readonly TriangleFillMode: number;
  86889. /**
  86890. * Returns the wireframe mode
  86891. */
  86892. static readonly WireFrameFillMode: number;
  86893. /**
  86894. * Returns the point fill mode
  86895. */
  86896. static readonly PointFillMode: number;
  86897. /**
  86898. * Returns the point list draw mode
  86899. */
  86900. static readonly PointListDrawMode: number;
  86901. /**
  86902. * Returns the line list draw mode
  86903. */
  86904. static readonly LineListDrawMode: number;
  86905. /**
  86906. * Returns the line loop draw mode
  86907. */
  86908. static readonly LineLoopDrawMode: number;
  86909. /**
  86910. * Returns the line strip draw mode
  86911. */
  86912. static readonly LineStripDrawMode: number;
  86913. /**
  86914. * Returns the triangle strip draw mode
  86915. */
  86916. static readonly TriangleStripDrawMode: number;
  86917. /**
  86918. * Returns the triangle fan draw mode
  86919. */
  86920. static readonly TriangleFanDrawMode: number;
  86921. /**
  86922. * Stores the clock-wise side orientation
  86923. */
  86924. static readonly ClockWiseSideOrientation: number;
  86925. /**
  86926. * Stores the counter clock-wise side orientation
  86927. */
  86928. static readonly CounterClockWiseSideOrientation: number;
  86929. /**
  86930. * The dirty texture flag value
  86931. */
  86932. static readonly TextureDirtyFlag: number;
  86933. /**
  86934. * The dirty light flag value
  86935. */
  86936. static readonly LightDirtyFlag: number;
  86937. /**
  86938. * The dirty fresnel flag value
  86939. */
  86940. static readonly FresnelDirtyFlag: number;
  86941. /**
  86942. * The dirty attribute flag value
  86943. */
  86944. static readonly AttributesDirtyFlag: number;
  86945. /**
  86946. * The dirty misc flag value
  86947. */
  86948. static readonly MiscDirtyFlag: number;
  86949. /**
  86950. * The all dirty flag value
  86951. */
  86952. static readonly AllDirtyFlag: number;
  86953. /**
  86954. * The ID of the material
  86955. */
  86956. id: string;
  86957. /**
  86958. * Gets or sets the unique id of the material
  86959. */
  86960. uniqueId: number;
  86961. /**
  86962. * The name of the material
  86963. */
  86964. name: string;
  86965. /**
  86966. * Gets or sets user defined metadata
  86967. */
  86968. metadata: any;
  86969. /**
  86970. * For internal use only. Please do not use.
  86971. */
  86972. reservedDataStore: any;
  86973. /**
  86974. * Specifies if the ready state should be checked on each call
  86975. */
  86976. checkReadyOnEveryCall: boolean;
  86977. /**
  86978. * Specifies if the ready state should be checked once
  86979. */
  86980. checkReadyOnlyOnce: boolean;
  86981. /**
  86982. * The state of the material
  86983. */
  86984. state: string;
  86985. /**
  86986. * The alpha value of the material
  86987. */
  86988. protected _alpha: number;
  86989. /**
  86990. * List of inspectable custom properties (used by the Inspector)
  86991. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86992. */
  86993. inspectableCustomProperties: IInspectable[];
  86994. /**
  86995. * Sets the alpha value of the material
  86996. */
  86997. /**
  86998. * Gets the alpha value of the material
  86999. */
  87000. alpha: number;
  87001. /**
  87002. * Specifies if back face culling is enabled
  87003. */
  87004. protected _backFaceCulling: boolean;
  87005. /**
  87006. * Sets the back-face culling state
  87007. */
  87008. /**
  87009. * Gets the back-face culling state
  87010. */
  87011. backFaceCulling: boolean;
  87012. /**
  87013. * Stores the value for side orientation
  87014. */
  87015. sideOrientation: number;
  87016. /**
  87017. * Callback triggered when the material is compiled
  87018. */
  87019. onCompiled: Nullable<(effect: Effect) => void>;
  87020. /**
  87021. * Callback triggered when an error occurs
  87022. */
  87023. onError: Nullable<(effect: Effect, errors: string) => void>;
  87024. /**
  87025. * Callback triggered to get the render target textures
  87026. */
  87027. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87028. /**
  87029. * Gets a boolean indicating that current material needs to register RTT
  87030. */
  87031. readonly hasRenderTargetTextures: boolean;
  87032. /**
  87033. * Specifies if the material should be serialized
  87034. */
  87035. doNotSerialize: boolean;
  87036. /**
  87037. * @hidden
  87038. */
  87039. _storeEffectOnSubMeshes: boolean;
  87040. /**
  87041. * Stores the animations for the material
  87042. */
  87043. animations: Nullable<Array<Animation>>;
  87044. /**
  87045. * An event triggered when the material is disposed
  87046. */
  87047. onDisposeObservable: Observable<Material>;
  87048. /**
  87049. * An observer which watches for dispose events
  87050. */
  87051. private _onDisposeObserver;
  87052. private _onUnBindObservable;
  87053. /**
  87054. * Called during a dispose event
  87055. */
  87056. onDispose: () => void;
  87057. private _onBindObservable;
  87058. /**
  87059. * An event triggered when the material is bound
  87060. */
  87061. readonly onBindObservable: Observable<AbstractMesh>;
  87062. /**
  87063. * An observer which watches for bind events
  87064. */
  87065. private _onBindObserver;
  87066. /**
  87067. * Called during a bind event
  87068. */
  87069. onBind: (Mesh: AbstractMesh) => void;
  87070. /**
  87071. * An event triggered when the material is unbound
  87072. */
  87073. readonly onUnBindObservable: Observable<Material>;
  87074. /**
  87075. * Stores the value of the alpha mode
  87076. */
  87077. private _alphaMode;
  87078. /**
  87079. * Sets the value of the alpha mode.
  87080. *
  87081. * | Value | Type | Description |
  87082. * | --- | --- | --- |
  87083. * | 0 | ALPHA_DISABLE | |
  87084. * | 1 | ALPHA_ADD | |
  87085. * | 2 | ALPHA_COMBINE | |
  87086. * | 3 | ALPHA_SUBTRACT | |
  87087. * | 4 | ALPHA_MULTIPLY | |
  87088. * | 5 | ALPHA_MAXIMIZED | |
  87089. * | 6 | ALPHA_ONEONE | |
  87090. * | 7 | ALPHA_PREMULTIPLIED | |
  87091. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87092. * | 9 | ALPHA_INTERPOLATE | |
  87093. * | 10 | ALPHA_SCREENMODE | |
  87094. *
  87095. */
  87096. /**
  87097. * Gets the value of the alpha mode
  87098. */
  87099. alphaMode: number;
  87100. /**
  87101. * Stores the state of the need depth pre-pass value
  87102. */
  87103. private _needDepthPrePass;
  87104. /**
  87105. * Sets the need depth pre-pass value
  87106. */
  87107. /**
  87108. * Gets the depth pre-pass value
  87109. */
  87110. needDepthPrePass: boolean;
  87111. /**
  87112. * Specifies if depth writing should be disabled
  87113. */
  87114. disableDepthWrite: boolean;
  87115. /**
  87116. * Specifies if depth writing should be forced
  87117. */
  87118. forceDepthWrite: boolean;
  87119. /**
  87120. * Specifies if there should be a separate pass for culling
  87121. */
  87122. separateCullingPass: boolean;
  87123. /**
  87124. * Stores the state specifing if fog should be enabled
  87125. */
  87126. private _fogEnabled;
  87127. /**
  87128. * Sets the state for enabling fog
  87129. */
  87130. /**
  87131. * Gets the value of the fog enabled state
  87132. */
  87133. fogEnabled: boolean;
  87134. /**
  87135. * Stores the size of points
  87136. */
  87137. pointSize: number;
  87138. /**
  87139. * Stores the z offset value
  87140. */
  87141. zOffset: number;
  87142. /**
  87143. * Gets a value specifying if wireframe mode is enabled
  87144. */
  87145. /**
  87146. * Sets the state of wireframe mode
  87147. */
  87148. wireframe: boolean;
  87149. /**
  87150. * Gets the value specifying if point clouds are enabled
  87151. */
  87152. /**
  87153. * Sets the state of point cloud mode
  87154. */
  87155. pointsCloud: boolean;
  87156. /**
  87157. * Gets the material fill mode
  87158. */
  87159. /**
  87160. * Sets the material fill mode
  87161. */
  87162. fillMode: number;
  87163. /**
  87164. * @hidden
  87165. * Stores the effects for the material
  87166. */
  87167. _effect: Nullable<Effect>;
  87168. /**
  87169. * @hidden
  87170. * Specifies if the material was previously ready
  87171. */
  87172. _wasPreviouslyReady: boolean;
  87173. /**
  87174. * Specifies if uniform buffers should be used
  87175. */
  87176. private _useUBO;
  87177. /**
  87178. * Stores a reference to the scene
  87179. */
  87180. private _scene;
  87181. /**
  87182. * Stores the fill mode state
  87183. */
  87184. private _fillMode;
  87185. /**
  87186. * Specifies if the depth write state should be cached
  87187. */
  87188. private _cachedDepthWriteState;
  87189. /**
  87190. * Stores the uniform buffer
  87191. */
  87192. protected _uniformBuffer: UniformBuffer;
  87193. /** @hidden */
  87194. _indexInSceneMaterialArray: number;
  87195. /** @hidden */
  87196. meshMap: Nullable<{
  87197. [id: string]: AbstractMesh | undefined;
  87198. }>;
  87199. /**
  87200. * Creates a material instance
  87201. * @param name defines the name of the material
  87202. * @param scene defines the scene to reference
  87203. * @param doNotAdd specifies if the material should be added to the scene
  87204. */
  87205. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87206. /**
  87207. * Returns a string representation of the current material
  87208. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87209. * @returns a string with material information
  87210. */
  87211. toString(fullDetails?: boolean): string;
  87212. /**
  87213. * Gets the class name of the material
  87214. * @returns a string with the class name of the material
  87215. */
  87216. getClassName(): string;
  87217. /**
  87218. * Specifies if updates for the material been locked
  87219. */
  87220. readonly isFrozen: boolean;
  87221. /**
  87222. * Locks updates for the material
  87223. */
  87224. freeze(): void;
  87225. /**
  87226. * Unlocks updates for the material
  87227. */
  87228. unfreeze(): void;
  87229. /**
  87230. * Specifies if the material is ready to be used
  87231. * @param mesh defines the mesh to check
  87232. * @param useInstances specifies if instances should be used
  87233. * @returns a boolean indicating if the material is ready to be used
  87234. */
  87235. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87236. /**
  87237. * Specifies that the submesh is ready to be used
  87238. * @param mesh defines the mesh to check
  87239. * @param subMesh defines which submesh to check
  87240. * @param useInstances specifies that instances should be used
  87241. * @returns a boolean indicating that the submesh is ready or not
  87242. */
  87243. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87244. /**
  87245. * Returns the material effect
  87246. * @returns the effect associated with the material
  87247. */
  87248. getEffect(): Nullable<Effect>;
  87249. /**
  87250. * Returns the current scene
  87251. * @returns a Scene
  87252. */
  87253. getScene(): Scene;
  87254. /**
  87255. * Specifies if the material will require alpha blending
  87256. * @returns a boolean specifying if alpha blending is needed
  87257. */
  87258. needAlphaBlending(): boolean;
  87259. /**
  87260. * Specifies if the mesh will require alpha blending
  87261. * @param mesh defines the mesh to check
  87262. * @returns a boolean specifying if alpha blending is needed for the mesh
  87263. */
  87264. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87265. /**
  87266. * Specifies if this material should be rendered in alpha test mode
  87267. * @returns a boolean specifying if an alpha test is needed.
  87268. */
  87269. needAlphaTesting(): boolean;
  87270. /**
  87271. * Gets the texture used for the alpha test
  87272. * @returns the texture to use for alpha testing
  87273. */
  87274. getAlphaTestTexture(): Nullable<BaseTexture>;
  87275. /**
  87276. * Marks the material to indicate that it needs to be re-calculated
  87277. */
  87278. markDirty(): void;
  87279. /** @hidden */
  87280. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87281. /**
  87282. * Binds the material to the mesh
  87283. * @param world defines the world transformation matrix
  87284. * @param mesh defines the mesh to bind the material to
  87285. */
  87286. bind(world: Matrix, mesh?: Mesh): void;
  87287. /**
  87288. * Binds the submesh to the material
  87289. * @param world defines the world transformation matrix
  87290. * @param mesh defines the mesh containing the submesh
  87291. * @param subMesh defines the submesh to bind the material to
  87292. */
  87293. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87294. /**
  87295. * Binds the world matrix to the material
  87296. * @param world defines the world transformation matrix
  87297. */
  87298. bindOnlyWorldMatrix(world: Matrix): void;
  87299. /**
  87300. * Binds the scene's uniform buffer to the effect.
  87301. * @param effect defines the effect to bind to the scene uniform buffer
  87302. * @param sceneUbo defines the uniform buffer storing scene data
  87303. */
  87304. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87305. /**
  87306. * Binds the view matrix to the effect
  87307. * @param effect defines the effect to bind the view matrix to
  87308. */
  87309. bindView(effect: Effect): void;
  87310. /**
  87311. * Binds the view projection matrix to the effect
  87312. * @param effect defines the effect to bind the view projection matrix to
  87313. */
  87314. bindViewProjection(effect: Effect): void;
  87315. /**
  87316. * Specifies if material alpha testing should be turned on for the mesh
  87317. * @param mesh defines the mesh to check
  87318. */
  87319. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87320. /**
  87321. * Processes to execute after binding the material to a mesh
  87322. * @param mesh defines the rendered mesh
  87323. */
  87324. protected _afterBind(mesh?: Mesh): void;
  87325. /**
  87326. * Unbinds the material from the mesh
  87327. */
  87328. unbind(): void;
  87329. /**
  87330. * Gets the active textures from the material
  87331. * @returns an array of textures
  87332. */
  87333. getActiveTextures(): BaseTexture[];
  87334. /**
  87335. * Specifies if the material uses a texture
  87336. * @param texture defines the texture to check against the material
  87337. * @returns a boolean specifying if the material uses the texture
  87338. */
  87339. hasTexture(texture: BaseTexture): boolean;
  87340. /**
  87341. * Makes a duplicate of the material, and gives it a new name
  87342. * @param name defines the new name for the duplicated material
  87343. * @returns the cloned material
  87344. */
  87345. clone(name: string): Nullable<Material>;
  87346. /**
  87347. * Gets the meshes bound to the material
  87348. * @returns an array of meshes bound to the material
  87349. */
  87350. getBindedMeshes(): AbstractMesh[];
  87351. /**
  87352. * Force shader compilation
  87353. * @param mesh defines the mesh associated with this material
  87354. * @param onCompiled defines a function to execute once the material is compiled
  87355. * @param options defines the options to configure the compilation
  87356. * @param onError defines a function to execute if the material fails compiling
  87357. */
  87358. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87359. clipPlane: boolean;
  87360. }>, onError?: (reason: string) => void): void;
  87361. /**
  87362. * Force shader compilation
  87363. * @param mesh defines the mesh that will use this material
  87364. * @param options defines additional options for compiling the shaders
  87365. * @returns a promise that resolves when the compilation completes
  87366. */
  87367. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87368. clipPlane: boolean;
  87369. }>): Promise<void>;
  87370. private static readonly _AllDirtyCallBack;
  87371. private static readonly _ImageProcessingDirtyCallBack;
  87372. private static readonly _TextureDirtyCallBack;
  87373. private static readonly _FresnelDirtyCallBack;
  87374. private static readonly _MiscDirtyCallBack;
  87375. private static readonly _LightsDirtyCallBack;
  87376. private static readonly _AttributeDirtyCallBack;
  87377. private static _FresnelAndMiscDirtyCallBack;
  87378. private static _TextureAndMiscDirtyCallBack;
  87379. private static readonly _DirtyCallbackArray;
  87380. private static readonly _RunDirtyCallBacks;
  87381. /**
  87382. * Marks a define in the material to indicate that it needs to be re-computed
  87383. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87384. */
  87385. markAsDirty(flag: number): void;
  87386. /**
  87387. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87388. * @param func defines a function which checks material defines against the submeshes
  87389. */
  87390. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87391. /**
  87392. * Indicates that we need to re-calculated for all submeshes
  87393. */
  87394. protected _markAllSubMeshesAsAllDirty(): void;
  87395. /**
  87396. * Indicates that image processing needs to be re-calculated for all submeshes
  87397. */
  87398. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87399. /**
  87400. * Indicates that textures need to be re-calculated for all submeshes
  87401. */
  87402. protected _markAllSubMeshesAsTexturesDirty(): void;
  87403. /**
  87404. * Indicates that fresnel needs to be re-calculated for all submeshes
  87405. */
  87406. protected _markAllSubMeshesAsFresnelDirty(): void;
  87407. /**
  87408. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87409. */
  87410. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87411. /**
  87412. * Indicates that lights need to be re-calculated for all submeshes
  87413. */
  87414. protected _markAllSubMeshesAsLightsDirty(): void;
  87415. /**
  87416. * Indicates that attributes need to be re-calculated for all submeshes
  87417. */
  87418. protected _markAllSubMeshesAsAttributesDirty(): void;
  87419. /**
  87420. * Indicates that misc needs to be re-calculated for all submeshes
  87421. */
  87422. protected _markAllSubMeshesAsMiscDirty(): void;
  87423. /**
  87424. * Indicates that textures and misc need to be re-calculated for all submeshes
  87425. */
  87426. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87427. /**
  87428. * Disposes the material
  87429. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87430. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87431. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87432. */
  87433. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87434. /** @hidden */
  87435. private releaseVertexArrayObject;
  87436. /**
  87437. * Serializes this material
  87438. * @returns the serialized material object
  87439. */
  87440. serialize(): any;
  87441. /**
  87442. * Creates a material from parsed material data
  87443. * @param parsedMaterial defines parsed material data
  87444. * @param scene defines the hosting scene
  87445. * @param rootUrl defines the root URL to use to load textures
  87446. * @returns a new material
  87447. */
  87448. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87449. }
  87450. }
  87451. declare module BABYLON {
  87452. /**
  87453. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87454. * separate meshes. This can be use to improve performances.
  87455. * @see http://doc.babylonjs.com/how_to/multi_materials
  87456. */
  87457. export class MultiMaterial extends Material {
  87458. private _subMaterials;
  87459. /**
  87460. * Gets or Sets the list of Materials used within the multi material.
  87461. * They need to be ordered according to the submeshes order in the associated mesh
  87462. */
  87463. subMaterials: Nullable<Material>[];
  87464. /**
  87465. * Function used to align with Node.getChildren()
  87466. * @returns the list of Materials used within the multi material
  87467. */
  87468. getChildren(): Nullable<Material>[];
  87469. /**
  87470. * Instantiates a new Multi Material
  87471. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87472. * separate meshes. This can be use to improve performances.
  87473. * @see http://doc.babylonjs.com/how_to/multi_materials
  87474. * @param name Define the name in the scene
  87475. * @param scene Define the scene the material belongs to
  87476. */
  87477. constructor(name: string, scene: Scene);
  87478. private _hookArray;
  87479. /**
  87480. * Get one of the submaterial by its index in the submaterials array
  87481. * @param index The index to look the sub material at
  87482. * @returns The Material if the index has been defined
  87483. */
  87484. getSubMaterial(index: number): Nullable<Material>;
  87485. /**
  87486. * Get the list of active textures for the whole sub materials list.
  87487. * @returns All the textures that will be used during the rendering
  87488. */
  87489. getActiveTextures(): BaseTexture[];
  87490. /**
  87491. * Gets the current class name of the material e.g. "MultiMaterial"
  87492. * Mainly use in serialization.
  87493. * @returns the class name
  87494. */
  87495. getClassName(): string;
  87496. /**
  87497. * Checks if the material is ready to render the requested sub mesh
  87498. * @param mesh Define the mesh the submesh belongs to
  87499. * @param subMesh Define the sub mesh to look readyness for
  87500. * @param useInstances Define whether or not the material is used with instances
  87501. * @returns true if ready, otherwise false
  87502. */
  87503. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87504. /**
  87505. * Clones the current material and its related sub materials
  87506. * @param name Define the name of the newly cloned material
  87507. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87508. * @returns the cloned material
  87509. */
  87510. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87511. /**
  87512. * Serializes the materials into a JSON representation.
  87513. * @returns the JSON representation
  87514. */
  87515. serialize(): any;
  87516. /**
  87517. * Dispose the material and release its associated resources
  87518. * @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)
  87519. * @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)
  87520. * @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)
  87521. */
  87522. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87523. /**
  87524. * Creates a MultiMaterial from parsed MultiMaterial data.
  87525. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87526. * @param scene defines the hosting scene
  87527. * @returns a new MultiMaterial
  87528. */
  87529. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /**
  87534. * Base class for submeshes
  87535. */
  87536. export class BaseSubMesh {
  87537. /** @hidden */
  87538. _materialDefines: Nullable<MaterialDefines>;
  87539. /** @hidden */
  87540. _materialEffect: Nullable<Effect>;
  87541. /**
  87542. * Gets associated effect
  87543. */
  87544. readonly effect: Nullable<Effect>;
  87545. /**
  87546. * Sets associated effect (effect used to render this submesh)
  87547. * @param effect defines the effect to associate with
  87548. * @param defines defines the set of defines used to compile this effect
  87549. */
  87550. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87551. }
  87552. /**
  87553. * Defines a subdivision inside a mesh
  87554. */
  87555. export class SubMesh extends BaseSubMesh implements ICullable {
  87556. /** the material index to use */
  87557. materialIndex: number;
  87558. /** vertex index start */
  87559. verticesStart: number;
  87560. /** vertices count */
  87561. verticesCount: number;
  87562. /** index start */
  87563. indexStart: number;
  87564. /** indices count */
  87565. indexCount: number;
  87566. /** @hidden */
  87567. _linesIndexCount: number;
  87568. private _mesh;
  87569. private _renderingMesh;
  87570. private _boundingInfo;
  87571. private _linesIndexBuffer;
  87572. /** @hidden */
  87573. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87574. /** @hidden */
  87575. _trianglePlanes: Plane[];
  87576. /** @hidden */
  87577. _lastColliderTransformMatrix: Nullable<Matrix>;
  87578. /** @hidden */
  87579. _renderId: number;
  87580. /** @hidden */
  87581. _alphaIndex: number;
  87582. /** @hidden */
  87583. _distanceToCamera: number;
  87584. /** @hidden */
  87585. _id: number;
  87586. private _currentMaterial;
  87587. /**
  87588. * Add a new submesh to a mesh
  87589. * @param materialIndex defines the material index to use
  87590. * @param verticesStart defines vertex index start
  87591. * @param verticesCount defines vertices count
  87592. * @param indexStart defines index start
  87593. * @param indexCount defines indices count
  87594. * @param mesh defines the parent mesh
  87595. * @param renderingMesh defines an optional rendering mesh
  87596. * @param createBoundingBox defines if bounding box should be created for this submesh
  87597. * @returns the new submesh
  87598. */
  87599. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87600. /**
  87601. * Creates a new submesh
  87602. * @param materialIndex defines the material index to use
  87603. * @param verticesStart defines vertex index start
  87604. * @param verticesCount defines vertices count
  87605. * @param indexStart defines index start
  87606. * @param indexCount defines indices count
  87607. * @param mesh defines the parent mesh
  87608. * @param renderingMesh defines an optional rendering mesh
  87609. * @param createBoundingBox defines if bounding box should be created for this submesh
  87610. */
  87611. constructor(
  87612. /** the material index to use */
  87613. materialIndex: number,
  87614. /** vertex index start */
  87615. verticesStart: number,
  87616. /** vertices count */
  87617. verticesCount: number,
  87618. /** index start */
  87619. indexStart: number,
  87620. /** indices count */
  87621. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87622. /**
  87623. * Returns true if this submesh covers the entire parent mesh
  87624. * @ignorenaming
  87625. */
  87626. readonly IsGlobal: boolean;
  87627. /**
  87628. * Returns the submesh BoudingInfo object
  87629. * @returns current bounding info (or mesh's one if the submesh is global)
  87630. */
  87631. getBoundingInfo(): BoundingInfo;
  87632. /**
  87633. * Sets the submesh BoundingInfo
  87634. * @param boundingInfo defines the new bounding info to use
  87635. * @returns the SubMesh
  87636. */
  87637. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87638. /**
  87639. * Returns the mesh of the current submesh
  87640. * @return the parent mesh
  87641. */
  87642. getMesh(): AbstractMesh;
  87643. /**
  87644. * Returns the rendering mesh of the submesh
  87645. * @returns the rendering mesh (could be different from parent mesh)
  87646. */
  87647. getRenderingMesh(): Mesh;
  87648. /**
  87649. * Returns the submesh material
  87650. * @returns null or the current material
  87651. */
  87652. getMaterial(): Nullable<Material>;
  87653. /**
  87654. * Sets a new updated BoundingInfo object to the submesh
  87655. * @param data defines an optional position array to use to determine the bounding info
  87656. * @returns the SubMesh
  87657. */
  87658. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87659. /** @hidden */
  87660. _checkCollision(collider: Collider): boolean;
  87661. /**
  87662. * Updates the submesh BoundingInfo
  87663. * @param world defines the world matrix to use to update the bounding info
  87664. * @returns the submesh
  87665. */
  87666. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87667. /**
  87668. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87669. * @param frustumPlanes defines the frustum planes
  87670. * @returns true if the submesh is intersecting with the frustum
  87671. */
  87672. isInFrustum(frustumPlanes: Plane[]): boolean;
  87673. /**
  87674. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87675. * @param frustumPlanes defines the frustum planes
  87676. * @returns true if the submesh is inside the frustum
  87677. */
  87678. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87679. /**
  87680. * Renders the submesh
  87681. * @param enableAlphaMode defines if alpha needs to be used
  87682. * @returns the submesh
  87683. */
  87684. render(enableAlphaMode: boolean): SubMesh;
  87685. /**
  87686. * @hidden
  87687. */
  87688. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87689. /**
  87690. * Checks if the submesh intersects with a ray
  87691. * @param ray defines the ray to test
  87692. * @returns true is the passed ray intersects the submesh bounding box
  87693. */
  87694. canIntersects(ray: Ray): boolean;
  87695. /**
  87696. * Intersects current submesh with a ray
  87697. * @param ray defines the ray to test
  87698. * @param positions defines mesh's positions array
  87699. * @param indices defines mesh's indices array
  87700. * @param fastCheck defines if only bounding info should be used
  87701. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87702. * @returns intersection info or null if no intersection
  87703. */
  87704. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87705. /** @hidden */
  87706. private _intersectLines;
  87707. /** @hidden */
  87708. private _intersectUnIndexedLines;
  87709. /** @hidden */
  87710. private _intersectTriangles;
  87711. /** @hidden */
  87712. private _intersectUnIndexedTriangles;
  87713. /** @hidden */
  87714. _rebuild(): void;
  87715. /**
  87716. * Creates a new submesh from the passed mesh
  87717. * @param newMesh defines the new hosting mesh
  87718. * @param newRenderingMesh defines an optional rendering mesh
  87719. * @returns the new submesh
  87720. */
  87721. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87722. /**
  87723. * Release associated resources
  87724. */
  87725. dispose(): void;
  87726. /**
  87727. * Gets the class name
  87728. * @returns the string "SubMesh".
  87729. */
  87730. getClassName(): string;
  87731. /**
  87732. * Creates a new submesh from indices data
  87733. * @param materialIndex the index of the main mesh material
  87734. * @param startIndex the index where to start the copy in the mesh indices array
  87735. * @param indexCount the number of indices to copy then from the startIndex
  87736. * @param mesh the main mesh to create the submesh from
  87737. * @param renderingMesh the optional rendering mesh
  87738. * @returns a new submesh
  87739. */
  87740. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87741. }
  87742. }
  87743. declare module BABYLON {
  87744. /**
  87745. * Class used to represent data loading progression
  87746. */
  87747. export class SceneLoaderFlags {
  87748. private static _ForceFullSceneLoadingForIncremental;
  87749. private static _ShowLoadingScreen;
  87750. private static _CleanBoneMatrixWeights;
  87751. private static _loggingLevel;
  87752. /**
  87753. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87754. */
  87755. static ForceFullSceneLoadingForIncremental: boolean;
  87756. /**
  87757. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87758. */
  87759. static ShowLoadingScreen: boolean;
  87760. /**
  87761. * Defines the current logging level (while loading the scene)
  87762. * @ignorenaming
  87763. */
  87764. static loggingLevel: number;
  87765. /**
  87766. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87767. */
  87768. static CleanBoneMatrixWeights: boolean;
  87769. }
  87770. }
  87771. declare module BABYLON {
  87772. /**
  87773. * Class used to store geometry data (vertex buffers + index buffer)
  87774. */
  87775. export class Geometry implements IGetSetVerticesData {
  87776. /**
  87777. * Gets or sets the ID of the geometry
  87778. */
  87779. id: string;
  87780. /**
  87781. * Gets or sets the unique ID of the geometry
  87782. */
  87783. uniqueId: number;
  87784. /**
  87785. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87786. */
  87787. delayLoadState: number;
  87788. /**
  87789. * Gets the file containing the data to load when running in delay load state
  87790. */
  87791. delayLoadingFile: Nullable<string>;
  87792. /**
  87793. * Callback called when the geometry is updated
  87794. */
  87795. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87796. private _scene;
  87797. private _engine;
  87798. private _meshes;
  87799. private _totalVertices;
  87800. /** @hidden */
  87801. _indices: IndicesArray;
  87802. /** @hidden */
  87803. _vertexBuffers: {
  87804. [key: string]: VertexBuffer;
  87805. };
  87806. private _isDisposed;
  87807. private _extend;
  87808. private _boundingBias;
  87809. /** @hidden */
  87810. _delayInfo: Array<string>;
  87811. private _indexBuffer;
  87812. private _indexBufferIsUpdatable;
  87813. /** @hidden */
  87814. _boundingInfo: Nullable<BoundingInfo>;
  87815. /** @hidden */
  87816. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87817. /** @hidden */
  87818. _softwareSkinningFrameId: number;
  87819. private _vertexArrayObjects;
  87820. private _updatable;
  87821. /** @hidden */
  87822. _positions: Nullable<Vector3[]>;
  87823. /**
  87824. * 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
  87825. */
  87826. /**
  87827. * 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
  87828. */
  87829. boundingBias: Vector2;
  87830. /**
  87831. * Static function used to attach a new empty geometry to a mesh
  87832. * @param mesh defines the mesh to attach the geometry to
  87833. * @returns the new Geometry
  87834. */
  87835. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87836. /**
  87837. * Creates a new geometry
  87838. * @param id defines the unique ID
  87839. * @param scene defines the hosting scene
  87840. * @param vertexData defines the VertexData used to get geometry data
  87841. * @param updatable defines if geometry must be updatable (false by default)
  87842. * @param mesh defines the mesh that will be associated with the geometry
  87843. */
  87844. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87845. /**
  87846. * Gets the current extend of the geometry
  87847. */
  87848. readonly extend: {
  87849. minimum: Vector3;
  87850. maximum: Vector3;
  87851. };
  87852. /**
  87853. * Gets the hosting scene
  87854. * @returns the hosting Scene
  87855. */
  87856. getScene(): Scene;
  87857. /**
  87858. * Gets the hosting engine
  87859. * @returns the hosting Engine
  87860. */
  87861. getEngine(): Engine;
  87862. /**
  87863. * Defines if the geometry is ready to use
  87864. * @returns true if the geometry is ready to be used
  87865. */
  87866. isReady(): boolean;
  87867. /**
  87868. * Gets a value indicating that the geometry should not be serialized
  87869. */
  87870. readonly doNotSerialize: boolean;
  87871. /** @hidden */
  87872. _rebuild(): void;
  87873. /**
  87874. * Affects all geometry data in one call
  87875. * @param vertexData defines the geometry data
  87876. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87877. */
  87878. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87879. /**
  87880. * Set specific vertex data
  87881. * @param kind defines the data kind (Position, normal, etc...)
  87882. * @param data defines the vertex data to use
  87883. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87884. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87885. */
  87886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87887. /**
  87888. * Removes a specific vertex data
  87889. * @param kind defines the data kind (Position, normal, etc...)
  87890. */
  87891. removeVerticesData(kind: string): void;
  87892. /**
  87893. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87894. * @param buffer defines the vertex buffer to use
  87895. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87896. */
  87897. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87898. /**
  87899. * Update a specific vertex buffer
  87900. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87901. * It will do nothing if the buffer is not updatable
  87902. * @param kind defines the data kind (Position, normal, etc...)
  87903. * @param data defines the data to use
  87904. * @param offset defines the offset in the target buffer where to store the data
  87905. * @param useBytes set to true if the offset is in bytes
  87906. */
  87907. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87908. /**
  87909. * Update a specific vertex buffer
  87910. * This function will create a new buffer if the current one is not updatable
  87911. * @param kind defines the data kind (Position, normal, etc...)
  87912. * @param data defines the data to use
  87913. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87914. */
  87915. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87916. private _updateBoundingInfo;
  87917. /** @hidden */
  87918. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87919. /**
  87920. * Gets total number of vertices
  87921. * @returns the total number of vertices
  87922. */
  87923. getTotalVertices(): number;
  87924. /**
  87925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87926. * @param kind defines the data kind (Position, normal, etc...)
  87927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87929. * @returns a float array containing vertex data
  87930. */
  87931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87932. /**
  87933. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87934. * @param kind defines the data kind (Position, normal, etc...)
  87935. * @returns true if the vertex buffer with the specified kind is updatable
  87936. */
  87937. isVertexBufferUpdatable(kind: string): boolean;
  87938. /**
  87939. * Gets a specific vertex buffer
  87940. * @param kind defines the data kind (Position, normal, etc...)
  87941. * @returns a VertexBuffer
  87942. */
  87943. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87944. /**
  87945. * Returns all vertex buffers
  87946. * @return an object holding all vertex buffers indexed by kind
  87947. */
  87948. getVertexBuffers(): Nullable<{
  87949. [key: string]: VertexBuffer;
  87950. }>;
  87951. /**
  87952. * Gets a boolean indicating if specific vertex buffer is present
  87953. * @param kind defines the data kind (Position, normal, etc...)
  87954. * @returns true if data is present
  87955. */
  87956. isVerticesDataPresent(kind: string): boolean;
  87957. /**
  87958. * Gets a list of all attached data kinds (Position, normal, etc...)
  87959. * @returns a list of string containing all kinds
  87960. */
  87961. getVerticesDataKinds(): string[];
  87962. /**
  87963. * Update index buffer
  87964. * @param indices defines the indices to store in the index buffer
  87965. * @param offset defines the offset in the target buffer where to store the data
  87966. * @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)
  87967. */
  87968. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87969. /**
  87970. * Creates a new index buffer
  87971. * @param indices defines the indices to store in the index buffer
  87972. * @param totalVertices defines the total number of vertices (could be null)
  87973. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87974. */
  87975. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87976. /**
  87977. * Return the total number of indices
  87978. * @returns the total number of indices
  87979. */
  87980. getTotalIndices(): number;
  87981. /**
  87982. * Gets the index buffer array
  87983. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87984. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87985. * @returns the index buffer array
  87986. */
  87987. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87988. /**
  87989. * Gets the index buffer
  87990. * @return the index buffer
  87991. */
  87992. getIndexBuffer(): Nullable<DataBuffer>;
  87993. /** @hidden */
  87994. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87995. /**
  87996. * Release the associated resources for a specific mesh
  87997. * @param mesh defines the source mesh
  87998. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87999. */
  88000. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88001. /**
  88002. * Apply current geometry to a given mesh
  88003. * @param mesh defines the mesh to apply geometry to
  88004. */
  88005. applyToMesh(mesh: Mesh): void;
  88006. private _updateExtend;
  88007. private _applyToMesh;
  88008. private notifyUpdate;
  88009. /**
  88010. * Load the geometry if it was flagged as delay loaded
  88011. * @param scene defines the hosting scene
  88012. * @param onLoaded defines a callback called when the geometry is loaded
  88013. */
  88014. load(scene: Scene, onLoaded?: () => void): void;
  88015. private _queueLoad;
  88016. /**
  88017. * Invert the geometry to move from a right handed system to a left handed one.
  88018. */
  88019. toLeftHanded(): void;
  88020. /** @hidden */
  88021. _resetPointsArrayCache(): void;
  88022. /** @hidden */
  88023. _generatePointsArray(): boolean;
  88024. /**
  88025. * Gets a value indicating if the geometry is disposed
  88026. * @returns true if the geometry was disposed
  88027. */
  88028. isDisposed(): boolean;
  88029. private _disposeVertexArrayObjects;
  88030. /**
  88031. * Free all associated resources
  88032. */
  88033. dispose(): void;
  88034. /**
  88035. * Clone the current geometry into a new geometry
  88036. * @param id defines the unique ID of the new geometry
  88037. * @returns a new geometry object
  88038. */
  88039. copy(id: string): Geometry;
  88040. /**
  88041. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88042. * @return a JSON representation of the current geometry data (without the vertices data)
  88043. */
  88044. serialize(): any;
  88045. private toNumberArray;
  88046. /**
  88047. * Serialize all vertices data into a JSON oject
  88048. * @returns a JSON representation of the current geometry data
  88049. */
  88050. serializeVerticeData(): any;
  88051. /**
  88052. * Extracts a clone of a mesh geometry
  88053. * @param mesh defines the source mesh
  88054. * @param id defines the unique ID of the new geometry object
  88055. * @returns the new geometry object
  88056. */
  88057. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88058. /**
  88059. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88060. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88061. * Be aware Math.random() could cause collisions, but:
  88062. * "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"
  88063. * @returns a string containing a new GUID
  88064. */
  88065. static RandomId(): string;
  88066. /** @hidden */
  88067. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88068. private static _CleanMatricesWeights;
  88069. /**
  88070. * Create a new geometry from persisted data (Using .babylon file format)
  88071. * @param parsedVertexData defines the persisted data
  88072. * @param scene defines the hosting scene
  88073. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88074. * @returns the new geometry object
  88075. */
  88076. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88077. }
  88078. }
  88079. declare module BABYLON {
  88080. /**
  88081. * Define an interface for all classes that will get and set the data on vertices
  88082. */
  88083. export interface IGetSetVerticesData {
  88084. /**
  88085. * Gets a boolean indicating if specific vertex data is present
  88086. * @param kind defines the vertex data kind to use
  88087. * @returns true is data kind is present
  88088. */
  88089. isVerticesDataPresent(kind: string): boolean;
  88090. /**
  88091. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88092. * @param kind defines the data kind (Position, normal, etc...)
  88093. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88094. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88095. * @returns a float array containing vertex data
  88096. */
  88097. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88098. /**
  88099. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88100. * @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.
  88101. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88102. * @returns the indices array or an empty array if the mesh has no geometry
  88103. */
  88104. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88105. /**
  88106. * Set specific vertex data
  88107. * @param kind defines the data kind (Position, normal, etc...)
  88108. * @param data defines the vertex data to use
  88109. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88110. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88111. */
  88112. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88113. /**
  88114. * Update a specific associated vertex buffer
  88115. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88116. * - VertexBuffer.PositionKind
  88117. * - VertexBuffer.UVKind
  88118. * - VertexBuffer.UV2Kind
  88119. * - VertexBuffer.UV3Kind
  88120. * - VertexBuffer.UV4Kind
  88121. * - VertexBuffer.UV5Kind
  88122. * - VertexBuffer.UV6Kind
  88123. * - VertexBuffer.ColorKind
  88124. * - VertexBuffer.MatricesIndicesKind
  88125. * - VertexBuffer.MatricesIndicesExtraKind
  88126. * - VertexBuffer.MatricesWeightsKind
  88127. * - VertexBuffer.MatricesWeightsExtraKind
  88128. * @param data defines the data source
  88129. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88130. * @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)
  88131. */
  88132. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88133. /**
  88134. * Creates a new index buffer
  88135. * @param indices defines the indices to store in the index buffer
  88136. * @param totalVertices defines the total number of vertices (could be null)
  88137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88138. */
  88139. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88140. }
  88141. /**
  88142. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88143. */
  88144. export class VertexData {
  88145. /**
  88146. * Mesh side orientation : usually the external or front surface
  88147. */
  88148. static readonly FRONTSIDE: number;
  88149. /**
  88150. * Mesh side orientation : usually the internal or back surface
  88151. */
  88152. static readonly BACKSIDE: number;
  88153. /**
  88154. * Mesh side orientation : both internal and external or front and back surfaces
  88155. */
  88156. static readonly DOUBLESIDE: number;
  88157. /**
  88158. * Mesh side orientation : by default, `FRONTSIDE`
  88159. */
  88160. static readonly DEFAULTSIDE: number;
  88161. /**
  88162. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88163. */
  88164. positions: Nullable<FloatArray>;
  88165. /**
  88166. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88167. */
  88168. normals: Nullable<FloatArray>;
  88169. /**
  88170. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88171. */
  88172. tangents: Nullable<FloatArray>;
  88173. /**
  88174. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88175. */
  88176. uvs: Nullable<FloatArray>;
  88177. /**
  88178. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88179. */
  88180. uvs2: Nullable<FloatArray>;
  88181. /**
  88182. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88183. */
  88184. uvs3: Nullable<FloatArray>;
  88185. /**
  88186. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88187. */
  88188. uvs4: Nullable<FloatArray>;
  88189. /**
  88190. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88191. */
  88192. uvs5: Nullable<FloatArray>;
  88193. /**
  88194. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88195. */
  88196. uvs6: Nullable<FloatArray>;
  88197. /**
  88198. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88199. */
  88200. colors: Nullable<FloatArray>;
  88201. /**
  88202. * 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).
  88203. */
  88204. matricesIndices: Nullable<FloatArray>;
  88205. /**
  88206. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88207. */
  88208. matricesWeights: Nullable<FloatArray>;
  88209. /**
  88210. * An array extending the number of possible indices
  88211. */
  88212. matricesIndicesExtra: Nullable<FloatArray>;
  88213. /**
  88214. * An array extending the number of possible weights when the number of indices is extended
  88215. */
  88216. matricesWeightsExtra: Nullable<FloatArray>;
  88217. /**
  88218. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88219. */
  88220. indices: Nullable<IndicesArray>;
  88221. /**
  88222. * Uses the passed data array to set the set the values for the specified kind of data
  88223. * @param data a linear array of floating numbers
  88224. * @param kind the type of data that is being set, eg positions, colors etc
  88225. */
  88226. set(data: FloatArray, kind: string): void;
  88227. /**
  88228. * Associates the vertexData to the passed Mesh.
  88229. * Sets it as updatable or not (default `false`)
  88230. * @param mesh the mesh the vertexData is applied to
  88231. * @param updatable when used and having the value true allows new data to update the vertexData
  88232. * @returns the VertexData
  88233. */
  88234. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88235. /**
  88236. * Associates the vertexData to the passed Geometry.
  88237. * Sets it as updatable or not (default `false`)
  88238. * @param geometry the geometry the vertexData is applied to
  88239. * @param updatable when used and having the value true allows new data to update the vertexData
  88240. * @returns VertexData
  88241. */
  88242. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88243. /**
  88244. * Updates the associated mesh
  88245. * @param mesh the mesh to be updated
  88246. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88247. * @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
  88248. * @returns VertexData
  88249. */
  88250. updateMesh(mesh: Mesh): VertexData;
  88251. /**
  88252. * Updates the associated geometry
  88253. * @param geometry the geometry to be updated
  88254. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88255. * @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
  88256. * @returns VertexData.
  88257. */
  88258. updateGeometry(geometry: Geometry): VertexData;
  88259. private _applyTo;
  88260. private _update;
  88261. /**
  88262. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88263. * @param matrix the transforming matrix
  88264. * @returns the VertexData
  88265. */
  88266. transform(matrix: Matrix): VertexData;
  88267. /**
  88268. * Merges the passed VertexData into the current one
  88269. * @param other the VertexData to be merged into the current one
  88270. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88271. * @returns the modified VertexData
  88272. */
  88273. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88274. private _mergeElement;
  88275. private _validate;
  88276. /**
  88277. * Serializes the VertexData
  88278. * @returns a serialized object
  88279. */
  88280. serialize(): any;
  88281. /**
  88282. * Extracts the vertexData from a mesh
  88283. * @param mesh the mesh from which to extract the VertexData
  88284. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88285. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88286. * @returns the object VertexData associated to the passed mesh
  88287. */
  88288. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88289. /**
  88290. * Extracts the vertexData from the geometry
  88291. * @param geometry the geometry from which to extract the VertexData
  88292. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88293. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88294. * @returns the object VertexData associated to the passed mesh
  88295. */
  88296. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88297. private static _ExtractFrom;
  88298. /**
  88299. * Creates the VertexData for a Ribbon
  88300. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88301. * * pathArray array of paths, each of which an array of successive Vector3
  88302. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88303. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88304. * * 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
  88305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88306. * * 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)
  88307. * * 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)
  88308. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88309. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88310. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88311. * @returns the VertexData of the ribbon
  88312. */
  88313. static CreateRibbon(options: {
  88314. pathArray: Vector3[][];
  88315. closeArray?: boolean;
  88316. closePath?: boolean;
  88317. offset?: number;
  88318. sideOrientation?: number;
  88319. frontUVs?: Vector4;
  88320. backUVs?: Vector4;
  88321. invertUV?: boolean;
  88322. uvs?: Vector2[];
  88323. colors?: Color4[];
  88324. }): VertexData;
  88325. /**
  88326. * Creates the VertexData for a box
  88327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88328. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88329. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88330. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88331. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88332. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88333. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88334. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88335. * * 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)
  88336. * * 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)
  88337. * @returns the VertexData of the box
  88338. */
  88339. static CreateBox(options: {
  88340. size?: number;
  88341. width?: number;
  88342. height?: number;
  88343. depth?: number;
  88344. faceUV?: Vector4[];
  88345. faceColors?: Color4[];
  88346. sideOrientation?: number;
  88347. frontUVs?: Vector4;
  88348. backUVs?: Vector4;
  88349. }): VertexData;
  88350. /**
  88351. * Creates the VertexData for a tiled box
  88352. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88353. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88354. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88355. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88356. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88357. * @returns the VertexData of the box
  88358. */
  88359. static CreateTiledBox(options: {
  88360. pattern?: number;
  88361. width?: number;
  88362. height?: number;
  88363. depth?: number;
  88364. tileSize?: number;
  88365. tileWidth?: number;
  88366. tileHeight?: number;
  88367. alignHorizontal?: number;
  88368. alignVertical?: number;
  88369. faceUV?: Vector4[];
  88370. faceColors?: Color4[];
  88371. sideOrientation?: number;
  88372. }): VertexData;
  88373. /**
  88374. * Creates the VertexData for a tiled plane
  88375. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88376. * * pattern a limited pattern arrangement depending on the number
  88377. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88378. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88379. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88380. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88381. * * 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)
  88382. * * 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)
  88383. * @returns the VertexData of the tiled plane
  88384. */
  88385. static CreateTiledPlane(options: {
  88386. pattern?: number;
  88387. tileSize?: number;
  88388. tileWidth?: number;
  88389. tileHeight?: number;
  88390. size?: number;
  88391. width?: number;
  88392. height?: number;
  88393. alignHorizontal?: number;
  88394. alignVertical?: number;
  88395. sideOrientation?: number;
  88396. frontUVs?: Vector4;
  88397. backUVs?: Vector4;
  88398. }): VertexData;
  88399. /**
  88400. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88402. * * segments sets the number of horizontal strips optional, default 32
  88403. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88404. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88405. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88406. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88407. * * 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
  88408. * * 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
  88409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88410. * * 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)
  88411. * * 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)
  88412. * @returns the VertexData of the ellipsoid
  88413. */
  88414. static CreateSphere(options: {
  88415. segments?: number;
  88416. diameter?: number;
  88417. diameterX?: number;
  88418. diameterY?: number;
  88419. diameterZ?: number;
  88420. arc?: number;
  88421. slice?: number;
  88422. sideOrientation?: number;
  88423. frontUVs?: Vector4;
  88424. backUVs?: Vector4;
  88425. }): VertexData;
  88426. /**
  88427. * Creates the VertexData for a cylinder, cone or prism
  88428. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88429. * * height sets the height (y direction) of the cylinder, optional, default 2
  88430. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88431. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88432. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88433. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88434. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88435. * * 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
  88436. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88437. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88438. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88439. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88440. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88441. * * 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)
  88442. * * 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)
  88443. * @returns the VertexData of the cylinder, cone or prism
  88444. */
  88445. static CreateCylinder(options: {
  88446. height?: number;
  88447. diameterTop?: number;
  88448. diameterBottom?: number;
  88449. diameter?: number;
  88450. tessellation?: number;
  88451. subdivisions?: number;
  88452. arc?: number;
  88453. faceColors?: Color4[];
  88454. faceUV?: Vector4[];
  88455. hasRings?: boolean;
  88456. enclose?: boolean;
  88457. sideOrientation?: number;
  88458. frontUVs?: Vector4;
  88459. backUVs?: Vector4;
  88460. }): VertexData;
  88461. /**
  88462. * Creates the VertexData for a torus
  88463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88464. * * diameter the diameter of the torus, optional default 1
  88465. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88466. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88468. * * 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)
  88469. * * 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)
  88470. * @returns the VertexData of the torus
  88471. */
  88472. static CreateTorus(options: {
  88473. diameter?: number;
  88474. thickness?: number;
  88475. tessellation?: number;
  88476. sideOrientation?: number;
  88477. frontUVs?: Vector4;
  88478. backUVs?: Vector4;
  88479. }): VertexData;
  88480. /**
  88481. * Creates the VertexData of the LineSystem
  88482. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88483. * - lines an array of lines, each line being an array of successive Vector3
  88484. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88485. * @returns the VertexData of the LineSystem
  88486. */
  88487. static CreateLineSystem(options: {
  88488. lines: Vector3[][];
  88489. colors?: Nullable<Color4[][]>;
  88490. }): VertexData;
  88491. /**
  88492. * Create the VertexData for a DashedLines
  88493. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88494. * - points an array successive Vector3
  88495. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88496. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88497. * - dashNb the intended total number of dashes, optional, default 200
  88498. * @returns the VertexData for the DashedLines
  88499. */
  88500. static CreateDashedLines(options: {
  88501. points: Vector3[];
  88502. dashSize?: number;
  88503. gapSize?: number;
  88504. dashNb?: number;
  88505. }): VertexData;
  88506. /**
  88507. * Creates the VertexData for a Ground
  88508. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88509. * - width the width (x direction) of the ground, optional, default 1
  88510. * - height the height (z direction) of the ground, optional, default 1
  88511. * - subdivisions the number of subdivisions per side, optional, default 1
  88512. * @returns the VertexData of the Ground
  88513. */
  88514. static CreateGround(options: {
  88515. width?: number;
  88516. height?: number;
  88517. subdivisions?: number;
  88518. subdivisionsX?: number;
  88519. subdivisionsY?: number;
  88520. }): VertexData;
  88521. /**
  88522. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88523. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88524. * * xmin the ground minimum X coordinate, optional, default -1
  88525. * * zmin the ground minimum Z coordinate, optional, default -1
  88526. * * xmax the ground maximum X coordinate, optional, default 1
  88527. * * zmax the ground maximum Z coordinate, optional, default 1
  88528. * * 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}
  88529. * * 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}
  88530. * @returns the VertexData of the TiledGround
  88531. */
  88532. static CreateTiledGround(options: {
  88533. xmin: number;
  88534. zmin: number;
  88535. xmax: number;
  88536. zmax: number;
  88537. subdivisions?: {
  88538. w: number;
  88539. h: number;
  88540. };
  88541. precision?: {
  88542. w: number;
  88543. h: number;
  88544. };
  88545. }): VertexData;
  88546. /**
  88547. * Creates the VertexData of the Ground designed from a heightmap
  88548. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88549. * * width the width (x direction) of the ground
  88550. * * height the height (z direction) of the ground
  88551. * * subdivisions the number of subdivisions per side
  88552. * * minHeight the minimum altitude on the ground, optional, default 0
  88553. * * maxHeight the maximum altitude on the ground, optional default 1
  88554. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88555. * * buffer the array holding the image color data
  88556. * * bufferWidth the width of image
  88557. * * bufferHeight the height of image
  88558. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88559. * @returns the VertexData of the Ground designed from a heightmap
  88560. */
  88561. static CreateGroundFromHeightMap(options: {
  88562. width: number;
  88563. height: number;
  88564. subdivisions: number;
  88565. minHeight: number;
  88566. maxHeight: number;
  88567. colorFilter: Color3;
  88568. buffer: Uint8Array;
  88569. bufferWidth: number;
  88570. bufferHeight: number;
  88571. alphaFilter: number;
  88572. }): VertexData;
  88573. /**
  88574. * Creates the VertexData for a Plane
  88575. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88576. * * size sets the width and height of the plane to the value of size, optional default 1
  88577. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88578. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88580. * * 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)
  88581. * * 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)
  88582. * @returns the VertexData of the box
  88583. */
  88584. static CreatePlane(options: {
  88585. size?: number;
  88586. width?: number;
  88587. height?: number;
  88588. sideOrientation?: number;
  88589. frontUVs?: Vector4;
  88590. backUVs?: Vector4;
  88591. }): VertexData;
  88592. /**
  88593. * Creates the VertexData of the Disc or regular Polygon
  88594. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88595. * * radius the radius of the disc, optional default 0.5
  88596. * * tessellation the number of polygon sides, optional, default 64
  88597. * * 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
  88598. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88599. * * 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)
  88600. * * 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)
  88601. * @returns the VertexData of the box
  88602. */
  88603. static CreateDisc(options: {
  88604. radius?: number;
  88605. tessellation?: number;
  88606. arc?: number;
  88607. sideOrientation?: number;
  88608. frontUVs?: Vector4;
  88609. backUVs?: Vector4;
  88610. }): VertexData;
  88611. /**
  88612. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88613. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88614. * @param polygon a mesh built from polygonTriangulation.build()
  88615. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88616. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88617. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88618. * @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)
  88619. * @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)
  88620. * @returns the VertexData of the Polygon
  88621. */
  88622. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88623. /**
  88624. * Creates the VertexData of the IcoSphere
  88625. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88626. * * radius the radius of the IcoSphere, optional default 1
  88627. * * radiusX allows stretching in the x direction, optional, default radius
  88628. * * radiusY allows stretching in the y direction, optional, default radius
  88629. * * radiusZ allows stretching in the z direction, optional, default radius
  88630. * * flat when true creates a flat shaded mesh, optional, default true
  88631. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88632. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88633. * * 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)
  88634. * * 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)
  88635. * @returns the VertexData of the IcoSphere
  88636. */
  88637. static CreateIcoSphere(options: {
  88638. radius?: number;
  88639. radiusX?: number;
  88640. radiusY?: number;
  88641. radiusZ?: number;
  88642. flat?: boolean;
  88643. subdivisions?: number;
  88644. sideOrientation?: number;
  88645. frontUVs?: Vector4;
  88646. backUVs?: Vector4;
  88647. }): VertexData;
  88648. /**
  88649. * Creates the VertexData for a Polyhedron
  88650. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88651. * * type provided types are:
  88652. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88653. * * 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)
  88654. * * size the size of the IcoSphere, optional default 1
  88655. * * sizeX allows stretching in the x direction, optional, default size
  88656. * * sizeY allows stretching in the y direction, optional, default size
  88657. * * sizeZ allows stretching in the z direction, optional, default size
  88658. * * 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
  88659. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88660. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88661. * * flat when true creates a flat shaded mesh, optional, default true
  88662. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88663. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88664. * * 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)
  88665. * * 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)
  88666. * @returns the VertexData of the Polyhedron
  88667. */
  88668. static CreatePolyhedron(options: {
  88669. type?: number;
  88670. size?: number;
  88671. sizeX?: number;
  88672. sizeY?: number;
  88673. sizeZ?: number;
  88674. custom?: any;
  88675. faceUV?: Vector4[];
  88676. faceColors?: Color4[];
  88677. flat?: boolean;
  88678. sideOrientation?: number;
  88679. frontUVs?: Vector4;
  88680. backUVs?: Vector4;
  88681. }): VertexData;
  88682. /**
  88683. * Creates the VertexData for a TorusKnot
  88684. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88685. * * radius the radius of the torus knot, optional, default 2
  88686. * * tube the thickness of the tube, optional, default 0.5
  88687. * * radialSegments the number of sides on each tube segments, optional, default 32
  88688. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88689. * * p the number of windings around the z axis, optional, default 2
  88690. * * q the number of windings around the x axis, optional, default 3
  88691. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88692. * * 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)
  88693. * * 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)
  88694. * @returns the VertexData of the Torus Knot
  88695. */
  88696. static CreateTorusKnot(options: {
  88697. radius?: number;
  88698. tube?: number;
  88699. radialSegments?: number;
  88700. tubularSegments?: number;
  88701. p?: number;
  88702. q?: number;
  88703. sideOrientation?: number;
  88704. frontUVs?: Vector4;
  88705. backUVs?: Vector4;
  88706. }): VertexData;
  88707. /**
  88708. * Compute normals for given positions and indices
  88709. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88710. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88711. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88712. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88713. * * facetNormals : optional array of facet normals (vector3)
  88714. * * facetPositions : optional array of facet positions (vector3)
  88715. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88716. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88717. * * bInfo : optional bounding info, required for facetPartitioning computation
  88718. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88719. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88720. * * useRightHandedSystem: optional boolean to for right handed system computation
  88721. * * depthSort : optional boolean to enable the facet depth sort computation
  88722. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88723. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88724. */
  88725. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88726. facetNormals?: any;
  88727. facetPositions?: any;
  88728. facetPartitioning?: any;
  88729. ratio?: number;
  88730. bInfo?: any;
  88731. bbSize?: Vector3;
  88732. subDiv?: any;
  88733. useRightHandedSystem?: boolean;
  88734. depthSort?: boolean;
  88735. distanceTo?: Vector3;
  88736. depthSortedFacets?: any;
  88737. }): void;
  88738. /** @hidden */
  88739. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88740. /**
  88741. * Applies VertexData created from the imported parameters to the geometry
  88742. * @param parsedVertexData the parsed data from an imported file
  88743. * @param geometry the geometry to apply the VertexData to
  88744. */
  88745. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88746. }
  88747. }
  88748. declare module BABYLON {
  88749. /**
  88750. * Defines a target to use with MorphTargetManager
  88751. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88752. */
  88753. export class MorphTarget implements IAnimatable {
  88754. /** defines the name of the target */
  88755. name: string;
  88756. /**
  88757. * Gets or sets the list of animations
  88758. */
  88759. animations: Animation[];
  88760. private _scene;
  88761. private _positions;
  88762. private _normals;
  88763. private _tangents;
  88764. private _uvs;
  88765. private _influence;
  88766. /**
  88767. * Observable raised when the influence changes
  88768. */
  88769. onInfluenceChanged: Observable<boolean>;
  88770. /** @hidden */
  88771. _onDataLayoutChanged: Observable<void>;
  88772. /**
  88773. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88774. */
  88775. influence: number;
  88776. /**
  88777. * Gets or sets the id of the morph Target
  88778. */
  88779. id: string;
  88780. private _animationPropertiesOverride;
  88781. /**
  88782. * Gets or sets the animation properties override
  88783. */
  88784. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88785. /**
  88786. * Creates a new MorphTarget
  88787. * @param name defines the name of the target
  88788. * @param influence defines the influence to use
  88789. * @param scene defines the scene the morphtarget belongs to
  88790. */
  88791. constructor(
  88792. /** defines the name of the target */
  88793. name: string, influence?: number, scene?: Nullable<Scene>);
  88794. /**
  88795. * Gets a boolean defining if the target contains position data
  88796. */
  88797. readonly hasPositions: boolean;
  88798. /**
  88799. * Gets a boolean defining if the target contains normal data
  88800. */
  88801. readonly hasNormals: boolean;
  88802. /**
  88803. * Gets a boolean defining if the target contains tangent data
  88804. */
  88805. readonly hasTangents: boolean;
  88806. /**
  88807. * Gets a boolean defining if the target contains texture coordinates data
  88808. */
  88809. readonly hasUVs: boolean;
  88810. /**
  88811. * Affects position data to this target
  88812. * @param data defines the position data to use
  88813. */
  88814. setPositions(data: Nullable<FloatArray>): void;
  88815. /**
  88816. * Gets the position data stored in this target
  88817. * @returns a FloatArray containing the position data (or null if not present)
  88818. */
  88819. getPositions(): Nullable<FloatArray>;
  88820. /**
  88821. * Affects normal data to this target
  88822. * @param data defines the normal data to use
  88823. */
  88824. setNormals(data: Nullable<FloatArray>): void;
  88825. /**
  88826. * Gets the normal data stored in this target
  88827. * @returns a FloatArray containing the normal data (or null if not present)
  88828. */
  88829. getNormals(): Nullable<FloatArray>;
  88830. /**
  88831. * Affects tangent data to this target
  88832. * @param data defines the tangent data to use
  88833. */
  88834. setTangents(data: Nullable<FloatArray>): void;
  88835. /**
  88836. * Gets the tangent data stored in this target
  88837. * @returns a FloatArray containing the tangent data (or null if not present)
  88838. */
  88839. getTangents(): Nullable<FloatArray>;
  88840. /**
  88841. * Affects texture coordinates data to this target
  88842. * @param data defines the texture coordinates data to use
  88843. */
  88844. setUVs(data: Nullable<FloatArray>): void;
  88845. /**
  88846. * Gets the texture coordinates data stored in this target
  88847. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88848. */
  88849. getUVs(): Nullable<FloatArray>;
  88850. /**
  88851. * Serializes the current target into a Serialization object
  88852. * @returns the serialized object
  88853. */
  88854. serialize(): any;
  88855. /**
  88856. * Returns the string "MorphTarget"
  88857. * @returns "MorphTarget"
  88858. */
  88859. getClassName(): string;
  88860. /**
  88861. * Creates a new target from serialized data
  88862. * @param serializationObject defines the serialized data to use
  88863. * @returns a new MorphTarget
  88864. */
  88865. static Parse(serializationObject: any): MorphTarget;
  88866. /**
  88867. * Creates a MorphTarget from mesh data
  88868. * @param mesh defines the source mesh
  88869. * @param name defines the name to use for the new target
  88870. * @param influence defines the influence to attach to the target
  88871. * @returns a new MorphTarget
  88872. */
  88873. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88874. }
  88875. }
  88876. declare module BABYLON {
  88877. /**
  88878. * This class is used to deform meshes using morphing between different targets
  88879. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88880. */
  88881. export class MorphTargetManager {
  88882. private _targets;
  88883. private _targetInfluenceChangedObservers;
  88884. private _targetDataLayoutChangedObservers;
  88885. private _activeTargets;
  88886. private _scene;
  88887. private _influences;
  88888. private _supportsNormals;
  88889. private _supportsTangents;
  88890. private _supportsUVs;
  88891. private _vertexCount;
  88892. private _uniqueId;
  88893. private _tempInfluences;
  88894. /**
  88895. * Gets or sets a boolean indicating if normals must be morphed
  88896. */
  88897. enableNormalMorphing: boolean;
  88898. /**
  88899. * Gets or sets a boolean indicating if tangents must be morphed
  88900. */
  88901. enableTangentMorphing: boolean;
  88902. /**
  88903. * Gets or sets a boolean indicating if UV must be morphed
  88904. */
  88905. enableUVMorphing: boolean;
  88906. /**
  88907. * Creates a new MorphTargetManager
  88908. * @param scene defines the current scene
  88909. */
  88910. constructor(scene?: Nullable<Scene>);
  88911. /**
  88912. * Gets the unique ID of this manager
  88913. */
  88914. readonly uniqueId: number;
  88915. /**
  88916. * Gets the number of vertices handled by this manager
  88917. */
  88918. readonly vertexCount: number;
  88919. /**
  88920. * Gets a boolean indicating if this manager supports morphing of normals
  88921. */
  88922. readonly supportsNormals: boolean;
  88923. /**
  88924. * Gets a boolean indicating if this manager supports morphing of tangents
  88925. */
  88926. readonly supportsTangents: boolean;
  88927. /**
  88928. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88929. */
  88930. readonly supportsUVs: boolean;
  88931. /**
  88932. * Gets the number of targets stored in this manager
  88933. */
  88934. readonly numTargets: number;
  88935. /**
  88936. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88937. */
  88938. readonly numInfluencers: number;
  88939. /**
  88940. * Gets the list of influences (one per target)
  88941. */
  88942. readonly influences: Float32Array;
  88943. /**
  88944. * Gets the active target at specified index. An active target is a target with an influence > 0
  88945. * @param index defines the index to check
  88946. * @returns the requested target
  88947. */
  88948. getActiveTarget(index: number): MorphTarget;
  88949. /**
  88950. * Gets the target at specified index
  88951. * @param index defines the index to check
  88952. * @returns the requested target
  88953. */
  88954. getTarget(index: number): MorphTarget;
  88955. /**
  88956. * Add a new target to this manager
  88957. * @param target defines the target to add
  88958. */
  88959. addTarget(target: MorphTarget): void;
  88960. /**
  88961. * Removes a target from the manager
  88962. * @param target defines the target to remove
  88963. */
  88964. removeTarget(target: MorphTarget): void;
  88965. /**
  88966. * Serializes the current manager into a Serialization object
  88967. * @returns the serialized object
  88968. */
  88969. serialize(): any;
  88970. private _syncActiveTargets;
  88971. /**
  88972. * Syncrhonize the targets with all the meshes using this morph target manager
  88973. */
  88974. synchronize(): void;
  88975. /**
  88976. * Creates a new MorphTargetManager from serialized data
  88977. * @param serializationObject defines the serialized data
  88978. * @param scene defines the hosting scene
  88979. * @returns the new MorphTargetManager
  88980. */
  88981. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88982. }
  88983. }
  88984. declare module BABYLON {
  88985. /**
  88986. * Class used to represent a specific level of detail of a mesh
  88987. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88988. */
  88989. export class MeshLODLevel {
  88990. /** Defines the distance where this level should start being displayed */
  88991. distance: number;
  88992. /** Defines the mesh to use to render this level */
  88993. mesh: Nullable<Mesh>;
  88994. /**
  88995. * Creates a new LOD level
  88996. * @param distance defines the distance where this level should star being displayed
  88997. * @param mesh defines the mesh to use to render this level
  88998. */
  88999. constructor(
  89000. /** Defines the distance where this level should start being displayed */
  89001. distance: number,
  89002. /** Defines the mesh to use to render this level */
  89003. mesh: Nullable<Mesh>);
  89004. }
  89005. }
  89006. declare module BABYLON {
  89007. /**
  89008. * Mesh representing the gorund
  89009. */
  89010. export class GroundMesh extends Mesh {
  89011. /** If octree should be generated */
  89012. generateOctree: boolean;
  89013. private _heightQuads;
  89014. /** @hidden */
  89015. _subdivisionsX: number;
  89016. /** @hidden */
  89017. _subdivisionsY: number;
  89018. /** @hidden */
  89019. _width: number;
  89020. /** @hidden */
  89021. _height: number;
  89022. /** @hidden */
  89023. _minX: number;
  89024. /** @hidden */
  89025. _maxX: number;
  89026. /** @hidden */
  89027. _minZ: number;
  89028. /** @hidden */
  89029. _maxZ: number;
  89030. constructor(name: string, scene: Scene);
  89031. /**
  89032. * "GroundMesh"
  89033. * @returns "GroundMesh"
  89034. */
  89035. getClassName(): string;
  89036. /**
  89037. * The minimum of x and y subdivisions
  89038. */
  89039. readonly subdivisions: number;
  89040. /**
  89041. * X subdivisions
  89042. */
  89043. readonly subdivisionsX: number;
  89044. /**
  89045. * Y subdivisions
  89046. */
  89047. readonly subdivisionsY: number;
  89048. /**
  89049. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89050. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89051. * @param chunksCount the number of subdivisions for x and y
  89052. * @param octreeBlocksSize (Default: 32)
  89053. */
  89054. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89055. /**
  89056. * Returns a height (y) value in the Worl system :
  89057. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89058. * @param x x coordinate
  89059. * @param z z coordinate
  89060. * @returns the ground y position if (x, z) are outside the ground surface.
  89061. */
  89062. getHeightAtCoordinates(x: number, z: number): number;
  89063. /**
  89064. * Returns a normalized vector (Vector3) orthogonal to the ground
  89065. * at the ground coordinates (x, z) expressed in the World system.
  89066. * @param x x coordinate
  89067. * @param z z coordinate
  89068. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89069. */
  89070. getNormalAtCoordinates(x: number, z: number): Vector3;
  89071. /**
  89072. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89073. * at the ground coordinates (x, z) expressed in the World system.
  89074. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89075. * @param x x coordinate
  89076. * @param z z coordinate
  89077. * @param ref vector to store the result
  89078. * @returns the GroundMesh.
  89079. */
  89080. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89081. /**
  89082. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89083. * if the ground has been updated.
  89084. * This can be used in the render loop.
  89085. * @returns the GroundMesh.
  89086. */
  89087. updateCoordinateHeights(): GroundMesh;
  89088. private _getFacetAt;
  89089. private _initHeightQuads;
  89090. private _computeHeightQuads;
  89091. /**
  89092. * Serializes this ground mesh
  89093. * @param serializationObject object to write serialization to
  89094. */
  89095. serialize(serializationObject: any): void;
  89096. /**
  89097. * Parses a serialized ground mesh
  89098. * @param parsedMesh the serialized mesh
  89099. * @param scene the scene to create the ground mesh in
  89100. * @returns the created ground mesh
  89101. */
  89102. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89103. }
  89104. }
  89105. declare module BABYLON {
  89106. /**
  89107. * Interface for Physics-Joint data
  89108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89109. */
  89110. export interface PhysicsJointData {
  89111. /**
  89112. * The main pivot of the joint
  89113. */
  89114. mainPivot?: Vector3;
  89115. /**
  89116. * The connected pivot of the joint
  89117. */
  89118. connectedPivot?: Vector3;
  89119. /**
  89120. * The main axis of the joint
  89121. */
  89122. mainAxis?: Vector3;
  89123. /**
  89124. * The connected axis of the joint
  89125. */
  89126. connectedAxis?: Vector3;
  89127. /**
  89128. * The collision of the joint
  89129. */
  89130. collision?: boolean;
  89131. /**
  89132. * Native Oimo/Cannon/Energy data
  89133. */
  89134. nativeParams?: any;
  89135. }
  89136. /**
  89137. * This is a holder class for the physics joint created by the physics plugin
  89138. * It holds a set of functions to control the underlying joint
  89139. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89140. */
  89141. export class PhysicsJoint {
  89142. /**
  89143. * The type of the physics joint
  89144. */
  89145. type: number;
  89146. /**
  89147. * The data for the physics joint
  89148. */
  89149. jointData: PhysicsJointData;
  89150. private _physicsJoint;
  89151. protected _physicsPlugin: IPhysicsEnginePlugin;
  89152. /**
  89153. * Initializes the physics joint
  89154. * @param type The type of the physics joint
  89155. * @param jointData The data for the physics joint
  89156. */
  89157. constructor(
  89158. /**
  89159. * The type of the physics joint
  89160. */
  89161. type: number,
  89162. /**
  89163. * The data for the physics joint
  89164. */
  89165. jointData: PhysicsJointData);
  89166. /**
  89167. * Gets the physics joint
  89168. */
  89169. /**
  89170. * Sets the physics joint
  89171. */
  89172. physicsJoint: any;
  89173. /**
  89174. * Sets the physics plugin
  89175. */
  89176. physicsPlugin: IPhysicsEnginePlugin;
  89177. /**
  89178. * Execute a function that is physics-plugin specific.
  89179. * @param {Function} func the function that will be executed.
  89180. * It accepts two parameters: the physics world and the physics joint
  89181. */
  89182. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89183. /**
  89184. * Distance-Joint type
  89185. */
  89186. static DistanceJoint: number;
  89187. /**
  89188. * Hinge-Joint type
  89189. */
  89190. static HingeJoint: number;
  89191. /**
  89192. * Ball-and-Socket joint type
  89193. */
  89194. static BallAndSocketJoint: number;
  89195. /**
  89196. * Wheel-Joint type
  89197. */
  89198. static WheelJoint: number;
  89199. /**
  89200. * Slider-Joint type
  89201. */
  89202. static SliderJoint: number;
  89203. /**
  89204. * Prismatic-Joint type
  89205. */
  89206. static PrismaticJoint: number;
  89207. /**
  89208. * Universal-Joint type
  89209. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89210. */
  89211. static UniversalJoint: number;
  89212. /**
  89213. * Hinge-Joint 2 type
  89214. */
  89215. static Hinge2Joint: number;
  89216. /**
  89217. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89218. */
  89219. static PointToPointJoint: number;
  89220. /**
  89221. * Spring-Joint type
  89222. */
  89223. static SpringJoint: number;
  89224. /**
  89225. * Lock-Joint type
  89226. */
  89227. static LockJoint: number;
  89228. }
  89229. /**
  89230. * A class representing a physics distance joint
  89231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89232. */
  89233. export class DistanceJoint extends PhysicsJoint {
  89234. /**
  89235. *
  89236. * @param jointData The data for the Distance-Joint
  89237. */
  89238. constructor(jointData: DistanceJointData);
  89239. /**
  89240. * Update the predefined distance.
  89241. * @param maxDistance The maximum preferred distance
  89242. * @param minDistance The minimum preferred distance
  89243. */
  89244. updateDistance(maxDistance: number, minDistance?: number): void;
  89245. }
  89246. /**
  89247. * Represents a Motor-Enabled Joint
  89248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89249. */
  89250. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89251. /**
  89252. * Initializes the Motor-Enabled Joint
  89253. * @param type The type of the joint
  89254. * @param jointData The physica joint data for the joint
  89255. */
  89256. constructor(type: number, jointData: PhysicsJointData);
  89257. /**
  89258. * Set the motor values.
  89259. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89260. * @param force the force to apply
  89261. * @param maxForce max force for this motor.
  89262. */
  89263. setMotor(force?: number, maxForce?: number): void;
  89264. /**
  89265. * Set the motor's limits.
  89266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89267. * @param upperLimit The upper limit of the motor
  89268. * @param lowerLimit The lower limit of the motor
  89269. */
  89270. setLimit(upperLimit: number, lowerLimit?: number): void;
  89271. }
  89272. /**
  89273. * This class represents a single physics Hinge-Joint
  89274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89275. */
  89276. export class HingeJoint extends MotorEnabledJoint {
  89277. /**
  89278. * Initializes the Hinge-Joint
  89279. * @param jointData The joint data for the Hinge-Joint
  89280. */
  89281. constructor(jointData: PhysicsJointData);
  89282. /**
  89283. * Set the motor values.
  89284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89285. * @param {number} force the force to apply
  89286. * @param {number} maxForce max force for this motor.
  89287. */
  89288. setMotor(force?: number, maxForce?: number): void;
  89289. /**
  89290. * Set the motor's limits.
  89291. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89292. * @param upperLimit The upper limit of the motor
  89293. * @param lowerLimit The lower limit of the motor
  89294. */
  89295. setLimit(upperLimit: number, lowerLimit?: number): void;
  89296. }
  89297. /**
  89298. * This class represents a dual hinge physics joint (same as wheel joint)
  89299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89300. */
  89301. export class Hinge2Joint extends MotorEnabledJoint {
  89302. /**
  89303. * Initializes the Hinge2-Joint
  89304. * @param jointData The joint data for the Hinge2-Joint
  89305. */
  89306. constructor(jointData: PhysicsJointData);
  89307. /**
  89308. * Set the motor values.
  89309. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89310. * @param {number} targetSpeed the speed the motor is to reach
  89311. * @param {number} maxForce max force for this motor.
  89312. * @param {motorIndex} the motor's index, 0 or 1.
  89313. */
  89314. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89315. /**
  89316. * Set the motor limits.
  89317. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89318. * @param {number} upperLimit the upper limit
  89319. * @param {number} lowerLimit lower limit
  89320. * @param {motorIndex} the motor's index, 0 or 1.
  89321. */
  89322. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89323. }
  89324. /**
  89325. * Interface for a motor enabled joint
  89326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89327. */
  89328. export interface IMotorEnabledJoint {
  89329. /**
  89330. * Physics joint
  89331. */
  89332. physicsJoint: any;
  89333. /**
  89334. * Sets the motor of the motor-enabled joint
  89335. * @param force The force of the motor
  89336. * @param maxForce The maximum force of the motor
  89337. * @param motorIndex The index of the motor
  89338. */
  89339. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89340. /**
  89341. * Sets the limit of the motor
  89342. * @param upperLimit The upper limit of the motor
  89343. * @param lowerLimit The lower limit of the motor
  89344. * @param motorIndex The index of the motor
  89345. */
  89346. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89347. }
  89348. /**
  89349. * Joint data for a Distance-Joint
  89350. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89351. */
  89352. export interface DistanceJointData extends PhysicsJointData {
  89353. /**
  89354. * Max distance the 2 joint objects can be apart
  89355. */
  89356. maxDistance: number;
  89357. }
  89358. /**
  89359. * Joint data from a spring joint
  89360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89361. */
  89362. export interface SpringJointData extends PhysicsJointData {
  89363. /**
  89364. * Length of the spring
  89365. */
  89366. length: number;
  89367. /**
  89368. * Stiffness of the spring
  89369. */
  89370. stiffness: number;
  89371. /**
  89372. * Damping of the spring
  89373. */
  89374. damping: number;
  89375. /** this callback will be called when applying the force to the impostors. */
  89376. forceApplicationCallback: () => void;
  89377. }
  89378. }
  89379. declare module BABYLON {
  89380. /**
  89381. * Holds the data for the raycast result
  89382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89383. */
  89384. export class PhysicsRaycastResult {
  89385. private _hasHit;
  89386. private _hitDistance;
  89387. private _hitNormalWorld;
  89388. private _hitPointWorld;
  89389. private _rayFromWorld;
  89390. private _rayToWorld;
  89391. /**
  89392. * Gets if there was a hit
  89393. */
  89394. readonly hasHit: boolean;
  89395. /**
  89396. * Gets the distance from the hit
  89397. */
  89398. readonly hitDistance: number;
  89399. /**
  89400. * Gets the hit normal/direction in the world
  89401. */
  89402. readonly hitNormalWorld: Vector3;
  89403. /**
  89404. * Gets the hit point in the world
  89405. */
  89406. readonly hitPointWorld: Vector3;
  89407. /**
  89408. * Gets the ray "start point" of the ray in the world
  89409. */
  89410. readonly rayFromWorld: Vector3;
  89411. /**
  89412. * Gets the ray "end point" of the ray in the world
  89413. */
  89414. readonly rayToWorld: Vector3;
  89415. /**
  89416. * Sets the hit data (normal & point in world space)
  89417. * @param hitNormalWorld defines the normal in world space
  89418. * @param hitPointWorld defines the point in world space
  89419. */
  89420. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89421. /**
  89422. * Sets the distance from the start point to the hit point
  89423. * @param distance
  89424. */
  89425. setHitDistance(distance: number): void;
  89426. /**
  89427. * Calculates the distance manually
  89428. */
  89429. calculateHitDistance(): void;
  89430. /**
  89431. * Resets all the values to default
  89432. * @param from The from point on world space
  89433. * @param to The to point on world space
  89434. */
  89435. reset(from?: Vector3, to?: Vector3): void;
  89436. }
  89437. /**
  89438. * Interface for the size containing width and height
  89439. */
  89440. interface IXYZ {
  89441. /**
  89442. * X
  89443. */
  89444. x: number;
  89445. /**
  89446. * Y
  89447. */
  89448. y: number;
  89449. /**
  89450. * Z
  89451. */
  89452. z: number;
  89453. }
  89454. }
  89455. declare module BABYLON {
  89456. /**
  89457. * Interface used to describe a physics joint
  89458. */
  89459. export interface PhysicsImpostorJoint {
  89460. /** Defines the main impostor to which the joint is linked */
  89461. mainImpostor: PhysicsImpostor;
  89462. /** Defines the impostor that is connected to the main impostor using this joint */
  89463. connectedImpostor: PhysicsImpostor;
  89464. /** Defines the joint itself */
  89465. joint: PhysicsJoint;
  89466. }
  89467. /** @hidden */
  89468. export interface IPhysicsEnginePlugin {
  89469. world: any;
  89470. name: string;
  89471. setGravity(gravity: Vector3): void;
  89472. setTimeStep(timeStep: number): void;
  89473. getTimeStep(): number;
  89474. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89475. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89476. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89477. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89478. removePhysicsBody(impostor: PhysicsImpostor): void;
  89479. generateJoint(joint: PhysicsImpostorJoint): void;
  89480. removeJoint(joint: PhysicsImpostorJoint): void;
  89481. isSupported(): boolean;
  89482. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89483. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89484. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89485. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89486. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89487. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89488. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89489. getBodyMass(impostor: PhysicsImpostor): number;
  89490. getBodyFriction(impostor: PhysicsImpostor): number;
  89491. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89492. getBodyRestitution(impostor: PhysicsImpostor): number;
  89493. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89494. getBodyPressure?(impostor: PhysicsImpostor): number;
  89495. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89496. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89497. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89498. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89499. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89500. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89501. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89502. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89503. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89504. sleepBody(impostor: PhysicsImpostor): void;
  89505. wakeUpBody(impostor: PhysicsImpostor): void;
  89506. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89507. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89508. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89509. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89510. getRadius(impostor: PhysicsImpostor): number;
  89511. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89512. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89513. dispose(): void;
  89514. }
  89515. /**
  89516. * Interface used to define a physics engine
  89517. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89518. */
  89519. export interface IPhysicsEngine {
  89520. /**
  89521. * Gets the gravity vector used by the simulation
  89522. */
  89523. gravity: Vector3;
  89524. /**
  89525. * Sets the gravity vector used by the simulation
  89526. * @param gravity defines the gravity vector to use
  89527. */
  89528. setGravity(gravity: Vector3): void;
  89529. /**
  89530. * Set the time step of the physics engine.
  89531. * Default is 1/60.
  89532. * To slow it down, enter 1/600 for example.
  89533. * To speed it up, 1/30
  89534. * @param newTimeStep the new timestep to apply to this world.
  89535. */
  89536. setTimeStep(newTimeStep: number): void;
  89537. /**
  89538. * Get the time step of the physics engine.
  89539. * @returns the current time step
  89540. */
  89541. getTimeStep(): number;
  89542. /**
  89543. * Release all resources
  89544. */
  89545. dispose(): void;
  89546. /**
  89547. * Gets the name of the current physics plugin
  89548. * @returns the name of the plugin
  89549. */
  89550. getPhysicsPluginName(): string;
  89551. /**
  89552. * Adding a new impostor for the impostor tracking.
  89553. * This will be done by the impostor itself.
  89554. * @param impostor the impostor to add
  89555. */
  89556. addImpostor(impostor: PhysicsImpostor): void;
  89557. /**
  89558. * Remove an impostor from the engine.
  89559. * This impostor and its mesh will not longer be updated by the physics engine.
  89560. * @param impostor the impostor to remove
  89561. */
  89562. removeImpostor(impostor: PhysicsImpostor): void;
  89563. /**
  89564. * Add a joint to the physics engine
  89565. * @param mainImpostor defines the main impostor to which the joint is added.
  89566. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89567. * @param joint defines the joint that will connect both impostors.
  89568. */
  89569. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89570. /**
  89571. * Removes a joint from the simulation
  89572. * @param mainImpostor defines the impostor used with the joint
  89573. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89574. * @param joint defines the joint to remove
  89575. */
  89576. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89577. /**
  89578. * Gets the current plugin used to run the simulation
  89579. * @returns current plugin
  89580. */
  89581. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89582. /**
  89583. * Gets the list of physic impostors
  89584. * @returns an array of PhysicsImpostor
  89585. */
  89586. getImpostors(): Array<PhysicsImpostor>;
  89587. /**
  89588. * Gets the impostor for a physics enabled object
  89589. * @param object defines the object impersonated by the impostor
  89590. * @returns the PhysicsImpostor or null if not found
  89591. */
  89592. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89593. /**
  89594. * Gets the impostor for a physics body object
  89595. * @param body defines physics body used by the impostor
  89596. * @returns the PhysicsImpostor or null if not found
  89597. */
  89598. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89599. /**
  89600. * Does a raycast in the physics world
  89601. * @param from when should the ray start?
  89602. * @param to when should the ray end?
  89603. * @returns PhysicsRaycastResult
  89604. */
  89605. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89606. /**
  89607. * Called by the scene. No need to call it.
  89608. * @param delta defines the timespam between frames
  89609. */
  89610. _step(delta: number): void;
  89611. }
  89612. }
  89613. declare module BABYLON {
  89614. /**
  89615. * The interface for the physics imposter parameters
  89616. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89617. */
  89618. export interface PhysicsImpostorParameters {
  89619. /**
  89620. * The mass of the physics imposter
  89621. */
  89622. mass: number;
  89623. /**
  89624. * The friction of the physics imposter
  89625. */
  89626. friction?: number;
  89627. /**
  89628. * The coefficient of restitution of the physics imposter
  89629. */
  89630. restitution?: number;
  89631. /**
  89632. * The native options of the physics imposter
  89633. */
  89634. nativeOptions?: any;
  89635. /**
  89636. * Specifies if the parent should be ignored
  89637. */
  89638. ignoreParent?: boolean;
  89639. /**
  89640. * Specifies if bi-directional transformations should be disabled
  89641. */
  89642. disableBidirectionalTransformation?: boolean;
  89643. /**
  89644. * The pressure inside the physics imposter, soft object only
  89645. */
  89646. pressure?: number;
  89647. /**
  89648. * The stiffness the physics imposter, soft object only
  89649. */
  89650. stiffness?: number;
  89651. /**
  89652. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89653. */
  89654. velocityIterations?: number;
  89655. /**
  89656. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89657. */
  89658. positionIterations?: number;
  89659. /**
  89660. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89661. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89662. * Add to fix multiple points
  89663. */
  89664. fixedPoints?: number;
  89665. /**
  89666. * The collision margin around a soft object
  89667. */
  89668. margin?: number;
  89669. /**
  89670. * The collision margin around a soft object
  89671. */
  89672. damping?: number;
  89673. /**
  89674. * The path for a rope based on an extrusion
  89675. */
  89676. path?: any;
  89677. /**
  89678. * The shape of an extrusion used for a rope based on an extrusion
  89679. */
  89680. shape?: any;
  89681. }
  89682. /**
  89683. * Interface for a physics-enabled object
  89684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89685. */
  89686. export interface IPhysicsEnabledObject {
  89687. /**
  89688. * The position of the physics-enabled object
  89689. */
  89690. position: Vector3;
  89691. /**
  89692. * The rotation of the physics-enabled object
  89693. */
  89694. rotationQuaternion: Nullable<Quaternion>;
  89695. /**
  89696. * The scale of the physics-enabled object
  89697. */
  89698. scaling: Vector3;
  89699. /**
  89700. * The rotation of the physics-enabled object
  89701. */
  89702. rotation?: Vector3;
  89703. /**
  89704. * The parent of the physics-enabled object
  89705. */
  89706. parent?: any;
  89707. /**
  89708. * The bounding info of the physics-enabled object
  89709. * @returns The bounding info of the physics-enabled object
  89710. */
  89711. getBoundingInfo(): BoundingInfo;
  89712. /**
  89713. * Computes the world matrix
  89714. * @param force Specifies if the world matrix should be computed by force
  89715. * @returns A world matrix
  89716. */
  89717. computeWorldMatrix(force: boolean): Matrix;
  89718. /**
  89719. * Gets the world matrix
  89720. * @returns A world matrix
  89721. */
  89722. getWorldMatrix?(): Matrix;
  89723. /**
  89724. * Gets the child meshes
  89725. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89726. * @returns An array of abstract meshes
  89727. */
  89728. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89729. /**
  89730. * Gets the vertex data
  89731. * @param kind The type of vertex data
  89732. * @returns A nullable array of numbers, or a float32 array
  89733. */
  89734. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89735. /**
  89736. * Gets the indices from the mesh
  89737. * @returns A nullable array of index arrays
  89738. */
  89739. getIndices?(): Nullable<IndicesArray>;
  89740. /**
  89741. * Gets the scene from the mesh
  89742. * @returns the indices array or null
  89743. */
  89744. getScene?(): Scene;
  89745. /**
  89746. * Gets the absolute position from the mesh
  89747. * @returns the absolute position
  89748. */
  89749. getAbsolutePosition(): Vector3;
  89750. /**
  89751. * Gets the absolute pivot point from the mesh
  89752. * @returns the absolute pivot point
  89753. */
  89754. getAbsolutePivotPoint(): Vector3;
  89755. /**
  89756. * Rotates the mesh
  89757. * @param axis The axis of rotation
  89758. * @param amount The amount of rotation
  89759. * @param space The space of the rotation
  89760. * @returns The rotation transform node
  89761. */
  89762. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89763. /**
  89764. * Translates the mesh
  89765. * @param axis The axis of translation
  89766. * @param distance The distance of translation
  89767. * @param space The space of the translation
  89768. * @returns The transform node
  89769. */
  89770. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89771. /**
  89772. * Sets the absolute position of the mesh
  89773. * @param absolutePosition The absolute position of the mesh
  89774. * @returns The transform node
  89775. */
  89776. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89777. /**
  89778. * Gets the class name of the mesh
  89779. * @returns The class name
  89780. */
  89781. getClassName(): string;
  89782. }
  89783. /**
  89784. * Represents a physics imposter
  89785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89786. */
  89787. export class PhysicsImpostor {
  89788. /**
  89789. * The physics-enabled object used as the physics imposter
  89790. */
  89791. object: IPhysicsEnabledObject;
  89792. /**
  89793. * The type of the physics imposter
  89794. */
  89795. type: number;
  89796. private _options;
  89797. private _scene?;
  89798. /**
  89799. * The default object size of the imposter
  89800. */
  89801. static DEFAULT_OBJECT_SIZE: Vector3;
  89802. /**
  89803. * The identity quaternion of the imposter
  89804. */
  89805. static IDENTITY_QUATERNION: Quaternion;
  89806. /** @hidden */
  89807. _pluginData: any;
  89808. private _physicsEngine;
  89809. private _physicsBody;
  89810. private _bodyUpdateRequired;
  89811. private _onBeforePhysicsStepCallbacks;
  89812. private _onAfterPhysicsStepCallbacks;
  89813. /** @hidden */
  89814. _onPhysicsCollideCallbacks: Array<{
  89815. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89816. otherImpostors: Array<PhysicsImpostor>;
  89817. }>;
  89818. private _deltaPosition;
  89819. private _deltaRotation;
  89820. private _deltaRotationConjugated;
  89821. /** @hidden */
  89822. _isFromLine: boolean;
  89823. private _parent;
  89824. private _isDisposed;
  89825. private static _tmpVecs;
  89826. private static _tmpQuat;
  89827. /**
  89828. * Specifies if the physics imposter is disposed
  89829. */
  89830. readonly isDisposed: boolean;
  89831. /**
  89832. * Gets the mass of the physics imposter
  89833. */
  89834. mass: number;
  89835. /**
  89836. * Gets the coefficient of friction
  89837. */
  89838. /**
  89839. * Sets the coefficient of friction
  89840. */
  89841. friction: number;
  89842. /**
  89843. * Gets the coefficient of restitution
  89844. */
  89845. /**
  89846. * Sets the coefficient of restitution
  89847. */
  89848. restitution: number;
  89849. /**
  89850. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89851. */
  89852. /**
  89853. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89854. */
  89855. pressure: number;
  89856. /**
  89857. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89858. */
  89859. /**
  89860. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89861. */
  89862. stiffness: number;
  89863. /**
  89864. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89865. */
  89866. /**
  89867. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89868. */
  89869. velocityIterations: number;
  89870. /**
  89871. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89872. */
  89873. /**
  89874. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89875. */
  89876. positionIterations: number;
  89877. /**
  89878. * The unique id of the physics imposter
  89879. * set by the physics engine when adding this impostor to the array
  89880. */
  89881. uniqueId: number;
  89882. /**
  89883. * @hidden
  89884. */
  89885. soft: boolean;
  89886. /**
  89887. * @hidden
  89888. */
  89889. segments: number;
  89890. private _joints;
  89891. /**
  89892. * Initializes the physics imposter
  89893. * @param object The physics-enabled object used as the physics imposter
  89894. * @param type The type of the physics imposter
  89895. * @param _options The options for the physics imposter
  89896. * @param _scene The Babylon scene
  89897. */
  89898. constructor(
  89899. /**
  89900. * The physics-enabled object used as the physics imposter
  89901. */
  89902. object: IPhysicsEnabledObject,
  89903. /**
  89904. * The type of the physics imposter
  89905. */
  89906. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89907. /**
  89908. * This function will completly initialize this impostor.
  89909. * It will create a new body - but only if this mesh has no parent.
  89910. * If it has, this impostor will not be used other than to define the impostor
  89911. * of the child mesh.
  89912. * @hidden
  89913. */
  89914. _init(): void;
  89915. private _getPhysicsParent;
  89916. /**
  89917. * Should a new body be generated.
  89918. * @returns boolean specifying if body initialization is required
  89919. */
  89920. isBodyInitRequired(): boolean;
  89921. /**
  89922. * Sets the updated scaling
  89923. * @param updated Specifies if the scaling is updated
  89924. */
  89925. setScalingUpdated(): void;
  89926. /**
  89927. * Force a regeneration of this or the parent's impostor's body.
  89928. * Use under cautious - This will remove all joints already implemented.
  89929. */
  89930. forceUpdate(): void;
  89931. /**
  89932. * Gets the body that holds this impostor. Either its own, or its parent.
  89933. */
  89934. /**
  89935. * Set the physics body. Used mainly by the physics engine/plugin
  89936. */
  89937. physicsBody: any;
  89938. /**
  89939. * Get the parent of the physics imposter
  89940. * @returns Physics imposter or null
  89941. */
  89942. /**
  89943. * Sets the parent of the physics imposter
  89944. */
  89945. parent: Nullable<PhysicsImpostor>;
  89946. /**
  89947. * Resets the update flags
  89948. */
  89949. resetUpdateFlags(): void;
  89950. /**
  89951. * Gets the object extend size
  89952. * @returns the object extend size
  89953. */
  89954. getObjectExtendSize(): Vector3;
  89955. /**
  89956. * Gets the object center
  89957. * @returns The object center
  89958. */
  89959. getObjectCenter(): Vector3;
  89960. /**
  89961. * Get a specific parametes from the options parameter
  89962. * @param paramName The object parameter name
  89963. * @returns The object parameter
  89964. */
  89965. getParam(paramName: string): any;
  89966. /**
  89967. * Sets a specific parameter in the options given to the physics plugin
  89968. * @param paramName The parameter name
  89969. * @param value The value of the parameter
  89970. */
  89971. setParam(paramName: string, value: number): void;
  89972. /**
  89973. * Specifically change the body's mass option. Won't recreate the physics body object
  89974. * @param mass The mass of the physics imposter
  89975. */
  89976. setMass(mass: number): void;
  89977. /**
  89978. * Gets the linear velocity
  89979. * @returns linear velocity or null
  89980. */
  89981. getLinearVelocity(): Nullable<Vector3>;
  89982. /**
  89983. * Sets the linear velocity
  89984. * @param velocity linear velocity or null
  89985. */
  89986. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89987. /**
  89988. * Gets the angular velocity
  89989. * @returns angular velocity or null
  89990. */
  89991. getAngularVelocity(): Nullable<Vector3>;
  89992. /**
  89993. * Sets the angular velocity
  89994. * @param velocity The velocity or null
  89995. */
  89996. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89997. /**
  89998. * Execute a function with the physics plugin native code
  89999. * Provide a function the will have two variables - the world object and the physics body object
  90000. * @param func The function to execute with the physics plugin native code
  90001. */
  90002. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90003. /**
  90004. * Register a function that will be executed before the physics world is stepping forward
  90005. * @param func The function to execute before the physics world is stepped forward
  90006. */
  90007. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90008. /**
  90009. * Unregister a function that will be executed before the physics world is stepping forward
  90010. * @param func The function to execute before the physics world is stepped forward
  90011. */
  90012. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90013. /**
  90014. * Register a function that will be executed after the physics step
  90015. * @param func The function to execute after physics step
  90016. */
  90017. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90018. /**
  90019. * Unregisters a function that will be executed after the physics step
  90020. * @param func The function to execute after physics step
  90021. */
  90022. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90023. /**
  90024. * register a function that will be executed when this impostor collides against a different body
  90025. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90026. * @param func Callback that is executed on collision
  90027. */
  90028. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90029. /**
  90030. * Unregisters the physics imposter on contact
  90031. * @param collideAgainst The physics object to collide against
  90032. * @param func Callback to execute on collision
  90033. */
  90034. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90035. private _tmpQuat;
  90036. private _tmpQuat2;
  90037. /**
  90038. * Get the parent rotation
  90039. * @returns The parent rotation
  90040. */
  90041. getParentsRotation(): Quaternion;
  90042. /**
  90043. * this function is executed by the physics engine.
  90044. */
  90045. beforeStep: () => void;
  90046. /**
  90047. * this function is executed by the physics engine
  90048. */
  90049. afterStep: () => void;
  90050. /**
  90051. * Legacy collision detection event support
  90052. */
  90053. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90054. /**
  90055. * event and body object due to cannon's event-based architecture.
  90056. */
  90057. onCollide: (e: {
  90058. body: any;
  90059. }) => void;
  90060. /**
  90061. * Apply a force
  90062. * @param force The force to apply
  90063. * @param contactPoint The contact point for the force
  90064. * @returns The physics imposter
  90065. */
  90066. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90067. /**
  90068. * Apply an impulse
  90069. * @param force The impulse force
  90070. * @param contactPoint The contact point for the impulse force
  90071. * @returns The physics imposter
  90072. */
  90073. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90074. /**
  90075. * A help function to create a joint
  90076. * @param otherImpostor A physics imposter used to create a joint
  90077. * @param jointType The type of joint
  90078. * @param jointData The data for the joint
  90079. * @returns The physics imposter
  90080. */
  90081. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90082. /**
  90083. * Add a joint to this impostor with a different impostor
  90084. * @param otherImpostor A physics imposter used to add a joint
  90085. * @param joint The joint to add
  90086. * @returns The physics imposter
  90087. */
  90088. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90089. /**
  90090. * Add an anchor to a cloth impostor
  90091. * @param otherImpostor rigid impostor to anchor to
  90092. * @param width ratio across width from 0 to 1
  90093. * @param height ratio up height from 0 to 1
  90094. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90095. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90096. * @returns impostor the soft imposter
  90097. */
  90098. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90099. /**
  90100. * Add a hook to a rope impostor
  90101. * @param otherImpostor rigid impostor to anchor to
  90102. * @param length ratio across rope from 0 to 1
  90103. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90104. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90105. * @returns impostor the rope imposter
  90106. */
  90107. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90108. /**
  90109. * Will keep this body still, in a sleep mode.
  90110. * @returns the physics imposter
  90111. */
  90112. sleep(): PhysicsImpostor;
  90113. /**
  90114. * Wake the body up.
  90115. * @returns The physics imposter
  90116. */
  90117. wakeUp(): PhysicsImpostor;
  90118. /**
  90119. * Clones the physics imposter
  90120. * @param newObject The physics imposter clones to this physics-enabled object
  90121. * @returns A nullable physics imposter
  90122. */
  90123. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90124. /**
  90125. * Disposes the physics imposter
  90126. */
  90127. dispose(): void;
  90128. /**
  90129. * Sets the delta position
  90130. * @param position The delta position amount
  90131. */
  90132. setDeltaPosition(position: Vector3): void;
  90133. /**
  90134. * Sets the delta rotation
  90135. * @param rotation The delta rotation amount
  90136. */
  90137. setDeltaRotation(rotation: Quaternion): void;
  90138. /**
  90139. * Gets the box size of the physics imposter and stores the result in the input parameter
  90140. * @param result Stores the box size
  90141. * @returns The physics imposter
  90142. */
  90143. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90144. /**
  90145. * Gets the radius of the physics imposter
  90146. * @returns Radius of the physics imposter
  90147. */
  90148. getRadius(): number;
  90149. /**
  90150. * Sync a bone with this impostor
  90151. * @param bone The bone to sync to the impostor.
  90152. * @param boneMesh The mesh that the bone is influencing.
  90153. * @param jointPivot The pivot of the joint / bone in local space.
  90154. * @param distToJoint Optional distance from the impostor to the joint.
  90155. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90156. */
  90157. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90158. /**
  90159. * Sync impostor to a bone
  90160. * @param bone The bone that the impostor will be synced to.
  90161. * @param boneMesh The mesh that the bone is influencing.
  90162. * @param jointPivot The pivot of the joint / bone in local space.
  90163. * @param distToJoint Optional distance from the impostor to the joint.
  90164. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90165. * @param boneAxis Optional vector3 axis the bone is aligned with
  90166. */
  90167. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90168. /**
  90169. * No-Imposter type
  90170. */
  90171. static NoImpostor: number;
  90172. /**
  90173. * Sphere-Imposter type
  90174. */
  90175. static SphereImpostor: number;
  90176. /**
  90177. * Box-Imposter type
  90178. */
  90179. static BoxImpostor: number;
  90180. /**
  90181. * Plane-Imposter type
  90182. */
  90183. static PlaneImpostor: number;
  90184. /**
  90185. * Mesh-imposter type
  90186. */
  90187. static MeshImpostor: number;
  90188. /**
  90189. * Capsule-Impostor type (Ammo.js plugin only)
  90190. */
  90191. static CapsuleImpostor: number;
  90192. /**
  90193. * Cylinder-Imposter type
  90194. */
  90195. static CylinderImpostor: number;
  90196. /**
  90197. * Particle-Imposter type
  90198. */
  90199. static ParticleImpostor: number;
  90200. /**
  90201. * Heightmap-Imposter type
  90202. */
  90203. static HeightmapImpostor: number;
  90204. /**
  90205. * ConvexHull-Impostor type (Ammo.js plugin only)
  90206. */
  90207. static ConvexHullImpostor: number;
  90208. /**
  90209. * Rope-Imposter type
  90210. */
  90211. static RopeImpostor: number;
  90212. /**
  90213. * Cloth-Imposter type
  90214. */
  90215. static ClothImpostor: number;
  90216. /**
  90217. * Softbody-Imposter type
  90218. */
  90219. static SoftbodyImpostor: number;
  90220. }
  90221. }
  90222. declare module BABYLON {
  90223. /**
  90224. * @hidden
  90225. **/
  90226. export class _CreationDataStorage {
  90227. closePath?: boolean;
  90228. closeArray?: boolean;
  90229. idx: number[];
  90230. dashSize: number;
  90231. gapSize: number;
  90232. path3D: Path3D;
  90233. pathArray: Vector3[][];
  90234. arc: number;
  90235. radius: number;
  90236. cap: number;
  90237. tessellation: number;
  90238. }
  90239. /**
  90240. * @hidden
  90241. **/
  90242. class _InstanceDataStorage {
  90243. visibleInstances: any;
  90244. batchCache: _InstancesBatch;
  90245. instancesBufferSize: number;
  90246. instancesBuffer: Nullable<Buffer>;
  90247. instancesData: Float32Array;
  90248. overridenInstanceCount: number;
  90249. isFrozen: boolean;
  90250. previousBatch: Nullable<_InstancesBatch>;
  90251. hardwareInstancedRendering: boolean;
  90252. sideOrientation: number;
  90253. }
  90254. /**
  90255. * @hidden
  90256. **/
  90257. export class _InstancesBatch {
  90258. mustReturn: boolean;
  90259. visibleInstances: Nullable<InstancedMesh[]>[];
  90260. renderSelf: boolean[];
  90261. hardwareInstancedRendering: boolean[];
  90262. }
  90263. /**
  90264. * Class used to represent renderable models
  90265. */
  90266. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90267. /**
  90268. * Mesh side orientation : usually the external or front surface
  90269. */
  90270. static readonly FRONTSIDE: number;
  90271. /**
  90272. * Mesh side orientation : usually the internal or back surface
  90273. */
  90274. static readonly BACKSIDE: number;
  90275. /**
  90276. * Mesh side orientation : both internal and external or front and back surfaces
  90277. */
  90278. static readonly DOUBLESIDE: number;
  90279. /**
  90280. * Mesh side orientation : by default, `FRONTSIDE`
  90281. */
  90282. static readonly DEFAULTSIDE: number;
  90283. /**
  90284. * Mesh cap setting : no cap
  90285. */
  90286. static readonly NO_CAP: number;
  90287. /**
  90288. * Mesh cap setting : one cap at the beginning of the mesh
  90289. */
  90290. static readonly CAP_START: number;
  90291. /**
  90292. * Mesh cap setting : one cap at the end of the mesh
  90293. */
  90294. static readonly CAP_END: number;
  90295. /**
  90296. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90297. */
  90298. static readonly CAP_ALL: number;
  90299. /**
  90300. * Mesh pattern setting : no flip or rotate
  90301. */
  90302. static readonly NO_FLIP: number;
  90303. /**
  90304. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90305. */
  90306. static readonly FLIP_TILE: number;
  90307. /**
  90308. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90309. */
  90310. static readonly ROTATE_TILE: number;
  90311. /**
  90312. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90313. */
  90314. static readonly FLIP_ROW: number;
  90315. /**
  90316. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90317. */
  90318. static readonly ROTATE_ROW: number;
  90319. /**
  90320. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90321. */
  90322. static readonly FLIP_N_ROTATE_TILE: number;
  90323. /**
  90324. * Mesh pattern setting : rotate pattern and rotate
  90325. */
  90326. static readonly FLIP_N_ROTATE_ROW: number;
  90327. /**
  90328. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90329. */
  90330. static readonly CENTER: number;
  90331. /**
  90332. * Mesh tile positioning : part tiles on left
  90333. */
  90334. static readonly LEFT: number;
  90335. /**
  90336. * Mesh tile positioning : part tiles on right
  90337. */
  90338. static readonly RIGHT: number;
  90339. /**
  90340. * Mesh tile positioning : part tiles on top
  90341. */
  90342. static readonly TOP: number;
  90343. /**
  90344. * Mesh tile positioning : part tiles on bottom
  90345. */
  90346. static readonly BOTTOM: number;
  90347. /**
  90348. * Gets the default side orientation.
  90349. * @param orientation the orientation to value to attempt to get
  90350. * @returns the default orientation
  90351. * @hidden
  90352. */
  90353. static _GetDefaultSideOrientation(orientation?: number): number;
  90354. private _internalMeshDataInfo;
  90355. /**
  90356. * An event triggered before rendering the mesh
  90357. */
  90358. readonly onBeforeRenderObservable: Observable<Mesh>;
  90359. /**
  90360. * An event triggered before binding the mesh
  90361. */
  90362. readonly onBeforeBindObservable: Observable<Mesh>;
  90363. /**
  90364. * An event triggered after rendering the mesh
  90365. */
  90366. readonly onAfterRenderObservable: Observable<Mesh>;
  90367. /**
  90368. * An event triggered before drawing the mesh
  90369. */
  90370. readonly onBeforeDrawObservable: Observable<Mesh>;
  90371. private _onBeforeDrawObserver;
  90372. /**
  90373. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90374. */
  90375. onBeforeDraw: () => void;
  90376. readonly hasInstances: boolean;
  90377. /**
  90378. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90379. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90380. */
  90381. delayLoadState: number;
  90382. /**
  90383. * Gets the list of instances created from this mesh
  90384. * it is not supposed to be modified manually.
  90385. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90386. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90387. */
  90388. instances: InstancedMesh[];
  90389. /**
  90390. * Gets the file containing delay loading data for this mesh
  90391. */
  90392. delayLoadingFile: string;
  90393. /** @hidden */
  90394. _binaryInfo: any;
  90395. /**
  90396. * User defined function used to change how LOD level selection is done
  90397. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90398. */
  90399. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90400. /**
  90401. * Gets or sets the morph target manager
  90402. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90403. */
  90404. morphTargetManager: Nullable<MorphTargetManager>;
  90405. /** @hidden */
  90406. _creationDataStorage: Nullable<_CreationDataStorage>;
  90407. /** @hidden */
  90408. _geometry: Nullable<Geometry>;
  90409. /** @hidden */
  90410. _delayInfo: Array<string>;
  90411. /** @hidden */
  90412. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90413. /** @hidden */
  90414. _instanceDataStorage: _InstanceDataStorage;
  90415. private _effectiveMaterial;
  90416. /** @hidden */
  90417. _shouldGenerateFlatShading: boolean;
  90418. /** @hidden */
  90419. _originalBuilderSideOrientation: number;
  90420. /**
  90421. * Use this property to change the original side orientation defined at construction time
  90422. */
  90423. overrideMaterialSideOrientation: Nullable<number>;
  90424. /**
  90425. * Gets the source mesh (the one used to clone this one from)
  90426. */
  90427. readonly source: Nullable<Mesh>;
  90428. /**
  90429. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90430. */
  90431. isUnIndexed: boolean;
  90432. /**
  90433. * @constructor
  90434. * @param name The value used by scene.getMeshByName() to do a lookup.
  90435. * @param scene The scene to add this mesh to.
  90436. * @param parent The parent of this mesh, if it has one
  90437. * @param source An optional Mesh from which geometry is shared, cloned.
  90438. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90439. * When false, achieved by calling a clone(), also passing False.
  90440. * This will make creation of children, recursive.
  90441. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90442. */
  90443. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90444. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90445. /**
  90446. * Gets the class name
  90447. * @returns the string "Mesh".
  90448. */
  90449. getClassName(): string;
  90450. /** @hidden */
  90451. readonly _isMesh: boolean;
  90452. /**
  90453. * Returns a description of this mesh
  90454. * @param fullDetails define if full details about this mesh must be used
  90455. * @returns a descriptive string representing this mesh
  90456. */
  90457. toString(fullDetails?: boolean): string;
  90458. /** @hidden */
  90459. _unBindEffect(): void;
  90460. /**
  90461. * Gets a boolean indicating if this mesh has LOD
  90462. */
  90463. readonly hasLODLevels: boolean;
  90464. /**
  90465. * Gets the list of MeshLODLevel associated with the current mesh
  90466. * @returns an array of MeshLODLevel
  90467. */
  90468. getLODLevels(): MeshLODLevel[];
  90469. private _sortLODLevels;
  90470. /**
  90471. * Add a mesh as LOD level triggered at the given distance.
  90472. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90473. * @param distance The distance from the center of the object to show this level
  90474. * @param mesh The mesh to be added as LOD level (can be null)
  90475. * @return This mesh (for chaining)
  90476. */
  90477. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90478. /**
  90479. * Returns the LOD level mesh at the passed distance or null if not found.
  90480. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90481. * @param distance The distance from the center of the object to show this level
  90482. * @returns a Mesh or `null`
  90483. */
  90484. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90485. /**
  90486. * Remove a mesh from the LOD array
  90487. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90488. * @param mesh defines the mesh to be removed
  90489. * @return This mesh (for chaining)
  90490. */
  90491. removeLODLevel(mesh: Mesh): Mesh;
  90492. /**
  90493. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90495. * @param camera defines the camera to use to compute distance
  90496. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90497. * @return This mesh (for chaining)
  90498. */
  90499. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90500. /**
  90501. * Gets the mesh internal Geometry object
  90502. */
  90503. readonly geometry: Nullable<Geometry>;
  90504. /**
  90505. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90506. * @returns the total number of vertices
  90507. */
  90508. getTotalVertices(): number;
  90509. /**
  90510. * Returns the content of an associated vertex buffer
  90511. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90512. * - VertexBuffer.PositionKind
  90513. * - VertexBuffer.UVKind
  90514. * - VertexBuffer.UV2Kind
  90515. * - VertexBuffer.UV3Kind
  90516. * - VertexBuffer.UV4Kind
  90517. * - VertexBuffer.UV5Kind
  90518. * - VertexBuffer.UV6Kind
  90519. * - VertexBuffer.ColorKind
  90520. * - VertexBuffer.MatricesIndicesKind
  90521. * - VertexBuffer.MatricesIndicesExtraKind
  90522. * - VertexBuffer.MatricesWeightsKind
  90523. * - VertexBuffer.MatricesWeightsExtraKind
  90524. * @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
  90525. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90526. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90527. */
  90528. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90529. /**
  90530. * Returns the mesh VertexBuffer object from the requested `kind`
  90531. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90532. * - VertexBuffer.PositionKind
  90533. * - VertexBuffer.NormalKind
  90534. * - VertexBuffer.UVKind
  90535. * - VertexBuffer.UV2Kind
  90536. * - VertexBuffer.UV3Kind
  90537. * - VertexBuffer.UV4Kind
  90538. * - VertexBuffer.UV5Kind
  90539. * - VertexBuffer.UV6Kind
  90540. * - VertexBuffer.ColorKind
  90541. * - VertexBuffer.MatricesIndicesKind
  90542. * - VertexBuffer.MatricesIndicesExtraKind
  90543. * - VertexBuffer.MatricesWeightsKind
  90544. * - VertexBuffer.MatricesWeightsExtraKind
  90545. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90546. */
  90547. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90548. /**
  90549. * Tests if a specific vertex buffer is associated with this mesh
  90550. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90551. * - VertexBuffer.PositionKind
  90552. * - VertexBuffer.NormalKind
  90553. * - VertexBuffer.UVKind
  90554. * - VertexBuffer.UV2Kind
  90555. * - VertexBuffer.UV3Kind
  90556. * - VertexBuffer.UV4Kind
  90557. * - VertexBuffer.UV5Kind
  90558. * - VertexBuffer.UV6Kind
  90559. * - VertexBuffer.ColorKind
  90560. * - VertexBuffer.MatricesIndicesKind
  90561. * - VertexBuffer.MatricesIndicesExtraKind
  90562. * - VertexBuffer.MatricesWeightsKind
  90563. * - VertexBuffer.MatricesWeightsExtraKind
  90564. * @returns a boolean
  90565. */
  90566. isVerticesDataPresent(kind: string): boolean;
  90567. /**
  90568. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90569. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90570. * - VertexBuffer.PositionKind
  90571. * - VertexBuffer.UVKind
  90572. * - VertexBuffer.UV2Kind
  90573. * - VertexBuffer.UV3Kind
  90574. * - VertexBuffer.UV4Kind
  90575. * - VertexBuffer.UV5Kind
  90576. * - VertexBuffer.UV6Kind
  90577. * - VertexBuffer.ColorKind
  90578. * - VertexBuffer.MatricesIndicesKind
  90579. * - VertexBuffer.MatricesIndicesExtraKind
  90580. * - VertexBuffer.MatricesWeightsKind
  90581. * - VertexBuffer.MatricesWeightsExtraKind
  90582. * @returns a boolean
  90583. */
  90584. isVertexBufferUpdatable(kind: string): boolean;
  90585. /**
  90586. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90587. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90588. * - VertexBuffer.PositionKind
  90589. * - VertexBuffer.NormalKind
  90590. * - VertexBuffer.UVKind
  90591. * - VertexBuffer.UV2Kind
  90592. * - VertexBuffer.UV3Kind
  90593. * - VertexBuffer.UV4Kind
  90594. * - VertexBuffer.UV5Kind
  90595. * - VertexBuffer.UV6Kind
  90596. * - VertexBuffer.ColorKind
  90597. * - VertexBuffer.MatricesIndicesKind
  90598. * - VertexBuffer.MatricesIndicesExtraKind
  90599. * - VertexBuffer.MatricesWeightsKind
  90600. * - VertexBuffer.MatricesWeightsExtraKind
  90601. * @returns an array of strings
  90602. */
  90603. getVerticesDataKinds(): string[];
  90604. /**
  90605. * Returns a positive integer : the total number of indices in this mesh geometry.
  90606. * @returns the numner of indices or zero if the mesh has no geometry.
  90607. */
  90608. getTotalIndices(): number;
  90609. /**
  90610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90611. * @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.
  90612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90613. * @returns the indices array or an empty array if the mesh has no geometry
  90614. */
  90615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90616. readonly isBlocked: boolean;
  90617. /**
  90618. * Determine if the current mesh is ready to be rendered
  90619. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90620. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90621. * @returns true if all associated assets are ready (material, textures, shaders)
  90622. */
  90623. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90624. /**
  90625. * 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.
  90626. */
  90627. readonly areNormalsFrozen: boolean;
  90628. /**
  90629. * 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.
  90630. * @returns the current mesh
  90631. */
  90632. freezeNormals(): Mesh;
  90633. /**
  90634. * 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
  90635. * @returns the current mesh
  90636. */
  90637. unfreezeNormals(): Mesh;
  90638. /**
  90639. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90640. */
  90641. overridenInstanceCount: number;
  90642. /** @hidden */
  90643. _preActivate(): Mesh;
  90644. /** @hidden */
  90645. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90646. /** @hidden */
  90647. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90648. /**
  90649. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90650. * This means the mesh underlying bounding box and sphere are recomputed.
  90651. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90652. * @returns the current mesh
  90653. */
  90654. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90655. /** @hidden */
  90656. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90657. /**
  90658. * This function will subdivide the mesh into multiple submeshes
  90659. * @param count defines the expected number of submeshes
  90660. */
  90661. subdivide(count: number): void;
  90662. /**
  90663. * Copy a FloatArray into a specific associated vertex buffer
  90664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90665. * - VertexBuffer.PositionKind
  90666. * - VertexBuffer.UVKind
  90667. * - VertexBuffer.UV2Kind
  90668. * - VertexBuffer.UV3Kind
  90669. * - VertexBuffer.UV4Kind
  90670. * - VertexBuffer.UV5Kind
  90671. * - VertexBuffer.UV6Kind
  90672. * - VertexBuffer.ColorKind
  90673. * - VertexBuffer.MatricesIndicesKind
  90674. * - VertexBuffer.MatricesIndicesExtraKind
  90675. * - VertexBuffer.MatricesWeightsKind
  90676. * - VertexBuffer.MatricesWeightsExtraKind
  90677. * @param data defines the data source
  90678. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90679. * @param stride defines the data stride size (can be null)
  90680. * @returns the current mesh
  90681. */
  90682. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90683. /**
  90684. * Flags an associated vertex buffer as updatable
  90685. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90686. * - VertexBuffer.PositionKind
  90687. * - VertexBuffer.UVKind
  90688. * - VertexBuffer.UV2Kind
  90689. * - VertexBuffer.UV3Kind
  90690. * - VertexBuffer.UV4Kind
  90691. * - VertexBuffer.UV5Kind
  90692. * - VertexBuffer.UV6Kind
  90693. * - VertexBuffer.ColorKind
  90694. * - VertexBuffer.MatricesIndicesKind
  90695. * - VertexBuffer.MatricesIndicesExtraKind
  90696. * - VertexBuffer.MatricesWeightsKind
  90697. * - VertexBuffer.MatricesWeightsExtraKind
  90698. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90699. */
  90700. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90701. /**
  90702. * Sets the mesh global Vertex Buffer
  90703. * @param buffer defines the buffer to use
  90704. * @returns the current mesh
  90705. */
  90706. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90707. /**
  90708. * Update a specific associated vertex buffer
  90709. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90710. * - VertexBuffer.PositionKind
  90711. * - VertexBuffer.UVKind
  90712. * - VertexBuffer.UV2Kind
  90713. * - VertexBuffer.UV3Kind
  90714. * - VertexBuffer.UV4Kind
  90715. * - VertexBuffer.UV5Kind
  90716. * - VertexBuffer.UV6Kind
  90717. * - VertexBuffer.ColorKind
  90718. * - VertexBuffer.MatricesIndicesKind
  90719. * - VertexBuffer.MatricesIndicesExtraKind
  90720. * - VertexBuffer.MatricesWeightsKind
  90721. * - VertexBuffer.MatricesWeightsExtraKind
  90722. * @param data defines the data source
  90723. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90724. * @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)
  90725. * @returns the current mesh
  90726. */
  90727. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90728. /**
  90729. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90730. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90731. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90732. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90733. * @returns the current mesh
  90734. */
  90735. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90736. /**
  90737. * Creates a un-shared specific occurence of the geometry for the mesh.
  90738. * @returns the current mesh
  90739. */
  90740. makeGeometryUnique(): Mesh;
  90741. /**
  90742. * Set the index buffer of this mesh
  90743. * @param indices defines the source data
  90744. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90745. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90746. * @returns the current mesh
  90747. */
  90748. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90749. /**
  90750. * Update the current index buffer
  90751. * @param indices defines the source data
  90752. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90753. * @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)
  90754. * @returns the current mesh
  90755. */
  90756. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90757. /**
  90758. * Invert the geometry to move from a right handed system to a left handed one.
  90759. * @returns the current mesh
  90760. */
  90761. toLeftHanded(): Mesh;
  90762. /** @hidden */
  90763. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90764. /** @hidden */
  90765. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90766. /**
  90767. * Registers for this mesh a javascript function called just before the rendering process
  90768. * @param func defines the function to call before rendering this mesh
  90769. * @returns the current mesh
  90770. */
  90771. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90772. /**
  90773. * Disposes a previously registered javascript function called before the rendering
  90774. * @param func defines the function to remove
  90775. * @returns the current mesh
  90776. */
  90777. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90778. /**
  90779. * Registers for this mesh a javascript function called just after the rendering is complete
  90780. * @param func defines the function to call after rendering this mesh
  90781. * @returns the current mesh
  90782. */
  90783. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90784. /**
  90785. * Disposes a previously registered javascript function called after the rendering.
  90786. * @param func defines the function to remove
  90787. * @returns the current mesh
  90788. */
  90789. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90790. /** @hidden */
  90791. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90792. /** @hidden */
  90793. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90794. /** @hidden */
  90795. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90796. /** @hidden */
  90797. _rebuild(): void;
  90798. /** @hidden */
  90799. _freeze(): void;
  90800. /** @hidden */
  90801. _unFreeze(): void;
  90802. /**
  90803. * 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
  90804. * @param subMesh defines the subMesh to render
  90805. * @param enableAlphaMode defines if alpha mode can be changed
  90806. * @returns the current mesh
  90807. */
  90808. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90809. private _onBeforeDraw;
  90810. /**
  90811. * Renormalize the mesh and patch it up if there are no weights
  90812. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90813. * However in the case of zero weights then we set just a single influence to 1.
  90814. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90815. */
  90816. cleanMatrixWeights(): void;
  90817. private normalizeSkinFourWeights;
  90818. private normalizeSkinWeightsAndExtra;
  90819. /**
  90820. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90821. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90822. * the user know there was an issue with importing the mesh
  90823. * @returns a validation object with skinned, valid and report string
  90824. */
  90825. validateSkinning(): {
  90826. skinned: boolean;
  90827. valid: boolean;
  90828. report: string;
  90829. };
  90830. /** @hidden */
  90831. _checkDelayState(): Mesh;
  90832. private _queueLoad;
  90833. /**
  90834. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90835. * A mesh is in the frustum if its bounding box intersects the frustum
  90836. * @param frustumPlanes defines the frustum to test
  90837. * @returns true if the mesh is in the frustum planes
  90838. */
  90839. isInFrustum(frustumPlanes: Plane[]): boolean;
  90840. /**
  90841. * Sets the mesh material by the material or multiMaterial `id` property
  90842. * @param id is a string identifying the material or the multiMaterial
  90843. * @returns the current mesh
  90844. */
  90845. setMaterialByID(id: string): Mesh;
  90846. /**
  90847. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90848. * @returns an array of IAnimatable
  90849. */
  90850. getAnimatables(): IAnimatable[];
  90851. /**
  90852. * Modifies the mesh geometry according to the passed transformation matrix.
  90853. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90854. * The mesh normals are modified using the same transformation.
  90855. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90856. * @param transform defines the transform matrix to use
  90857. * @see http://doc.babylonjs.com/resources/baking_transformations
  90858. * @returns the current mesh
  90859. */
  90860. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90861. /**
  90862. * Modifies the mesh geometry according to its own current World Matrix.
  90863. * The mesh World Matrix is then reset.
  90864. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90865. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90866. * @see http://doc.babylonjs.com/resources/baking_transformations
  90867. * @returns the current mesh
  90868. */
  90869. bakeCurrentTransformIntoVertices(): Mesh;
  90870. /** @hidden */
  90871. readonly _positions: Nullable<Vector3[]>;
  90872. /** @hidden */
  90873. _resetPointsArrayCache(): Mesh;
  90874. /** @hidden */
  90875. _generatePointsArray(): boolean;
  90876. /**
  90877. * Returns a new Mesh object generated from the current mesh properties.
  90878. * This method must not get confused with createInstance()
  90879. * @param name is a string, the name given to the new mesh
  90880. * @param newParent can be any Node object (default `null`)
  90881. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90882. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90883. * @returns a new mesh
  90884. */
  90885. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90886. /**
  90887. * Releases resources associated with this mesh.
  90888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90890. */
  90891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90892. /**
  90893. * Modifies the mesh geometry according to a displacement map.
  90894. * 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.
  90895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90896. * @param url is a string, the URL from the image file is to be downloaded.
  90897. * @param minHeight is the lower limit of the displacement.
  90898. * @param maxHeight is the upper limit of the displacement.
  90899. * @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.
  90900. * @param uvOffset is an optional vector2 used to offset UV.
  90901. * @param uvScale is an optional vector2 used to scale UV.
  90902. * @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.
  90903. * @returns the Mesh.
  90904. */
  90905. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90906. /**
  90907. * Modifies the mesh geometry according to a displacementMap buffer.
  90908. * 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.
  90909. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90910. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90911. * @param heightMapWidth is the width of the buffer image.
  90912. * @param heightMapHeight is the height of the buffer image.
  90913. * @param minHeight is the lower limit of the displacement.
  90914. * @param maxHeight is the upper limit of the displacement.
  90915. * @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.
  90916. * @param uvOffset is an optional vector2 used to offset UV.
  90917. * @param uvScale is an optional vector2 used to scale UV.
  90918. * @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.
  90919. * @returns the Mesh.
  90920. */
  90921. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90922. /**
  90923. * Modify the mesh to get a flat shading rendering.
  90924. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90925. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90926. * @returns current mesh
  90927. */
  90928. convertToFlatShadedMesh(): Mesh;
  90929. /**
  90930. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90931. * In other words, more vertices, no more indices and a single bigger VBO.
  90932. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90933. * @returns current mesh
  90934. */
  90935. convertToUnIndexedMesh(): Mesh;
  90936. /**
  90937. * Inverses facet orientations.
  90938. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90939. * @param flipNormals will also inverts the normals
  90940. * @returns current mesh
  90941. */
  90942. flipFaces(flipNormals?: boolean): Mesh;
  90943. /**
  90944. * Increase the number of facets and hence vertices in a mesh
  90945. * Vertex normals are interpolated from existing vertex normals
  90946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90947. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90948. */
  90949. increaseVertices(numberPerEdge: number): void;
  90950. /**
  90951. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90952. * This will undo any application of covertToFlatShadedMesh
  90953. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90954. */
  90955. forceSharedVertices(): void;
  90956. /** @hidden */
  90957. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90958. /** @hidden */
  90959. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90960. /**
  90961. * Creates a new InstancedMesh object from the mesh model.
  90962. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90963. * @param name defines the name of the new instance
  90964. * @returns a new InstancedMesh
  90965. */
  90966. createInstance(name: string): InstancedMesh;
  90967. /**
  90968. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90969. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90970. * @returns the current mesh
  90971. */
  90972. synchronizeInstances(): Mesh;
  90973. /**
  90974. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90975. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90976. * This should be used together with the simplification to avoid disappearing triangles.
  90977. * @param successCallback an optional success callback to be called after the optimization finished.
  90978. * @returns the current mesh
  90979. */
  90980. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90981. /**
  90982. * Serialize current mesh
  90983. * @param serializationObject defines the object which will receive the serialization data
  90984. */
  90985. serialize(serializationObject: any): void;
  90986. /** @hidden */
  90987. _syncGeometryWithMorphTargetManager(): void;
  90988. /** @hidden */
  90989. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90990. /**
  90991. * Returns a new Mesh object parsed from the source provided.
  90992. * @param parsedMesh is the source
  90993. * @param scene defines the hosting scene
  90994. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90995. * @returns a new Mesh
  90996. */
  90997. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90998. /**
  90999. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91000. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91001. * @param name defines the name of the mesh to create
  91002. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91003. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91004. * @param closePath creates a seam between the first and the last points of each path of the path array
  91005. * @param offset is taken in account only if the `pathArray` is containing a single path
  91006. * @param scene defines the hosting scene
  91007. * @param updatable defines if the mesh must be flagged as updatable
  91008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91009. * @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)
  91010. * @returns a new Mesh
  91011. */
  91012. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91013. /**
  91014. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91015. * @param name defines the name of the mesh to create
  91016. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91017. * @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
  91018. * @param scene defines the hosting scene
  91019. * @param updatable defines if the mesh must be flagged as updatable
  91020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91021. * @returns a new Mesh
  91022. */
  91023. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91024. /**
  91025. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91026. * @param name defines the name of the mesh to create
  91027. * @param size sets the size (float) of each box side (default 1)
  91028. * @param scene defines the hosting scene
  91029. * @param updatable defines if the mesh must be flagged as updatable
  91030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91031. * @returns a new Mesh
  91032. */
  91033. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91034. /**
  91035. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91036. * @param name defines the name of the mesh to create
  91037. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91038. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91039. * @param scene defines the hosting scene
  91040. * @param updatable defines if the mesh must be flagged as updatable
  91041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91042. * @returns a new Mesh
  91043. */
  91044. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91045. /**
  91046. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91047. * @param name defines the name of the mesh to create
  91048. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91049. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91050. * @param scene defines the hosting scene
  91051. * @returns a new Mesh
  91052. */
  91053. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91054. /**
  91055. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91056. * @param name defines the name of the mesh to create
  91057. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91058. * @param diameterTop set the top cap diameter (floats, default 1)
  91059. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91060. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91061. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91062. * @param scene defines the hosting scene
  91063. * @param updatable defines if the mesh must be flagged as updatable
  91064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91065. * @returns a new Mesh
  91066. */
  91067. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91068. /**
  91069. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91070. * @param name defines the name of the mesh to create
  91071. * @param diameter sets the diameter size (float) of the torus (default 1)
  91072. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91073. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91074. * @param scene defines the hosting scene
  91075. * @param updatable defines if the mesh must be flagged as updatable
  91076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91077. * @returns a new Mesh
  91078. */
  91079. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91080. /**
  91081. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91082. * @param name defines the name of the mesh to create
  91083. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91084. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91085. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91086. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91087. * @param p the number of windings on X axis (positive integers, default 2)
  91088. * @param q the number of windings on Y axis (positive integers, default 3)
  91089. * @param scene defines the hosting scene
  91090. * @param updatable defines if the mesh must be flagged as updatable
  91091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91092. * @returns a new Mesh
  91093. */
  91094. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91095. /**
  91096. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91097. * @param name defines the name of the mesh to create
  91098. * @param points is an array successive Vector3
  91099. * @param scene defines the hosting scene
  91100. * @param updatable defines if the mesh must be flagged as updatable
  91101. * @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).
  91102. * @returns a new Mesh
  91103. */
  91104. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91105. /**
  91106. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91107. * @param name defines the name of the mesh to create
  91108. * @param points is an array successive Vector3
  91109. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91110. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91111. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91112. * @param scene defines the hosting scene
  91113. * @param updatable defines if the mesh must be flagged as updatable
  91114. * @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)
  91115. * @returns a new Mesh
  91116. */
  91117. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91118. /**
  91119. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91120. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91121. * 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.
  91122. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91123. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91124. * Remember you can only change the shape positions, not their number when updating a polygon.
  91125. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91126. * @param name defines the name of the mesh to create
  91127. * @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
  91128. * @param scene defines the hosting scene
  91129. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91130. * @param updatable defines if the mesh must be flagged as updatable
  91131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91132. * @param earcutInjection can be used to inject your own earcut reference
  91133. * @returns a new Mesh
  91134. */
  91135. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91136. /**
  91137. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91139. * @param name defines the name of the mesh to create
  91140. * @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
  91141. * @param depth defines the height of extrusion
  91142. * @param scene defines the hosting scene
  91143. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91144. * @param updatable defines if the mesh must be flagged as updatable
  91145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91146. * @param earcutInjection can be used to inject your own earcut reference
  91147. * @returns a new Mesh
  91148. */
  91149. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91150. /**
  91151. * Creates an extruded shape mesh.
  91152. * 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
  91153. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91154. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91155. * @param name defines the name of the mesh to create
  91156. * @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
  91157. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91158. * @param scale is the value to scale the shape
  91159. * @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
  91160. * @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
  91161. * @param scene defines the hosting scene
  91162. * @param updatable defines if the mesh must be flagged as updatable
  91163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91164. * @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)
  91165. * @returns a new Mesh
  91166. */
  91167. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91168. /**
  91169. * Creates an custom extruded shape mesh.
  91170. * The custom extrusion is a parametric shape.
  91171. * It has no predefined shape. Its final shape will depend on the input parameters.
  91172. * Please consider using the same method from the MeshBuilder class instead
  91173. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91174. * @param name defines the name of the mesh to create
  91175. * @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
  91176. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91177. * @param scaleFunction is a custom Javascript function called on each path point
  91178. * @param rotationFunction is a custom Javascript function called on each path point
  91179. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91180. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91181. * @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
  91182. * @param scene defines the hosting scene
  91183. * @param updatable defines if the mesh must be flagged as updatable
  91184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91185. * @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)
  91186. * @returns a new Mesh
  91187. */
  91188. 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;
  91189. /**
  91190. * Creates lathe mesh.
  91191. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91192. * Please consider using the same method from the MeshBuilder class instead
  91193. * @param name defines the name of the mesh to create
  91194. * @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
  91195. * @param radius is the radius value of the lathe
  91196. * @param tessellation is the side number of the lathe.
  91197. * @param scene defines the hosting scene
  91198. * @param updatable defines if the mesh must be flagged as updatable
  91199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91200. * @returns a new Mesh
  91201. */
  91202. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91203. /**
  91204. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91205. * @param name defines the name of the mesh to create
  91206. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91207. * @param scene defines the hosting scene
  91208. * @param updatable defines if the mesh must be flagged as updatable
  91209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91210. * @returns a new Mesh
  91211. */
  91212. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91213. /**
  91214. * Creates a ground mesh.
  91215. * Please consider using the same method from the MeshBuilder class instead
  91216. * @param name defines the name of the mesh to create
  91217. * @param width set the width of the ground
  91218. * @param height set the height of the ground
  91219. * @param subdivisions sets the number of subdivisions per side
  91220. * @param scene defines the hosting scene
  91221. * @param updatable defines if the mesh must be flagged as updatable
  91222. * @returns a new Mesh
  91223. */
  91224. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91225. /**
  91226. * Creates a tiled ground mesh.
  91227. * Please consider using the same method from the MeshBuilder class instead
  91228. * @param name defines the name of the mesh to create
  91229. * @param xmin set the ground minimum X coordinate
  91230. * @param zmin set the ground minimum Y coordinate
  91231. * @param xmax set the ground maximum X coordinate
  91232. * @param zmax set the ground maximum Z coordinate
  91233. * @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
  91234. * @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
  91235. * @param scene defines the hosting scene
  91236. * @param updatable defines if the mesh must be flagged as updatable
  91237. * @returns a new Mesh
  91238. */
  91239. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91240. w: number;
  91241. h: number;
  91242. }, precision: {
  91243. w: number;
  91244. h: number;
  91245. }, scene: Scene, updatable?: boolean): Mesh;
  91246. /**
  91247. * Creates a ground mesh from a height map.
  91248. * Please consider using the same method from the MeshBuilder class instead
  91249. * @see http://doc.babylonjs.com/babylon101/height_map
  91250. * @param name defines the name of the mesh to create
  91251. * @param url sets the URL of the height map image resource
  91252. * @param width set the ground width size
  91253. * @param height set the ground height size
  91254. * @param subdivisions sets the number of subdivision per side
  91255. * @param minHeight is the minimum altitude on the ground
  91256. * @param maxHeight is the maximum altitude on the ground
  91257. * @param scene defines the hosting scene
  91258. * @param updatable defines if the mesh must be flagged as updatable
  91259. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91260. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91261. * @returns a new Mesh
  91262. */
  91263. 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;
  91264. /**
  91265. * Creates a tube mesh.
  91266. * The tube is a parametric shape.
  91267. * It has no predefined shape. Its final shape will depend on the input parameters.
  91268. * Please consider using the same method from the MeshBuilder class instead
  91269. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91270. * @param name defines the name of the mesh to create
  91271. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91272. * @param radius sets the tube radius size
  91273. * @param tessellation is the number of sides on the tubular surface
  91274. * @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
  91275. * @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
  91276. * @param scene defines the hosting scene
  91277. * @param updatable defines if the mesh must be flagged as updatable
  91278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91279. * @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)
  91280. * @returns a new Mesh
  91281. */
  91282. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91283. (i: number, distance: number): number;
  91284. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91285. /**
  91286. * Creates a polyhedron mesh.
  91287. * Please consider using the same method from the MeshBuilder class instead.
  91288. * * 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
  91289. * * The parameter `size` (positive float, default 1) sets the polygon size
  91290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91291. * * 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`
  91292. * * 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
  91293. * * 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)`)
  91294. * * 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
  91295. * * 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
  91296. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91297. * * If you create a double-sided mesh, you can choose what parts of 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
  91298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91299. * @param name defines the name of the mesh to create
  91300. * @param options defines the options used to create the mesh
  91301. * @param scene defines the hosting scene
  91302. * @returns a new Mesh
  91303. */
  91304. static CreatePolyhedron(name: string, options: {
  91305. type?: number;
  91306. size?: number;
  91307. sizeX?: number;
  91308. sizeY?: number;
  91309. sizeZ?: number;
  91310. custom?: any;
  91311. faceUV?: Vector4[];
  91312. faceColors?: Color4[];
  91313. updatable?: boolean;
  91314. sideOrientation?: number;
  91315. }, scene: Scene): Mesh;
  91316. /**
  91317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91319. * * 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`)
  91320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91321. * * 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
  91322. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91323. * * If you create a double-sided mesh, you can choose what parts of 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
  91324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91325. * @param name defines the name of the mesh
  91326. * @param options defines the options used to create the mesh
  91327. * @param scene defines the hosting scene
  91328. * @returns a new Mesh
  91329. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91330. */
  91331. static CreateIcoSphere(name: string, options: {
  91332. radius?: number;
  91333. flat?: boolean;
  91334. subdivisions?: number;
  91335. sideOrientation?: number;
  91336. updatable?: boolean;
  91337. }, scene: Scene): Mesh;
  91338. /**
  91339. * Creates a decal mesh.
  91340. * Please consider using the same method from the MeshBuilder class instead.
  91341. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91342. * @param name defines the name of the mesh
  91343. * @param sourceMesh defines the mesh receiving the decal
  91344. * @param position sets the position of the decal in world coordinates
  91345. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91346. * @param size sets the decal scaling
  91347. * @param angle sets the angle to rotate the decal
  91348. * @returns a new Mesh
  91349. */
  91350. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91351. /**
  91352. * Prepare internal position array for software CPU skinning
  91353. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91354. */
  91355. setPositionsForCPUSkinning(): Float32Array;
  91356. /**
  91357. * Prepare internal normal array for software CPU skinning
  91358. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91359. */
  91360. setNormalsForCPUSkinning(): Float32Array;
  91361. /**
  91362. * Updates the vertex buffer by applying transformation from the bones
  91363. * @param skeleton defines the skeleton to apply to current mesh
  91364. * @returns the current mesh
  91365. */
  91366. applySkeleton(skeleton: Skeleton): Mesh;
  91367. /**
  91368. * 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
  91369. * @param meshes defines the list of meshes to scan
  91370. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91371. */
  91372. static MinMax(meshes: AbstractMesh[]): {
  91373. min: Vector3;
  91374. max: Vector3;
  91375. };
  91376. /**
  91377. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91378. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91379. * @returns a vector3
  91380. */
  91381. static Center(meshesOrMinMaxVector: {
  91382. min: Vector3;
  91383. max: Vector3;
  91384. } | AbstractMesh[]): Vector3;
  91385. /**
  91386. * Merge the array of meshes into a single mesh for performance reasons.
  91387. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91388. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91389. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91390. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91391. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91392. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91393. * @returns a new mesh
  91394. */
  91395. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91396. /** @hidden */
  91397. addInstance(instance: InstancedMesh): void;
  91398. /** @hidden */
  91399. removeInstance(instance: InstancedMesh): void;
  91400. }
  91401. }
  91402. declare module BABYLON {
  91403. /**
  91404. * This is the base class of all the camera used in the application.
  91405. * @see http://doc.babylonjs.com/features/cameras
  91406. */
  91407. export class Camera extends Node {
  91408. /** @hidden */
  91409. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91410. /**
  91411. * This is the default projection mode used by the cameras.
  91412. * It helps recreating a feeling of perspective and better appreciate depth.
  91413. * This is the best way to simulate real life cameras.
  91414. */
  91415. static readonly PERSPECTIVE_CAMERA: number;
  91416. /**
  91417. * This helps creating camera with an orthographic mode.
  91418. * 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.
  91419. */
  91420. static readonly ORTHOGRAPHIC_CAMERA: number;
  91421. /**
  91422. * This is the default FOV mode for perspective cameras.
  91423. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91424. */
  91425. static readonly FOVMODE_VERTICAL_FIXED: number;
  91426. /**
  91427. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91428. */
  91429. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91430. /**
  91431. * This specifies ther is no need for a camera rig.
  91432. * Basically only one eye is rendered corresponding to the camera.
  91433. */
  91434. static readonly RIG_MODE_NONE: number;
  91435. /**
  91436. * Simulates a camera Rig with one blue eye and one red eye.
  91437. * This can be use with 3d blue and red glasses.
  91438. */
  91439. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91440. /**
  91441. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91442. */
  91443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91444. /**
  91445. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91446. */
  91447. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91448. /**
  91449. * Defines that both eyes of the camera will be rendered over under each other.
  91450. */
  91451. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91452. /**
  91453. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91454. */
  91455. static readonly RIG_MODE_VR: number;
  91456. /**
  91457. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91458. */
  91459. static readonly RIG_MODE_WEBVR: number;
  91460. /**
  91461. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91462. */
  91463. static readonly RIG_MODE_CUSTOM: number;
  91464. /**
  91465. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91466. */
  91467. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91468. /**
  91469. * Define the input manager associated with the camera.
  91470. */
  91471. inputs: CameraInputsManager<Camera>;
  91472. /** @hidden */
  91473. _position: Vector3;
  91474. /**
  91475. * Define the current local position of the camera in the scene
  91476. */
  91477. position: Vector3;
  91478. /**
  91479. * The vector the camera should consider as up.
  91480. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91481. */
  91482. upVector: Vector3;
  91483. /**
  91484. * Define the current limit on the left side for an orthographic camera
  91485. * In scene unit
  91486. */
  91487. orthoLeft: Nullable<number>;
  91488. /**
  91489. * Define the current limit on the right side for an orthographic camera
  91490. * In scene unit
  91491. */
  91492. orthoRight: Nullable<number>;
  91493. /**
  91494. * Define the current limit on the bottom side for an orthographic camera
  91495. * In scene unit
  91496. */
  91497. orthoBottom: Nullable<number>;
  91498. /**
  91499. * Define the current limit on the top side for an orthographic camera
  91500. * In scene unit
  91501. */
  91502. orthoTop: Nullable<number>;
  91503. /**
  91504. * Field Of View is set in Radians. (default is 0.8)
  91505. */
  91506. fov: number;
  91507. /**
  91508. * Define the minimum distance the camera can see from.
  91509. * This is important to note that the depth buffer are not infinite and the closer it starts
  91510. * the more your scene might encounter depth fighting issue.
  91511. */
  91512. minZ: number;
  91513. /**
  91514. * Define the maximum distance the camera can see to.
  91515. * This is important to note that the depth buffer are not infinite and the further it end
  91516. * the more your scene might encounter depth fighting issue.
  91517. */
  91518. maxZ: number;
  91519. /**
  91520. * Define the default inertia of the camera.
  91521. * This helps giving a smooth feeling to the camera movement.
  91522. */
  91523. inertia: number;
  91524. /**
  91525. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91526. */
  91527. mode: number;
  91528. /**
  91529. * Define wether the camera is intermediate.
  91530. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91531. */
  91532. isIntermediate: boolean;
  91533. /**
  91534. * Define the viewport of the camera.
  91535. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91536. */
  91537. viewport: Viewport;
  91538. /**
  91539. * Restricts the camera to viewing objects with the same layerMask.
  91540. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91541. */
  91542. layerMask: number;
  91543. /**
  91544. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91545. */
  91546. fovMode: number;
  91547. /**
  91548. * Rig mode of the camera.
  91549. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91550. * This is normally controlled byt the camera themselves as internal use.
  91551. */
  91552. cameraRigMode: number;
  91553. /**
  91554. * Defines the distance between both "eyes" in case of a RIG
  91555. */
  91556. interaxialDistance: number;
  91557. /**
  91558. * Defines if stereoscopic rendering is done side by side or over under.
  91559. */
  91560. isStereoscopicSideBySide: boolean;
  91561. /**
  91562. * 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
  91563. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91564. * else in the scene. (Eg. security camera)
  91565. *
  91566. * 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)
  91567. */
  91568. customRenderTargets: RenderTargetTexture[];
  91569. /**
  91570. * When set, the camera will render to this render target instead of the default canvas
  91571. *
  91572. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91573. */
  91574. outputRenderTarget: Nullable<RenderTargetTexture>;
  91575. /**
  91576. * Observable triggered when the camera view matrix has changed.
  91577. */
  91578. onViewMatrixChangedObservable: Observable<Camera>;
  91579. /**
  91580. * Observable triggered when the camera Projection matrix has changed.
  91581. */
  91582. onProjectionMatrixChangedObservable: Observable<Camera>;
  91583. /**
  91584. * Observable triggered when the inputs have been processed.
  91585. */
  91586. onAfterCheckInputsObservable: Observable<Camera>;
  91587. /**
  91588. * Observable triggered when reset has been called and applied to the camera.
  91589. */
  91590. onRestoreStateObservable: Observable<Camera>;
  91591. /** @hidden */
  91592. _cameraRigParams: any;
  91593. /** @hidden */
  91594. _rigCameras: Camera[];
  91595. /** @hidden */
  91596. _rigPostProcess: Nullable<PostProcess>;
  91597. protected _webvrViewMatrix: Matrix;
  91598. /** @hidden */
  91599. _skipRendering: boolean;
  91600. /** @hidden */
  91601. _projectionMatrix: Matrix;
  91602. /** @hidden */
  91603. _postProcesses: Nullable<PostProcess>[];
  91604. /** @hidden */
  91605. _activeMeshes: SmartArray<AbstractMesh>;
  91606. protected _globalPosition: Vector3;
  91607. /** @hidden */
  91608. _computedViewMatrix: Matrix;
  91609. private _doNotComputeProjectionMatrix;
  91610. private _transformMatrix;
  91611. private _frustumPlanes;
  91612. private _refreshFrustumPlanes;
  91613. private _storedFov;
  91614. private _stateStored;
  91615. /**
  91616. * Instantiates a new camera object.
  91617. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91618. * @see http://doc.babylonjs.com/features/cameras
  91619. * @param name Defines the name of the camera in the scene
  91620. * @param position Defines the position of the camera
  91621. * @param scene Defines the scene the camera belongs too
  91622. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91623. */
  91624. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91625. /**
  91626. * Store current camera state (fov, position, etc..)
  91627. * @returns the camera
  91628. */
  91629. storeState(): Camera;
  91630. /**
  91631. * Restores the camera state values if it has been stored. You must call storeState() first
  91632. */
  91633. protected _restoreStateValues(): boolean;
  91634. /**
  91635. * Restored camera state. You must call storeState() first.
  91636. * @returns true if restored and false otherwise
  91637. */
  91638. restoreState(): boolean;
  91639. /**
  91640. * Gets the class name of the camera.
  91641. * @returns the class name
  91642. */
  91643. getClassName(): string;
  91644. /** @hidden */
  91645. readonly _isCamera: boolean;
  91646. /**
  91647. * Gets a string representation of the camera useful for debug purpose.
  91648. * @param fullDetails Defines that a more verboe level of logging is required
  91649. * @returns the string representation
  91650. */
  91651. toString(fullDetails?: boolean): string;
  91652. /**
  91653. * Gets the current world space position of the camera.
  91654. */
  91655. readonly globalPosition: Vector3;
  91656. /**
  91657. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91658. * @returns the active meshe list
  91659. */
  91660. getActiveMeshes(): SmartArray<AbstractMesh>;
  91661. /**
  91662. * Check wether a mesh is part of the current active mesh list of the camera
  91663. * @param mesh Defines the mesh to check
  91664. * @returns true if active, false otherwise
  91665. */
  91666. isActiveMesh(mesh: Mesh): boolean;
  91667. /**
  91668. * Is this camera ready to be used/rendered
  91669. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91670. * @return true if the camera is ready
  91671. */
  91672. isReady(completeCheck?: boolean): boolean;
  91673. /** @hidden */
  91674. _initCache(): void;
  91675. /** @hidden */
  91676. _updateCache(ignoreParentClass?: boolean): void;
  91677. /** @hidden */
  91678. _isSynchronized(): boolean;
  91679. /** @hidden */
  91680. _isSynchronizedViewMatrix(): boolean;
  91681. /** @hidden */
  91682. _isSynchronizedProjectionMatrix(): boolean;
  91683. /**
  91684. * Attach the input controls to a specific dom element to get the input from.
  91685. * @param element Defines the element the controls should be listened from
  91686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91687. */
  91688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91689. /**
  91690. * Detach the current controls from the specified dom element.
  91691. * @param element Defines the element to stop listening the inputs from
  91692. */
  91693. detachControl(element: HTMLElement): void;
  91694. /**
  91695. * Update the camera state according to the different inputs gathered during the frame.
  91696. */
  91697. update(): void;
  91698. /** @hidden */
  91699. _checkInputs(): void;
  91700. /** @hidden */
  91701. readonly rigCameras: Camera[];
  91702. /**
  91703. * Gets the post process used by the rig cameras
  91704. */
  91705. readonly rigPostProcess: Nullable<PostProcess>;
  91706. /**
  91707. * Internal, gets the first post proces.
  91708. * @returns the first post process to be run on this camera.
  91709. */
  91710. _getFirstPostProcess(): Nullable<PostProcess>;
  91711. private _cascadePostProcessesToRigCams;
  91712. /**
  91713. * Attach a post process to the camera.
  91714. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91715. * @param postProcess The post process to attach to the camera
  91716. * @param insertAt The position of the post process in case several of them are in use in the scene
  91717. * @returns the position the post process has been inserted at
  91718. */
  91719. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91720. /**
  91721. * Detach a post process to the camera.
  91722. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91723. * @param postProcess The post process to detach from the camera
  91724. */
  91725. detachPostProcess(postProcess: PostProcess): void;
  91726. /**
  91727. * Gets the current world matrix of the camera
  91728. */
  91729. getWorldMatrix(): Matrix;
  91730. /** @hidden */
  91731. _getViewMatrix(): Matrix;
  91732. /**
  91733. * Gets the current view matrix of the camera.
  91734. * @param force forces the camera to recompute the matrix without looking at the cached state
  91735. * @returns the view matrix
  91736. */
  91737. getViewMatrix(force?: boolean): Matrix;
  91738. /**
  91739. * Freeze the projection matrix.
  91740. * It will prevent the cache check of the camera projection compute and can speed up perf
  91741. * if no parameter of the camera are meant to change
  91742. * @param projection Defines manually a projection if necessary
  91743. */
  91744. freezeProjectionMatrix(projection?: Matrix): void;
  91745. /**
  91746. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91747. */
  91748. unfreezeProjectionMatrix(): void;
  91749. /**
  91750. * Gets the current projection matrix of the camera.
  91751. * @param force forces the camera to recompute the matrix without looking at the cached state
  91752. * @returns the projection matrix
  91753. */
  91754. getProjectionMatrix(force?: boolean): Matrix;
  91755. /**
  91756. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91757. * @returns a Matrix
  91758. */
  91759. getTransformationMatrix(): Matrix;
  91760. private _updateFrustumPlanes;
  91761. /**
  91762. * Checks if a cullable object (mesh...) is in the camera frustum
  91763. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91764. * @param target The object to check
  91765. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91766. * @returns true if the object is in frustum otherwise false
  91767. */
  91768. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91769. /**
  91770. * Checks if a cullable object (mesh...) is in the camera frustum
  91771. * Unlike isInFrustum this cheks the full bounding box
  91772. * @param target The object to check
  91773. * @returns true if the object is in frustum otherwise false
  91774. */
  91775. isCompletelyInFrustum(target: ICullable): boolean;
  91776. /**
  91777. * Gets a ray in the forward direction from the camera.
  91778. * @param length Defines the length of the ray to create
  91779. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91780. * @param origin Defines the start point of the ray which defaults to the camera position
  91781. * @returns the forward ray
  91782. */
  91783. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91784. /**
  91785. * Releases resources associated with this node.
  91786. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91787. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91788. */
  91789. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91790. /** @hidden */
  91791. _isLeftCamera: boolean;
  91792. /**
  91793. * Gets the left camera of a rig setup in case of Rigged Camera
  91794. */
  91795. readonly isLeftCamera: boolean;
  91796. /** @hidden */
  91797. _isRightCamera: boolean;
  91798. /**
  91799. * Gets the right camera of a rig setup in case of Rigged Camera
  91800. */
  91801. readonly isRightCamera: boolean;
  91802. /**
  91803. * Gets the left camera of a rig setup in case of Rigged Camera
  91804. */
  91805. readonly leftCamera: Nullable<FreeCamera>;
  91806. /**
  91807. * Gets the right camera of a rig setup in case of Rigged Camera
  91808. */
  91809. readonly rightCamera: Nullable<FreeCamera>;
  91810. /**
  91811. * Gets the left camera target of a rig setup in case of Rigged Camera
  91812. * @returns the target position
  91813. */
  91814. getLeftTarget(): Nullable<Vector3>;
  91815. /**
  91816. * Gets the right camera target of a rig setup in case of Rigged Camera
  91817. * @returns the target position
  91818. */
  91819. getRightTarget(): Nullable<Vector3>;
  91820. /**
  91821. * @hidden
  91822. */
  91823. setCameraRigMode(mode: number, rigParams: any): void;
  91824. /** @hidden */
  91825. static _setStereoscopicRigMode(camera: Camera): void;
  91826. /** @hidden */
  91827. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91828. /** @hidden */
  91829. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91830. /** @hidden */
  91831. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91832. /** @hidden */
  91833. _getVRProjectionMatrix(): Matrix;
  91834. protected _updateCameraRotationMatrix(): void;
  91835. protected _updateWebVRCameraRotationMatrix(): void;
  91836. /**
  91837. * This function MUST be overwritten by the different WebVR cameras available.
  91838. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91839. * @hidden
  91840. */
  91841. _getWebVRProjectionMatrix(): Matrix;
  91842. /**
  91843. * This function MUST be overwritten by the different WebVR cameras available.
  91844. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91845. * @hidden
  91846. */
  91847. _getWebVRViewMatrix(): Matrix;
  91848. /** @hidden */
  91849. setCameraRigParameter(name: string, value: any): void;
  91850. /**
  91851. * needs to be overridden by children so sub has required properties to be copied
  91852. * @hidden
  91853. */
  91854. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91855. /**
  91856. * May need to be overridden by children
  91857. * @hidden
  91858. */
  91859. _updateRigCameras(): void;
  91860. /** @hidden */
  91861. _setupInputs(): void;
  91862. /**
  91863. * Serialiaze the camera setup to a json represention
  91864. * @returns the JSON representation
  91865. */
  91866. serialize(): any;
  91867. /**
  91868. * Clones the current camera.
  91869. * @param name The cloned camera name
  91870. * @returns the cloned camera
  91871. */
  91872. clone(name: string): Camera;
  91873. /**
  91874. * Gets the direction of the camera relative to a given local axis.
  91875. * @param localAxis Defines the reference axis to provide a relative direction.
  91876. * @return the direction
  91877. */
  91878. getDirection(localAxis: Vector3): Vector3;
  91879. /**
  91880. * Returns the current camera absolute rotation
  91881. */
  91882. readonly absoluteRotation: Quaternion;
  91883. /**
  91884. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91885. * @param localAxis Defines the reference axis to provide a relative direction.
  91886. * @param result Defines the vector to store the result in
  91887. */
  91888. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91889. /**
  91890. * Gets a camera constructor for a given camera type
  91891. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91892. * @param name The name of the camera the result will be able to instantiate
  91893. * @param scene The scene the result will construct the camera in
  91894. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91895. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91896. * @returns a factory method to construc the camera
  91897. */
  91898. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91899. /**
  91900. * Compute the world matrix of the camera.
  91901. * @returns the camera workd matrix
  91902. */
  91903. computeWorldMatrix(): Matrix;
  91904. /**
  91905. * Parse a JSON and creates the camera from the parsed information
  91906. * @param parsedCamera The JSON to parse
  91907. * @param scene The scene to instantiate the camera in
  91908. * @returns the newly constructed camera
  91909. */
  91910. static Parse(parsedCamera: any, scene: Scene): Camera;
  91911. }
  91912. }
  91913. declare module BABYLON {
  91914. /**
  91915. * Class containing static functions to help procedurally build meshes
  91916. */
  91917. export class DiscBuilder {
  91918. /**
  91919. * Creates a plane polygonal mesh. By default, this is a disc
  91920. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91921. * * 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
  91922. * * 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
  91923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91926. * @param name defines the name of the mesh
  91927. * @param options defines the options used to create the mesh
  91928. * @param scene defines the hosting scene
  91929. * @returns the plane polygonal mesh
  91930. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91931. */
  91932. static CreateDisc(name: string, options: {
  91933. radius?: number;
  91934. tessellation?: number;
  91935. arc?: number;
  91936. updatable?: boolean;
  91937. sideOrientation?: number;
  91938. frontUVs?: Vector4;
  91939. backUVs?: Vector4;
  91940. }, scene?: Nullable<Scene>): Mesh;
  91941. }
  91942. }
  91943. declare module BABYLON {
  91944. /**
  91945. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91946. *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.
  91947. * The SPS is also a particle system. It provides some methods to manage the particles.
  91948. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91949. *
  91950. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91951. */
  91952. export class SolidParticleSystem implements IDisposable {
  91953. /**
  91954. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91955. * Example : var p = SPS.particles[i];
  91956. */
  91957. particles: SolidParticle[];
  91958. /**
  91959. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91960. */
  91961. nbParticles: number;
  91962. /**
  91963. * If the particles must ever face the camera (default false). Useful for planar particles.
  91964. */
  91965. billboard: boolean;
  91966. /**
  91967. * Recompute normals when adding a shape
  91968. */
  91969. recomputeNormals: boolean;
  91970. /**
  91971. * This a counter ofr your own usage. It's not set by any SPS functions.
  91972. */
  91973. counter: number;
  91974. /**
  91975. * The SPS name. This name is also given to the underlying mesh.
  91976. */
  91977. name: string;
  91978. /**
  91979. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91980. */
  91981. mesh: Mesh;
  91982. /**
  91983. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91984. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91985. */
  91986. vars: any;
  91987. /**
  91988. * This array is populated when the SPS is set as 'pickable'.
  91989. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91990. * Each element of this array is an object `{idx: int, faceId: int}`.
  91991. * `idx` is the picked particle index in the `SPS.particles` array
  91992. * `faceId` is the picked face index counted within this particle.
  91993. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91994. */
  91995. pickedParticles: {
  91996. idx: number;
  91997. faceId: number;
  91998. }[];
  91999. /**
  92000. * This array is populated when `enableDepthSort` is set to true.
  92001. * Each element of this array is an instance of the class DepthSortedParticle.
  92002. */
  92003. depthSortedParticles: DepthSortedParticle[];
  92004. /**
  92005. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92006. * @hidden
  92007. */
  92008. _bSphereOnly: boolean;
  92009. /**
  92010. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92011. * @hidden
  92012. */
  92013. _bSphereRadiusFactor: number;
  92014. private _scene;
  92015. private _positions;
  92016. private _indices;
  92017. private _normals;
  92018. private _colors;
  92019. private _uvs;
  92020. private _indices32;
  92021. private _positions32;
  92022. private _normals32;
  92023. private _fixedNormal32;
  92024. private _colors32;
  92025. private _uvs32;
  92026. private _index;
  92027. private _updatable;
  92028. private _pickable;
  92029. private _isVisibilityBoxLocked;
  92030. private _alwaysVisible;
  92031. private _depthSort;
  92032. private _expandable;
  92033. private _shapeCounter;
  92034. private _copy;
  92035. private _color;
  92036. private _computeParticleColor;
  92037. private _computeParticleTexture;
  92038. private _computeParticleRotation;
  92039. private _computeParticleVertex;
  92040. private _computeBoundingBox;
  92041. private _depthSortParticles;
  92042. private _camera;
  92043. private _mustUnrotateFixedNormals;
  92044. private _particlesIntersect;
  92045. private _needs32Bits;
  92046. /**
  92047. * Creates a SPS (Solid Particle System) object.
  92048. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92049. * @param scene (Scene) is the scene in which the SPS is added.
  92050. * @param options defines the options of the sps e.g.
  92051. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92052. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92053. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92054. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92055. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92056. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92057. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92058. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92059. */
  92060. constructor(name: string, scene: Scene, options?: {
  92061. updatable?: boolean;
  92062. isPickable?: boolean;
  92063. enableDepthSort?: boolean;
  92064. particleIntersection?: boolean;
  92065. boundingSphereOnly?: boolean;
  92066. bSphereRadiusFactor?: number;
  92067. expandable?: boolean;
  92068. });
  92069. /**
  92070. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92071. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92072. * @returns the created mesh
  92073. */
  92074. buildMesh(): Mesh;
  92075. /**
  92076. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92077. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92078. * Thus the particles generated from `digest()` have their property `position` set yet.
  92079. * @param mesh ( Mesh ) is the mesh to be digested
  92080. * @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
  92081. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92082. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92083. * @returns the current SPS
  92084. */
  92085. digest(mesh: Mesh, options?: {
  92086. facetNb?: number;
  92087. number?: number;
  92088. delta?: number;
  92089. }): SolidParticleSystem;
  92090. private _unrotateFixedNormals;
  92091. private _resetCopy;
  92092. private _meshBuilder;
  92093. private _posToShape;
  92094. private _uvsToShapeUV;
  92095. private _addParticle;
  92096. /**
  92097. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92098. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92099. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92100. * @param nb (positive integer) the number of particles to be created from this model
  92101. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92102. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92103. * @returns the number of shapes in the system
  92104. */
  92105. addShape(mesh: Mesh, nb: number, options?: {
  92106. positionFunction?: any;
  92107. vertexFunction?: any;
  92108. }): number;
  92109. private _rebuildParticle;
  92110. /**
  92111. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92112. * @returns the SPS.
  92113. */
  92114. rebuildMesh(): SolidParticleSystem;
  92115. /**
  92116. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92117. * This method calls `updateParticle()` for each particle of the SPS.
  92118. * For an animated SPS, it is usually called within the render loop.
  92119. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92120. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92121. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92122. * @returns the SPS.
  92123. */
  92124. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92125. /**
  92126. * Disposes the SPS.
  92127. */
  92128. dispose(): void;
  92129. /**
  92130. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92132. * @returns the SPS.
  92133. */
  92134. refreshVisibleSize(): SolidParticleSystem;
  92135. /**
  92136. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92137. * @param size the size (float) of the visibility box
  92138. * note : this doesn't lock the SPS mesh bounding box.
  92139. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92140. */
  92141. setVisibilityBox(size: number): void;
  92142. /**
  92143. * Gets whether the SPS as always visible or not
  92144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92145. */
  92146. /**
  92147. * Sets the SPS as always visible or not
  92148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92149. */
  92150. isAlwaysVisible: boolean;
  92151. /**
  92152. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92153. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92154. */
  92155. /**
  92156. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92157. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92158. */
  92159. isVisibilityBoxLocked: boolean;
  92160. /**
  92161. * Tells to `setParticles()` to compute the particle rotations or not.
  92162. * Default value : true. The SPS is faster when it's set to false.
  92163. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92164. */
  92165. /**
  92166. * Gets if `setParticles()` computes the particle rotations or not.
  92167. * Default value : true. The SPS is faster when it's set to false.
  92168. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92169. */
  92170. computeParticleRotation: boolean;
  92171. /**
  92172. * Tells to `setParticles()` to compute the particle colors or not.
  92173. * Default value : true. The SPS is faster when it's set to false.
  92174. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92175. */
  92176. /**
  92177. * Gets if `setParticles()` computes the particle colors or not.
  92178. * Default value : true. The SPS is faster when it's set to false.
  92179. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92180. */
  92181. computeParticleColor: boolean;
  92182. /**
  92183. * Gets if `setParticles()` computes the particle textures or not.
  92184. * Default value : true. The SPS is faster when it's set to false.
  92185. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92186. */
  92187. computeParticleTexture: boolean;
  92188. /**
  92189. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92190. * Default value : false. The SPS is faster when it's set to false.
  92191. * Note : the particle custom vertex positions aren't stored values.
  92192. */
  92193. /**
  92194. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92195. * Default value : false. The SPS is faster when it's set to false.
  92196. * Note : the particle custom vertex positions aren't stored values.
  92197. */
  92198. computeParticleVertex: boolean;
  92199. /**
  92200. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92201. */
  92202. /**
  92203. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92204. */
  92205. computeBoundingBox: boolean;
  92206. /**
  92207. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92208. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92209. * Default : `true`
  92210. */
  92211. /**
  92212. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92213. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92214. * Default : `true`
  92215. */
  92216. depthSortParticles: boolean;
  92217. /**
  92218. * Gets if the SPS is created as expandable at construction time.
  92219. * Default : `false`
  92220. */
  92221. readonly expandable: boolean;
  92222. /**
  92223. * This function does nothing. It may be overwritten to set all the particle first values.
  92224. * The SPS doesn't call this function, you may have to call it by your own.
  92225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92226. */
  92227. initParticles(): void;
  92228. /**
  92229. * This function does nothing. It may be overwritten to recycle a particle.
  92230. * The SPS doesn't call this function, you may have to call it by your own.
  92231. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92232. * @param particle The particle to recycle
  92233. * @returns the recycled particle
  92234. */
  92235. recycleParticle(particle: SolidParticle): SolidParticle;
  92236. /**
  92237. * Updates a particle : this function should be overwritten by the user.
  92238. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92239. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92240. * @example : just set a particle position or velocity and recycle conditions
  92241. * @param particle The particle to update
  92242. * @returns the updated particle
  92243. */
  92244. updateParticle(particle: SolidParticle): SolidParticle;
  92245. /**
  92246. * Updates a vertex of a particle : it can be overwritten by the user.
  92247. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92248. * @param particle the current particle
  92249. * @param vertex the current index of the current particle
  92250. * @param pt the index of the current vertex in the particle shape
  92251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92252. * @example : just set a vertex particle position
  92253. * @returns the updated vertex
  92254. */
  92255. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92256. /**
  92257. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92258. * This does nothing and may be overwritten by the user.
  92259. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92260. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92261. * @param update the boolean update value actually passed to setParticles()
  92262. */
  92263. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92264. /**
  92265. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92266. * This will be passed three parameters.
  92267. * This does nothing and may be overwritten by the user.
  92268. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92269. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92270. * @param update the boolean update value actually passed to setParticles()
  92271. */
  92272. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92273. }
  92274. }
  92275. declare module BABYLON {
  92276. /**
  92277. * Represents one particle of a solid particle system.
  92278. */
  92279. export class SolidParticle {
  92280. /**
  92281. * particle global index
  92282. */
  92283. idx: number;
  92284. /**
  92285. * The color of the particle
  92286. */
  92287. color: Nullable<Color4>;
  92288. /**
  92289. * The world space position of the particle.
  92290. */
  92291. position: Vector3;
  92292. /**
  92293. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92294. */
  92295. rotation: Vector3;
  92296. /**
  92297. * The world space rotation quaternion of the particle.
  92298. */
  92299. rotationQuaternion: Nullable<Quaternion>;
  92300. /**
  92301. * The scaling of the particle.
  92302. */
  92303. scaling: Vector3;
  92304. /**
  92305. * The uvs of the particle.
  92306. */
  92307. uvs: Vector4;
  92308. /**
  92309. * The current speed of the particle.
  92310. */
  92311. velocity: Vector3;
  92312. /**
  92313. * The pivot point in the particle local space.
  92314. */
  92315. pivot: Vector3;
  92316. /**
  92317. * Must the particle be translated from its pivot point in its local space ?
  92318. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92319. * Default : false
  92320. */
  92321. translateFromPivot: boolean;
  92322. /**
  92323. * Is the particle active or not ?
  92324. */
  92325. alive: boolean;
  92326. /**
  92327. * Is the particle visible or not ?
  92328. */
  92329. isVisible: boolean;
  92330. /**
  92331. * Index of this particle in the global "positions" array (Internal use)
  92332. * @hidden
  92333. */
  92334. _pos: number;
  92335. /**
  92336. * @hidden Index of this particle in the global "indices" array (Internal use)
  92337. */
  92338. _ind: number;
  92339. /**
  92340. * @hidden ModelShape of this particle (Internal use)
  92341. */
  92342. _model: ModelShape;
  92343. /**
  92344. * ModelShape id of this particle
  92345. */
  92346. shapeId: number;
  92347. /**
  92348. * Index of the particle in its shape id
  92349. */
  92350. idxInShape: number;
  92351. /**
  92352. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92353. */
  92354. _modelBoundingInfo: BoundingInfo;
  92355. /**
  92356. * @hidden Particle BoundingInfo object (Internal use)
  92357. */
  92358. _boundingInfo: BoundingInfo;
  92359. /**
  92360. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92361. */
  92362. _sps: SolidParticleSystem;
  92363. /**
  92364. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92365. */
  92366. _stillInvisible: boolean;
  92367. /**
  92368. * @hidden Last computed particle rotation matrix
  92369. */
  92370. _rotationMatrix: number[];
  92371. /**
  92372. * Parent particle Id, if any.
  92373. * Default null.
  92374. */
  92375. parentId: Nullable<number>;
  92376. /**
  92377. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92378. * The possible values are :
  92379. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92380. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92381. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92382. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92383. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92384. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92385. * */
  92386. cullingStrategy: number;
  92387. /**
  92388. * @hidden Internal global position in the SPS.
  92389. */
  92390. _globalPosition: Vector3;
  92391. /**
  92392. * Creates a Solid Particle object.
  92393. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92394. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92395. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92396. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92397. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92398. * @param shapeId (integer) is the model shape identifier in the SPS.
  92399. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92400. * @param sps defines the sps it is associated to
  92401. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92402. */
  92403. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92404. /**
  92405. * Legacy support, changed scale to scaling
  92406. */
  92407. /**
  92408. * Legacy support, changed scale to scaling
  92409. */
  92410. scale: Vector3;
  92411. /**
  92412. * Legacy support, changed quaternion to rotationQuaternion
  92413. */
  92414. /**
  92415. * Legacy support, changed quaternion to rotationQuaternion
  92416. */
  92417. quaternion: Nullable<Quaternion>;
  92418. /**
  92419. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92420. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92421. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92422. * @returns true if it intersects
  92423. */
  92424. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92425. /**
  92426. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92427. * A particle is in the frustum if its bounding box intersects the frustum
  92428. * @param frustumPlanes defines the frustum to test
  92429. * @returns true if the particle is in the frustum planes
  92430. */
  92431. isInFrustum(frustumPlanes: Plane[]): boolean;
  92432. /**
  92433. * get the rotation matrix of the particle
  92434. * @hidden
  92435. */
  92436. getRotationMatrix(m: Matrix): void;
  92437. }
  92438. /**
  92439. * Represents the shape of the model used by one particle of a solid particle system.
  92440. * SPS internal tool, don't use it manually.
  92441. */
  92442. export class ModelShape {
  92443. /**
  92444. * The shape id
  92445. * @hidden
  92446. */
  92447. shapeID: number;
  92448. /**
  92449. * flat array of model positions (internal use)
  92450. * @hidden
  92451. */
  92452. _shape: Vector3[];
  92453. /**
  92454. * flat array of model UVs (internal use)
  92455. * @hidden
  92456. */
  92457. _shapeUV: number[];
  92458. /**
  92459. * length of the shape in the model indices array (internal use)
  92460. * @hidden
  92461. */
  92462. _indicesLength: number;
  92463. /**
  92464. * Custom position function (internal use)
  92465. * @hidden
  92466. */
  92467. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92468. /**
  92469. * Custom vertex function (internal use)
  92470. * @hidden
  92471. */
  92472. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92473. /**
  92474. * 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.
  92475. * SPS internal tool, don't use it manually.
  92476. * @hidden
  92477. */
  92478. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  92479. }
  92480. /**
  92481. * Represents a Depth Sorted Particle in the solid particle system.
  92482. */
  92483. export class DepthSortedParticle {
  92484. /**
  92485. * Index of the particle in the "indices" array
  92486. */
  92487. ind: number;
  92488. /**
  92489. * Length of the particle shape in the "indices" array
  92490. */
  92491. indicesLength: number;
  92492. /**
  92493. * Squared distance from the particle to the camera
  92494. */
  92495. sqDistance: number;
  92496. }
  92497. }
  92498. declare module BABYLON {
  92499. /**
  92500. * @hidden
  92501. */
  92502. export class _MeshCollisionData {
  92503. _checkCollisions: boolean;
  92504. _collisionMask: number;
  92505. _collisionGroup: number;
  92506. _collider: Nullable<Collider>;
  92507. _oldPositionForCollisions: Vector3;
  92508. _diffPositionForCollisions: Vector3;
  92509. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92510. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92511. }
  92512. }
  92513. declare module BABYLON {
  92514. /** @hidden */
  92515. class _FacetDataStorage {
  92516. facetPositions: Vector3[];
  92517. facetNormals: Vector3[];
  92518. facetPartitioning: number[][];
  92519. facetNb: number;
  92520. partitioningSubdivisions: number;
  92521. partitioningBBoxRatio: number;
  92522. facetDataEnabled: boolean;
  92523. facetParameters: any;
  92524. bbSize: Vector3;
  92525. subDiv: {
  92526. max: number;
  92527. X: number;
  92528. Y: number;
  92529. Z: number;
  92530. };
  92531. facetDepthSort: boolean;
  92532. facetDepthSortEnabled: boolean;
  92533. depthSortedIndices: IndicesArray;
  92534. depthSortedFacets: {
  92535. ind: number;
  92536. sqDistance: number;
  92537. }[];
  92538. facetDepthSortFunction: (f1: {
  92539. ind: number;
  92540. sqDistance: number;
  92541. }, f2: {
  92542. ind: number;
  92543. sqDistance: number;
  92544. }) => number;
  92545. facetDepthSortFrom: Vector3;
  92546. facetDepthSortOrigin: Vector3;
  92547. invertedMatrix: Matrix;
  92548. }
  92549. /**
  92550. * @hidden
  92551. **/
  92552. class _InternalAbstractMeshDataInfo {
  92553. _hasVertexAlpha: boolean;
  92554. _useVertexColors: boolean;
  92555. _numBoneInfluencers: number;
  92556. _applyFog: boolean;
  92557. _receiveShadows: boolean;
  92558. _facetData: _FacetDataStorage;
  92559. _visibility: number;
  92560. _skeleton: Nullable<Skeleton>;
  92561. _layerMask: number;
  92562. _computeBonesUsingShaders: boolean;
  92563. _isActive: boolean;
  92564. _onlyForInstances: boolean;
  92565. _isActiveIntermediate: boolean;
  92566. _onlyForInstancesIntermediate: boolean;
  92567. }
  92568. /**
  92569. * Class used to store all common mesh properties
  92570. */
  92571. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92572. /** No occlusion */
  92573. static OCCLUSION_TYPE_NONE: number;
  92574. /** Occlusion set to optimisitic */
  92575. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92576. /** Occlusion set to strict */
  92577. static OCCLUSION_TYPE_STRICT: number;
  92578. /** Use an accurante occlusion algorithm */
  92579. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92580. /** Use a conservative occlusion algorithm */
  92581. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92582. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92583. * Test order :
  92584. * Is the bounding sphere outside the frustum ?
  92585. * If not, are the bounding box vertices outside the frustum ?
  92586. * It not, then the cullable object is in the frustum.
  92587. */
  92588. static readonly CULLINGSTRATEGY_STANDARD: number;
  92589. /** Culling strategy : Bounding Sphere Only.
  92590. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92591. * It's also less accurate than the standard because some not visible objects can still be selected.
  92592. * Test : is the bounding sphere outside the frustum ?
  92593. * If not, then the cullable object is in the frustum.
  92594. */
  92595. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92596. /** Culling strategy : Optimistic Inclusion.
  92597. * This in an inclusion test first, then the standard exclusion test.
  92598. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92599. * 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.
  92600. * Anyway, it's as accurate as the standard strategy.
  92601. * Test :
  92602. * Is the cullable object bounding sphere center in the frustum ?
  92603. * If not, apply the default culling strategy.
  92604. */
  92605. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92606. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92607. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92608. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92609. * 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.
  92610. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92611. * Test :
  92612. * Is the cullable object bounding sphere center in the frustum ?
  92613. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92614. */
  92615. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92616. /**
  92617. * No billboard
  92618. */
  92619. static readonly BILLBOARDMODE_NONE: number;
  92620. /** Billboard on X axis */
  92621. static readonly BILLBOARDMODE_X: number;
  92622. /** Billboard on Y axis */
  92623. static readonly BILLBOARDMODE_Y: number;
  92624. /** Billboard on Z axis */
  92625. static readonly BILLBOARDMODE_Z: number;
  92626. /** Billboard on all axes */
  92627. static readonly BILLBOARDMODE_ALL: number;
  92628. /** Billboard on using position instead of orientation */
  92629. static readonly BILLBOARDMODE_USE_POSITION: number;
  92630. /** @hidden */
  92631. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92632. /**
  92633. * The culling strategy to use to check whether the mesh must be rendered or not.
  92634. * This value can be changed at any time and will be used on the next render mesh selection.
  92635. * The possible values are :
  92636. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92637. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92638. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92639. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92640. * Please read each static variable documentation to get details about the culling process.
  92641. * */
  92642. cullingStrategy: number;
  92643. /**
  92644. * Gets the number of facets in the mesh
  92645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92646. */
  92647. readonly facetNb: number;
  92648. /**
  92649. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92651. */
  92652. partitioningSubdivisions: number;
  92653. /**
  92654. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92655. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92656. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92657. */
  92658. partitioningBBoxRatio: number;
  92659. /**
  92660. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92661. * Works only for updatable meshes.
  92662. * Doesn't work with multi-materials
  92663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92664. */
  92665. mustDepthSortFacets: boolean;
  92666. /**
  92667. * The location (Vector3) where the facet depth sort must be computed from.
  92668. * By default, the active camera position.
  92669. * Used only when facet depth sort is enabled
  92670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92671. */
  92672. facetDepthSortFrom: Vector3;
  92673. /**
  92674. * gets a boolean indicating if facetData is enabled
  92675. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92676. */
  92677. readonly isFacetDataEnabled: boolean;
  92678. /** @hidden */
  92679. _updateNonUniformScalingState(value: boolean): boolean;
  92680. /**
  92681. * An event triggered when this mesh collides with another one
  92682. */
  92683. onCollideObservable: Observable<AbstractMesh>;
  92684. /** Set a function to call when this mesh collides with another one */
  92685. onCollide: () => void;
  92686. /**
  92687. * An event triggered when the collision's position changes
  92688. */
  92689. onCollisionPositionChangeObservable: Observable<Vector3>;
  92690. /** Set a function to call when the collision's position changes */
  92691. onCollisionPositionChange: () => void;
  92692. /**
  92693. * An event triggered when material is changed
  92694. */
  92695. onMaterialChangedObservable: Observable<AbstractMesh>;
  92696. /**
  92697. * Gets or sets the orientation for POV movement & rotation
  92698. */
  92699. definedFacingForward: boolean;
  92700. /** @hidden */
  92701. _occlusionQuery: Nullable<WebGLQuery>;
  92702. /** @hidden */
  92703. _renderingGroup: Nullable<RenderingGroup>;
  92704. /**
  92705. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92706. */
  92707. /**
  92708. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92709. */
  92710. visibility: number;
  92711. /** Gets or sets the alpha index used to sort transparent meshes
  92712. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92713. */
  92714. alphaIndex: number;
  92715. /**
  92716. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92717. */
  92718. isVisible: boolean;
  92719. /**
  92720. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92721. */
  92722. isPickable: boolean;
  92723. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92724. showSubMeshesBoundingBox: boolean;
  92725. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92726. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92727. */
  92728. isBlocker: boolean;
  92729. /**
  92730. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92731. */
  92732. enablePointerMoveEvents: boolean;
  92733. /**
  92734. * Specifies the rendering group id for this mesh (0 by default)
  92735. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92736. */
  92737. renderingGroupId: number;
  92738. private _material;
  92739. /** Gets or sets current material */
  92740. material: Nullable<Material>;
  92741. /**
  92742. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92743. * @see http://doc.babylonjs.com/babylon101/shadows
  92744. */
  92745. receiveShadows: boolean;
  92746. /** Defines color to use when rendering outline */
  92747. outlineColor: Color3;
  92748. /** Define width to use when rendering outline */
  92749. outlineWidth: number;
  92750. /** Defines color to use when rendering overlay */
  92751. overlayColor: Color3;
  92752. /** Defines alpha to use when rendering overlay */
  92753. overlayAlpha: number;
  92754. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92755. hasVertexAlpha: boolean;
  92756. /** 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) */
  92757. useVertexColors: boolean;
  92758. /**
  92759. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92760. */
  92761. computeBonesUsingShaders: boolean;
  92762. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92763. numBoneInfluencers: number;
  92764. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92765. applyFog: boolean;
  92766. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92767. useOctreeForRenderingSelection: boolean;
  92768. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92769. useOctreeForPicking: boolean;
  92770. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92771. useOctreeForCollisions: boolean;
  92772. /**
  92773. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92774. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92775. */
  92776. layerMask: number;
  92777. /**
  92778. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92779. */
  92780. alwaysSelectAsActiveMesh: boolean;
  92781. /**
  92782. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92783. */
  92784. doNotSyncBoundingInfo: boolean;
  92785. /**
  92786. * Gets or sets the current action manager
  92787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92788. */
  92789. actionManager: Nullable<AbstractActionManager>;
  92790. private _meshCollisionData;
  92791. /**
  92792. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92793. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92794. */
  92795. ellipsoid: Vector3;
  92796. /**
  92797. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92799. */
  92800. ellipsoidOffset: Vector3;
  92801. /**
  92802. * Gets or sets a collision mask used to mask collisions (default is -1).
  92803. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92804. */
  92805. collisionMask: number;
  92806. /**
  92807. * Gets or sets the current collision group mask (-1 by default).
  92808. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92809. */
  92810. collisionGroup: number;
  92811. /**
  92812. * Defines edge width used when edgesRenderer is enabled
  92813. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92814. */
  92815. edgesWidth: number;
  92816. /**
  92817. * Defines edge color used when edgesRenderer is enabled
  92818. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92819. */
  92820. edgesColor: Color4;
  92821. /** @hidden */
  92822. _edgesRenderer: Nullable<IEdgesRenderer>;
  92823. /** @hidden */
  92824. _masterMesh: Nullable<AbstractMesh>;
  92825. /** @hidden */
  92826. _boundingInfo: Nullable<BoundingInfo>;
  92827. /** @hidden */
  92828. _renderId: number;
  92829. /**
  92830. * Gets or sets the list of subMeshes
  92831. * @see http://doc.babylonjs.com/how_to/multi_materials
  92832. */
  92833. subMeshes: SubMesh[];
  92834. /** @hidden */
  92835. _intersectionsInProgress: AbstractMesh[];
  92836. /** @hidden */
  92837. _unIndexed: boolean;
  92838. /** @hidden */
  92839. _lightSources: Light[];
  92840. /** Gets the list of lights affecting that mesh */
  92841. readonly lightSources: Light[];
  92842. /** @hidden */
  92843. readonly _positions: Nullable<Vector3[]>;
  92844. /** @hidden */
  92845. _waitingData: {
  92846. lods: Nullable<any>;
  92847. actions: Nullable<any>;
  92848. freezeWorldMatrix: Nullable<boolean>;
  92849. };
  92850. /** @hidden */
  92851. _bonesTransformMatrices: Nullable<Float32Array>;
  92852. /** @hidden */
  92853. _transformMatrixTexture: Nullable<RawTexture>;
  92854. /**
  92855. * Gets or sets a skeleton to apply skining transformations
  92856. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92857. */
  92858. skeleton: Nullable<Skeleton>;
  92859. /**
  92860. * An event triggered when the mesh is rebuilt.
  92861. */
  92862. onRebuildObservable: Observable<AbstractMesh>;
  92863. /**
  92864. * Creates a new AbstractMesh
  92865. * @param name defines the name of the mesh
  92866. * @param scene defines the hosting scene
  92867. */
  92868. constructor(name: string, scene?: Nullable<Scene>);
  92869. /**
  92870. * Returns the string "AbstractMesh"
  92871. * @returns "AbstractMesh"
  92872. */
  92873. getClassName(): string;
  92874. /**
  92875. * Gets a string representation of the current mesh
  92876. * @param fullDetails defines a boolean indicating if full details must be included
  92877. * @returns a string representation of the current mesh
  92878. */
  92879. toString(fullDetails?: boolean): string;
  92880. /**
  92881. * @hidden
  92882. */
  92883. protected _getEffectiveParent(): Nullable<Node>;
  92884. /** @hidden */
  92885. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92886. /** @hidden */
  92887. _rebuild(): void;
  92888. /** @hidden */
  92889. _resyncLightSources(): void;
  92890. /** @hidden */
  92891. _resyncLighSource(light: Light): void;
  92892. /** @hidden */
  92893. _unBindEffect(): void;
  92894. /** @hidden */
  92895. _removeLightSource(light: Light, dispose: boolean): void;
  92896. private _markSubMeshesAsDirty;
  92897. /** @hidden */
  92898. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92899. /** @hidden */
  92900. _markSubMeshesAsAttributesDirty(): void;
  92901. /** @hidden */
  92902. _markSubMeshesAsMiscDirty(): void;
  92903. /**
  92904. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92905. */
  92906. scaling: Vector3;
  92907. /**
  92908. * Returns true if the mesh is blocked. Implemented by child classes
  92909. */
  92910. readonly isBlocked: boolean;
  92911. /**
  92912. * Returns the mesh itself by default. Implemented by child classes
  92913. * @param camera defines the camera to use to pick the right LOD level
  92914. * @returns the currentAbstractMesh
  92915. */
  92916. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92917. /**
  92918. * Returns 0 by default. Implemented by child classes
  92919. * @returns an integer
  92920. */
  92921. getTotalVertices(): number;
  92922. /**
  92923. * Returns a positive integer : the total number of indices in this mesh geometry.
  92924. * @returns the numner of indices or zero if the mesh has no geometry.
  92925. */
  92926. getTotalIndices(): number;
  92927. /**
  92928. * Returns null by default. Implemented by child classes
  92929. * @returns null
  92930. */
  92931. getIndices(): Nullable<IndicesArray>;
  92932. /**
  92933. * Returns the array of the requested vertex data kind. Implemented by child classes
  92934. * @param kind defines the vertex data kind to use
  92935. * @returns null
  92936. */
  92937. getVerticesData(kind: string): Nullable<FloatArray>;
  92938. /**
  92939. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92940. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92941. * Note that a new underlying VertexBuffer object is created each call.
  92942. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92943. * @param kind defines vertex data kind:
  92944. * * VertexBuffer.PositionKind
  92945. * * VertexBuffer.UVKind
  92946. * * VertexBuffer.UV2Kind
  92947. * * VertexBuffer.UV3Kind
  92948. * * VertexBuffer.UV4Kind
  92949. * * VertexBuffer.UV5Kind
  92950. * * VertexBuffer.UV6Kind
  92951. * * VertexBuffer.ColorKind
  92952. * * VertexBuffer.MatricesIndicesKind
  92953. * * VertexBuffer.MatricesIndicesExtraKind
  92954. * * VertexBuffer.MatricesWeightsKind
  92955. * * VertexBuffer.MatricesWeightsExtraKind
  92956. * @param data defines the data source
  92957. * @param updatable defines if the data must be flagged as updatable (or static)
  92958. * @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
  92959. * @returns the current mesh
  92960. */
  92961. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92962. /**
  92963. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92964. * If the mesh has no geometry, it is simply returned as it is.
  92965. * @param kind defines vertex data kind:
  92966. * * VertexBuffer.PositionKind
  92967. * * VertexBuffer.UVKind
  92968. * * VertexBuffer.UV2Kind
  92969. * * VertexBuffer.UV3Kind
  92970. * * VertexBuffer.UV4Kind
  92971. * * VertexBuffer.UV5Kind
  92972. * * VertexBuffer.UV6Kind
  92973. * * VertexBuffer.ColorKind
  92974. * * VertexBuffer.MatricesIndicesKind
  92975. * * VertexBuffer.MatricesIndicesExtraKind
  92976. * * VertexBuffer.MatricesWeightsKind
  92977. * * VertexBuffer.MatricesWeightsExtraKind
  92978. * @param data defines the data source
  92979. * @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
  92980. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92981. * @returns the current mesh
  92982. */
  92983. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92984. /**
  92985. * Sets the mesh indices,
  92986. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92987. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92988. * @param totalVertices Defines the total number of vertices
  92989. * @returns the current mesh
  92990. */
  92991. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92992. /**
  92993. * Gets a boolean indicating if specific vertex data is present
  92994. * @param kind defines the vertex data kind to use
  92995. * @returns true is data kind is present
  92996. */
  92997. isVerticesDataPresent(kind: string): boolean;
  92998. /**
  92999. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93000. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93001. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93002. * @returns a BoundingInfo
  93003. */
  93004. getBoundingInfo(): BoundingInfo;
  93005. /**
  93006. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93007. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93008. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93009. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93010. * @returns the current mesh
  93011. */
  93012. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93013. /**
  93014. * Overwrite the current bounding info
  93015. * @param boundingInfo defines the new bounding info
  93016. * @returns the current mesh
  93017. */
  93018. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93019. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93020. readonly useBones: boolean;
  93021. /** @hidden */
  93022. _preActivate(): void;
  93023. /** @hidden */
  93024. _preActivateForIntermediateRendering(renderId: number): void;
  93025. /** @hidden */
  93026. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93027. /** @hidden */
  93028. _postActivate(): void;
  93029. /** @hidden */
  93030. _freeze(): void;
  93031. /** @hidden */
  93032. _unFreeze(): void;
  93033. /**
  93034. * Gets the current world matrix
  93035. * @returns a Matrix
  93036. */
  93037. getWorldMatrix(): Matrix;
  93038. /** @hidden */
  93039. _getWorldMatrixDeterminant(): number;
  93040. /**
  93041. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93042. */
  93043. readonly isAnInstance: boolean;
  93044. /**
  93045. * Gets a boolean indicating if this mesh has instances
  93046. */
  93047. readonly hasInstances: boolean;
  93048. /**
  93049. * Perform relative position change from the point of view of behind the front of the mesh.
  93050. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93051. * Supports definition of mesh facing forward or backward
  93052. * @param amountRight defines the distance on the right axis
  93053. * @param amountUp defines the distance on the up axis
  93054. * @param amountForward defines the distance on the forward axis
  93055. * @returns the current mesh
  93056. */
  93057. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93058. /**
  93059. * Calculate relative position change from the point of view of behind the front of the mesh.
  93060. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93061. * Supports definition of mesh facing forward or backward
  93062. * @param amountRight defines the distance on the right axis
  93063. * @param amountUp defines the distance on the up axis
  93064. * @param amountForward defines the distance on the forward axis
  93065. * @returns the new displacement vector
  93066. */
  93067. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93068. /**
  93069. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93070. * Supports definition of mesh facing forward or backward
  93071. * @param flipBack defines the flip
  93072. * @param twirlClockwise defines the twirl
  93073. * @param tiltRight defines the tilt
  93074. * @returns the current mesh
  93075. */
  93076. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93077. /**
  93078. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93079. * Supports definition of mesh facing forward or backward.
  93080. * @param flipBack defines the flip
  93081. * @param twirlClockwise defines the twirl
  93082. * @param tiltRight defines the tilt
  93083. * @returns the new rotation vector
  93084. */
  93085. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93086. /**
  93087. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93088. * This means the mesh underlying bounding box and sphere are recomputed.
  93089. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93090. * @returns the current mesh
  93091. */
  93092. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93093. /** @hidden */
  93094. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93095. /** @hidden */
  93096. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93097. /** @hidden */
  93098. _updateBoundingInfo(): AbstractMesh;
  93099. /** @hidden */
  93100. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93101. /** @hidden */
  93102. protected _afterComputeWorldMatrix(): void;
  93103. /** @hidden */
  93104. readonly _effectiveMesh: AbstractMesh;
  93105. /**
  93106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93107. * A mesh is in the frustum if its bounding box intersects the frustum
  93108. * @param frustumPlanes defines the frustum to test
  93109. * @returns true if the mesh is in the frustum planes
  93110. */
  93111. isInFrustum(frustumPlanes: Plane[]): boolean;
  93112. /**
  93113. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93114. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93115. * @param frustumPlanes defines the frustum to test
  93116. * @returns true if the mesh is completely in the frustum planes
  93117. */
  93118. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93119. /**
  93120. * True if the mesh intersects another mesh or a SolidParticle object
  93121. * @param mesh defines a target mesh or SolidParticle to test
  93122. * @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)
  93123. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93124. * @returns true if there is an intersection
  93125. */
  93126. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93127. /**
  93128. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93129. * @param point defines the point to test
  93130. * @returns true if there is an intersection
  93131. */
  93132. intersectsPoint(point: Vector3): boolean;
  93133. /**
  93134. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93135. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93136. */
  93137. checkCollisions: boolean;
  93138. /**
  93139. * Gets Collider object used to compute collisions (not physics)
  93140. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93141. */
  93142. readonly collider: Nullable<Collider>;
  93143. /**
  93144. * Move the mesh using collision engine
  93145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93146. * @param displacement defines the requested displacement vector
  93147. * @returns the current mesh
  93148. */
  93149. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93150. private _onCollisionPositionChange;
  93151. /** @hidden */
  93152. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93153. /** @hidden */
  93154. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93155. /** @hidden */
  93156. _checkCollision(collider: Collider): AbstractMesh;
  93157. /** @hidden */
  93158. _generatePointsArray(): boolean;
  93159. /**
  93160. * Checks if the passed Ray intersects with the mesh
  93161. * @param ray defines the ray to use
  93162. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93163. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93164. * @returns the picking info
  93165. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93166. */
  93167. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93168. /**
  93169. * Clones the current mesh
  93170. * @param name defines the mesh name
  93171. * @param newParent defines the new mesh parent
  93172. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93173. * @returns the new mesh
  93174. */
  93175. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93176. /**
  93177. * Disposes all the submeshes of the current meshnp
  93178. * @returns the current mesh
  93179. */
  93180. releaseSubMeshes(): AbstractMesh;
  93181. /**
  93182. * Releases resources associated with this abstract mesh.
  93183. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93184. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93185. */
  93186. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93187. /**
  93188. * Adds the passed mesh as a child to the current mesh
  93189. * @param mesh defines the child mesh
  93190. * @returns the current mesh
  93191. */
  93192. addChild(mesh: AbstractMesh): AbstractMesh;
  93193. /**
  93194. * Removes the passed mesh from the current mesh children list
  93195. * @param mesh defines the child mesh
  93196. * @returns the current mesh
  93197. */
  93198. removeChild(mesh: AbstractMesh): AbstractMesh;
  93199. /** @hidden */
  93200. private _initFacetData;
  93201. /**
  93202. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93203. * This method can be called within the render loop.
  93204. * 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
  93205. * @returns the current mesh
  93206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93207. */
  93208. updateFacetData(): AbstractMesh;
  93209. /**
  93210. * Returns the facetLocalNormals array.
  93211. * The normals are expressed in the mesh local spac
  93212. * @returns an array of Vector3
  93213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93214. */
  93215. getFacetLocalNormals(): Vector3[];
  93216. /**
  93217. * Returns the facetLocalPositions array.
  93218. * The facet positions are expressed in the mesh local space
  93219. * @returns an array of Vector3
  93220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93221. */
  93222. getFacetLocalPositions(): Vector3[];
  93223. /**
  93224. * Returns the facetLocalPartioning array
  93225. * @returns an array of array of numbers
  93226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93227. */
  93228. getFacetLocalPartitioning(): number[][];
  93229. /**
  93230. * Returns the i-th facet position in the world system.
  93231. * This method allocates a new Vector3 per call
  93232. * @param i defines the facet index
  93233. * @returns a new Vector3
  93234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93235. */
  93236. getFacetPosition(i: number): Vector3;
  93237. /**
  93238. * Sets the reference Vector3 with the i-th facet position in the world system
  93239. * @param i defines the facet index
  93240. * @param ref defines the target vector
  93241. * @returns the current mesh
  93242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93243. */
  93244. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93245. /**
  93246. * Returns the i-th facet normal in the world system.
  93247. * This method allocates a new Vector3 per call
  93248. * @param i defines the facet index
  93249. * @returns a new Vector3
  93250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93251. */
  93252. getFacetNormal(i: number): Vector3;
  93253. /**
  93254. * Sets the reference Vector3 with the i-th facet normal in the world system
  93255. * @param i defines the facet index
  93256. * @param ref defines the target vector
  93257. * @returns the current mesh
  93258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93259. */
  93260. getFacetNormalToRef(i: number, ref: Vector3): this;
  93261. /**
  93262. * 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)
  93263. * @param x defines x coordinate
  93264. * @param y defines y coordinate
  93265. * @param z defines z coordinate
  93266. * @returns the array of facet indexes
  93267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93268. */
  93269. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93270. /**
  93271. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93272. * @param projected sets as the (x,y,z) world projection on the facet
  93273. * @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
  93274. * @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
  93275. * @param x defines x coordinate
  93276. * @param y defines y coordinate
  93277. * @param z defines z coordinate
  93278. * @returns the face index if found (or null instead)
  93279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93280. */
  93281. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93282. /**
  93283. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93284. * @param projected sets as the (x,y,z) local projection on the facet
  93285. * @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
  93286. * @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
  93287. * @param x defines x coordinate
  93288. * @param y defines y coordinate
  93289. * @param z defines z coordinate
  93290. * @returns the face index if found (or null instead)
  93291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93292. */
  93293. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93294. /**
  93295. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93296. * @returns the parameters
  93297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93298. */
  93299. getFacetDataParameters(): any;
  93300. /**
  93301. * Disables the feature FacetData and frees the related memory
  93302. * @returns the current mesh
  93303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93304. */
  93305. disableFacetData(): AbstractMesh;
  93306. /**
  93307. * Updates the AbstractMesh indices array
  93308. * @param indices defines the data source
  93309. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93310. * @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)
  93311. * @returns the current mesh
  93312. */
  93313. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93314. /**
  93315. * Creates new normals data for the mesh
  93316. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93317. * @returns the current mesh
  93318. */
  93319. createNormals(updatable: boolean): AbstractMesh;
  93320. /**
  93321. * Align the mesh with a normal
  93322. * @param normal defines the normal to use
  93323. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93324. * @returns the current mesh
  93325. */
  93326. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93327. /** @hidden */
  93328. _checkOcclusionQuery(): boolean;
  93329. /**
  93330. * Disables the mesh edge rendering mode
  93331. * @returns the currentAbstractMesh
  93332. */
  93333. disableEdgesRendering(): AbstractMesh;
  93334. /**
  93335. * Enables the edge rendering mode on the mesh.
  93336. * This mode makes the mesh edges visible
  93337. * @param epsilon defines the maximal distance between two angles to detect a face
  93338. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93339. * @returns the currentAbstractMesh
  93340. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93341. */
  93342. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93343. }
  93344. }
  93345. declare module BABYLON {
  93346. /**
  93347. * Interface used to define ActionEvent
  93348. */
  93349. export interface IActionEvent {
  93350. /** The mesh or sprite that triggered the action */
  93351. source: any;
  93352. /** The X mouse cursor position at the time of the event */
  93353. pointerX: number;
  93354. /** The Y mouse cursor position at the time of the event */
  93355. pointerY: number;
  93356. /** The mesh that is currently pointed at (can be null) */
  93357. meshUnderPointer: Nullable<AbstractMesh>;
  93358. /** the original (browser) event that triggered the ActionEvent */
  93359. sourceEvent?: any;
  93360. /** additional data for the event */
  93361. additionalData?: any;
  93362. }
  93363. /**
  93364. * ActionEvent is the event being sent when an action is triggered.
  93365. */
  93366. export class ActionEvent implements IActionEvent {
  93367. /** The mesh or sprite that triggered the action */
  93368. source: any;
  93369. /** The X mouse cursor position at the time of the event */
  93370. pointerX: number;
  93371. /** The Y mouse cursor position at the time of the event */
  93372. pointerY: number;
  93373. /** The mesh that is currently pointed at (can be null) */
  93374. meshUnderPointer: Nullable<AbstractMesh>;
  93375. /** the original (browser) event that triggered the ActionEvent */
  93376. sourceEvent?: any;
  93377. /** additional data for the event */
  93378. additionalData?: any;
  93379. /**
  93380. * Creates a new ActionEvent
  93381. * @param source The mesh or sprite that triggered the action
  93382. * @param pointerX The X mouse cursor position at the time of the event
  93383. * @param pointerY The Y mouse cursor position at the time of the event
  93384. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93385. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93386. * @param additionalData additional data for the event
  93387. */
  93388. constructor(
  93389. /** The mesh or sprite that triggered the action */
  93390. source: any,
  93391. /** The X mouse cursor position at the time of the event */
  93392. pointerX: number,
  93393. /** The Y mouse cursor position at the time of the event */
  93394. pointerY: number,
  93395. /** The mesh that is currently pointed at (can be null) */
  93396. meshUnderPointer: Nullable<AbstractMesh>,
  93397. /** the original (browser) event that triggered the ActionEvent */
  93398. sourceEvent?: any,
  93399. /** additional data for the event */
  93400. additionalData?: any);
  93401. /**
  93402. * Helper function to auto-create an ActionEvent from a source mesh.
  93403. * @param source The source mesh that triggered the event
  93404. * @param evt The original (browser) event
  93405. * @param additionalData additional data for the event
  93406. * @returns the new ActionEvent
  93407. */
  93408. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93409. /**
  93410. * Helper function to auto-create an ActionEvent from a source sprite
  93411. * @param source The source sprite that triggered the event
  93412. * @param scene Scene associated with the sprite
  93413. * @param evt The original (browser) event
  93414. * @param additionalData additional data for the event
  93415. * @returns the new ActionEvent
  93416. */
  93417. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93418. /**
  93419. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93420. * @param scene the scene where the event occurred
  93421. * @param evt The original (browser) event
  93422. * @returns the new ActionEvent
  93423. */
  93424. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93425. /**
  93426. * Helper function to auto-create an ActionEvent from a primitive
  93427. * @param prim defines the target primitive
  93428. * @param pointerPos defines the pointer position
  93429. * @param evt The original (browser) event
  93430. * @param additionalData additional data for the event
  93431. * @returns the new ActionEvent
  93432. */
  93433. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93434. }
  93435. }
  93436. declare module BABYLON {
  93437. /**
  93438. * Abstract class used to decouple action Manager from scene and meshes.
  93439. * Do not instantiate.
  93440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93441. */
  93442. export abstract class AbstractActionManager implements IDisposable {
  93443. /** Gets the list of active triggers */
  93444. static Triggers: {
  93445. [key: string]: number;
  93446. };
  93447. /** Gets the cursor to use when hovering items */
  93448. hoverCursor: string;
  93449. /** Gets the list of actions */
  93450. actions: IAction[];
  93451. /**
  93452. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93453. */
  93454. isRecursive: boolean;
  93455. /**
  93456. * Releases all associated resources
  93457. */
  93458. abstract dispose(): void;
  93459. /**
  93460. * Does this action manager has pointer triggers
  93461. */
  93462. abstract readonly hasPointerTriggers: boolean;
  93463. /**
  93464. * Does this action manager has pick triggers
  93465. */
  93466. abstract readonly hasPickTriggers: boolean;
  93467. /**
  93468. * Process a specific trigger
  93469. * @param trigger defines the trigger to process
  93470. * @param evt defines the event details to be processed
  93471. */
  93472. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93473. /**
  93474. * Does this action manager handles actions of any of the given triggers
  93475. * @param triggers defines the triggers to be tested
  93476. * @return a boolean indicating whether one (or more) of the triggers is handled
  93477. */
  93478. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93479. /**
  93480. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93481. * speed.
  93482. * @param triggerA defines the trigger to be tested
  93483. * @param triggerB defines the trigger to be tested
  93484. * @return a boolean indicating whether one (or more) of the triggers is handled
  93485. */
  93486. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93487. /**
  93488. * Does this action manager handles actions of a given trigger
  93489. * @param trigger defines the trigger to be tested
  93490. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93491. * @return whether the trigger is handled
  93492. */
  93493. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93494. /**
  93495. * Serialize this manager to a JSON object
  93496. * @param name defines the property name to store this manager
  93497. * @returns a JSON representation of this manager
  93498. */
  93499. abstract serialize(name: string): any;
  93500. /**
  93501. * Registers an action to this action manager
  93502. * @param action defines the action to be registered
  93503. * @return the action amended (prepared) after registration
  93504. */
  93505. abstract registerAction(action: IAction): Nullable<IAction>;
  93506. /**
  93507. * Unregisters an action to this action manager
  93508. * @param action defines the action to be unregistered
  93509. * @return a boolean indicating whether the action has been unregistered
  93510. */
  93511. abstract unregisterAction(action: IAction): Boolean;
  93512. /**
  93513. * Does exist one action manager with at least one trigger
  93514. **/
  93515. static readonly HasTriggers: boolean;
  93516. /**
  93517. * Does exist one action manager with at least one pick trigger
  93518. **/
  93519. static readonly HasPickTriggers: boolean;
  93520. /**
  93521. * Does exist one action manager that handles actions of a given trigger
  93522. * @param trigger defines the trigger to be tested
  93523. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93524. **/
  93525. static HasSpecificTrigger(trigger: number): boolean;
  93526. }
  93527. }
  93528. declare module BABYLON {
  93529. /**
  93530. * Defines how a node can be built from a string name.
  93531. */
  93532. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93533. /**
  93534. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93535. */
  93536. export class Node implements IBehaviorAware<Node> {
  93537. /** @hidden */
  93538. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93539. private static _NodeConstructors;
  93540. /**
  93541. * Add a new node constructor
  93542. * @param type defines the type name of the node to construct
  93543. * @param constructorFunc defines the constructor function
  93544. */
  93545. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93546. /**
  93547. * Returns a node constructor based on type name
  93548. * @param type defines the type name
  93549. * @param name defines the new node name
  93550. * @param scene defines the hosting scene
  93551. * @param options defines optional options to transmit to constructors
  93552. * @returns the new constructor or null
  93553. */
  93554. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93555. /**
  93556. * Gets or sets the name of the node
  93557. */
  93558. name: string;
  93559. /**
  93560. * Gets or sets the id of the node
  93561. */
  93562. id: string;
  93563. /**
  93564. * Gets or sets the unique id of the node
  93565. */
  93566. uniqueId: number;
  93567. /**
  93568. * Gets or sets a string used to store user defined state for the node
  93569. */
  93570. state: string;
  93571. /**
  93572. * Gets or sets an object used to store user defined information for the node
  93573. */
  93574. metadata: any;
  93575. /**
  93576. * For internal use only. Please do not use.
  93577. */
  93578. reservedDataStore: any;
  93579. /**
  93580. * List of inspectable custom properties (used by the Inspector)
  93581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93582. */
  93583. inspectableCustomProperties: IInspectable[];
  93584. private _doNotSerialize;
  93585. /**
  93586. * Gets or sets a boolean used to define if the node must be serialized
  93587. */
  93588. doNotSerialize: boolean;
  93589. /** @hidden */
  93590. _isDisposed: boolean;
  93591. /**
  93592. * Gets a list of Animations associated with the node
  93593. */
  93594. animations: Animation[];
  93595. protected _ranges: {
  93596. [name: string]: Nullable<AnimationRange>;
  93597. };
  93598. /**
  93599. * Callback raised when the node is ready to be used
  93600. */
  93601. onReady: Nullable<(node: Node) => void>;
  93602. private _isEnabled;
  93603. private _isParentEnabled;
  93604. private _isReady;
  93605. /** @hidden */
  93606. _currentRenderId: number;
  93607. private _parentUpdateId;
  93608. /** @hidden */
  93609. _childUpdateId: number;
  93610. /** @hidden */
  93611. _waitingParentId: Nullable<string>;
  93612. /** @hidden */
  93613. _scene: Scene;
  93614. /** @hidden */
  93615. _cache: any;
  93616. private _parentNode;
  93617. private _children;
  93618. /** @hidden */
  93619. _worldMatrix: Matrix;
  93620. /** @hidden */
  93621. _worldMatrixDeterminant: number;
  93622. /** @hidden */
  93623. _worldMatrixDeterminantIsDirty: boolean;
  93624. /** @hidden */
  93625. private _sceneRootNodesIndex;
  93626. /**
  93627. * Gets a boolean indicating if the node has been disposed
  93628. * @returns true if the node was disposed
  93629. */
  93630. isDisposed(): boolean;
  93631. /**
  93632. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93633. * @see https://doc.babylonjs.com/how_to/parenting
  93634. */
  93635. parent: Nullable<Node>;
  93636. private addToSceneRootNodes;
  93637. private removeFromSceneRootNodes;
  93638. private _animationPropertiesOverride;
  93639. /**
  93640. * Gets or sets the animation properties override
  93641. */
  93642. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93643. /**
  93644. * Gets a string idenfifying the name of the class
  93645. * @returns "Node" string
  93646. */
  93647. getClassName(): string;
  93648. /** @hidden */
  93649. readonly _isNode: boolean;
  93650. /**
  93651. * An event triggered when the mesh is disposed
  93652. */
  93653. onDisposeObservable: Observable<Node>;
  93654. private _onDisposeObserver;
  93655. /**
  93656. * Sets a callback that will be raised when the node will be disposed
  93657. */
  93658. onDispose: () => void;
  93659. /**
  93660. * Creates a new Node
  93661. * @param name the name and id to be given to this node
  93662. * @param scene the scene this node will be added to
  93663. * @param addToRootNodes the node will be added to scene.rootNodes
  93664. */
  93665. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93666. /**
  93667. * Gets the scene of the node
  93668. * @returns a scene
  93669. */
  93670. getScene(): Scene;
  93671. /**
  93672. * Gets the engine of the node
  93673. * @returns a Engine
  93674. */
  93675. getEngine(): Engine;
  93676. private _behaviors;
  93677. /**
  93678. * Attach a behavior to the node
  93679. * @see http://doc.babylonjs.com/features/behaviour
  93680. * @param behavior defines the behavior to attach
  93681. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93682. * @returns the current Node
  93683. */
  93684. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93685. /**
  93686. * Remove an attached behavior
  93687. * @see http://doc.babylonjs.com/features/behaviour
  93688. * @param behavior defines the behavior to attach
  93689. * @returns the current Node
  93690. */
  93691. removeBehavior(behavior: Behavior<Node>): Node;
  93692. /**
  93693. * Gets the list of attached behaviors
  93694. * @see http://doc.babylonjs.com/features/behaviour
  93695. */
  93696. readonly behaviors: Behavior<Node>[];
  93697. /**
  93698. * Gets an attached behavior by name
  93699. * @param name defines the name of the behavior to look for
  93700. * @see http://doc.babylonjs.com/features/behaviour
  93701. * @returns null if behavior was not found else the requested behavior
  93702. */
  93703. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93704. /**
  93705. * Returns the latest update of the World matrix
  93706. * @returns a Matrix
  93707. */
  93708. getWorldMatrix(): Matrix;
  93709. /** @hidden */
  93710. _getWorldMatrixDeterminant(): number;
  93711. /**
  93712. * Returns directly the latest state of the mesh World matrix.
  93713. * A Matrix is returned.
  93714. */
  93715. readonly worldMatrixFromCache: Matrix;
  93716. /** @hidden */
  93717. _initCache(): void;
  93718. /** @hidden */
  93719. updateCache(force?: boolean): void;
  93720. /** @hidden */
  93721. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93722. /** @hidden */
  93723. _updateCache(ignoreParentClass?: boolean): void;
  93724. /** @hidden */
  93725. _isSynchronized(): boolean;
  93726. /** @hidden */
  93727. _markSyncedWithParent(): void;
  93728. /** @hidden */
  93729. isSynchronizedWithParent(): boolean;
  93730. /** @hidden */
  93731. isSynchronized(): boolean;
  93732. /**
  93733. * Is this node ready to be used/rendered
  93734. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93735. * @return true if the node is ready
  93736. */
  93737. isReady(completeCheck?: boolean): boolean;
  93738. /**
  93739. * Is this node enabled?
  93740. * 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
  93741. * @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
  93742. * @return whether this node (and its parent) is enabled
  93743. */
  93744. isEnabled(checkAncestors?: boolean): boolean;
  93745. /** @hidden */
  93746. protected _syncParentEnabledState(): void;
  93747. /**
  93748. * Set the enabled state of this node
  93749. * @param value defines the new enabled state
  93750. */
  93751. setEnabled(value: boolean): void;
  93752. /**
  93753. * Is this node a descendant of the given node?
  93754. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93755. * @param ancestor defines the parent node to inspect
  93756. * @returns a boolean indicating if this node is a descendant of the given node
  93757. */
  93758. isDescendantOf(ancestor: Node): boolean;
  93759. /** @hidden */
  93760. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93761. /**
  93762. * Will return all nodes that have this node as ascendant
  93763. * @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
  93764. * @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
  93765. * @return all children nodes of all types
  93766. */
  93767. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93768. /**
  93769. * Get all child-meshes of this node
  93770. * @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)
  93771. * @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
  93772. * @returns an array of AbstractMesh
  93773. */
  93774. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93775. /**
  93776. * Get all direct children of this node
  93777. * @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
  93778. * @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)
  93779. * @returns an array of Node
  93780. */
  93781. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93782. /** @hidden */
  93783. _setReady(state: boolean): void;
  93784. /**
  93785. * Get an animation by name
  93786. * @param name defines the name of the animation to look for
  93787. * @returns null if not found else the requested animation
  93788. */
  93789. getAnimationByName(name: string): Nullable<Animation>;
  93790. /**
  93791. * Creates an animation range for this node
  93792. * @param name defines the name of the range
  93793. * @param from defines the starting key
  93794. * @param to defines the end key
  93795. */
  93796. createAnimationRange(name: string, from: number, to: number): void;
  93797. /**
  93798. * Delete a specific animation range
  93799. * @param name defines the name of the range to delete
  93800. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93801. */
  93802. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93803. /**
  93804. * Get an animation range by name
  93805. * @param name defines the name of the animation range to look for
  93806. * @returns null if not found else the requested animation range
  93807. */
  93808. getAnimationRange(name: string): Nullable<AnimationRange>;
  93809. /**
  93810. * Gets the list of all animation ranges defined on this node
  93811. * @returns an array
  93812. */
  93813. getAnimationRanges(): Nullable<AnimationRange>[];
  93814. /**
  93815. * Will start the animation sequence
  93816. * @param name defines the range frames for animation sequence
  93817. * @param loop defines if the animation should loop (false by default)
  93818. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93819. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93820. * @returns the object created for this animation. If range does not exist, it will return null
  93821. */
  93822. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93823. /**
  93824. * Serialize animation ranges into a JSON compatible object
  93825. * @returns serialization object
  93826. */
  93827. serializeAnimationRanges(): any;
  93828. /**
  93829. * Computes the world matrix of the node
  93830. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93831. * @returns the world matrix
  93832. */
  93833. computeWorldMatrix(force?: boolean): Matrix;
  93834. /**
  93835. * Releases resources associated with this node.
  93836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93838. */
  93839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93840. /**
  93841. * Parse animation range data from a serialization object and store them into a given node
  93842. * @param node defines where to store the animation ranges
  93843. * @param parsedNode defines the serialization object to read data from
  93844. * @param scene defines the hosting scene
  93845. */
  93846. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93847. /**
  93848. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93849. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93850. * @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
  93851. * @returns the new bounding vectors
  93852. */
  93853. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93854. min: Vector3;
  93855. max: Vector3;
  93856. };
  93857. }
  93858. }
  93859. declare module BABYLON {
  93860. /**
  93861. * @hidden
  93862. */
  93863. export class _IAnimationState {
  93864. key: number;
  93865. repeatCount: number;
  93866. workValue?: any;
  93867. loopMode?: number;
  93868. offsetValue?: any;
  93869. highLimitValue?: any;
  93870. }
  93871. /**
  93872. * Class used to store any kind of animation
  93873. */
  93874. export class Animation {
  93875. /**Name of the animation */
  93876. name: string;
  93877. /**Property to animate */
  93878. targetProperty: string;
  93879. /**The frames per second of the animation */
  93880. framePerSecond: number;
  93881. /**The data type of the animation */
  93882. dataType: number;
  93883. /**The loop mode of the animation */
  93884. loopMode?: number | undefined;
  93885. /**Specifies if blending should be enabled */
  93886. enableBlending?: boolean | undefined;
  93887. /**
  93888. * Use matrix interpolation instead of using direct key value when animating matrices
  93889. */
  93890. static AllowMatricesInterpolation: boolean;
  93891. /**
  93892. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93893. */
  93894. static AllowMatrixDecomposeForInterpolation: boolean;
  93895. /**
  93896. * Stores the key frames of the animation
  93897. */
  93898. private _keys;
  93899. /**
  93900. * Stores the easing function of the animation
  93901. */
  93902. private _easingFunction;
  93903. /**
  93904. * @hidden Internal use only
  93905. */
  93906. _runtimeAnimations: RuntimeAnimation[];
  93907. /**
  93908. * The set of event that will be linked to this animation
  93909. */
  93910. private _events;
  93911. /**
  93912. * Stores an array of target property paths
  93913. */
  93914. targetPropertyPath: string[];
  93915. /**
  93916. * Stores the blending speed of the animation
  93917. */
  93918. blendingSpeed: number;
  93919. /**
  93920. * Stores the animation ranges for the animation
  93921. */
  93922. private _ranges;
  93923. /**
  93924. * @hidden Internal use
  93925. */
  93926. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93927. /**
  93928. * Sets up an animation
  93929. * @param property The property to animate
  93930. * @param animationType The animation type to apply
  93931. * @param framePerSecond The frames per second of the animation
  93932. * @param easingFunction The easing function used in the animation
  93933. * @returns The created animation
  93934. */
  93935. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93936. /**
  93937. * Create and start an animation on a node
  93938. * @param name defines the name of the global animation that will be run on all nodes
  93939. * @param node defines the root node where the animation will take place
  93940. * @param targetProperty defines property to animate
  93941. * @param framePerSecond defines the number of frame per second yo use
  93942. * @param totalFrame defines the number of frames in total
  93943. * @param from defines the initial value
  93944. * @param to defines the final value
  93945. * @param loopMode defines which loop mode you want to use (off by default)
  93946. * @param easingFunction defines the easing function to use (linear by default)
  93947. * @param onAnimationEnd defines the callback to call when animation end
  93948. * @returns the animatable created for this animation
  93949. */
  93950. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93951. /**
  93952. * Create and start an animation on a node and its descendants
  93953. * @param name defines the name of the global animation that will be run on all nodes
  93954. * @param node defines the root node where the animation will take place
  93955. * @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
  93956. * @param targetProperty defines property to animate
  93957. * @param framePerSecond defines the number of frame per second to use
  93958. * @param totalFrame defines the number of frames in total
  93959. * @param from defines the initial value
  93960. * @param to defines the final value
  93961. * @param loopMode defines which loop mode you want to use (off by default)
  93962. * @param easingFunction defines the easing function to use (linear by default)
  93963. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93964. * @returns the list of animatables created for all nodes
  93965. * @example https://www.babylonjs-playground.com/#MH0VLI
  93966. */
  93967. 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[]>;
  93968. /**
  93969. * Creates a new animation, merges it with the existing animations and starts it
  93970. * @param name Name of the animation
  93971. * @param node Node which contains the scene that begins the animations
  93972. * @param targetProperty Specifies which property to animate
  93973. * @param framePerSecond The frames per second of the animation
  93974. * @param totalFrame The total number of frames
  93975. * @param from The frame at the beginning of the animation
  93976. * @param to The frame at the end of the animation
  93977. * @param loopMode Specifies the loop mode of the animation
  93978. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93979. * @param onAnimationEnd Callback to run once the animation is complete
  93980. * @returns Nullable animation
  93981. */
  93982. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93983. /**
  93984. * Transition property of an host to the target Value
  93985. * @param property The property to transition
  93986. * @param targetValue The target Value of the property
  93987. * @param host The object where the property to animate belongs
  93988. * @param scene Scene used to run the animation
  93989. * @param frameRate Framerate (in frame/s) to use
  93990. * @param transition The transition type we want to use
  93991. * @param duration The duration of the animation, in milliseconds
  93992. * @param onAnimationEnd Callback trigger at the end of the animation
  93993. * @returns Nullable animation
  93994. */
  93995. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93996. /**
  93997. * Return the array of runtime animations currently using this animation
  93998. */
  93999. readonly runtimeAnimations: RuntimeAnimation[];
  94000. /**
  94001. * Specifies if any of the runtime animations are currently running
  94002. */
  94003. readonly hasRunningRuntimeAnimations: boolean;
  94004. /**
  94005. * Initializes the animation
  94006. * @param name Name of the animation
  94007. * @param targetProperty Property to animate
  94008. * @param framePerSecond The frames per second of the animation
  94009. * @param dataType The data type of the animation
  94010. * @param loopMode The loop mode of the animation
  94011. * @param enableBlending Specifies if blending should be enabled
  94012. */
  94013. constructor(
  94014. /**Name of the animation */
  94015. name: string,
  94016. /**Property to animate */
  94017. targetProperty: string,
  94018. /**The frames per second of the animation */
  94019. framePerSecond: number,
  94020. /**The data type of the animation */
  94021. dataType: number,
  94022. /**The loop mode of the animation */
  94023. loopMode?: number | undefined,
  94024. /**Specifies if blending should be enabled */
  94025. enableBlending?: boolean | undefined);
  94026. /**
  94027. * Converts the animation to a string
  94028. * @param fullDetails support for multiple levels of logging within scene loading
  94029. * @returns String form of the animation
  94030. */
  94031. toString(fullDetails?: boolean): string;
  94032. /**
  94033. * Add an event to this animation
  94034. * @param event Event to add
  94035. */
  94036. addEvent(event: AnimationEvent): void;
  94037. /**
  94038. * Remove all events found at the given frame
  94039. * @param frame The frame to remove events from
  94040. */
  94041. removeEvents(frame: number): void;
  94042. /**
  94043. * Retrieves all the events from the animation
  94044. * @returns Events from the animation
  94045. */
  94046. getEvents(): AnimationEvent[];
  94047. /**
  94048. * Creates an animation range
  94049. * @param name Name of the animation range
  94050. * @param from Starting frame of the animation range
  94051. * @param to Ending frame of the animation
  94052. */
  94053. createRange(name: string, from: number, to: number): void;
  94054. /**
  94055. * Deletes an animation range by name
  94056. * @param name Name of the animation range to delete
  94057. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94058. */
  94059. deleteRange(name: string, deleteFrames?: boolean): void;
  94060. /**
  94061. * Gets the animation range by name, or null if not defined
  94062. * @param name Name of the animation range
  94063. * @returns Nullable animation range
  94064. */
  94065. getRange(name: string): Nullable<AnimationRange>;
  94066. /**
  94067. * Gets the key frames from the animation
  94068. * @returns The key frames of the animation
  94069. */
  94070. getKeys(): Array<IAnimationKey>;
  94071. /**
  94072. * Gets the highest frame rate of the animation
  94073. * @returns Highest frame rate of the animation
  94074. */
  94075. getHighestFrame(): number;
  94076. /**
  94077. * Gets the easing function of the animation
  94078. * @returns Easing function of the animation
  94079. */
  94080. getEasingFunction(): IEasingFunction;
  94081. /**
  94082. * Sets the easing function of the animation
  94083. * @param easingFunction A custom mathematical formula for animation
  94084. */
  94085. setEasingFunction(easingFunction: EasingFunction): void;
  94086. /**
  94087. * Interpolates a scalar linearly
  94088. * @param startValue Start value of the animation curve
  94089. * @param endValue End value of the animation curve
  94090. * @param gradient Scalar amount to interpolate
  94091. * @returns Interpolated scalar value
  94092. */
  94093. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94094. /**
  94095. * Interpolates a scalar cubically
  94096. * @param startValue Start value of the animation curve
  94097. * @param outTangent End tangent of the animation
  94098. * @param endValue End value of the animation curve
  94099. * @param inTangent Start tangent of the animation curve
  94100. * @param gradient Scalar amount to interpolate
  94101. * @returns Interpolated scalar value
  94102. */
  94103. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94104. /**
  94105. * Interpolates a quaternion using a spherical linear interpolation
  94106. * @param startValue Start value of the animation curve
  94107. * @param endValue End value of the animation curve
  94108. * @param gradient Scalar amount to interpolate
  94109. * @returns Interpolated quaternion value
  94110. */
  94111. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94112. /**
  94113. * Interpolates a quaternion cubically
  94114. * @param startValue Start value of the animation curve
  94115. * @param outTangent End tangent of the animation curve
  94116. * @param endValue End value of the animation curve
  94117. * @param inTangent Start tangent of the animation curve
  94118. * @param gradient Scalar amount to interpolate
  94119. * @returns Interpolated quaternion value
  94120. */
  94121. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94122. /**
  94123. * Interpolates a Vector3 linearl
  94124. * @param startValue Start value of the animation curve
  94125. * @param endValue End value of the animation curve
  94126. * @param gradient Scalar amount to interpolate
  94127. * @returns Interpolated scalar value
  94128. */
  94129. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94130. /**
  94131. * Interpolates a Vector3 cubically
  94132. * @param startValue Start value of the animation curve
  94133. * @param outTangent End tangent of the animation
  94134. * @param endValue End value of the animation curve
  94135. * @param inTangent Start tangent of the animation curve
  94136. * @param gradient Scalar amount to interpolate
  94137. * @returns InterpolatedVector3 value
  94138. */
  94139. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94140. /**
  94141. * Interpolates a Vector2 linearly
  94142. * @param startValue Start value of the animation curve
  94143. * @param endValue End value of the animation curve
  94144. * @param gradient Scalar amount to interpolate
  94145. * @returns Interpolated Vector2 value
  94146. */
  94147. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94148. /**
  94149. * Interpolates a Vector2 cubically
  94150. * @param startValue Start value of the animation curve
  94151. * @param outTangent End tangent of the animation
  94152. * @param endValue End value of the animation curve
  94153. * @param inTangent Start tangent of the animation curve
  94154. * @param gradient Scalar amount to interpolate
  94155. * @returns Interpolated Vector2 value
  94156. */
  94157. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94158. /**
  94159. * Interpolates a size linearly
  94160. * @param startValue Start value of the animation curve
  94161. * @param endValue End value of the animation curve
  94162. * @param gradient Scalar amount to interpolate
  94163. * @returns Interpolated Size value
  94164. */
  94165. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94166. /**
  94167. * Interpolates a Color3 linearly
  94168. * @param startValue Start value of the animation curve
  94169. * @param endValue End value of the animation curve
  94170. * @param gradient Scalar amount to interpolate
  94171. * @returns Interpolated Color3 value
  94172. */
  94173. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94174. /**
  94175. * @hidden Internal use only
  94176. */
  94177. _getKeyValue(value: any): any;
  94178. /**
  94179. * @hidden Internal use only
  94180. */
  94181. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94182. /**
  94183. * Defines the function to use to interpolate matrices
  94184. * @param startValue defines the start matrix
  94185. * @param endValue defines the end matrix
  94186. * @param gradient defines the gradient between both matrices
  94187. * @param result defines an optional target matrix where to store the interpolation
  94188. * @returns the interpolated matrix
  94189. */
  94190. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94191. /**
  94192. * Makes a copy of the animation
  94193. * @returns Cloned animation
  94194. */
  94195. clone(): Animation;
  94196. /**
  94197. * Sets the key frames of the animation
  94198. * @param values The animation key frames to set
  94199. */
  94200. setKeys(values: Array<IAnimationKey>): void;
  94201. /**
  94202. * Serializes the animation to an object
  94203. * @returns Serialized object
  94204. */
  94205. serialize(): any;
  94206. /**
  94207. * Float animation type
  94208. */
  94209. private static _ANIMATIONTYPE_FLOAT;
  94210. /**
  94211. * Vector3 animation type
  94212. */
  94213. private static _ANIMATIONTYPE_VECTOR3;
  94214. /**
  94215. * Quaternion animation type
  94216. */
  94217. private static _ANIMATIONTYPE_QUATERNION;
  94218. /**
  94219. * Matrix animation type
  94220. */
  94221. private static _ANIMATIONTYPE_MATRIX;
  94222. /**
  94223. * Color3 animation type
  94224. */
  94225. private static _ANIMATIONTYPE_COLOR3;
  94226. /**
  94227. * Vector2 animation type
  94228. */
  94229. private static _ANIMATIONTYPE_VECTOR2;
  94230. /**
  94231. * Size animation type
  94232. */
  94233. private static _ANIMATIONTYPE_SIZE;
  94234. /**
  94235. * Relative Loop Mode
  94236. */
  94237. private static _ANIMATIONLOOPMODE_RELATIVE;
  94238. /**
  94239. * Cycle Loop Mode
  94240. */
  94241. private static _ANIMATIONLOOPMODE_CYCLE;
  94242. /**
  94243. * Constant Loop Mode
  94244. */
  94245. private static _ANIMATIONLOOPMODE_CONSTANT;
  94246. /**
  94247. * Get the float animation type
  94248. */
  94249. static readonly ANIMATIONTYPE_FLOAT: number;
  94250. /**
  94251. * Get the Vector3 animation type
  94252. */
  94253. static readonly ANIMATIONTYPE_VECTOR3: number;
  94254. /**
  94255. * Get the Vector2 animation type
  94256. */
  94257. static readonly ANIMATIONTYPE_VECTOR2: number;
  94258. /**
  94259. * Get the Size animation type
  94260. */
  94261. static readonly ANIMATIONTYPE_SIZE: number;
  94262. /**
  94263. * Get the Quaternion animation type
  94264. */
  94265. static readonly ANIMATIONTYPE_QUATERNION: number;
  94266. /**
  94267. * Get the Matrix animation type
  94268. */
  94269. static readonly ANIMATIONTYPE_MATRIX: number;
  94270. /**
  94271. * Get the Color3 animation type
  94272. */
  94273. static readonly ANIMATIONTYPE_COLOR3: number;
  94274. /**
  94275. * Get the Relative Loop Mode
  94276. */
  94277. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94278. /**
  94279. * Get the Cycle Loop Mode
  94280. */
  94281. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94282. /**
  94283. * Get the Constant Loop Mode
  94284. */
  94285. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94286. /** @hidden */
  94287. static _UniversalLerp(left: any, right: any, amount: number): any;
  94288. /**
  94289. * Parses an animation object and creates an animation
  94290. * @param parsedAnimation Parsed animation object
  94291. * @returns Animation object
  94292. */
  94293. static Parse(parsedAnimation: any): Animation;
  94294. /**
  94295. * Appends the serialized animations from the source animations
  94296. * @param source Source containing the animations
  94297. * @param destination Target to store the animations
  94298. */
  94299. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94300. }
  94301. }
  94302. declare module BABYLON {
  94303. /**
  94304. * Interface containing an array of animations
  94305. */
  94306. export interface IAnimatable {
  94307. /**
  94308. * Array of animations
  94309. */
  94310. animations: Nullable<Array<Animation>>;
  94311. }
  94312. }
  94313. declare module BABYLON {
  94314. /**
  94315. * This represents all the required information to add a fresnel effect on a material:
  94316. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94317. */
  94318. export class FresnelParameters {
  94319. private _isEnabled;
  94320. /**
  94321. * Define if the fresnel effect is enable or not.
  94322. */
  94323. isEnabled: boolean;
  94324. /**
  94325. * Define the color used on edges (grazing angle)
  94326. */
  94327. leftColor: Color3;
  94328. /**
  94329. * Define the color used on center
  94330. */
  94331. rightColor: Color3;
  94332. /**
  94333. * Define bias applied to computed fresnel term
  94334. */
  94335. bias: number;
  94336. /**
  94337. * Defined the power exponent applied to fresnel term
  94338. */
  94339. power: number;
  94340. /**
  94341. * Clones the current fresnel and its valuues
  94342. * @returns a clone fresnel configuration
  94343. */
  94344. clone(): FresnelParameters;
  94345. /**
  94346. * Serializes the current fresnel parameters to a JSON representation.
  94347. * @return the JSON serialization
  94348. */
  94349. serialize(): any;
  94350. /**
  94351. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94352. * @param parsedFresnelParameters Define the JSON representation
  94353. * @returns the parsed parameters
  94354. */
  94355. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94356. }
  94357. }
  94358. declare module BABYLON {
  94359. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94360. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94361. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94362. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94363. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94364. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94365. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94366. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94367. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94368. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94369. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94370. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94371. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. /**
  94373. * Decorator used to define property that can be serialized as reference to a camera
  94374. * @param sourceName defines the name of the property to decorate
  94375. */
  94376. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94377. /**
  94378. * Class used to help serialization objects
  94379. */
  94380. export class SerializationHelper {
  94381. /** @hidden */
  94382. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94383. /** @hidden */
  94384. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94385. /** @hidden */
  94386. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94387. /** @hidden */
  94388. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94389. /**
  94390. * Appends the serialized animations from the source animations
  94391. * @param source Source containing the animations
  94392. * @param destination Target to store the animations
  94393. */
  94394. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94395. /**
  94396. * Static function used to serialized a specific entity
  94397. * @param entity defines the entity to serialize
  94398. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94399. * @returns a JSON compatible object representing the serialization of the entity
  94400. */
  94401. static Serialize<T>(entity: T, serializationObject?: any): any;
  94402. /**
  94403. * Creates a new entity from a serialization data object
  94404. * @param creationFunction defines a function used to instanciated the new entity
  94405. * @param source defines the source serialization data
  94406. * @param scene defines the hosting scene
  94407. * @param rootUrl defines the root url for resources
  94408. * @returns a new entity
  94409. */
  94410. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94411. /**
  94412. * Clones an object
  94413. * @param creationFunction defines the function used to instanciate the new object
  94414. * @param source defines the source object
  94415. * @returns the cloned object
  94416. */
  94417. static Clone<T>(creationFunction: () => T, source: T): T;
  94418. /**
  94419. * Instanciates a new object based on a source one (some data will be shared between both object)
  94420. * @param creationFunction defines the function used to instanciate the new object
  94421. * @param source defines the source object
  94422. * @returns the new object
  94423. */
  94424. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94425. }
  94426. }
  94427. declare module BABYLON {
  94428. /**
  94429. * Class used to manipulate GUIDs
  94430. */
  94431. export class GUID {
  94432. /**
  94433. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94434. * Be aware Math.random() could cause collisions, but:
  94435. * "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"
  94436. * @returns a pseudo random id
  94437. */
  94438. static RandomId(): string;
  94439. }
  94440. }
  94441. declare module BABYLON {
  94442. /**
  94443. * Base class of all the textures in babylon.
  94444. * It groups all the common properties the materials, post process, lights... might need
  94445. * in order to make a correct use of the texture.
  94446. */
  94447. export class BaseTexture implements IAnimatable {
  94448. /**
  94449. * Default anisotropic filtering level for the application.
  94450. * It is set to 4 as a good tradeoff between perf and quality.
  94451. */
  94452. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94453. /**
  94454. * Gets or sets the unique id of the texture
  94455. */
  94456. uniqueId: number;
  94457. /**
  94458. * Define the name of the texture.
  94459. */
  94460. name: string;
  94461. /**
  94462. * Gets or sets an object used to store user defined information.
  94463. */
  94464. metadata: any;
  94465. /**
  94466. * For internal use only. Please do not use.
  94467. */
  94468. reservedDataStore: any;
  94469. private _hasAlpha;
  94470. /**
  94471. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94472. */
  94473. hasAlpha: boolean;
  94474. /**
  94475. * Defines if the alpha value should be determined via the rgb values.
  94476. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94477. */
  94478. getAlphaFromRGB: boolean;
  94479. /**
  94480. * Intensity or strength of the texture.
  94481. * It is commonly used by materials to fine tune the intensity of the texture
  94482. */
  94483. level: number;
  94484. /**
  94485. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94486. * This is part of the texture as textures usually maps to one uv set.
  94487. */
  94488. coordinatesIndex: number;
  94489. private _coordinatesMode;
  94490. /**
  94491. * How a texture is mapped.
  94492. *
  94493. * | Value | Type | Description |
  94494. * | ----- | ----------------------------------- | ----------- |
  94495. * | 0 | EXPLICIT_MODE | |
  94496. * | 1 | SPHERICAL_MODE | |
  94497. * | 2 | PLANAR_MODE | |
  94498. * | 3 | CUBIC_MODE | |
  94499. * | 4 | PROJECTION_MODE | |
  94500. * | 5 | SKYBOX_MODE | |
  94501. * | 6 | INVCUBIC_MODE | |
  94502. * | 7 | EQUIRECTANGULAR_MODE | |
  94503. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94504. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94505. */
  94506. coordinatesMode: number;
  94507. /**
  94508. * | Value | Type | Description |
  94509. * | ----- | ------------------ | ----------- |
  94510. * | 0 | CLAMP_ADDRESSMODE | |
  94511. * | 1 | WRAP_ADDRESSMODE | |
  94512. * | 2 | MIRROR_ADDRESSMODE | |
  94513. */
  94514. wrapU: number;
  94515. /**
  94516. * | Value | Type | Description |
  94517. * | ----- | ------------------ | ----------- |
  94518. * | 0 | CLAMP_ADDRESSMODE | |
  94519. * | 1 | WRAP_ADDRESSMODE | |
  94520. * | 2 | MIRROR_ADDRESSMODE | |
  94521. */
  94522. wrapV: number;
  94523. /**
  94524. * | Value | Type | Description |
  94525. * | ----- | ------------------ | ----------- |
  94526. * | 0 | CLAMP_ADDRESSMODE | |
  94527. * | 1 | WRAP_ADDRESSMODE | |
  94528. * | 2 | MIRROR_ADDRESSMODE | |
  94529. */
  94530. wrapR: number;
  94531. /**
  94532. * With compliant hardware and browser (supporting anisotropic filtering)
  94533. * this defines the level of anisotropic filtering in the texture.
  94534. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94535. */
  94536. anisotropicFilteringLevel: number;
  94537. /**
  94538. * Define if the texture is a cube texture or if false a 2d texture.
  94539. */
  94540. isCube: boolean;
  94541. /**
  94542. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94543. */
  94544. is3D: boolean;
  94545. /**
  94546. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94547. * HDR texture are usually stored in linear space.
  94548. * This only impacts the PBR and Background materials
  94549. */
  94550. gammaSpace: boolean;
  94551. /**
  94552. * Gets or sets whether or not the texture contains RGBD data.
  94553. */
  94554. isRGBD: boolean;
  94555. /**
  94556. * Is Z inverted in the texture (useful in a cube texture).
  94557. */
  94558. invertZ: boolean;
  94559. /**
  94560. * Are mip maps generated for this texture or not.
  94561. */
  94562. readonly noMipmap: boolean;
  94563. /**
  94564. * @hidden
  94565. */
  94566. lodLevelInAlpha: boolean;
  94567. /**
  94568. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94569. */
  94570. lodGenerationOffset: number;
  94571. /**
  94572. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94573. */
  94574. lodGenerationScale: number;
  94575. /**
  94576. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94577. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94578. * average roughness values.
  94579. */
  94580. linearSpecularLOD: boolean;
  94581. /**
  94582. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94583. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94584. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94585. */
  94586. irradianceTexture: Nullable<BaseTexture>;
  94587. /**
  94588. * Define if the texture is a render target.
  94589. */
  94590. isRenderTarget: boolean;
  94591. /**
  94592. * Define the unique id of the texture in the scene.
  94593. */
  94594. readonly uid: string;
  94595. /**
  94596. * Return a string representation of the texture.
  94597. * @returns the texture as a string
  94598. */
  94599. toString(): string;
  94600. /**
  94601. * Get the class name of the texture.
  94602. * @returns "BaseTexture"
  94603. */
  94604. getClassName(): string;
  94605. /**
  94606. * Define the list of animation attached to the texture.
  94607. */
  94608. animations: Animation[];
  94609. /**
  94610. * An event triggered when the texture is disposed.
  94611. */
  94612. onDisposeObservable: Observable<BaseTexture>;
  94613. private _onDisposeObserver;
  94614. /**
  94615. * Callback triggered when the texture has been disposed.
  94616. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94617. */
  94618. onDispose: () => void;
  94619. /**
  94620. * Define the current state of the loading sequence when in delayed load mode.
  94621. */
  94622. delayLoadState: number;
  94623. private _scene;
  94624. /** @hidden */
  94625. _texture: Nullable<InternalTexture>;
  94626. private _uid;
  94627. /**
  94628. * Define if the texture is preventinga material to render or not.
  94629. * If not and the texture is not ready, the engine will use a default black texture instead.
  94630. */
  94631. readonly isBlocking: boolean;
  94632. /**
  94633. * Instantiates a new BaseTexture.
  94634. * Base class of all the textures in babylon.
  94635. * It groups all the common properties the materials, post process, lights... might need
  94636. * in order to make a correct use of the texture.
  94637. * @param scene Define the scene the texture blongs to
  94638. */
  94639. constructor(scene: Nullable<Scene>);
  94640. /**
  94641. * Get the scene the texture belongs to.
  94642. * @returns the scene or null if undefined
  94643. */
  94644. getScene(): Nullable<Scene>;
  94645. /**
  94646. * Get the texture transform matrix used to offset tile the texture for istance.
  94647. * @returns the transformation matrix
  94648. */
  94649. getTextureMatrix(): Matrix;
  94650. /**
  94651. * Get the texture reflection matrix used to rotate/transform the reflection.
  94652. * @returns the reflection matrix
  94653. */
  94654. getReflectionTextureMatrix(): Matrix;
  94655. /**
  94656. * Get the underlying lower level texture from Babylon.
  94657. * @returns the insternal texture
  94658. */
  94659. getInternalTexture(): Nullable<InternalTexture>;
  94660. /**
  94661. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94662. * @returns true if ready or not blocking
  94663. */
  94664. isReadyOrNotBlocking(): boolean;
  94665. /**
  94666. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94667. * @returns true if fully ready
  94668. */
  94669. isReady(): boolean;
  94670. private _cachedSize;
  94671. /**
  94672. * Get the size of the texture.
  94673. * @returns the texture size.
  94674. */
  94675. getSize(): ISize;
  94676. /**
  94677. * Get the base size of the texture.
  94678. * It can be different from the size if the texture has been resized for POT for instance
  94679. * @returns the base size
  94680. */
  94681. getBaseSize(): ISize;
  94682. /**
  94683. * Update the sampling mode of the texture.
  94684. * Default is Trilinear mode.
  94685. *
  94686. * | Value | Type | Description |
  94687. * | ----- | ------------------ | ----------- |
  94688. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94689. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94690. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94691. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94692. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94693. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94694. * | 7 | NEAREST_LINEAR | |
  94695. * | 8 | NEAREST_NEAREST | |
  94696. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94697. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94698. * | 11 | LINEAR_LINEAR | |
  94699. * | 12 | LINEAR_NEAREST | |
  94700. *
  94701. * > _mag_: magnification filter (close to the viewer)
  94702. * > _min_: minification filter (far from the viewer)
  94703. * > _mip_: filter used between mip map levels
  94704. *@param samplingMode Define the new sampling mode of the texture
  94705. */
  94706. updateSamplingMode(samplingMode: number): void;
  94707. /**
  94708. * Scales the texture if is `canRescale()`
  94709. * @param ratio the resize factor we want to use to rescale
  94710. */
  94711. scale(ratio: number): void;
  94712. /**
  94713. * Get if the texture can rescale.
  94714. */
  94715. readonly canRescale: boolean;
  94716. /** @hidden */
  94717. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94718. /** @hidden */
  94719. _rebuild(): void;
  94720. /**
  94721. * Triggers the load sequence in delayed load mode.
  94722. */
  94723. delayLoad(): void;
  94724. /**
  94725. * Clones the texture.
  94726. * @returns the cloned texture
  94727. */
  94728. clone(): Nullable<BaseTexture>;
  94729. /**
  94730. * Get the texture underlying type (INT, FLOAT...)
  94731. */
  94732. readonly textureType: number;
  94733. /**
  94734. * Get the texture underlying format (RGB, RGBA...)
  94735. */
  94736. readonly textureFormat: number;
  94737. /**
  94738. * Indicates that textures need to be re-calculated for all materials
  94739. */
  94740. protected _markAllSubMeshesAsTexturesDirty(): void;
  94741. /**
  94742. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94743. * This will returns an RGBA array buffer containing either in values (0-255) or
  94744. * float values (0-1) depending of the underlying buffer type.
  94745. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94746. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94747. * @param buffer defines a user defined buffer to fill with data (can be null)
  94748. * @returns The Array buffer containing the pixels data.
  94749. */
  94750. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94751. /**
  94752. * Release and destroy the underlying lower level texture aka internalTexture.
  94753. */
  94754. releaseInternalTexture(): void;
  94755. /** @hidden */
  94756. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94757. /** @hidden */
  94758. readonly _lodTextureMid: Nullable<BaseTexture>;
  94759. /** @hidden */
  94760. readonly _lodTextureLow: Nullable<BaseTexture>;
  94761. /**
  94762. * Dispose the texture and release its associated resources.
  94763. */
  94764. dispose(): void;
  94765. /**
  94766. * Serialize the texture into a JSON representation that can be parsed later on.
  94767. * @returns the JSON representation of the texture
  94768. */
  94769. serialize(): any;
  94770. /**
  94771. * Helper function to be called back once a list of texture contains only ready textures.
  94772. * @param textures Define the list of textures to wait for
  94773. * @param callback Define the callback triggered once the entire list will be ready
  94774. */
  94775. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94776. }
  94777. }
  94778. declare module BABYLON {
  94779. /**
  94780. * Options to be used when creating an effect.
  94781. */
  94782. export interface IEffectCreationOptions {
  94783. /**
  94784. * Atrributes that will be used in the shader.
  94785. */
  94786. attributes: string[];
  94787. /**
  94788. * Uniform varible names that will be set in the shader.
  94789. */
  94790. uniformsNames: string[];
  94791. /**
  94792. * Uniform buffer varible names that will be set in the shader.
  94793. */
  94794. uniformBuffersNames: string[];
  94795. /**
  94796. * Sampler texture variable names that will be set in the shader.
  94797. */
  94798. samplers: string[];
  94799. /**
  94800. * Define statements that will be set in the shader.
  94801. */
  94802. defines: any;
  94803. /**
  94804. * Possible fallbacks for this effect to improve performance when needed.
  94805. */
  94806. fallbacks: Nullable<IEffectFallbacks>;
  94807. /**
  94808. * Callback that will be called when the shader is compiled.
  94809. */
  94810. onCompiled: Nullable<(effect: Effect) => void>;
  94811. /**
  94812. * Callback that will be called if an error occurs during shader compilation.
  94813. */
  94814. onError: Nullable<(effect: Effect, errors: string) => void>;
  94815. /**
  94816. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94817. */
  94818. indexParameters?: any;
  94819. /**
  94820. * Max number of lights that can be used in the shader.
  94821. */
  94822. maxSimultaneousLights?: number;
  94823. /**
  94824. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94825. */
  94826. transformFeedbackVaryings?: Nullable<string[]>;
  94827. }
  94828. /**
  94829. * Effect containing vertex and fragment shader that can be executed on an object.
  94830. */
  94831. export class Effect implements IDisposable {
  94832. /**
  94833. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94834. */
  94835. static ShadersRepository: string;
  94836. /**
  94837. * Name of the effect.
  94838. */
  94839. name: any;
  94840. /**
  94841. * String container all the define statements that should be set on the shader.
  94842. */
  94843. defines: string;
  94844. /**
  94845. * Callback that will be called when the shader is compiled.
  94846. */
  94847. onCompiled: Nullable<(effect: Effect) => void>;
  94848. /**
  94849. * Callback that will be called if an error occurs during shader compilation.
  94850. */
  94851. onError: Nullable<(effect: Effect, errors: string) => void>;
  94852. /**
  94853. * Callback that will be called when effect is bound.
  94854. */
  94855. onBind: Nullable<(effect: Effect) => void>;
  94856. /**
  94857. * Unique ID of the effect.
  94858. */
  94859. uniqueId: number;
  94860. /**
  94861. * Observable that will be called when the shader is compiled.
  94862. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94863. */
  94864. onCompileObservable: Observable<Effect>;
  94865. /**
  94866. * Observable that will be called if an error occurs during shader compilation.
  94867. */
  94868. onErrorObservable: Observable<Effect>;
  94869. /** @hidden */
  94870. _onBindObservable: Nullable<Observable<Effect>>;
  94871. /**
  94872. * Observable that will be called when effect is bound.
  94873. */
  94874. readonly onBindObservable: Observable<Effect>;
  94875. /** @hidden */
  94876. _bonesComputationForcedToCPU: boolean;
  94877. private static _uniqueIdSeed;
  94878. private _engine;
  94879. private _uniformBuffersNames;
  94880. private _uniformsNames;
  94881. private _samplerList;
  94882. private _samplers;
  94883. private _isReady;
  94884. private _compilationError;
  94885. private _allFallbacksProcessed;
  94886. private _attributesNames;
  94887. private _attributes;
  94888. private _uniforms;
  94889. /**
  94890. * Key for the effect.
  94891. * @hidden
  94892. */
  94893. _key: string;
  94894. private _indexParameters;
  94895. private _fallbacks;
  94896. private _vertexSourceCode;
  94897. private _fragmentSourceCode;
  94898. private _vertexSourceCodeOverride;
  94899. private _fragmentSourceCodeOverride;
  94900. private _transformFeedbackVaryings;
  94901. /**
  94902. * Compiled shader to webGL program.
  94903. * @hidden
  94904. */
  94905. _pipelineContext: Nullable<IPipelineContext>;
  94906. private _valueCache;
  94907. private static _baseCache;
  94908. /**
  94909. * Instantiates an effect.
  94910. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94911. * @param baseName Name of the effect.
  94912. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94913. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94914. * @param samplers List of sampler variables that will be passed to the shader.
  94915. * @param engine Engine to be used to render the effect
  94916. * @param defines Define statements to be added to the shader.
  94917. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94918. * @param onCompiled Callback that will be called when the shader is compiled.
  94919. * @param onError Callback that will be called if an error occurs during shader compilation.
  94920. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94921. */
  94922. 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);
  94923. private _useFinalCode;
  94924. /**
  94925. * Unique key for this effect
  94926. */
  94927. readonly key: string;
  94928. /**
  94929. * If the effect has been compiled and prepared.
  94930. * @returns if the effect is compiled and prepared.
  94931. */
  94932. isReady(): boolean;
  94933. private _isReadyInternal;
  94934. /**
  94935. * The engine the effect was initialized with.
  94936. * @returns the engine.
  94937. */
  94938. getEngine(): Engine;
  94939. /**
  94940. * The pipeline context for this effect
  94941. * @returns the associated pipeline context
  94942. */
  94943. getPipelineContext(): Nullable<IPipelineContext>;
  94944. /**
  94945. * The set of names of attribute variables for the shader.
  94946. * @returns An array of attribute names.
  94947. */
  94948. getAttributesNames(): string[];
  94949. /**
  94950. * Returns the attribute at the given index.
  94951. * @param index The index of the attribute.
  94952. * @returns The location of the attribute.
  94953. */
  94954. getAttributeLocation(index: number): number;
  94955. /**
  94956. * Returns the attribute based on the name of the variable.
  94957. * @param name of the attribute to look up.
  94958. * @returns the attribute location.
  94959. */
  94960. getAttributeLocationByName(name: string): number;
  94961. /**
  94962. * The number of attributes.
  94963. * @returns the numnber of attributes.
  94964. */
  94965. getAttributesCount(): number;
  94966. /**
  94967. * Gets the index of a uniform variable.
  94968. * @param uniformName of the uniform to look up.
  94969. * @returns the index.
  94970. */
  94971. getUniformIndex(uniformName: string): number;
  94972. /**
  94973. * Returns the attribute based on the name of the variable.
  94974. * @param uniformName of the uniform to look up.
  94975. * @returns the location of the uniform.
  94976. */
  94977. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94978. /**
  94979. * Returns an array of sampler variable names
  94980. * @returns The array of sampler variable neames.
  94981. */
  94982. getSamplers(): string[];
  94983. /**
  94984. * The error from the last compilation.
  94985. * @returns the error string.
  94986. */
  94987. getCompilationError(): string;
  94988. /**
  94989. * Gets a boolean indicating that all fallbacks were used during compilation
  94990. * @returns true if all fallbacks were used
  94991. */
  94992. allFallbacksProcessed(): boolean;
  94993. /**
  94994. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94995. * @param func The callback to be used.
  94996. */
  94997. executeWhenCompiled(func: (effect: Effect) => void): void;
  94998. private _checkIsReady;
  94999. private _loadShader;
  95000. /**
  95001. * Recompiles the webGL program
  95002. * @param vertexSourceCode The source code for the vertex shader.
  95003. * @param fragmentSourceCode The source code for the fragment shader.
  95004. * @param onCompiled Callback called when completed.
  95005. * @param onError Callback called on error.
  95006. * @hidden
  95007. */
  95008. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95009. /**
  95010. * Prepares the effect
  95011. * @hidden
  95012. */
  95013. _prepareEffect(): void;
  95014. private _processCompilationErrors;
  95015. /**
  95016. * Checks if the effect is supported. (Must be called after compilation)
  95017. */
  95018. readonly isSupported: boolean;
  95019. /**
  95020. * Binds a texture to the engine to be used as output of the shader.
  95021. * @param channel Name of the output variable.
  95022. * @param texture Texture to bind.
  95023. * @hidden
  95024. */
  95025. _bindTexture(channel: string, texture: InternalTexture): void;
  95026. /**
  95027. * Sets a texture on the engine to be used in the shader.
  95028. * @param channel Name of the sampler variable.
  95029. * @param texture Texture to set.
  95030. */
  95031. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95032. /**
  95033. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95034. * @param channel Name of the sampler variable.
  95035. * @param texture Texture to set.
  95036. */
  95037. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95038. /**
  95039. * Sets an array of textures on the engine to be used in the shader.
  95040. * @param channel Name of the variable.
  95041. * @param textures Textures to set.
  95042. */
  95043. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95044. /**
  95045. * 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)
  95046. * @param channel Name of the sampler variable.
  95047. * @param postProcess Post process to get the input texture from.
  95048. */
  95049. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95050. /**
  95051. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95052. * 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)
  95053. * @param channel Name of the sampler variable.
  95054. * @param postProcess Post process to get the output texture from.
  95055. */
  95056. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95057. /** @hidden */
  95058. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95059. /** @hidden */
  95060. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95061. /** @hidden */
  95062. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95063. /** @hidden */
  95064. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95065. /**
  95066. * Binds a buffer to a uniform.
  95067. * @param buffer Buffer to bind.
  95068. * @param name Name of the uniform variable to bind to.
  95069. */
  95070. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95071. /**
  95072. * Binds block to a uniform.
  95073. * @param blockName Name of the block to bind.
  95074. * @param index Index to bind.
  95075. */
  95076. bindUniformBlock(blockName: string, index: number): void;
  95077. /**
  95078. * Sets an interger value on a uniform variable.
  95079. * @param uniformName Name of the variable.
  95080. * @param value Value to be set.
  95081. * @returns this effect.
  95082. */
  95083. setInt(uniformName: string, value: number): Effect;
  95084. /**
  95085. * Sets an int array on a uniform variable.
  95086. * @param uniformName Name of the variable.
  95087. * @param array array to be set.
  95088. * @returns this effect.
  95089. */
  95090. setIntArray(uniformName: string, array: Int32Array): Effect;
  95091. /**
  95092. * 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)
  95093. * @param uniformName Name of the variable.
  95094. * @param array array to be set.
  95095. * @returns this effect.
  95096. */
  95097. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95098. /**
  95099. * 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)
  95100. * @param uniformName Name of the variable.
  95101. * @param array array to be set.
  95102. * @returns this effect.
  95103. */
  95104. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95105. /**
  95106. * 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)
  95107. * @param uniformName Name of the variable.
  95108. * @param array array to be set.
  95109. * @returns this effect.
  95110. */
  95111. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95112. /**
  95113. * Sets an float array on a uniform variable.
  95114. * @param uniformName Name of the variable.
  95115. * @param array array to be set.
  95116. * @returns this effect.
  95117. */
  95118. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95119. /**
  95120. * 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)
  95121. * @param uniformName Name of the variable.
  95122. * @param array array to be set.
  95123. * @returns this effect.
  95124. */
  95125. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95126. /**
  95127. * 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)
  95128. * @param uniformName Name of the variable.
  95129. * @param array array to be set.
  95130. * @returns this effect.
  95131. */
  95132. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95133. /**
  95134. * 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)
  95135. * @param uniformName Name of the variable.
  95136. * @param array array to be set.
  95137. * @returns this effect.
  95138. */
  95139. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95140. /**
  95141. * Sets an array on a uniform variable.
  95142. * @param uniformName Name of the variable.
  95143. * @param array array to be set.
  95144. * @returns this effect.
  95145. */
  95146. setArray(uniformName: string, array: number[]): Effect;
  95147. /**
  95148. * 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)
  95149. * @param uniformName Name of the variable.
  95150. * @param array array to be set.
  95151. * @returns this effect.
  95152. */
  95153. setArray2(uniformName: string, array: number[]): Effect;
  95154. /**
  95155. * 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)
  95156. * @param uniformName Name of the variable.
  95157. * @param array array to be set.
  95158. * @returns this effect.
  95159. */
  95160. setArray3(uniformName: string, array: number[]): Effect;
  95161. /**
  95162. * 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)
  95163. * @param uniformName Name of the variable.
  95164. * @param array array to be set.
  95165. * @returns this effect.
  95166. */
  95167. setArray4(uniformName: string, array: number[]): Effect;
  95168. /**
  95169. * Sets matrices on a uniform variable.
  95170. * @param uniformName Name of the variable.
  95171. * @param matrices matrices to be set.
  95172. * @returns this effect.
  95173. */
  95174. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95175. /**
  95176. * Sets matrix on a uniform variable.
  95177. * @param uniformName Name of the variable.
  95178. * @param matrix matrix to be set.
  95179. * @returns this effect.
  95180. */
  95181. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95182. /**
  95183. * 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)
  95184. * @param uniformName Name of the variable.
  95185. * @param matrix matrix to be set.
  95186. * @returns this effect.
  95187. */
  95188. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95189. /**
  95190. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95191. * @param uniformName Name of the variable.
  95192. * @param matrix matrix to be set.
  95193. * @returns this effect.
  95194. */
  95195. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95196. /**
  95197. * Sets a float on a uniform variable.
  95198. * @param uniformName Name of the variable.
  95199. * @param value value to be set.
  95200. * @returns this effect.
  95201. */
  95202. setFloat(uniformName: string, value: number): Effect;
  95203. /**
  95204. * Sets a boolean on a uniform variable.
  95205. * @param uniformName Name of the variable.
  95206. * @param bool value to be set.
  95207. * @returns this effect.
  95208. */
  95209. setBool(uniformName: string, bool: boolean): Effect;
  95210. /**
  95211. * Sets a Vector2 on a uniform variable.
  95212. * @param uniformName Name of the variable.
  95213. * @param vector2 vector2 to be set.
  95214. * @returns this effect.
  95215. */
  95216. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95217. /**
  95218. * Sets a float2 on a uniform variable.
  95219. * @param uniformName Name of the variable.
  95220. * @param x First float in float2.
  95221. * @param y Second float in float2.
  95222. * @returns this effect.
  95223. */
  95224. setFloat2(uniformName: string, x: number, y: number): Effect;
  95225. /**
  95226. * Sets a Vector3 on a uniform variable.
  95227. * @param uniformName Name of the variable.
  95228. * @param vector3 Value to be set.
  95229. * @returns this effect.
  95230. */
  95231. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95232. /**
  95233. * Sets a float3 on a uniform variable.
  95234. * @param uniformName Name of the variable.
  95235. * @param x First float in float3.
  95236. * @param y Second float in float3.
  95237. * @param z Third float in float3.
  95238. * @returns this effect.
  95239. */
  95240. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95241. /**
  95242. * Sets a Vector4 on a uniform variable.
  95243. * @param uniformName Name of the variable.
  95244. * @param vector4 Value to be set.
  95245. * @returns this effect.
  95246. */
  95247. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95248. /**
  95249. * Sets a float4 on a uniform variable.
  95250. * @param uniformName Name of the variable.
  95251. * @param x First float in float4.
  95252. * @param y Second float in float4.
  95253. * @param z Third float in float4.
  95254. * @param w Fourth float in float4.
  95255. * @returns this effect.
  95256. */
  95257. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95258. /**
  95259. * Sets a Color3 on a uniform variable.
  95260. * @param uniformName Name of the variable.
  95261. * @param color3 Value to be set.
  95262. * @returns this effect.
  95263. */
  95264. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95265. /**
  95266. * Sets a Color4 on a uniform variable.
  95267. * @param uniformName Name of the variable.
  95268. * @param color3 Value to be set.
  95269. * @param alpha Alpha value to be set.
  95270. * @returns this effect.
  95271. */
  95272. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95273. /**
  95274. * Sets a Color4 on a uniform variable
  95275. * @param uniformName defines the name of the variable
  95276. * @param color4 defines the value to be set
  95277. * @returns this effect.
  95278. */
  95279. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95280. /** Release all associated resources */
  95281. dispose(): void;
  95282. /**
  95283. * This function will add a new shader to the shader store
  95284. * @param name the name of the shader
  95285. * @param pixelShader optional pixel shader content
  95286. * @param vertexShader optional vertex shader content
  95287. */
  95288. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95289. /**
  95290. * Store of each shader (The can be looked up using effect.key)
  95291. */
  95292. static ShadersStore: {
  95293. [key: string]: string;
  95294. };
  95295. /**
  95296. * Store of each included file for a shader (The can be looked up using effect.key)
  95297. */
  95298. static IncludesShadersStore: {
  95299. [key: string]: string;
  95300. };
  95301. /**
  95302. * Resets the cache of effects.
  95303. */
  95304. static ResetCache(): void;
  95305. }
  95306. }
  95307. declare module BABYLON {
  95308. /**
  95309. * Class used to describe the capabilities of the engine relatively to the current browser
  95310. */
  95311. export class EngineCapabilities {
  95312. /** Maximum textures units per fragment shader */
  95313. maxTexturesImageUnits: number;
  95314. /** Maximum texture units per vertex shader */
  95315. maxVertexTextureImageUnits: number;
  95316. /** Maximum textures units in the entire pipeline */
  95317. maxCombinedTexturesImageUnits: number;
  95318. /** Maximum texture size */
  95319. maxTextureSize: number;
  95320. /** Maximum cube texture size */
  95321. maxCubemapTextureSize: number;
  95322. /** Maximum render texture size */
  95323. maxRenderTextureSize: number;
  95324. /** Maximum number of vertex attributes */
  95325. maxVertexAttribs: number;
  95326. /** Maximum number of varyings */
  95327. maxVaryingVectors: number;
  95328. /** Maximum number of uniforms per vertex shader */
  95329. maxVertexUniformVectors: number;
  95330. /** Maximum number of uniforms per fragment shader */
  95331. maxFragmentUniformVectors: number;
  95332. /** Defines if standard derivates (dx/dy) are supported */
  95333. standardDerivatives: boolean;
  95334. /** Defines if s3tc texture compression is supported */
  95335. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95336. /** Defines if pvrtc texture compression is supported */
  95337. pvrtc: any;
  95338. /** Defines if etc1 texture compression is supported */
  95339. etc1: any;
  95340. /** Defines if etc2 texture compression is supported */
  95341. etc2: any;
  95342. /** Defines if astc texture compression is supported */
  95343. astc: any;
  95344. /** Defines if float textures are supported */
  95345. textureFloat: boolean;
  95346. /** Defines if vertex array objects are supported */
  95347. vertexArrayObject: boolean;
  95348. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95349. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95350. /** Gets the maximum level of anisotropy supported */
  95351. maxAnisotropy: number;
  95352. /** Defines if instancing is supported */
  95353. instancedArrays: boolean;
  95354. /** Defines if 32 bits indices are supported */
  95355. uintIndices: boolean;
  95356. /** Defines if high precision shaders are supported */
  95357. highPrecisionShaderSupported: boolean;
  95358. /** Defines if depth reading in the fragment shader is supported */
  95359. fragmentDepthSupported: boolean;
  95360. /** Defines if float texture linear filtering is supported*/
  95361. textureFloatLinearFiltering: boolean;
  95362. /** Defines if rendering to float textures is supported */
  95363. textureFloatRender: boolean;
  95364. /** Defines if half float textures are supported*/
  95365. textureHalfFloat: boolean;
  95366. /** Defines if half float texture linear filtering is supported*/
  95367. textureHalfFloatLinearFiltering: boolean;
  95368. /** Defines if rendering to half float textures is supported */
  95369. textureHalfFloatRender: boolean;
  95370. /** Defines if textureLOD shader command is supported */
  95371. textureLOD: boolean;
  95372. /** Defines if draw buffers extension is supported */
  95373. drawBuffersExtension: boolean;
  95374. /** Defines if depth textures are supported */
  95375. depthTextureExtension: boolean;
  95376. /** Defines if float color buffer are supported */
  95377. colorBufferFloat: boolean;
  95378. /** Gets disjoint timer query extension (null if not supported) */
  95379. timerQuery: EXT_disjoint_timer_query;
  95380. /** Defines if timestamp can be used with timer query */
  95381. canUseTimestampForTimerQuery: boolean;
  95382. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95383. multiview: any;
  95384. /** Function used to let the system compiles shaders in background */
  95385. parallelShaderCompile: {
  95386. COMPLETION_STATUS_KHR: number;
  95387. };
  95388. /** Max number of texture samples for MSAA */
  95389. maxMSAASamples: number;
  95390. /** Defines if the blend min max extension is supported */
  95391. blendMinMax: boolean;
  95392. }
  95393. }
  95394. declare module BABYLON {
  95395. /**
  95396. * @hidden
  95397. **/
  95398. export class DepthCullingState {
  95399. private _isDepthTestDirty;
  95400. private _isDepthMaskDirty;
  95401. private _isDepthFuncDirty;
  95402. private _isCullFaceDirty;
  95403. private _isCullDirty;
  95404. private _isZOffsetDirty;
  95405. private _isFrontFaceDirty;
  95406. private _depthTest;
  95407. private _depthMask;
  95408. private _depthFunc;
  95409. private _cull;
  95410. private _cullFace;
  95411. private _zOffset;
  95412. private _frontFace;
  95413. /**
  95414. * Initializes the state.
  95415. */
  95416. constructor();
  95417. readonly isDirty: boolean;
  95418. zOffset: number;
  95419. cullFace: Nullable<number>;
  95420. cull: Nullable<boolean>;
  95421. depthFunc: Nullable<number>;
  95422. depthMask: boolean;
  95423. depthTest: boolean;
  95424. frontFace: Nullable<number>;
  95425. reset(): void;
  95426. apply(gl: WebGLRenderingContext): void;
  95427. }
  95428. }
  95429. declare module BABYLON {
  95430. /**
  95431. * @hidden
  95432. **/
  95433. export class StencilState {
  95434. /** 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 */
  95435. static readonly ALWAYS: number;
  95436. /** Passed to stencilOperation to specify that stencil value must be kept */
  95437. static readonly KEEP: number;
  95438. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95439. static readonly REPLACE: number;
  95440. private _isStencilTestDirty;
  95441. private _isStencilMaskDirty;
  95442. private _isStencilFuncDirty;
  95443. private _isStencilOpDirty;
  95444. private _stencilTest;
  95445. private _stencilMask;
  95446. private _stencilFunc;
  95447. private _stencilFuncRef;
  95448. private _stencilFuncMask;
  95449. private _stencilOpStencilFail;
  95450. private _stencilOpDepthFail;
  95451. private _stencilOpStencilDepthPass;
  95452. readonly isDirty: boolean;
  95453. stencilFunc: number;
  95454. stencilFuncRef: number;
  95455. stencilFuncMask: number;
  95456. stencilOpStencilFail: number;
  95457. stencilOpDepthFail: number;
  95458. stencilOpStencilDepthPass: number;
  95459. stencilMask: number;
  95460. stencilTest: boolean;
  95461. constructor();
  95462. reset(): void;
  95463. apply(gl: WebGLRenderingContext): void;
  95464. }
  95465. }
  95466. declare module BABYLON {
  95467. /**
  95468. * @hidden
  95469. **/
  95470. export class AlphaState {
  95471. private _isAlphaBlendDirty;
  95472. private _isBlendFunctionParametersDirty;
  95473. private _isBlendEquationParametersDirty;
  95474. private _isBlendConstantsDirty;
  95475. private _alphaBlend;
  95476. private _blendFunctionParameters;
  95477. private _blendEquationParameters;
  95478. private _blendConstants;
  95479. /**
  95480. * Initializes the state.
  95481. */
  95482. constructor();
  95483. readonly isDirty: boolean;
  95484. alphaBlend: boolean;
  95485. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95486. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95487. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95488. reset(): void;
  95489. apply(gl: WebGLRenderingContext): void;
  95490. }
  95491. }
  95492. declare module BABYLON {
  95493. /** @hidden */
  95494. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95495. attributeProcessor(attribute: string): string;
  95496. varyingProcessor(varying: string, isFragment: boolean): string;
  95497. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95498. }
  95499. }
  95500. declare module BABYLON {
  95501. /**
  95502. * Interface for attribute information associated with buffer instanciation
  95503. */
  95504. export class InstancingAttributeInfo {
  95505. /**
  95506. * Index/offset of the attribute in the vertex shader
  95507. */
  95508. index: number;
  95509. /**
  95510. * size of the attribute, 1, 2, 3 or 4
  95511. */
  95512. attributeSize: number;
  95513. /**
  95514. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95515. * default is FLOAT
  95516. */
  95517. attribyteType: number;
  95518. /**
  95519. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95520. */
  95521. normalized: boolean;
  95522. /**
  95523. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95524. */
  95525. offset: number;
  95526. /**
  95527. * Name of the GLSL attribute, for debugging purpose only
  95528. */
  95529. attributeName: string;
  95530. }
  95531. }
  95532. declare module BABYLON {
  95533. interface ThinEngine {
  95534. /**
  95535. * Update a video texture
  95536. * @param texture defines the texture to update
  95537. * @param video defines the video element to use
  95538. * @param invertY defines if data must be stored with Y axis inverted
  95539. */
  95540. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95541. }
  95542. }
  95543. declare module BABYLON {
  95544. /**
  95545. * Settings for finer control over video usage
  95546. */
  95547. export interface VideoTextureSettings {
  95548. /**
  95549. * Applies `autoplay` to video, if specified
  95550. */
  95551. autoPlay?: boolean;
  95552. /**
  95553. * Applies `loop` to video, if specified
  95554. */
  95555. loop?: boolean;
  95556. /**
  95557. * Automatically updates internal texture from video at every frame in the render loop
  95558. */
  95559. autoUpdateTexture: boolean;
  95560. /**
  95561. * Image src displayed during the video loading or until the user interacts with the video.
  95562. */
  95563. poster?: string;
  95564. }
  95565. /**
  95566. * If you want to display a video in your scene, this is the special texture for that.
  95567. * This special texture works similar to other textures, with the exception of a few parameters.
  95568. * @see https://doc.babylonjs.com/how_to/video_texture
  95569. */
  95570. export class VideoTexture extends Texture {
  95571. /**
  95572. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95573. */
  95574. readonly autoUpdateTexture: boolean;
  95575. /**
  95576. * The video instance used by the texture internally
  95577. */
  95578. readonly video: HTMLVideoElement;
  95579. private _onUserActionRequestedObservable;
  95580. /**
  95581. * Event triggerd when a dom action is required by the user to play the video.
  95582. * This happens due to recent changes in browser policies preventing video to auto start.
  95583. */
  95584. readonly onUserActionRequestedObservable: Observable<Texture>;
  95585. private _generateMipMaps;
  95586. private _engine;
  95587. private _stillImageCaptured;
  95588. private _displayingPosterTexture;
  95589. private _settings;
  95590. private _createInternalTextureOnEvent;
  95591. private _frameId;
  95592. /**
  95593. * Creates a video texture.
  95594. * If you want to display a video in your scene, this is the special texture for that.
  95595. * This special texture works similar to other textures, with the exception of a few parameters.
  95596. * @see https://doc.babylonjs.com/how_to/video_texture
  95597. * @param name optional name, will detect from video source, if not defined
  95598. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95599. * @param scene is obviously the current scene.
  95600. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95601. * @param invertY is false by default but can be used to invert video on Y axis
  95602. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95603. * @param settings allows finer control over video usage
  95604. */
  95605. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95606. private _getName;
  95607. private _getVideo;
  95608. private _createInternalTexture;
  95609. private reset;
  95610. /**
  95611. * @hidden Internal method to initiate `update`.
  95612. */
  95613. _rebuild(): void;
  95614. /**
  95615. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95616. */
  95617. update(): void;
  95618. /**
  95619. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95620. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95621. */
  95622. updateTexture(isVisible: boolean): void;
  95623. protected _updateInternalTexture: () => void;
  95624. /**
  95625. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95626. * @param url New url.
  95627. */
  95628. updateURL(url: string): void;
  95629. /**
  95630. * Dispose the texture and release its associated resources.
  95631. */
  95632. dispose(): void;
  95633. /**
  95634. * Creates a video texture straight from a stream.
  95635. * @param scene Define the scene the texture should be created in
  95636. * @param stream Define the stream the texture should be created from
  95637. * @returns The created video texture as a promise
  95638. */
  95639. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95640. /**
  95641. * Creates a video texture straight from your WebCam video feed.
  95642. * @param scene Define the scene the texture should be created in
  95643. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95644. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95645. * @returns The created video texture as a promise
  95646. */
  95647. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95648. minWidth: number;
  95649. maxWidth: number;
  95650. minHeight: number;
  95651. maxHeight: number;
  95652. deviceId: string;
  95653. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95654. /**
  95655. * Creates a video texture straight from your WebCam video feed.
  95656. * @param scene Define the scene the texture should be created in
  95657. * @param onReady Define a callback to triggered once the texture will be ready
  95658. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95659. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95660. */
  95661. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95662. minWidth: number;
  95663. maxWidth: number;
  95664. minHeight: number;
  95665. maxHeight: number;
  95666. deviceId: string;
  95667. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95668. }
  95669. }
  95670. declare module BABYLON {
  95671. /**
  95672. * Defines the interface used by objects working like Scene
  95673. * @hidden
  95674. */
  95675. interface ISceneLike {
  95676. _addPendingData(data: any): void;
  95677. _removePendingData(data: any): void;
  95678. offlineProvider: IOfflineProvider;
  95679. }
  95680. /** Interface defining initialization parameters for Engine class */
  95681. export interface EngineOptions extends WebGLContextAttributes {
  95682. /**
  95683. * Defines if the engine should no exceed a specified device ratio
  95684. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95685. */
  95686. limitDeviceRatio?: number;
  95687. /**
  95688. * Defines if webvr should be enabled automatically
  95689. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95690. */
  95691. autoEnableWebVR?: boolean;
  95692. /**
  95693. * Defines if webgl2 should be turned off even if supported
  95694. * @see http://doc.babylonjs.com/features/webgl2
  95695. */
  95696. disableWebGL2Support?: boolean;
  95697. /**
  95698. * Defines if webaudio should be initialized as well
  95699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95700. */
  95701. audioEngine?: boolean;
  95702. /**
  95703. * Defines if animations should run using a deterministic lock step
  95704. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95705. */
  95706. deterministicLockstep?: boolean;
  95707. /** Defines the maximum steps to use with deterministic lock step mode */
  95708. lockstepMaxSteps?: number;
  95709. /**
  95710. * Defines that engine should ignore context lost events
  95711. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95712. */
  95713. doNotHandleContextLost?: boolean;
  95714. /**
  95715. * Defines that engine should ignore modifying touch action attribute and style
  95716. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95717. */
  95718. doNotHandleTouchAction?: boolean;
  95719. /**
  95720. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95721. */
  95722. useHighPrecisionFloats?: boolean;
  95723. }
  95724. /**
  95725. * The base engine class (root of all engines)
  95726. */
  95727. export class ThinEngine {
  95728. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95729. static ExceptionList: ({
  95730. key: string;
  95731. capture: string;
  95732. captureConstraint: number;
  95733. targets: string[];
  95734. } | {
  95735. key: string;
  95736. capture: null;
  95737. captureConstraint: null;
  95738. targets: string[];
  95739. })[];
  95740. /** @hidden */
  95741. static _TextureLoaders: IInternalTextureLoader[];
  95742. /**
  95743. * Returns the current npm package of the sdk
  95744. */
  95745. static readonly NpmPackage: string;
  95746. /**
  95747. * Returns the current version of the framework
  95748. */
  95749. static readonly Version: string;
  95750. /**
  95751. * Returns a string describing the current engine
  95752. */
  95753. readonly description: string;
  95754. /**
  95755. * Gets or sets the epsilon value used by collision engine
  95756. */
  95757. static CollisionsEpsilon: number;
  95758. /**
  95759. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95760. */
  95761. static ShadersRepository: string;
  95762. /** @hidden */
  95763. _shaderProcessor: IShaderProcessor;
  95764. /**
  95765. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95766. */
  95767. forcePOTTextures: boolean;
  95768. /**
  95769. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95770. */
  95771. isFullscreen: boolean;
  95772. /**
  95773. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95774. */
  95775. cullBackFaces: boolean;
  95776. /**
  95777. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95778. */
  95779. renderEvenInBackground: boolean;
  95780. /**
  95781. * Gets or sets a boolean indicating that cache can be kept between frames
  95782. */
  95783. preventCacheWipeBetweenFrames: boolean;
  95784. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95785. validateShaderPrograms: boolean;
  95786. /**
  95787. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95788. */
  95789. disableUniformBuffers: boolean;
  95790. /** @hidden */
  95791. _uniformBuffers: UniformBuffer[];
  95792. /**
  95793. * Gets a boolean indicating that the engine supports uniform buffers
  95794. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95795. */
  95796. readonly supportsUniformBuffers: boolean;
  95797. /** @hidden */
  95798. _gl: WebGLRenderingContext;
  95799. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95800. protected _windowIsBackground: boolean;
  95801. protected _webGLVersion: number;
  95802. protected _highPrecisionShadersAllowed: boolean;
  95803. /** @hidden */
  95804. readonly _shouldUseHighPrecisionShader: boolean;
  95805. /**
  95806. * Gets a boolean indicating that only power of 2 textures are supported
  95807. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95808. */
  95809. readonly needPOTTextures: boolean;
  95810. /** @hidden */
  95811. _badOS: boolean;
  95812. /** @hidden */
  95813. _badDesktopOS: boolean;
  95814. private _hardwareScalingLevel;
  95815. /** @hidden */
  95816. _caps: EngineCapabilities;
  95817. private _isStencilEnable;
  95818. protected _colorWrite: boolean;
  95819. private _glVersion;
  95820. private _glRenderer;
  95821. private _glVendor;
  95822. /** @hidden */
  95823. _videoTextureSupported: boolean;
  95824. protected _renderingQueueLaunched: boolean;
  95825. protected _activeRenderLoops: (() => void)[];
  95826. /**
  95827. * Observable signaled when a context lost event is raised
  95828. */
  95829. onContextLostObservable: Observable<ThinEngine>;
  95830. /**
  95831. * Observable signaled when a context restored event is raised
  95832. */
  95833. onContextRestoredObservable: Observable<ThinEngine>;
  95834. private _onContextLost;
  95835. private _onContextRestored;
  95836. protected _contextWasLost: boolean;
  95837. /** @hidden */
  95838. _doNotHandleContextLost: boolean;
  95839. /**
  95840. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95842. */
  95843. doNotHandleContextLost: boolean;
  95844. /**
  95845. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95846. */
  95847. disableVertexArrayObjects: boolean;
  95848. /** @hidden */
  95849. protected _depthCullingState: DepthCullingState;
  95850. /** @hidden */
  95851. protected _stencilState: StencilState;
  95852. /** @hidden */
  95853. protected _alphaState: AlphaState;
  95854. /** @hidden */
  95855. _internalTexturesCache: InternalTexture[];
  95856. /** @hidden */
  95857. protected _activeChannel: number;
  95858. private _currentTextureChannel;
  95859. /** @hidden */
  95860. protected _boundTexturesCache: {
  95861. [key: string]: Nullable<InternalTexture>;
  95862. };
  95863. /** @hidden */
  95864. protected _currentEffect: Nullable<Effect>;
  95865. /** @hidden */
  95866. protected _currentProgram: Nullable<WebGLProgram>;
  95867. private _compiledEffects;
  95868. private _vertexAttribArraysEnabled;
  95869. /** @hidden */
  95870. protected _cachedViewport: Nullable<IViewportLike>;
  95871. private _cachedVertexArrayObject;
  95872. /** @hidden */
  95873. protected _cachedVertexBuffers: any;
  95874. /** @hidden */
  95875. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95876. /** @hidden */
  95877. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95878. /** @hidden */
  95879. _currentRenderTarget: Nullable<InternalTexture>;
  95880. private _uintIndicesCurrentlySet;
  95881. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95882. /** @hidden */
  95883. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95884. private _currentBufferPointers;
  95885. private _currentInstanceLocations;
  95886. private _currentInstanceBuffers;
  95887. private _textureUnits;
  95888. /** @hidden */
  95889. _workingCanvas: Nullable<HTMLCanvasElement>;
  95890. /** @hidden */
  95891. _workingContext: Nullable<CanvasRenderingContext2D>;
  95892. /** @hidden */
  95893. _bindedRenderFunction: any;
  95894. private _vaoRecordInProgress;
  95895. private _mustWipeVertexAttributes;
  95896. private _emptyTexture;
  95897. private _emptyCubeTexture;
  95898. private _emptyTexture3D;
  95899. /** @hidden */
  95900. _frameHandler: number;
  95901. private _nextFreeTextureSlots;
  95902. private _maxSimultaneousTextures;
  95903. private _activeRequests;
  95904. protected _texturesSupported: string[];
  95905. /** @hidden */
  95906. _textureFormatInUse: Nullable<string>;
  95907. protected readonly _supportsHardwareTextureRescaling: boolean;
  95908. /**
  95909. * Gets the list of texture formats supported
  95910. */
  95911. readonly texturesSupported: Array<string>;
  95912. /**
  95913. * Gets the list of texture formats in use
  95914. */
  95915. readonly textureFormatInUse: Nullable<string>;
  95916. /**
  95917. * Gets the current viewport
  95918. */
  95919. readonly currentViewport: Nullable<IViewportLike>;
  95920. /**
  95921. * Gets the default empty texture
  95922. */
  95923. readonly emptyTexture: InternalTexture;
  95924. /**
  95925. * Gets the default empty 3D texture
  95926. */
  95927. readonly emptyTexture3D: InternalTexture;
  95928. /**
  95929. * Gets the default empty cube texture
  95930. */
  95931. readonly emptyCubeTexture: InternalTexture;
  95932. /**
  95933. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95934. */
  95935. readonly premultipliedAlpha: boolean;
  95936. /**
  95937. * Observable event triggered before each texture is initialized
  95938. */
  95939. onBeforeTextureInitObservable: Observable<Texture>;
  95940. /**
  95941. * Creates a new engine
  95942. * @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
  95943. * @param antialias defines enable antialiasing (default: false)
  95944. * @param options defines further options to be sent to the getContext() function
  95945. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95946. */
  95947. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95948. private _rebuildInternalTextures;
  95949. private _rebuildEffects;
  95950. /**
  95951. * Gets a boolean indicating if all created effects are ready
  95952. * @returns true if all effects are ready
  95953. */
  95954. areAllEffectsReady(): boolean;
  95955. protected _rebuildBuffers(): void;
  95956. private _initGLContext;
  95957. /**
  95958. * Gets version of the current webGL context
  95959. */
  95960. readonly webGLVersion: number;
  95961. /**
  95962. * Gets a string idenfifying the name of the class
  95963. * @returns "Engine" string
  95964. */
  95965. getClassName(): string;
  95966. /**
  95967. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95968. */
  95969. readonly isStencilEnable: boolean;
  95970. /** @hidden */
  95971. _prepareWorkingCanvas(): void;
  95972. /**
  95973. * Reset the texture cache to empty state
  95974. */
  95975. resetTextureCache(): void;
  95976. /**
  95977. * Gets an object containing information about the current webGL context
  95978. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95979. */
  95980. getGlInfo(): {
  95981. vendor: string;
  95982. renderer: string;
  95983. version: string;
  95984. };
  95985. /**
  95986. * Defines the hardware scaling level.
  95987. * By default the hardware scaling level is computed from the window device ratio.
  95988. * 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.
  95989. * @param level defines the level to use
  95990. */
  95991. setHardwareScalingLevel(level: number): void;
  95992. /**
  95993. * Gets the current hardware scaling level.
  95994. * By default the hardware scaling level is computed from the window device ratio.
  95995. * 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.
  95996. * @returns a number indicating the current hardware scaling level
  95997. */
  95998. getHardwareScalingLevel(): number;
  95999. /**
  96000. * Gets the list of loaded textures
  96001. * @returns an array containing all loaded textures
  96002. */
  96003. getLoadedTexturesCache(): InternalTexture[];
  96004. /**
  96005. * Gets the object containing all engine capabilities
  96006. * @returns the EngineCapabilities object
  96007. */
  96008. getCaps(): EngineCapabilities;
  96009. /**
  96010. * stop executing a render loop function and remove it from the execution array
  96011. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96012. */
  96013. stopRenderLoop(renderFunction?: () => void): void;
  96014. /** @hidden */
  96015. _renderLoop(): void;
  96016. /**
  96017. * Gets the HTML canvas attached with the current webGL context
  96018. * @returns a HTML canvas
  96019. */
  96020. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96021. /**
  96022. * Gets host window
  96023. * @returns the host window object
  96024. */
  96025. getHostWindow(): Window;
  96026. /**
  96027. * Gets the current render width
  96028. * @param useScreen defines if screen size must be used (or the current render target if any)
  96029. * @returns a number defining the current render width
  96030. */
  96031. getRenderWidth(useScreen?: boolean): number;
  96032. /**
  96033. * Gets the current render height
  96034. * @param useScreen defines if screen size must be used (or the current render target if any)
  96035. * @returns a number defining the current render height
  96036. */
  96037. getRenderHeight(useScreen?: boolean): number;
  96038. /**
  96039. * Can be used to override the current requestAnimationFrame requester.
  96040. * @hidden
  96041. */
  96042. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96043. /**
  96044. * Register and execute a render loop. The engine can have more than one render function
  96045. * @param renderFunction defines the function to continuously execute
  96046. */
  96047. runRenderLoop(renderFunction: () => void): void;
  96048. /**
  96049. * Clear the current render buffer or the current render target (if any is set up)
  96050. * @param color defines the color to use
  96051. * @param backBuffer defines if the back buffer must be cleared
  96052. * @param depth defines if the depth buffer must be cleared
  96053. * @param stencil defines if the stencil buffer must be cleared
  96054. */
  96055. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96056. private _viewportCached;
  96057. /** @hidden */
  96058. _viewport(x: number, y: number, width: number, height: number): void;
  96059. /**
  96060. * Set the WebGL's viewport
  96061. * @param viewport defines the viewport element to be used
  96062. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96063. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96064. */
  96065. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96066. /**
  96067. * Begin a new frame
  96068. */
  96069. beginFrame(): void;
  96070. /**
  96071. * Enf the current frame
  96072. */
  96073. endFrame(): void;
  96074. /**
  96075. * Resize the view according to the canvas' size
  96076. */
  96077. resize(): void;
  96078. /**
  96079. * Force a specific size of the canvas
  96080. * @param width defines the new canvas' width
  96081. * @param height defines the new canvas' height
  96082. */
  96083. setSize(width: number, height: number): void;
  96084. /**
  96085. * Binds the frame buffer to the specified texture.
  96086. * @param texture The texture to render to or null for the default canvas
  96087. * @param faceIndex The face of the texture to render to in case of cube texture
  96088. * @param requiredWidth The width of the target to render to
  96089. * @param requiredHeight The height of the target to render to
  96090. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96091. * @param depthStencilTexture The depth stencil texture to use to render
  96092. * @param lodLevel defines le lod level to bind to the frame buffer
  96093. */
  96094. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96095. /** @hidden */
  96096. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96097. /**
  96098. * Unbind the current render target texture from the webGL context
  96099. * @param texture defines the render target texture to unbind
  96100. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96101. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96102. */
  96103. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96104. /**
  96105. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96106. */
  96107. flushFramebuffer(): void;
  96108. /**
  96109. * Unbind the current render target and bind the default framebuffer
  96110. */
  96111. restoreDefaultFramebuffer(): void;
  96112. private _resetVertexBufferBinding;
  96113. /**
  96114. * Creates a vertex buffer
  96115. * @param data the data for the vertex buffer
  96116. * @returns the new WebGL static buffer
  96117. */
  96118. createVertexBuffer(data: DataArray): DataBuffer;
  96119. private _createVertexBuffer;
  96120. /**
  96121. * Creates a dynamic vertex buffer
  96122. * @param data the data for the dynamic vertex buffer
  96123. * @returns the new WebGL dynamic buffer
  96124. */
  96125. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96126. /**
  96127. * Updates a dynamic vertex buffer.
  96128. * @param vertexBuffer the vertex buffer to update
  96129. * @param data the data used to update the vertex buffer
  96130. * @param byteOffset the byte offset of the data
  96131. * @param byteLength the byte length of the data
  96132. */
  96133. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96134. protected _resetIndexBufferBinding(): void;
  96135. /**
  96136. * Creates a new index buffer
  96137. * @param indices defines the content of the index buffer
  96138. * @param updatable defines if the index buffer must be updatable
  96139. * @returns a new webGL buffer
  96140. */
  96141. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96142. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96143. /**
  96144. * Bind a webGL buffer to the webGL context
  96145. * @param buffer defines the buffer to bind
  96146. */
  96147. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96148. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96149. private bindBuffer;
  96150. /**
  96151. * update the bound buffer with the given data
  96152. * @param data defines the data to update
  96153. */
  96154. updateArrayBuffer(data: Float32Array): void;
  96155. private _vertexAttribPointer;
  96156. private _bindIndexBufferWithCache;
  96157. private _bindVertexBuffersAttributes;
  96158. /**
  96159. * Records a vertex array object
  96160. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96161. * @param vertexBuffers defines the list of vertex buffers to store
  96162. * @param indexBuffer defines the index buffer to store
  96163. * @param effect defines the effect to store
  96164. * @returns the new vertex array object
  96165. */
  96166. recordVertexArrayObject(vertexBuffers: {
  96167. [key: string]: VertexBuffer;
  96168. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96169. /**
  96170. * Bind a specific vertex array object
  96171. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96172. * @param vertexArrayObject defines the vertex array object to bind
  96173. * @param indexBuffer defines the index buffer to bind
  96174. */
  96175. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96176. /**
  96177. * Bind webGl buffers directly to the webGL context
  96178. * @param vertexBuffer defines the vertex buffer to bind
  96179. * @param indexBuffer defines the index buffer to bind
  96180. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96181. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96182. * @param effect defines the effect associated with the vertex buffer
  96183. */
  96184. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96185. private _unbindVertexArrayObject;
  96186. /**
  96187. * Bind a list of vertex buffers to the webGL context
  96188. * @param vertexBuffers defines the list of vertex buffers to bind
  96189. * @param indexBuffer defines the index buffer to bind
  96190. * @param effect defines the effect associated with the vertex buffers
  96191. */
  96192. bindBuffers(vertexBuffers: {
  96193. [key: string]: Nullable<VertexBuffer>;
  96194. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96195. /**
  96196. * Unbind all instance attributes
  96197. */
  96198. unbindInstanceAttributes(): void;
  96199. /**
  96200. * Release and free the memory of a vertex array object
  96201. * @param vao defines the vertex array object to delete
  96202. */
  96203. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96204. /** @hidden */
  96205. _releaseBuffer(buffer: DataBuffer): boolean;
  96206. protected _deleteBuffer(buffer: DataBuffer): void;
  96207. /**
  96208. * Creates a webGL buffer to use with instanciation
  96209. * @param capacity defines the size of the buffer
  96210. * @returns the webGL buffer
  96211. */
  96212. createInstancesBuffer(capacity: number): DataBuffer;
  96213. /**
  96214. * Delete a webGL buffer used with instanciation
  96215. * @param buffer defines the webGL buffer to delete
  96216. */
  96217. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96218. /**
  96219. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96220. * @param instancesBuffer defines the webGL buffer to update and bind
  96221. * @param data defines the data to store in the buffer
  96222. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96223. */
  96224. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96225. /**
  96226. * Apply all cached states (depth, culling, stencil and alpha)
  96227. */
  96228. applyStates(): void;
  96229. /**
  96230. * Send a draw order
  96231. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96232. * @param indexStart defines the starting index
  96233. * @param indexCount defines the number of index to draw
  96234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96235. */
  96236. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96237. /**
  96238. * Draw a list of points
  96239. * @param verticesStart defines the index of first vertex to draw
  96240. * @param verticesCount defines the count of vertices to draw
  96241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96242. */
  96243. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96244. /**
  96245. * Draw a list of unindexed primitives
  96246. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96247. * @param verticesStart defines the index of first vertex to draw
  96248. * @param verticesCount defines the count of vertices to draw
  96249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96250. */
  96251. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96252. /**
  96253. * Draw a list of indexed primitives
  96254. * @param fillMode defines the primitive to use
  96255. * @param indexStart defines the starting index
  96256. * @param indexCount defines the number of index to draw
  96257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96258. */
  96259. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96260. /**
  96261. * Draw a list of unindexed primitives
  96262. * @param fillMode defines the primitive to use
  96263. * @param verticesStart defines the index of first vertex to draw
  96264. * @param verticesCount defines the count of vertices to draw
  96265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96266. */
  96267. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96268. private _drawMode;
  96269. /** @hidden */
  96270. protected _reportDrawCall(): void;
  96271. /** @hidden */
  96272. _releaseEffect(effect: Effect): void;
  96273. /** @hidden */
  96274. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96275. /**
  96276. * Create a new effect (used to store vertex/fragment shaders)
  96277. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96278. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96279. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96280. * @param samplers defines an array of string used to represent textures
  96281. * @param defines defines the string containing the defines to use to compile the shaders
  96282. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96283. * @param onCompiled defines a function to call when the effect creation is successful
  96284. * @param onError defines a function to call when the effect creation has failed
  96285. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96286. * @returns the new Effect
  96287. */
  96288. 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;
  96289. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96290. private _compileShader;
  96291. private _compileRawShader;
  96292. /**
  96293. * Directly creates a webGL program
  96294. * @param pipelineContext defines the pipeline context to attach to
  96295. * @param vertexCode defines the vertex shader code to use
  96296. * @param fragmentCode defines the fragment shader code to use
  96297. * @param context defines the webGL context to use (if not set, the current one will be used)
  96298. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96299. * @returns the new webGL program
  96300. */
  96301. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96302. /**
  96303. * Creates a webGL program
  96304. * @param pipelineContext defines the pipeline context to attach to
  96305. * @param vertexCode defines the vertex shader code to use
  96306. * @param fragmentCode defines the fragment shader code to use
  96307. * @param defines defines the string containing the defines to use to compile the shaders
  96308. * @param context defines the webGL context to use (if not set, the current one will be used)
  96309. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96310. * @returns the new webGL program
  96311. */
  96312. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96313. /**
  96314. * Creates a new pipeline context
  96315. * @returns the new pipeline
  96316. */
  96317. createPipelineContext(): IPipelineContext;
  96318. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96319. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96320. /** @hidden */
  96321. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96322. /** @hidden */
  96323. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96324. /** @hidden */
  96325. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96326. /**
  96327. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96328. * @param pipelineContext defines the pipeline context to use
  96329. * @param uniformsNames defines the list of uniform names
  96330. * @returns an array of webGL uniform locations
  96331. */
  96332. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96333. /**
  96334. * Gets the lsit of active attributes for a given webGL program
  96335. * @param pipelineContext defines the pipeline context to use
  96336. * @param attributesNames defines the list of attribute names to get
  96337. * @returns an array of indices indicating the offset of each attribute
  96338. */
  96339. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96340. /**
  96341. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96342. * @param effect defines the effect to activate
  96343. */
  96344. enableEffect(effect: Nullable<Effect>): void;
  96345. /**
  96346. * Set the value of an uniform to an array of int32
  96347. * @param uniform defines the webGL uniform location where to store the value
  96348. * @param array defines the array of int32 to store
  96349. */
  96350. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96351. /**
  96352. * Set the value of an uniform to an array of int32 (stored as vec2)
  96353. * @param uniform defines the webGL uniform location where to store the value
  96354. * @param array defines the array of int32 to store
  96355. */
  96356. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96357. /**
  96358. * Set the value of an uniform to an array of int32 (stored as vec3)
  96359. * @param uniform defines the webGL uniform location where to store the value
  96360. * @param array defines the array of int32 to store
  96361. */
  96362. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96363. /**
  96364. * Set the value of an uniform to an array of int32 (stored as vec4)
  96365. * @param uniform defines the webGL uniform location where to store the value
  96366. * @param array defines the array of int32 to store
  96367. */
  96368. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96369. /**
  96370. * Set the value of an uniform to an array of float32
  96371. * @param uniform defines the webGL uniform location where to store the value
  96372. * @param array defines the array of float32 to store
  96373. */
  96374. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96375. /**
  96376. * Set the value of an uniform to an array of float32 (stored as vec2)
  96377. * @param uniform defines the webGL uniform location where to store the value
  96378. * @param array defines the array of float32 to store
  96379. */
  96380. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96381. /**
  96382. * Set the value of an uniform to an array of float32 (stored as vec3)
  96383. * @param uniform defines the webGL uniform location where to store the value
  96384. * @param array defines the array of float32 to store
  96385. */
  96386. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96387. /**
  96388. * Set the value of an uniform to an array of float32 (stored as vec4)
  96389. * @param uniform defines the webGL uniform location where to store the value
  96390. * @param array defines the array of float32 to store
  96391. */
  96392. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96393. /**
  96394. * Set the value of an uniform to an array of number
  96395. * @param uniform defines the webGL uniform location where to store the value
  96396. * @param array defines the array of number to store
  96397. */
  96398. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96399. /**
  96400. * Set the value of an uniform to an array of number (stored as vec2)
  96401. * @param uniform defines the webGL uniform location where to store the value
  96402. * @param array defines the array of number to store
  96403. */
  96404. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96405. /**
  96406. * Set the value of an uniform to an array of number (stored as vec3)
  96407. * @param uniform defines the webGL uniform location where to store the value
  96408. * @param array defines the array of number to store
  96409. */
  96410. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96411. /**
  96412. * Set the value of an uniform to an array of number (stored as vec4)
  96413. * @param uniform defines the webGL uniform location where to store the value
  96414. * @param array defines the array of number to store
  96415. */
  96416. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96417. /**
  96418. * Set the value of an uniform to an array of float32 (stored as matrices)
  96419. * @param uniform defines the webGL uniform location where to store the value
  96420. * @param matrices defines the array of float32 to store
  96421. */
  96422. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96423. /**
  96424. * Set the value of an uniform to a matrix (3x3)
  96425. * @param uniform defines the webGL uniform location where to store the value
  96426. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96427. */
  96428. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96429. /**
  96430. * Set the value of an uniform to a matrix (2x2)
  96431. * @param uniform defines the webGL uniform location where to store the value
  96432. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96433. */
  96434. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96435. /**
  96436. * Set the value of an uniform to a number (int)
  96437. * @param uniform defines the webGL uniform location where to store the value
  96438. * @param value defines the int number to store
  96439. */
  96440. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96441. /**
  96442. * Set the value of an uniform to a number (float)
  96443. * @param uniform defines the webGL uniform location where to store the value
  96444. * @param value defines the float number to store
  96445. */
  96446. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96447. /**
  96448. * Set the value of an uniform to a vec2
  96449. * @param uniform defines the webGL uniform location where to store the value
  96450. * @param x defines the 1st component of the value
  96451. * @param y defines the 2nd component of the value
  96452. */
  96453. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96454. /**
  96455. * Set the value of an uniform to a vec3
  96456. * @param uniform defines the webGL uniform location where to store the value
  96457. * @param x defines the 1st component of the value
  96458. * @param y defines the 2nd component of the value
  96459. * @param z defines the 3rd component of the value
  96460. */
  96461. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96462. /**
  96463. * Set the value of an uniform to a boolean
  96464. * @param uniform defines the webGL uniform location where to store the value
  96465. * @param bool defines the boolean to store
  96466. */
  96467. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96468. /**
  96469. * Set the value of an uniform to a vec4
  96470. * @param uniform defines the webGL uniform location where to store the value
  96471. * @param x defines the 1st component of the value
  96472. * @param y defines the 2nd component of the value
  96473. * @param z defines the 3rd component of the value
  96474. * @param w defines the 4th component of the value
  96475. */
  96476. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96477. /**
  96478. * Sets a Color4 on a uniform variable
  96479. * @param uniform defines the uniform location
  96480. * @param color4 defines the value to be set
  96481. */
  96482. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96483. /**
  96484. * Gets the depth culling state manager
  96485. */
  96486. readonly depthCullingState: DepthCullingState;
  96487. /**
  96488. * Gets the alpha state manager
  96489. */
  96490. readonly alphaState: AlphaState;
  96491. /**
  96492. * Gets the stencil state manager
  96493. */
  96494. readonly stencilState: StencilState;
  96495. /**
  96496. * Clears the list of texture accessible through engine.
  96497. * This can help preventing texture load conflict due to name collision.
  96498. */
  96499. clearInternalTexturesCache(): void;
  96500. /**
  96501. * Force the entire cache to be cleared
  96502. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96503. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96504. */
  96505. wipeCaches(bruteForce?: boolean): void;
  96506. /** @hidden */
  96507. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96508. min: number;
  96509. mag: number;
  96510. };
  96511. /** @hidden */
  96512. _createTexture(): WebGLTexture;
  96513. /**
  96514. * Usually called from Texture.ts.
  96515. * Passed information to create a WebGLTexture
  96516. * @param urlArg defines a value which contains one of the following:
  96517. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96518. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96519. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96521. * @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)
  96522. * @param scene needed for loading to the correct scene
  96523. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96524. * @param onLoad optional callback to be called upon successful completion
  96525. * @param onError optional callback to be called upon failure
  96526. * @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
  96527. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96528. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96529. * @param forcedExtension defines the extension to use to pick the right loader
  96530. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96531. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96532. */
  96533. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96534. /**
  96535. * @hidden
  96536. */
  96537. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96538. /**
  96539. * Creates a raw texture
  96540. * @param data defines the data to store in the texture
  96541. * @param width defines the width of the texture
  96542. * @param height defines the height of the texture
  96543. * @param format defines the format of the data
  96544. * @param generateMipMaps defines if the engine should generate the mip levels
  96545. * @param invertY defines if data must be stored with Y axis inverted
  96546. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96547. * @param compression defines the compression used (null by default)
  96548. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96549. * @returns the raw texture inside an InternalTexture
  96550. */
  96551. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96552. /**
  96553. * Creates a new raw cube texture
  96554. * @param data defines the array of data to use to create each face
  96555. * @param size defines the size of the textures
  96556. * @param format defines the format of the data
  96557. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96558. * @param generateMipMaps defines if the engine should generate the mip levels
  96559. * @param invertY defines if data must be stored with Y axis inverted
  96560. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96561. * @param compression defines the compression used (null by default)
  96562. * @returns the cube texture as an InternalTexture
  96563. */
  96564. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96565. /**
  96566. * Creates a new raw 3D texture
  96567. * @param data defines the data used to create the texture
  96568. * @param width defines the width of the texture
  96569. * @param height defines the height of the texture
  96570. * @param depth defines the depth of the texture
  96571. * @param format defines the format of the texture
  96572. * @param generateMipMaps defines if the engine must generate mip levels
  96573. * @param invertY defines if data must be stored with Y axis inverted
  96574. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96575. * @param compression defines the compressed used (can be null)
  96576. * @param textureType defines the compressed used (can be null)
  96577. * @returns a new raw 3D texture (stored in an InternalTexture)
  96578. */
  96579. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96580. private _unpackFlipYCached;
  96581. /**
  96582. * In case you are sharing the context with other applications, it might
  96583. * be interested to not cache the unpack flip y state to ensure a consistent
  96584. * value would be set.
  96585. */
  96586. enableUnpackFlipYCached: boolean;
  96587. /** @hidden */
  96588. _unpackFlipY(value: boolean): void;
  96589. /** @hidden */
  96590. _getUnpackAlignement(): number;
  96591. /**
  96592. * Update the sampling mode of a given texture
  96593. * @param samplingMode defines the required sampling mode
  96594. * @param texture defines the texture to update
  96595. */
  96596. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96597. /**
  96598. * Updates a depth texture Comparison Mode and Function.
  96599. * If the comparison Function is equal to 0, the mode will be set to none.
  96600. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96601. * @param texture The texture to set the comparison function for
  96602. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96603. */
  96604. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96605. /** @hidden */
  96606. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96607. width: number;
  96608. height: number;
  96609. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96610. /**
  96611. * Creates a depth stencil texture.
  96612. * This is only available in WebGL 2 or with the depth texture extension available.
  96613. * @param size The size of face edge in the texture.
  96614. * @param options The options defining the texture.
  96615. * @returns The texture
  96616. */
  96617. createDepthStencilTexture(size: number | {
  96618. width: number;
  96619. height: number;
  96620. }, options: DepthTextureCreationOptions): InternalTexture;
  96621. /**
  96622. * Creates a depth stencil texture.
  96623. * This is only available in WebGL 2 or with the depth texture extension available.
  96624. * @param size The size of face edge in the texture.
  96625. * @param options The options defining the texture.
  96626. * @returns The texture
  96627. */
  96628. private _createDepthStencilTexture;
  96629. /** @hidden */
  96630. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96631. /** @hidden */
  96632. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96633. /** @hidden */
  96634. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96635. /** @hidden */
  96636. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96637. /**
  96638. * @hidden
  96639. */
  96640. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96641. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96642. private _prepareWebGLTexture;
  96643. /** @hidden */
  96644. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96645. /** @hidden */
  96646. _releaseFramebufferObjects(texture: InternalTexture): void;
  96647. /** @hidden */
  96648. _releaseTexture(texture: InternalTexture): void;
  96649. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96650. protected _setProgram(program: WebGLProgram): void;
  96651. protected _boundUniforms: {
  96652. [key: number]: WebGLUniformLocation;
  96653. };
  96654. /**
  96655. * Binds an effect to the webGL context
  96656. * @param effect defines the effect to bind
  96657. */
  96658. bindSamplers(effect: Effect): void;
  96659. private _activateCurrentTexture;
  96660. /** @hidden */
  96661. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96662. /** @hidden */
  96663. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96664. /**
  96665. * Unbind all textures from the webGL context
  96666. */
  96667. unbindAllTextures(): void;
  96668. /**
  96669. * Sets a texture to the according uniform.
  96670. * @param channel The texture channel
  96671. * @param uniform The uniform to set
  96672. * @param texture The texture to apply
  96673. */
  96674. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96675. private _bindSamplerUniformToChannel;
  96676. private _getTextureWrapMode;
  96677. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96678. /**
  96679. * Sets an array of texture to the webGL context
  96680. * @param channel defines the channel where the texture array must be set
  96681. * @param uniform defines the associated uniform location
  96682. * @param textures defines the array of textures to bind
  96683. */
  96684. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96685. /** @hidden */
  96686. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96687. private _setTextureParameterFloat;
  96688. private _setTextureParameterInteger;
  96689. /**
  96690. * Unbind all vertex attributes from the webGL context
  96691. */
  96692. unbindAllAttributes(): void;
  96693. /**
  96694. * 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
  96695. */
  96696. releaseEffects(): void;
  96697. /**
  96698. * Dispose and release all associated resources
  96699. */
  96700. dispose(): void;
  96701. /**
  96702. * Attach a new callback raised when context lost event is fired
  96703. * @param callback defines the callback to call
  96704. */
  96705. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96706. /**
  96707. * Attach a new callback raised when context restored event is fired
  96708. * @param callback defines the callback to call
  96709. */
  96710. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96711. /**
  96712. * Get the current error code of the webGL context
  96713. * @returns the error code
  96714. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96715. */
  96716. getError(): number;
  96717. private _canRenderToFloatFramebuffer;
  96718. private _canRenderToHalfFloatFramebuffer;
  96719. private _canRenderToFramebuffer;
  96720. /** @hidden */
  96721. _getWebGLTextureType(type: number): number;
  96722. /** @hidden */
  96723. _getInternalFormat(format: number): number;
  96724. /** @hidden */
  96725. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96726. /** @hidden */
  96727. _getRGBAMultiSampleBufferFormat(type: number): number;
  96728. /** @hidden */
  96729. _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;
  96730. /**
  96731. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96732. * @returns true if the engine can be created
  96733. * @ignorenaming
  96734. */
  96735. static isSupported(): boolean;
  96736. /**
  96737. * Find the next highest power of two.
  96738. * @param x Number to start search from.
  96739. * @return Next highest power of two.
  96740. */
  96741. static CeilingPOT(x: number): number;
  96742. /**
  96743. * Find the next lowest power of two.
  96744. * @param x Number to start search from.
  96745. * @return Next lowest power of two.
  96746. */
  96747. static FloorPOT(x: number): number;
  96748. /**
  96749. * Find the nearest power of two.
  96750. * @param x Number to start search from.
  96751. * @return Next nearest power of two.
  96752. */
  96753. static NearestPOT(x: number): number;
  96754. /**
  96755. * Get the closest exponent of two
  96756. * @param value defines the value to approximate
  96757. * @param max defines the maximum value to return
  96758. * @param mode defines how to define the closest value
  96759. * @returns closest exponent of two of the given value
  96760. */
  96761. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96762. /**
  96763. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96764. * @param func - the function to be called
  96765. * @param requester - the object that will request the next frame. Falls back to window.
  96766. * @returns frame number
  96767. */
  96768. static QueueNewFrame(func: () => void, requester?: any): number;
  96769. }
  96770. }
  96771. declare module BABYLON {
  96772. /**
  96773. * Class representing spherical harmonics coefficients to the 3rd degree
  96774. */
  96775. export class SphericalHarmonics {
  96776. /**
  96777. * Defines whether or not the harmonics have been prescaled for rendering.
  96778. */
  96779. preScaled: boolean;
  96780. /**
  96781. * The l0,0 coefficients of the spherical harmonics
  96782. */
  96783. l00: Vector3;
  96784. /**
  96785. * The l1,-1 coefficients of the spherical harmonics
  96786. */
  96787. l1_1: Vector3;
  96788. /**
  96789. * The l1,0 coefficients of the spherical harmonics
  96790. */
  96791. l10: Vector3;
  96792. /**
  96793. * The l1,1 coefficients of the spherical harmonics
  96794. */
  96795. l11: Vector3;
  96796. /**
  96797. * The l2,-2 coefficients of the spherical harmonics
  96798. */
  96799. l2_2: Vector3;
  96800. /**
  96801. * The l2,-1 coefficients of the spherical harmonics
  96802. */
  96803. l2_1: Vector3;
  96804. /**
  96805. * The l2,0 coefficients of the spherical harmonics
  96806. */
  96807. l20: Vector3;
  96808. /**
  96809. * The l2,1 coefficients of the spherical harmonics
  96810. */
  96811. l21: Vector3;
  96812. /**
  96813. * The l2,2 coefficients of the spherical harmonics
  96814. */
  96815. l22: Vector3;
  96816. /**
  96817. * Adds a light to the spherical harmonics
  96818. * @param direction the direction of the light
  96819. * @param color the color of the light
  96820. * @param deltaSolidAngle the delta solid angle of the light
  96821. */
  96822. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96823. /**
  96824. * Scales the spherical harmonics by the given amount
  96825. * @param scale the amount to scale
  96826. */
  96827. scaleInPlace(scale: number): void;
  96828. /**
  96829. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96830. *
  96831. * ```
  96832. * E_lm = A_l * L_lm
  96833. * ```
  96834. *
  96835. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96836. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96837. * the scaling factors are given in equation 9.
  96838. */
  96839. convertIncidentRadianceToIrradiance(): void;
  96840. /**
  96841. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96842. *
  96843. * ```
  96844. * L = (1/pi) * E * rho
  96845. * ```
  96846. *
  96847. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96848. */
  96849. convertIrradianceToLambertianRadiance(): void;
  96850. /**
  96851. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96852. * required operations at run time.
  96853. *
  96854. * This is simply done by scaling back the SH with Ylm constants parameter.
  96855. * The trigonometric part being applied by the shader at run time.
  96856. */
  96857. preScaleForRendering(): void;
  96858. /**
  96859. * Constructs a spherical harmonics from an array.
  96860. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96861. * @returns the spherical harmonics
  96862. */
  96863. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96864. /**
  96865. * Gets the spherical harmonics from polynomial
  96866. * @param polynomial the spherical polynomial
  96867. * @returns the spherical harmonics
  96868. */
  96869. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96870. }
  96871. /**
  96872. * Class representing spherical polynomial coefficients to the 3rd degree
  96873. */
  96874. export class SphericalPolynomial {
  96875. private _harmonics;
  96876. /**
  96877. * The spherical harmonics used to create the polynomials.
  96878. */
  96879. readonly preScaledHarmonics: SphericalHarmonics;
  96880. /**
  96881. * The x coefficients of the spherical polynomial
  96882. */
  96883. x: Vector3;
  96884. /**
  96885. * The y coefficients of the spherical polynomial
  96886. */
  96887. y: Vector3;
  96888. /**
  96889. * The z coefficients of the spherical polynomial
  96890. */
  96891. z: Vector3;
  96892. /**
  96893. * The xx coefficients of the spherical polynomial
  96894. */
  96895. xx: Vector3;
  96896. /**
  96897. * The yy coefficients of the spherical polynomial
  96898. */
  96899. yy: Vector3;
  96900. /**
  96901. * The zz coefficients of the spherical polynomial
  96902. */
  96903. zz: Vector3;
  96904. /**
  96905. * The xy coefficients of the spherical polynomial
  96906. */
  96907. xy: Vector3;
  96908. /**
  96909. * The yz coefficients of the spherical polynomial
  96910. */
  96911. yz: Vector3;
  96912. /**
  96913. * The zx coefficients of the spherical polynomial
  96914. */
  96915. zx: Vector3;
  96916. /**
  96917. * Adds an ambient color to the spherical polynomial
  96918. * @param color the color to add
  96919. */
  96920. addAmbient(color: Color3): void;
  96921. /**
  96922. * Scales the spherical polynomial by the given amount
  96923. * @param scale the amount to scale
  96924. */
  96925. scaleInPlace(scale: number): void;
  96926. /**
  96927. * Gets the spherical polynomial from harmonics
  96928. * @param harmonics the spherical harmonics
  96929. * @returns the spherical polynomial
  96930. */
  96931. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96932. /**
  96933. * Constructs a spherical polynomial from an array.
  96934. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96935. * @returns the spherical polynomial
  96936. */
  96937. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96938. }
  96939. }
  96940. declare module BABYLON {
  96941. /**
  96942. * Defines the source of the internal texture
  96943. */
  96944. export enum InternalTextureSource {
  96945. /**
  96946. * The source of the texture data is unknown
  96947. */
  96948. Unknown = 0,
  96949. /**
  96950. * Texture data comes from an URL
  96951. */
  96952. Url = 1,
  96953. /**
  96954. * Texture data is only used for temporary storage
  96955. */
  96956. Temp = 2,
  96957. /**
  96958. * Texture data comes from raw data (ArrayBuffer)
  96959. */
  96960. Raw = 3,
  96961. /**
  96962. * Texture content is dynamic (video or dynamic texture)
  96963. */
  96964. Dynamic = 4,
  96965. /**
  96966. * Texture content is generated by rendering to it
  96967. */
  96968. RenderTarget = 5,
  96969. /**
  96970. * Texture content is part of a multi render target process
  96971. */
  96972. MultiRenderTarget = 6,
  96973. /**
  96974. * Texture data comes from a cube data file
  96975. */
  96976. Cube = 7,
  96977. /**
  96978. * Texture data comes from a raw cube data
  96979. */
  96980. CubeRaw = 8,
  96981. /**
  96982. * Texture data come from a prefiltered cube data file
  96983. */
  96984. CubePrefiltered = 9,
  96985. /**
  96986. * Texture content is raw 3D data
  96987. */
  96988. Raw3D = 10,
  96989. /**
  96990. * Texture content is a depth texture
  96991. */
  96992. Depth = 11,
  96993. /**
  96994. * Texture data comes from a raw cube data encoded with RGBD
  96995. */
  96996. CubeRawRGBD = 12
  96997. }
  96998. /**
  96999. * Class used to store data associated with WebGL texture data for the engine
  97000. * This class should not be used directly
  97001. */
  97002. export class InternalTexture {
  97003. /** @hidden */
  97004. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97005. /**
  97006. * Defines if the texture is ready
  97007. */
  97008. isReady: boolean;
  97009. /**
  97010. * Defines if the texture is a cube texture
  97011. */
  97012. isCube: boolean;
  97013. /**
  97014. * Defines if the texture contains 3D data
  97015. */
  97016. is3D: boolean;
  97017. /**
  97018. * Defines if the texture contains multiview data
  97019. */
  97020. isMultiview: boolean;
  97021. /**
  97022. * Gets the URL used to load this texture
  97023. */
  97024. url: string;
  97025. /**
  97026. * Gets the sampling mode of the texture
  97027. */
  97028. samplingMode: number;
  97029. /**
  97030. * Gets a boolean indicating if the texture needs mipmaps generation
  97031. */
  97032. generateMipMaps: boolean;
  97033. /**
  97034. * Gets the number of samples used by the texture (WebGL2+ only)
  97035. */
  97036. samples: number;
  97037. /**
  97038. * Gets the type of the texture (int, float...)
  97039. */
  97040. type: number;
  97041. /**
  97042. * Gets the format of the texture (RGB, RGBA...)
  97043. */
  97044. format: number;
  97045. /**
  97046. * Observable called when the texture is loaded
  97047. */
  97048. onLoadedObservable: Observable<InternalTexture>;
  97049. /**
  97050. * Gets the width of the texture
  97051. */
  97052. width: number;
  97053. /**
  97054. * Gets the height of the texture
  97055. */
  97056. height: number;
  97057. /**
  97058. * Gets the depth of the texture
  97059. */
  97060. depth: number;
  97061. /**
  97062. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97063. */
  97064. baseWidth: number;
  97065. /**
  97066. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97067. */
  97068. baseHeight: number;
  97069. /**
  97070. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97071. */
  97072. baseDepth: number;
  97073. /**
  97074. * Gets a boolean indicating if the texture is inverted on Y axis
  97075. */
  97076. invertY: boolean;
  97077. /** @hidden */
  97078. _invertVScale: boolean;
  97079. /** @hidden */
  97080. _associatedChannel: number;
  97081. /** @hidden */
  97082. _source: InternalTextureSource;
  97083. /** @hidden */
  97084. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97085. /** @hidden */
  97086. _bufferView: Nullable<ArrayBufferView>;
  97087. /** @hidden */
  97088. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97089. /** @hidden */
  97090. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97091. /** @hidden */
  97092. _size: number;
  97093. /** @hidden */
  97094. _extension: string;
  97095. /** @hidden */
  97096. _files: Nullable<string[]>;
  97097. /** @hidden */
  97098. _workingCanvas: Nullable<HTMLCanvasElement>;
  97099. /** @hidden */
  97100. _workingContext: Nullable<CanvasRenderingContext2D>;
  97101. /** @hidden */
  97102. _framebuffer: Nullable<WebGLFramebuffer>;
  97103. /** @hidden */
  97104. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97105. /** @hidden */
  97106. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97107. /** @hidden */
  97108. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97109. /** @hidden */
  97110. _attachments: Nullable<number[]>;
  97111. /** @hidden */
  97112. _cachedCoordinatesMode: Nullable<number>;
  97113. /** @hidden */
  97114. _cachedWrapU: Nullable<number>;
  97115. /** @hidden */
  97116. _cachedWrapV: Nullable<number>;
  97117. /** @hidden */
  97118. _cachedWrapR: Nullable<number>;
  97119. /** @hidden */
  97120. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97121. /** @hidden */
  97122. _isDisabled: boolean;
  97123. /** @hidden */
  97124. _compression: Nullable<string>;
  97125. /** @hidden */
  97126. _generateStencilBuffer: boolean;
  97127. /** @hidden */
  97128. _generateDepthBuffer: boolean;
  97129. /** @hidden */
  97130. _comparisonFunction: number;
  97131. /** @hidden */
  97132. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97133. /** @hidden */
  97134. _lodGenerationScale: number;
  97135. /** @hidden */
  97136. _lodGenerationOffset: number;
  97137. /** @hidden */
  97138. _colorTextureArray: Nullable<WebGLTexture>;
  97139. /** @hidden */
  97140. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97141. /** @hidden */
  97142. _lodTextureHigh: Nullable<BaseTexture>;
  97143. /** @hidden */
  97144. _lodTextureMid: Nullable<BaseTexture>;
  97145. /** @hidden */
  97146. _lodTextureLow: Nullable<BaseTexture>;
  97147. /** @hidden */
  97148. _isRGBD: boolean;
  97149. /** @hidden */
  97150. _linearSpecularLOD: boolean;
  97151. /** @hidden */
  97152. _irradianceTexture: Nullable<BaseTexture>;
  97153. /** @hidden */
  97154. _webGLTexture: Nullable<WebGLTexture>;
  97155. /** @hidden */
  97156. _references: number;
  97157. private _engine;
  97158. /**
  97159. * Gets the Engine the texture belongs to.
  97160. * @returns The babylon engine
  97161. */
  97162. getEngine(): ThinEngine;
  97163. /**
  97164. * Gets the data source type of the texture
  97165. */
  97166. readonly source: InternalTextureSource;
  97167. /**
  97168. * Creates a new InternalTexture
  97169. * @param engine defines the engine to use
  97170. * @param source defines the type of data that will be used
  97171. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97172. */
  97173. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97174. /**
  97175. * Increments the number of references (ie. the number of Texture that point to it)
  97176. */
  97177. incrementReferences(): void;
  97178. /**
  97179. * Change the size of the texture (not the size of the content)
  97180. * @param width defines the new width
  97181. * @param height defines the new height
  97182. * @param depth defines the new depth (1 by default)
  97183. */
  97184. updateSize(width: int, height: int, depth?: int): void;
  97185. /** @hidden */
  97186. _rebuild(): void;
  97187. /** @hidden */
  97188. _swapAndDie(target: InternalTexture): void;
  97189. /**
  97190. * Dispose the current allocated resources
  97191. */
  97192. dispose(): void;
  97193. }
  97194. }
  97195. declare module BABYLON {
  97196. /**
  97197. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97199. */
  97200. export class Analyser {
  97201. /**
  97202. * Gets or sets the smoothing
  97203. * @ignorenaming
  97204. */
  97205. SMOOTHING: number;
  97206. /**
  97207. * Gets or sets the FFT table size
  97208. * @ignorenaming
  97209. */
  97210. FFT_SIZE: number;
  97211. /**
  97212. * Gets or sets the bar graph amplitude
  97213. * @ignorenaming
  97214. */
  97215. BARGRAPHAMPLITUDE: number;
  97216. /**
  97217. * Gets or sets the position of the debug canvas
  97218. * @ignorenaming
  97219. */
  97220. DEBUGCANVASPOS: {
  97221. x: number;
  97222. y: number;
  97223. };
  97224. /**
  97225. * Gets or sets the debug canvas size
  97226. * @ignorenaming
  97227. */
  97228. DEBUGCANVASSIZE: {
  97229. width: number;
  97230. height: number;
  97231. };
  97232. private _byteFreqs;
  97233. private _byteTime;
  97234. private _floatFreqs;
  97235. private _webAudioAnalyser;
  97236. private _debugCanvas;
  97237. private _debugCanvasContext;
  97238. private _scene;
  97239. private _registerFunc;
  97240. private _audioEngine;
  97241. /**
  97242. * Creates a new analyser
  97243. * @param scene defines hosting scene
  97244. */
  97245. constructor(scene: Scene);
  97246. /**
  97247. * Get the number of data values you will have to play with for the visualization
  97248. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97249. * @returns a number
  97250. */
  97251. getFrequencyBinCount(): number;
  97252. /**
  97253. * Gets the current frequency data as a byte array
  97254. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97255. * @returns a Uint8Array
  97256. */
  97257. getByteFrequencyData(): Uint8Array;
  97258. /**
  97259. * Gets the current waveform as a byte array
  97260. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97261. * @returns a Uint8Array
  97262. */
  97263. getByteTimeDomainData(): Uint8Array;
  97264. /**
  97265. * Gets the current frequency data as a float array
  97266. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97267. * @returns a Float32Array
  97268. */
  97269. getFloatFrequencyData(): Float32Array;
  97270. /**
  97271. * Renders the debug canvas
  97272. */
  97273. drawDebugCanvas(): void;
  97274. /**
  97275. * Stops rendering the debug canvas and removes it
  97276. */
  97277. stopDebugCanvas(): void;
  97278. /**
  97279. * Connects two audio nodes
  97280. * @param inputAudioNode defines first node to connect
  97281. * @param outputAudioNode defines second node to connect
  97282. */
  97283. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97284. /**
  97285. * Releases all associated resources
  97286. */
  97287. dispose(): void;
  97288. }
  97289. }
  97290. declare module BABYLON {
  97291. /**
  97292. * This represents an audio engine and it is responsible
  97293. * to play, synchronize and analyse sounds throughout the application.
  97294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97295. */
  97296. export interface IAudioEngine extends IDisposable {
  97297. /**
  97298. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97299. */
  97300. readonly canUseWebAudio: boolean;
  97301. /**
  97302. * Gets the current AudioContext if available.
  97303. */
  97304. readonly audioContext: Nullable<AudioContext>;
  97305. /**
  97306. * The master gain node defines the global audio volume of your audio engine.
  97307. */
  97308. readonly masterGain: GainNode;
  97309. /**
  97310. * Gets whether or not mp3 are supported by your browser.
  97311. */
  97312. readonly isMP3supported: boolean;
  97313. /**
  97314. * Gets whether or not ogg are supported by your browser.
  97315. */
  97316. readonly isOGGsupported: boolean;
  97317. /**
  97318. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97319. * @ignoreNaming
  97320. */
  97321. WarnedWebAudioUnsupported: boolean;
  97322. /**
  97323. * Defines if the audio engine relies on a custom unlocked button.
  97324. * In this case, the embedded button will not be displayed.
  97325. */
  97326. useCustomUnlockedButton: boolean;
  97327. /**
  97328. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97329. */
  97330. readonly unlocked: boolean;
  97331. /**
  97332. * Event raised when audio has been unlocked on the browser.
  97333. */
  97334. onAudioUnlockedObservable: Observable<AudioEngine>;
  97335. /**
  97336. * Event raised when audio has been locked on the browser.
  97337. */
  97338. onAudioLockedObservable: Observable<AudioEngine>;
  97339. /**
  97340. * Flags the audio engine in Locked state.
  97341. * This happens due to new browser policies preventing audio to autoplay.
  97342. */
  97343. lock(): void;
  97344. /**
  97345. * Unlocks the audio engine once a user action has been done on the dom.
  97346. * This is helpful to resume play once browser policies have been satisfied.
  97347. */
  97348. unlock(): void;
  97349. }
  97350. /**
  97351. * This represents the default audio engine used in babylon.
  97352. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97354. */
  97355. export class AudioEngine implements IAudioEngine {
  97356. private _audioContext;
  97357. private _audioContextInitialized;
  97358. private _muteButton;
  97359. private _hostElement;
  97360. /**
  97361. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97362. */
  97363. canUseWebAudio: boolean;
  97364. /**
  97365. * The master gain node defines the global audio volume of your audio engine.
  97366. */
  97367. masterGain: GainNode;
  97368. /**
  97369. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97370. * @ignoreNaming
  97371. */
  97372. WarnedWebAudioUnsupported: boolean;
  97373. /**
  97374. * Gets whether or not mp3 are supported by your browser.
  97375. */
  97376. isMP3supported: boolean;
  97377. /**
  97378. * Gets whether or not ogg are supported by your browser.
  97379. */
  97380. isOGGsupported: boolean;
  97381. /**
  97382. * Gets whether audio has been unlocked on the device.
  97383. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97384. * a user interaction has happened.
  97385. */
  97386. unlocked: boolean;
  97387. /**
  97388. * Defines if the audio engine relies on a custom unlocked button.
  97389. * In this case, the embedded button will not be displayed.
  97390. */
  97391. useCustomUnlockedButton: boolean;
  97392. /**
  97393. * Event raised when audio has been unlocked on the browser.
  97394. */
  97395. onAudioUnlockedObservable: Observable<AudioEngine>;
  97396. /**
  97397. * Event raised when audio has been locked on the browser.
  97398. */
  97399. onAudioLockedObservable: Observable<AudioEngine>;
  97400. /**
  97401. * Gets the current AudioContext if available.
  97402. */
  97403. readonly audioContext: Nullable<AudioContext>;
  97404. private _connectedAnalyser;
  97405. /**
  97406. * Instantiates a new audio engine.
  97407. *
  97408. * There should be only one per page as some browsers restrict the number
  97409. * of audio contexts you can create.
  97410. * @param hostElement defines the host element where to display the mute icon if necessary
  97411. */
  97412. constructor(hostElement?: Nullable<HTMLElement>);
  97413. /**
  97414. * Flags the audio engine in Locked state.
  97415. * This happens due to new browser policies preventing audio to autoplay.
  97416. */
  97417. lock(): void;
  97418. /**
  97419. * Unlocks the audio engine once a user action has been done on the dom.
  97420. * This is helpful to resume play once browser policies have been satisfied.
  97421. */
  97422. unlock(): void;
  97423. private _resumeAudioContext;
  97424. private _initializeAudioContext;
  97425. private _tryToRun;
  97426. private _triggerRunningState;
  97427. private _triggerSuspendedState;
  97428. private _displayMuteButton;
  97429. private _moveButtonToTopLeft;
  97430. private _onResize;
  97431. private _hideMuteButton;
  97432. /**
  97433. * Destroy and release the resources associated with the audio ccontext.
  97434. */
  97435. dispose(): void;
  97436. /**
  97437. * Gets the global volume sets on the master gain.
  97438. * @returns the global volume if set or -1 otherwise
  97439. */
  97440. getGlobalVolume(): number;
  97441. /**
  97442. * Sets the global volume of your experience (sets on the master gain).
  97443. * @param newVolume Defines the new global volume of the application
  97444. */
  97445. setGlobalVolume(newVolume: number): void;
  97446. /**
  97447. * Connect the audio engine to an audio analyser allowing some amazing
  97448. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97450. * @param analyser The analyser to connect to the engine
  97451. */
  97452. connectToAnalyser(analyser: Analyser): void;
  97453. }
  97454. }
  97455. declare module BABYLON {
  97456. /**
  97457. * Interface used to present a loading screen while loading a scene
  97458. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97459. */
  97460. export interface ILoadingScreen {
  97461. /**
  97462. * Function called to display the loading screen
  97463. */
  97464. displayLoadingUI: () => void;
  97465. /**
  97466. * Function called to hide the loading screen
  97467. */
  97468. hideLoadingUI: () => void;
  97469. /**
  97470. * Gets or sets the color to use for the background
  97471. */
  97472. loadingUIBackgroundColor: string;
  97473. /**
  97474. * Gets or sets the text to display while loading
  97475. */
  97476. loadingUIText: string;
  97477. }
  97478. /**
  97479. * Class used for the default loading screen
  97480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97481. */
  97482. export class DefaultLoadingScreen implements ILoadingScreen {
  97483. private _renderingCanvas;
  97484. private _loadingText;
  97485. private _loadingDivBackgroundColor;
  97486. private _loadingDiv;
  97487. private _loadingTextDiv;
  97488. /** Gets or sets the logo url to use for the default loading screen */
  97489. static DefaultLogoUrl: string;
  97490. /** Gets or sets the spinner url to use for the default loading screen */
  97491. static DefaultSpinnerUrl: string;
  97492. /**
  97493. * Creates a new default loading screen
  97494. * @param _renderingCanvas defines the canvas used to render the scene
  97495. * @param _loadingText defines the default text to display
  97496. * @param _loadingDivBackgroundColor defines the default background color
  97497. */
  97498. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97499. /**
  97500. * Function called to display the loading screen
  97501. */
  97502. displayLoadingUI(): void;
  97503. /**
  97504. * Function called to hide the loading screen
  97505. */
  97506. hideLoadingUI(): void;
  97507. /**
  97508. * Gets or sets the text to display while loading
  97509. */
  97510. loadingUIText: string;
  97511. /**
  97512. * Gets or sets the color to use for the background
  97513. */
  97514. loadingUIBackgroundColor: string;
  97515. private _resizeLoadingUI;
  97516. }
  97517. }
  97518. declare module BABYLON {
  97519. /**
  97520. * Interface for any object that can request an animation frame
  97521. */
  97522. export interface ICustomAnimationFrameRequester {
  97523. /**
  97524. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97525. */
  97526. renderFunction?: Function;
  97527. /**
  97528. * Called to request the next frame to render to
  97529. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97530. */
  97531. requestAnimationFrame: Function;
  97532. /**
  97533. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97534. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97535. */
  97536. requestID?: number;
  97537. }
  97538. }
  97539. declare module BABYLON {
  97540. /**
  97541. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97542. */
  97543. export class PerformanceMonitor {
  97544. private _enabled;
  97545. private _rollingFrameTime;
  97546. private _lastFrameTimeMs;
  97547. /**
  97548. * constructor
  97549. * @param frameSampleSize The number of samples required to saturate the sliding window
  97550. */
  97551. constructor(frameSampleSize?: number);
  97552. /**
  97553. * Samples current frame
  97554. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97555. */
  97556. sampleFrame(timeMs?: number): void;
  97557. /**
  97558. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97559. */
  97560. readonly averageFrameTime: number;
  97561. /**
  97562. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97563. */
  97564. readonly averageFrameTimeVariance: number;
  97565. /**
  97566. * Returns the frame time of the most recent frame
  97567. */
  97568. readonly instantaneousFrameTime: number;
  97569. /**
  97570. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97571. */
  97572. readonly averageFPS: number;
  97573. /**
  97574. * Returns the average framerate in frames per second using the most recent frame time
  97575. */
  97576. readonly instantaneousFPS: number;
  97577. /**
  97578. * Returns true if enough samples have been taken to completely fill the sliding window
  97579. */
  97580. readonly isSaturated: boolean;
  97581. /**
  97582. * Enables contributions to the sliding window sample set
  97583. */
  97584. enable(): void;
  97585. /**
  97586. * Disables contributions to the sliding window sample set
  97587. * Samples will not be interpolated over the disabled period
  97588. */
  97589. disable(): void;
  97590. /**
  97591. * Returns true if sampling is enabled
  97592. */
  97593. readonly isEnabled: boolean;
  97594. /**
  97595. * Resets performance monitor
  97596. */
  97597. reset(): void;
  97598. }
  97599. /**
  97600. * RollingAverage
  97601. *
  97602. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97603. */
  97604. export class RollingAverage {
  97605. /**
  97606. * Current average
  97607. */
  97608. average: number;
  97609. /**
  97610. * Current variance
  97611. */
  97612. variance: number;
  97613. protected _samples: Array<number>;
  97614. protected _sampleCount: number;
  97615. protected _pos: number;
  97616. protected _m2: number;
  97617. /**
  97618. * constructor
  97619. * @param length The number of samples required to saturate the sliding window
  97620. */
  97621. constructor(length: number);
  97622. /**
  97623. * Adds a sample to the sample set
  97624. * @param v The sample value
  97625. */
  97626. add(v: number): void;
  97627. /**
  97628. * Returns previously added values or null if outside of history or outside the sliding window domain
  97629. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97630. * @return Value previously recorded with add() or null if outside of range
  97631. */
  97632. history(i: number): number;
  97633. /**
  97634. * Returns true if enough samples have been taken to completely fill the sliding window
  97635. * @return true if sample-set saturated
  97636. */
  97637. isSaturated(): boolean;
  97638. /**
  97639. * Resets the rolling average (equivalent to 0 samples taken so far)
  97640. */
  97641. reset(): void;
  97642. /**
  97643. * Wraps a value around the sample range boundaries
  97644. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97645. * @return Wrapped position in sample range
  97646. */
  97647. protected _wrapPosition(i: number): number;
  97648. }
  97649. }
  97650. declare module BABYLON {
  97651. /**
  97652. * This class is used to track a performance counter which is number based.
  97653. * The user has access to many properties which give statistics of different nature.
  97654. *
  97655. * The implementer can track two kinds of Performance Counter: time and count.
  97656. * 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.
  97657. * 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.
  97658. */
  97659. export class PerfCounter {
  97660. /**
  97661. * Gets or sets a global boolean to turn on and off all the counters
  97662. */
  97663. static Enabled: boolean;
  97664. /**
  97665. * Returns the smallest value ever
  97666. */
  97667. readonly min: number;
  97668. /**
  97669. * Returns the biggest value ever
  97670. */
  97671. readonly max: number;
  97672. /**
  97673. * Returns the average value since the performance counter is running
  97674. */
  97675. readonly average: number;
  97676. /**
  97677. * Returns the average value of the last second the counter was monitored
  97678. */
  97679. readonly lastSecAverage: number;
  97680. /**
  97681. * Returns the current value
  97682. */
  97683. readonly current: number;
  97684. /**
  97685. * Gets the accumulated total
  97686. */
  97687. readonly total: number;
  97688. /**
  97689. * Gets the total value count
  97690. */
  97691. readonly count: number;
  97692. /**
  97693. * Creates a new counter
  97694. */
  97695. constructor();
  97696. /**
  97697. * Call this method to start monitoring a new frame.
  97698. * 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.
  97699. */
  97700. fetchNewFrame(): void;
  97701. /**
  97702. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97703. * @param newCount the count value to add to the monitored count
  97704. * @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.
  97705. */
  97706. addCount(newCount: number, fetchResult: boolean): void;
  97707. /**
  97708. * Start monitoring this performance counter
  97709. */
  97710. beginMonitoring(): void;
  97711. /**
  97712. * Compute the time lapsed since the previous beginMonitoring() call.
  97713. * @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
  97714. */
  97715. endMonitoring(newFrame?: boolean): void;
  97716. private _fetchResult;
  97717. private _startMonitoringTime;
  97718. private _min;
  97719. private _max;
  97720. private _average;
  97721. private _current;
  97722. private _totalValueCount;
  97723. private _totalAccumulated;
  97724. private _lastSecAverage;
  97725. private _lastSecAccumulated;
  97726. private _lastSecTime;
  97727. private _lastSecValueCount;
  97728. }
  97729. }
  97730. declare module BABYLON {
  97731. /**
  97732. * Defines the interface used by display changed events
  97733. */
  97734. export interface IDisplayChangedEventArgs {
  97735. /** Gets the vrDisplay object (if any) */
  97736. vrDisplay: Nullable<any>;
  97737. /** Gets a boolean indicating if webVR is supported */
  97738. vrSupported: boolean;
  97739. }
  97740. /**
  97741. * Defines the interface used by objects containing a viewport (like a camera)
  97742. */
  97743. interface IViewportOwnerLike {
  97744. /**
  97745. * Gets or sets the viewport
  97746. */
  97747. viewport: IViewportLike;
  97748. }
  97749. /**
  97750. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97751. */
  97752. export class Engine extends ThinEngine {
  97753. /** Defines that alpha blending is disabled */
  97754. static readonly ALPHA_DISABLE: number;
  97755. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97756. static readonly ALPHA_ADD: number;
  97757. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97758. static readonly ALPHA_COMBINE: number;
  97759. /** Defines that alpha blending to DEST - SRC * DEST */
  97760. static readonly ALPHA_SUBTRACT: number;
  97761. /** Defines that alpha blending to SRC * DEST */
  97762. static readonly ALPHA_MULTIPLY: number;
  97763. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97764. static readonly ALPHA_MAXIMIZED: number;
  97765. /** Defines that alpha blending to SRC + DEST */
  97766. static readonly ALPHA_ONEONE: number;
  97767. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97768. static readonly ALPHA_PREMULTIPLIED: number;
  97769. /**
  97770. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97771. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97772. */
  97773. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97774. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97775. static readonly ALPHA_INTERPOLATE: number;
  97776. /**
  97777. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97778. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97779. */
  97780. static readonly ALPHA_SCREENMODE: number;
  97781. /** Defines that the ressource is not delayed*/
  97782. static readonly DELAYLOADSTATE_NONE: number;
  97783. /** Defines that the ressource was successfully delay loaded */
  97784. static readonly DELAYLOADSTATE_LOADED: number;
  97785. /** Defines that the ressource is currently delay loading */
  97786. static readonly DELAYLOADSTATE_LOADING: number;
  97787. /** Defines that the ressource is delayed and has not started loading */
  97788. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97789. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97790. static readonly NEVER: number;
  97791. /** 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 */
  97792. static readonly ALWAYS: number;
  97793. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97794. static readonly LESS: number;
  97795. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97796. static readonly EQUAL: number;
  97797. /** 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 */
  97798. static readonly LEQUAL: number;
  97799. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97800. static readonly GREATER: number;
  97801. /** 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 */
  97802. static readonly GEQUAL: number;
  97803. /** 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 */
  97804. static readonly NOTEQUAL: number;
  97805. /** Passed to stencilOperation to specify that stencil value must be kept */
  97806. static readonly KEEP: number;
  97807. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97808. static readonly REPLACE: number;
  97809. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97810. static readonly INCR: number;
  97811. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97812. static readonly DECR: number;
  97813. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97814. static readonly INVERT: number;
  97815. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97816. static readonly INCR_WRAP: number;
  97817. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97818. static readonly DECR_WRAP: number;
  97819. /** Texture is not repeating outside of 0..1 UVs */
  97820. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97821. /** Texture is repeating outside of 0..1 UVs */
  97822. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97823. /** Texture is repeating and mirrored */
  97824. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97825. /** ALPHA */
  97826. static readonly TEXTUREFORMAT_ALPHA: number;
  97827. /** LUMINANCE */
  97828. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97829. /** LUMINANCE_ALPHA */
  97830. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97831. /** RGB */
  97832. static readonly TEXTUREFORMAT_RGB: number;
  97833. /** RGBA */
  97834. static readonly TEXTUREFORMAT_RGBA: number;
  97835. /** RED */
  97836. static readonly TEXTUREFORMAT_RED: number;
  97837. /** RED (2nd reference) */
  97838. static readonly TEXTUREFORMAT_R: number;
  97839. /** RG */
  97840. static readonly TEXTUREFORMAT_RG: number;
  97841. /** RED_INTEGER */
  97842. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97843. /** RED_INTEGER (2nd reference) */
  97844. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97845. /** RG_INTEGER */
  97846. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97847. /** RGB_INTEGER */
  97848. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97849. /** RGBA_INTEGER */
  97850. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97851. /** UNSIGNED_BYTE */
  97852. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97853. /** UNSIGNED_BYTE (2nd reference) */
  97854. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97855. /** FLOAT */
  97856. static readonly TEXTURETYPE_FLOAT: number;
  97857. /** HALF_FLOAT */
  97858. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97859. /** BYTE */
  97860. static readonly TEXTURETYPE_BYTE: number;
  97861. /** SHORT */
  97862. static readonly TEXTURETYPE_SHORT: number;
  97863. /** UNSIGNED_SHORT */
  97864. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97865. /** INT */
  97866. static readonly TEXTURETYPE_INT: number;
  97867. /** UNSIGNED_INT */
  97868. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97869. /** UNSIGNED_SHORT_4_4_4_4 */
  97870. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97871. /** UNSIGNED_SHORT_5_5_5_1 */
  97872. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97873. /** UNSIGNED_SHORT_5_6_5 */
  97874. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97875. /** UNSIGNED_INT_2_10_10_10_REV */
  97876. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97877. /** UNSIGNED_INT_24_8 */
  97878. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97879. /** UNSIGNED_INT_10F_11F_11F_REV */
  97880. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97881. /** UNSIGNED_INT_5_9_9_9_REV */
  97882. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97883. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97884. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97885. /** nearest is mag = nearest and min = nearest and mip = linear */
  97886. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97887. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97888. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97889. /** Trilinear is mag = linear and min = linear and mip = linear */
  97890. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97891. /** nearest is mag = nearest and min = nearest and mip = linear */
  97892. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97893. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97894. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97895. /** Trilinear is mag = linear and min = linear and mip = linear */
  97896. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97897. /** mag = nearest and min = nearest and mip = nearest */
  97898. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97899. /** mag = nearest and min = linear and mip = nearest */
  97900. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97901. /** mag = nearest and min = linear and mip = linear */
  97902. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97903. /** mag = nearest and min = linear and mip = none */
  97904. static readonly TEXTURE_NEAREST_LINEAR: number;
  97905. /** mag = nearest and min = nearest and mip = none */
  97906. static readonly TEXTURE_NEAREST_NEAREST: number;
  97907. /** mag = linear and min = nearest and mip = nearest */
  97908. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97909. /** mag = linear and min = nearest and mip = linear */
  97910. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97911. /** mag = linear and min = linear and mip = none */
  97912. static readonly TEXTURE_LINEAR_LINEAR: number;
  97913. /** mag = linear and min = nearest and mip = none */
  97914. static readonly TEXTURE_LINEAR_NEAREST: number;
  97915. /** Explicit coordinates mode */
  97916. static readonly TEXTURE_EXPLICIT_MODE: number;
  97917. /** Spherical coordinates mode */
  97918. static readonly TEXTURE_SPHERICAL_MODE: number;
  97919. /** Planar coordinates mode */
  97920. static readonly TEXTURE_PLANAR_MODE: number;
  97921. /** Cubic coordinates mode */
  97922. static readonly TEXTURE_CUBIC_MODE: number;
  97923. /** Projection coordinates mode */
  97924. static readonly TEXTURE_PROJECTION_MODE: number;
  97925. /** Skybox coordinates mode */
  97926. static readonly TEXTURE_SKYBOX_MODE: number;
  97927. /** Inverse Cubic coordinates mode */
  97928. static readonly TEXTURE_INVCUBIC_MODE: number;
  97929. /** Equirectangular coordinates mode */
  97930. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97931. /** Equirectangular Fixed coordinates mode */
  97932. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97933. /** Equirectangular Fixed Mirrored coordinates mode */
  97934. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97935. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97936. static readonly SCALEMODE_FLOOR: number;
  97937. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97938. static readonly SCALEMODE_NEAREST: number;
  97939. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97940. static readonly SCALEMODE_CEILING: number;
  97941. /**
  97942. * Returns the current npm package of the sdk
  97943. */
  97944. static readonly NpmPackage: string;
  97945. /**
  97946. * Returns the current version of the framework
  97947. */
  97948. static readonly Version: string;
  97949. /** Gets the list of created engines */
  97950. static readonly Instances: Engine[];
  97951. /**
  97952. * Gets the latest created engine
  97953. */
  97954. static readonly LastCreatedEngine: Nullable<Engine>;
  97955. /**
  97956. * Gets the latest created scene
  97957. */
  97958. static readonly LastCreatedScene: Nullable<Scene>;
  97959. /**
  97960. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97961. * @param flag defines which part of the materials must be marked as dirty
  97962. * @param predicate defines a predicate used to filter which materials should be affected
  97963. */
  97964. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97965. /**
  97966. * Method called to create the default loading screen.
  97967. * This can be overriden in your own app.
  97968. * @param canvas The rendering canvas element
  97969. * @returns The loading screen
  97970. */
  97971. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97972. /**
  97973. * Method called to create the default rescale post process on each engine.
  97974. */
  97975. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97976. /**
  97977. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97978. **/
  97979. enableOfflineSupport: boolean;
  97980. /**
  97981. * 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)
  97982. **/
  97983. disableManifestCheck: boolean;
  97984. /**
  97985. * Gets the list of created scenes
  97986. */
  97987. scenes: Scene[];
  97988. /**
  97989. * Event raised when a new scene is created
  97990. */
  97991. onNewSceneAddedObservable: Observable<Scene>;
  97992. /**
  97993. * Gets the list of created postprocesses
  97994. */
  97995. postProcesses: PostProcess[];
  97996. /**
  97997. * Gets a boolean indicating if the pointer is currently locked
  97998. */
  97999. isPointerLock: boolean;
  98000. /**
  98001. * Observable event triggered each time the rendering canvas is resized
  98002. */
  98003. onResizeObservable: Observable<Engine>;
  98004. /**
  98005. * Observable event triggered each time the canvas loses focus
  98006. */
  98007. onCanvasBlurObservable: Observable<Engine>;
  98008. /**
  98009. * Observable event triggered each time the canvas gains focus
  98010. */
  98011. onCanvasFocusObservable: Observable<Engine>;
  98012. /**
  98013. * Observable event triggered each time the canvas receives pointerout event
  98014. */
  98015. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98016. /**
  98017. * Observable raised when the engine begins a new frame
  98018. */
  98019. onBeginFrameObservable: Observable<Engine>;
  98020. /**
  98021. * If set, will be used to request the next animation frame for the render loop
  98022. */
  98023. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98024. /**
  98025. * Observable raised when the engine ends the current frame
  98026. */
  98027. onEndFrameObservable: Observable<Engine>;
  98028. /**
  98029. * Observable raised when the engine is about to compile a shader
  98030. */
  98031. onBeforeShaderCompilationObservable: Observable<Engine>;
  98032. /**
  98033. * Observable raised when the engine has jsut compiled a shader
  98034. */
  98035. onAfterShaderCompilationObservable: Observable<Engine>;
  98036. /**
  98037. * Gets the audio engine
  98038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98039. * @ignorenaming
  98040. */
  98041. static audioEngine: IAudioEngine;
  98042. /**
  98043. * Default AudioEngine factory responsible of creating the Audio Engine.
  98044. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98045. */
  98046. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98047. /**
  98048. * Default offline support factory responsible of creating a tool used to store data locally.
  98049. * By default, this will create a Database object if the workload has been embedded.
  98050. */
  98051. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98052. private _loadingScreen;
  98053. private _pointerLockRequested;
  98054. private _dummyFramebuffer;
  98055. private _rescalePostProcess;
  98056. /** @hidden */
  98057. protected _alphaMode: number;
  98058. /** @hidden */
  98059. protected _alphaEquation: number;
  98060. private _deterministicLockstep;
  98061. private _lockstepMaxSteps;
  98062. protected readonly _supportsHardwareTextureRescaling: boolean;
  98063. private _fps;
  98064. private _deltaTime;
  98065. /** @hidden */
  98066. _drawCalls: PerfCounter;
  98067. /**
  98068. * Turn this value on if you want to pause FPS computation when in background
  98069. */
  98070. disablePerformanceMonitorInBackground: boolean;
  98071. private _performanceMonitor;
  98072. /**
  98073. * Gets the performance monitor attached to this engine
  98074. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98075. */
  98076. readonly performanceMonitor: PerformanceMonitor;
  98077. private _onFocus;
  98078. private _onBlur;
  98079. private _onCanvasPointerOut;
  98080. private _onCanvasBlur;
  98081. private _onCanvasFocus;
  98082. private _onFullscreenChange;
  98083. private _onPointerLockChange;
  98084. /**
  98085. * Creates a new engine
  98086. * @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
  98087. * @param antialias defines enable antialiasing (default: false)
  98088. * @param options defines further options to be sent to the getContext() function
  98089. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98090. */
  98091. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98092. /**
  98093. * Gets current aspect ratio
  98094. * @param viewportOwner defines the camera to use to get the aspect ratio
  98095. * @param useScreen defines if screen size must be used (or the current render target if any)
  98096. * @returns a number defining the aspect ratio
  98097. */
  98098. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98099. /**
  98100. * Gets current screen aspect ratio
  98101. * @returns a number defining the aspect ratio
  98102. */
  98103. getScreenAspectRatio(): number;
  98104. /**
  98105. * Gets host document
  98106. * @returns the host document object
  98107. */
  98108. getHostDocument(): Document;
  98109. /**
  98110. * Gets the client rect of the HTML canvas attached with the current webGL context
  98111. * @returns a client rectanglee
  98112. */
  98113. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98114. /**
  98115. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98117. * @returns true if engine is in deterministic lock step mode
  98118. */
  98119. isDeterministicLockStep(): boolean;
  98120. /**
  98121. * Gets the max steps when engine is running in deterministic lock step
  98122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98123. * @returns the max steps
  98124. */
  98125. getLockstepMaxSteps(): number;
  98126. /**
  98127. * Force the mipmap generation for the given render target texture
  98128. * @param texture defines the render target texture to use
  98129. */
  98130. generateMipMapsForCubemap(texture: InternalTexture): void;
  98131. /** States */
  98132. /**
  98133. * Set various states to the webGL context
  98134. * @param culling defines backface culling state
  98135. * @param zOffset defines the value to apply to zOffset (0 by default)
  98136. * @param force defines if states must be applied even if cache is up to date
  98137. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98138. */
  98139. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98140. /**
  98141. * Set the z offset to apply to current rendering
  98142. * @param value defines the offset to apply
  98143. */
  98144. setZOffset(value: number): void;
  98145. /**
  98146. * Gets the current value of the zOffset
  98147. * @returns the current zOffset state
  98148. */
  98149. getZOffset(): number;
  98150. /**
  98151. * Enable or disable depth buffering
  98152. * @param enable defines the state to set
  98153. */
  98154. setDepthBuffer(enable: boolean): void;
  98155. /**
  98156. * Gets a boolean indicating if depth writing is enabled
  98157. * @returns the current depth writing state
  98158. */
  98159. getDepthWrite(): boolean;
  98160. /**
  98161. * Enable or disable depth writing
  98162. * @param enable defines the state to set
  98163. */
  98164. setDepthWrite(enable: boolean): void;
  98165. /**
  98166. * Enable or disable color writing
  98167. * @param enable defines the state to set
  98168. */
  98169. setColorWrite(enable: boolean): void;
  98170. /**
  98171. * Gets a boolean indicating if color writing is enabled
  98172. * @returns the current color writing state
  98173. */
  98174. getColorWrite(): boolean;
  98175. /**
  98176. * Sets alpha constants used by some alpha blending modes
  98177. * @param r defines the red component
  98178. * @param g defines the green component
  98179. * @param b defines the blue component
  98180. * @param a defines the alpha component
  98181. */
  98182. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98183. /**
  98184. * Sets the current alpha mode
  98185. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98186. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98187. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98188. */
  98189. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98190. /**
  98191. * Gets the current alpha mode
  98192. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98193. * @returns the current alpha mode
  98194. */
  98195. getAlphaMode(): number;
  98196. /**
  98197. * Sets the current alpha equation
  98198. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98199. */
  98200. setAlphaEquation(equation: number): void;
  98201. /**
  98202. * Gets the current alpha equation.
  98203. * @returns the current alpha equation
  98204. */
  98205. getAlphaEquation(): number;
  98206. /**
  98207. * Gets a boolean indicating if stencil buffer is enabled
  98208. * @returns the current stencil buffer state
  98209. */
  98210. getStencilBuffer(): boolean;
  98211. /**
  98212. * Enable or disable the stencil buffer
  98213. * @param enable defines if the stencil buffer must be enabled or disabled
  98214. */
  98215. setStencilBuffer(enable: boolean): void;
  98216. /**
  98217. * Gets the current stencil mask
  98218. * @returns a number defining the new stencil mask to use
  98219. */
  98220. getStencilMask(): number;
  98221. /**
  98222. * Sets the current stencil mask
  98223. * @param mask defines the new stencil mask to use
  98224. */
  98225. setStencilMask(mask: number): void;
  98226. /**
  98227. * Gets the current stencil function
  98228. * @returns a number defining the stencil function to use
  98229. */
  98230. getStencilFunction(): number;
  98231. /**
  98232. * Gets the current stencil reference value
  98233. * @returns a number defining the stencil reference value to use
  98234. */
  98235. getStencilFunctionReference(): number;
  98236. /**
  98237. * Gets the current stencil mask
  98238. * @returns a number defining the stencil mask to use
  98239. */
  98240. getStencilFunctionMask(): number;
  98241. /**
  98242. * Sets the current stencil function
  98243. * @param stencilFunc defines the new stencil function to use
  98244. */
  98245. setStencilFunction(stencilFunc: number): void;
  98246. /**
  98247. * Sets the current stencil reference
  98248. * @param reference defines the new stencil reference to use
  98249. */
  98250. setStencilFunctionReference(reference: number): void;
  98251. /**
  98252. * Sets the current stencil mask
  98253. * @param mask defines the new stencil mask to use
  98254. */
  98255. setStencilFunctionMask(mask: number): void;
  98256. /**
  98257. * Gets the current stencil operation when stencil fails
  98258. * @returns a number defining stencil operation to use when stencil fails
  98259. */
  98260. getStencilOperationFail(): number;
  98261. /**
  98262. * Gets the current stencil operation when depth fails
  98263. * @returns a number defining stencil operation to use when depth fails
  98264. */
  98265. getStencilOperationDepthFail(): number;
  98266. /**
  98267. * Gets the current stencil operation when stencil passes
  98268. * @returns a number defining stencil operation to use when stencil passes
  98269. */
  98270. getStencilOperationPass(): number;
  98271. /**
  98272. * Sets the stencil operation to use when stencil fails
  98273. * @param operation defines the stencil operation to use when stencil fails
  98274. */
  98275. setStencilOperationFail(operation: number): void;
  98276. /**
  98277. * Sets the stencil operation to use when depth fails
  98278. * @param operation defines the stencil operation to use when depth fails
  98279. */
  98280. setStencilOperationDepthFail(operation: number): void;
  98281. /**
  98282. * Sets the stencil operation to use when stencil passes
  98283. * @param operation defines the stencil operation to use when stencil passes
  98284. */
  98285. setStencilOperationPass(operation: number): void;
  98286. /**
  98287. * Sets a boolean indicating if the dithering state is enabled or disabled
  98288. * @param value defines the dithering state
  98289. */
  98290. setDitheringState(value: boolean): void;
  98291. /**
  98292. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98293. * @param value defines the rasterizer state
  98294. */
  98295. setRasterizerState(value: boolean): void;
  98296. /**
  98297. * Gets the current depth function
  98298. * @returns a number defining the depth function
  98299. */
  98300. getDepthFunction(): Nullable<number>;
  98301. /**
  98302. * Sets the current depth function
  98303. * @param depthFunc defines the function to use
  98304. */
  98305. setDepthFunction(depthFunc: number): void;
  98306. /**
  98307. * Sets the current depth function to GREATER
  98308. */
  98309. setDepthFunctionToGreater(): void;
  98310. /**
  98311. * Sets the current depth function to GEQUAL
  98312. */
  98313. setDepthFunctionToGreaterOrEqual(): void;
  98314. /**
  98315. * Sets the current depth function to LESS
  98316. */
  98317. setDepthFunctionToLess(): void;
  98318. /**
  98319. * Sets the current depth function to LEQUAL
  98320. */
  98321. setDepthFunctionToLessOrEqual(): void;
  98322. private _cachedStencilBuffer;
  98323. private _cachedStencilFunction;
  98324. private _cachedStencilMask;
  98325. private _cachedStencilOperationPass;
  98326. private _cachedStencilOperationFail;
  98327. private _cachedStencilOperationDepthFail;
  98328. private _cachedStencilReference;
  98329. /**
  98330. * Caches the the state of the stencil buffer
  98331. */
  98332. cacheStencilState(): void;
  98333. /**
  98334. * Restores the state of the stencil buffer
  98335. */
  98336. restoreStencilState(): void;
  98337. /**
  98338. * Directly set the WebGL Viewport
  98339. * @param x defines the x coordinate of the viewport (in screen space)
  98340. * @param y defines the y coordinate of the viewport (in screen space)
  98341. * @param width defines the width of the viewport (in screen space)
  98342. * @param height defines the height of the viewport (in screen space)
  98343. * @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
  98344. */
  98345. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98346. /**
  98347. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98348. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98349. * @param y defines the y-coordinate of the corner of the clear rectangle
  98350. * @param width defines the width of the clear rectangle
  98351. * @param height defines the height of the clear rectangle
  98352. * @param clearColor defines the clear color
  98353. */
  98354. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98355. /**
  98356. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98357. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98358. * @param y defines the y-coordinate of the corner of the clear rectangle
  98359. * @param width defines the width of the clear rectangle
  98360. * @param height defines the height of the clear rectangle
  98361. */
  98362. enableScissor(x: number, y: number, width: number, height: number): void;
  98363. /**
  98364. * Disable previously set scissor test rectangle
  98365. */
  98366. disableScissor(): void;
  98367. protected _reportDrawCall(): void;
  98368. /**
  98369. * Initializes a webVR display and starts listening to display change events
  98370. * The onVRDisplayChangedObservable will be notified upon these changes
  98371. * @returns The onVRDisplayChangedObservable
  98372. */
  98373. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98374. /** @hidden */
  98375. _prepareVRComponent(): void;
  98376. /** @hidden */
  98377. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98378. /** @hidden */
  98379. _submitVRFrame(): void;
  98380. /**
  98381. * Call this function to leave webVR mode
  98382. * Will do nothing if webVR is not supported or if there is no webVR device
  98383. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98384. */
  98385. disableVR(): void;
  98386. /**
  98387. * Gets a boolean indicating that the system is in VR mode and is presenting
  98388. * @returns true if VR mode is engaged
  98389. */
  98390. isVRPresenting(): boolean;
  98391. /** @hidden */
  98392. _requestVRFrame(): void;
  98393. /** @hidden */
  98394. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98395. /**
  98396. * Gets the source code of the vertex shader associated with a specific webGL program
  98397. * @param program defines the program to use
  98398. * @returns a string containing the source code of the vertex shader associated with the program
  98399. */
  98400. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98401. /**
  98402. * Gets the source code of the fragment shader associated with a specific webGL program
  98403. * @param program defines the program to use
  98404. * @returns a string containing the source code of the fragment shader associated with the program
  98405. */
  98406. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98407. /**
  98408. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98409. * @param x defines the x coordinate of the rectangle where pixels must be read
  98410. * @param y defines the y coordinate of the rectangle where pixels must be read
  98411. * @param width defines the width of the rectangle where pixels must be read
  98412. * @param height defines the height of the rectangle where pixels must be read
  98413. * @returns a Uint8Array containing RGBA colors
  98414. */
  98415. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98416. /**
  98417. * Sets a depth stencil texture from a render target to the according uniform.
  98418. * @param channel The texture channel
  98419. * @param uniform The uniform to set
  98420. * @param texture The render target texture containing the depth stencil texture to apply
  98421. */
  98422. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98423. /**
  98424. * Sets a texture to the webGL context from a postprocess
  98425. * @param channel defines the channel to use
  98426. * @param postProcess defines the source postprocess
  98427. */
  98428. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98429. /**
  98430. * Binds the output of the passed in post process to the texture channel specified
  98431. * @param channel The channel the texture should be bound to
  98432. * @param postProcess The post process which's output should be bound
  98433. */
  98434. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98435. /** @hidden */
  98436. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98437. protected _rebuildBuffers(): void;
  98438. _renderLoop(): void;
  98439. /**
  98440. * Toggle full screen mode
  98441. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98442. */
  98443. switchFullscreen(requestPointerLock: boolean): void;
  98444. /**
  98445. * Enters full screen mode
  98446. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98447. */
  98448. enterFullscreen(requestPointerLock: boolean): void;
  98449. /**
  98450. * Exits full screen mode
  98451. */
  98452. exitFullscreen(): void;
  98453. /**
  98454. * Enters Pointerlock mode
  98455. */
  98456. enterPointerlock(): void;
  98457. /**
  98458. * Exits Pointerlock mode
  98459. */
  98460. exitPointerlock(): void;
  98461. /**
  98462. * Begin a new frame
  98463. */
  98464. beginFrame(): void;
  98465. /**
  98466. * Enf the current frame
  98467. */
  98468. endFrame(): void;
  98469. resize(): void;
  98470. /**
  98471. * Set the compressed texture format to use, based on the formats you have, and the formats
  98472. * supported by the hardware / browser.
  98473. *
  98474. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98475. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98476. * to API arguments needed to compressed textures. This puts the burden on the container
  98477. * generator to house the arcane code for determining these for current & future formats.
  98478. *
  98479. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98480. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98481. *
  98482. * Note: The result of this call is not taken into account when a texture is base64.
  98483. *
  98484. * @param formatsAvailable defines the list of those format families you have created
  98485. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98486. *
  98487. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98488. * @returns The extension selected.
  98489. */
  98490. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98491. /**
  98492. * Force a specific size of the canvas
  98493. * @param width defines the new canvas' width
  98494. * @param height defines the new canvas' height
  98495. */
  98496. setSize(width: number, height: number): void;
  98497. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98498. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98499. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98500. _releaseTexture(texture: InternalTexture): void;
  98501. /**
  98502. * @hidden
  98503. * Rescales a texture
  98504. * @param source input texutre
  98505. * @param destination destination texture
  98506. * @param scene scene to use to render the resize
  98507. * @param internalFormat format to use when resizing
  98508. * @param onComplete callback to be called when resize has completed
  98509. */
  98510. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98511. /**
  98512. * Gets the current framerate
  98513. * @returns a number representing the framerate
  98514. */
  98515. getFps(): number;
  98516. /**
  98517. * Gets the time spent between current and previous frame
  98518. * @returns a number representing the delta time in ms
  98519. */
  98520. getDeltaTime(): number;
  98521. private _measureFps;
  98522. /**
  98523. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98524. * @param renderTarget The render target to set the frame buffer for
  98525. */
  98526. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98527. /**
  98528. * Update a dynamic index buffer
  98529. * @param indexBuffer defines the target index buffer
  98530. * @param indices defines the data to update
  98531. * @param offset defines the offset in the target index buffer where update should start
  98532. */
  98533. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98534. /**
  98535. * Updates the sample count of a render target texture
  98536. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98537. * @param texture defines the texture to update
  98538. * @param samples defines the sample count to set
  98539. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98540. */
  98541. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98542. /** @hidden */
  98543. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98544. dispose(): void;
  98545. private _disableTouchAction;
  98546. /**
  98547. * Display the loading screen
  98548. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98549. */
  98550. displayLoadingUI(): void;
  98551. /**
  98552. * Hide the loading screen
  98553. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98554. */
  98555. hideLoadingUI(): void;
  98556. /**
  98557. * Gets the current loading screen object
  98558. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98559. */
  98560. /**
  98561. * Sets the current loading screen object
  98562. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98563. */
  98564. loadingScreen: ILoadingScreen;
  98565. /**
  98566. * Sets the current loading screen text
  98567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98568. */
  98569. loadingUIText: string;
  98570. /**
  98571. * Sets the current loading screen background color
  98572. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98573. */
  98574. loadingUIBackgroundColor: string;
  98575. /** Pointerlock and fullscreen */
  98576. /**
  98577. * Ask the browser to promote the current element to pointerlock mode
  98578. * @param element defines the DOM element to promote
  98579. */
  98580. static _RequestPointerlock(element: HTMLElement): void;
  98581. /**
  98582. * Asks the browser to exit pointerlock mode
  98583. */
  98584. static _ExitPointerlock(): void;
  98585. /**
  98586. * Ask the browser to promote the current element to fullscreen rendering mode
  98587. * @param element defines the DOM element to promote
  98588. */
  98589. static _RequestFullscreen(element: HTMLElement): void;
  98590. /**
  98591. * Asks the browser to exit fullscreen mode
  98592. */
  98593. static _ExitFullscreen(): void;
  98594. }
  98595. }
  98596. declare module BABYLON {
  98597. /**
  98598. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98599. * during the life time of the application.
  98600. */
  98601. export class EngineStore {
  98602. /** Gets the list of created engines */
  98603. static Instances: Engine[];
  98604. /** @hidden */
  98605. static _LastCreatedScene: Nullable<Scene>;
  98606. /**
  98607. * Gets the latest created engine
  98608. */
  98609. static readonly LastCreatedEngine: Nullable<Engine>;
  98610. /**
  98611. * Gets the latest created scene
  98612. */
  98613. static readonly LastCreatedScene: Nullable<Scene>;
  98614. /**
  98615. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98616. * @ignorenaming
  98617. */
  98618. static UseFallbackTexture: boolean;
  98619. /**
  98620. * Texture content used if a texture cannot loaded
  98621. * @ignorenaming
  98622. */
  98623. static FallbackTexture: string;
  98624. }
  98625. }
  98626. declare module BABYLON {
  98627. /**
  98628. * Helper class that provides a small promise polyfill
  98629. */
  98630. export class PromisePolyfill {
  98631. /**
  98632. * Static function used to check if the polyfill is required
  98633. * If this is the case then the function will inject the polyfill to window.Promise
  98634. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98635. */
  98636. static Apply(force?: boolean): void;
  98637. }
  98638. }
  98639. declare module BABYLON {
  98640. /**
  98641. * Interface for screenshot methods with describe argument called `size` as object with options
  98642. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98643. */
  98644. export interface IScreenshotSize {
  98645. /**
  98646. * number in pixels for canvas height
  98647. */
  98648. height?: number;
  98649. /**
  98650. * multiplier allowing render at a higher or lower resolution
  98651. * If value is defined then height and width will be ignored and taken from camera
  98652. */
  98653. precision?: number;
  98654. /**
  98655. * number in pixels for canvas width
  98656. */
  98657. width?: number;
  98658. }
  98659. }
  98660. declare module BABYLON {
  98661. interface IColor4Like {
  98662. r: float;
  98663. g: float;
  98664. b: float;
  98665. a: float;
  98666. }
  98667. /**
  98668. * Class containing a set of static utilities functions
  98669. */
  98670. export class Tools {
  98671. /**
  98672. * Gets or sets the base URL to use to load assets
  98673. */
  98674. static BaseUrl: string;
  98675. /**
  98676. * Enable/Disable Custom HTTP Request Headers globally.
  98677. * default = false
  98678. * @see CustomRequestHeaders
  98679. */
  98680. static UseCustomRequestHeaders: boolean;
  98681. /**
  98682. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98683. * i.e. when loading files, where the server/service expects an Authorization header
  98684. */
  98685. static CustomRequestHeaders: {
  98686. [key: string]: string;
  98687. };
  98688. /**
  98689. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98690. */
  98691. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98692. /**
  98693. * Default behaviour for cors in the application.
  98694. * It can be a string if the expected behavior is identical in the entire app.
  98695. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98696. */
  98697. static CorsBehavior: string | ((url: string | string[]) => string);
  98698. /**
  98699. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98700. * @ignorenaming
  98701. */
  98702. static UseFallbackTexture: boolean;
  98703. /**
  98704. * Use this object to register external classes like custom textures or material
  98705. * to allow the laoders to instantiate them
  98706. */
  98707. static RegisteredExternalClasses: {
  98708. [key: string]: Object;
  98709. };
  98710. /**
  98711. * Texture content used if a texture cannot loaded
  98712. * @ignorenaming
  98713. */
  98714. static fallbackTexture: string;
  98715. /**
  98716. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98717. * @param u defines the coordinate on X axis
  98718. * @param v defines the coordinate on Y axis
  98719. * @param width defines the width of the source data
  98720. * @param height defines the height of the source data
  98721. * @param pixels defines the source byte array
  98722. * @param color defines the output color
  98723. */
  98724. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98725. /**
  98726. * Interpolates between a and b via alpha
  98727. * @param a The lower value (returned when alpha = 0)
  98728. * @param b The upper value (returned when alpha = 1)
  98729. * @param alpha The interpolation-factor
  98730. * @return The mixed value
  98731. */
  98732. static Mix(a: number, b: number, alpha: number): number;
  98733. /**
  98734. * Tries to instantiate a new object from a given class name
  98735. * @param className defines the class name to instantiate
  98736. * @returns the new object or null if the system was not able to do the instantiation
  98737. */
  98738. static Instantiate(className: string): any;
  98739. /**
  98740. * Provides a slice function that will work even on IE
  98741. * @param data defines the array to slice
  98742. * @param start defines the start of the data (optional)
  98743. * @param end defines the end of the data (optional)
  98744. * @returns the new sliced array
  98745. */
  98746. static Slice<T>(data: T, start?: number, end?: number): T;
  98747. /**
  98748. * Polyfill for setImmediate
  98749. * @param action defines the action to execute after the current execution block
  98750. */
  98751. static SetImmediate(action: () => void): void;
  98752. /**
  98753. * Function indicating if a number is an exponent of 2
  98754. * @param value defines the value to test
  98755. * @returns true if the value is an exponent of 2
  98756. */
  98757. static IsExponentOfTwo(value: number): boolean;
  98758. private static _tmpFloatArray;
  98759. /**
  98760. * Returns the nearest 32-bit single precision float representation of a Number
  98761. * @param value A Number. If the parameter is of a different type, it will get converted
  98762. * to a number or to NaN if it cannot be converted
  98763. * @returns number
  98764. */
  98765. static FloatRound(value: number): number;
  98766. /**
  98767. * Extracts the filename from a path
  98768. * @param path defines the path to use
  98769. * @returns the filename
  98770. */
  98771. static GetFilename(path: string): string;
  98772. /**
  98773. * Extracts the "folder" part of a path (everything before the filename).
  98774. * @param uri The URI to extract the info from
  98775. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98776. * @returns The "folder" part of the path
  98777. */
  98778. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98779. /**
  98780. * Extracts text content from a DOM element hierarchy
  98781. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98782. */
  98783. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98784. /**
  98785. * Convert an angle in radians to degrees
  98786. * @param angle defines the angle to convert
  98787. * @returns the angle in degrees
  98788. */
  98789. static ToDegrees(angle: number): number;
  98790. /**
  98791. * Convert an angle in degrees to radians
  98792. * @param angle defines the angle to convert
  98793. * @returns the angle in radians
  98794. */
  98795. static ToRadians(angle: number): number;
  98796. /**
  98797. * Encode a buffer to a base64 string
  98798. * @param buffer defines the buffer to encode
  98799. * @returns the encoded string
  98800. */
  98801. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98802. /**
  98803. * Returns an array if obj is not an array
  98804. * @param obj defines the object to evaluate as an array
  98805. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98806. * @returns either obj directly if obj is an array or a new array containing obj
  98807. */
  98808. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98809. /**
  98810. * Gets the pointer prefix to use
  98811. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98812. */
  98813. static GetPointerPrefix(): string;
  98814. /**
  98815. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98816. * @param url define the url we are trying
  98817. * @param element define the dom element where to configure the cors policy
  98818. */
  98819. static SetCorsBehavior(url: string | string[], element: {
  98820. crossOrigin: string | null;
  98821. }): void;
  98822. /**
  98823. * Removes unwanted characters from an url
  98824. * @param url defines the url to clean
  98825. * @returns the cleaned url
  98826. */
  98827. static CleanUrl(url: string): string;
  98828. /**
  98829. * Gets or sets a function used to pre-process url before using them to load assets
  98830. */
  98831. static PreprocessUrl: (url: string) => string;
  98832. /**
  98833. * Loads an image as an HTMLImageElement.
  98834. * @param input url string, ArrayBuffer, or Blob to load
  98835. * @param onLoad callback called when the image successfully loads
  98836. * @param onError callback called when the image fails to load
  98837. * @param offlineProvider offline provider for caching
  98838. * @returns the HTMLImageElement of the loaded image
  98839. */
  98840. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98841. /**
  98842. * Loads a file
  98843. * @param url url string, ArrayBuffer, or Blob to load
  98844. * @param onSuccess callback called when the file successfully loads
  98845. * @param onProgress callback called while file is loading (if the server supports this mode)
  98846. * @param offlineProvider defines the offline provider for caching
  98847. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98848. * @param onError callback called when the file fails to load
  98849. * @returns a file request object
  98850. */
  98851. 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;
  98852. /**
  98853. * Loads a file from a url
  98854. * @param url the file url to load
  98855. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98856. */
  98857. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98858. /**
  98859. * Load a script (identified by an url). When the url returns, the
  98860. * content of this file is added into a new script element, attached to the DOM (body element)
  98861. * @param scriptUrl defines the url of the script to laod
  98862. * @param onSuccess defines the callback called when the script is loaded
  98863. * @param onError defines the callback to call if an error occurs
  98864. * @param scriptId defines the id of the script element
  98865. */
  98866. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98867. /**
  98868. * Load an asynchronous script (identified by an url). When the url returns, the
  98869. * content of this file is added into a new script element, attached to the DOM (body element)
  98870. * @param scriptUrl defines the url of the script to laod
  98871. * @param scriptId defines the id of the script element
  98872. * @returns a promise request object
  98873. */
  98874. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98875. /**
  98876. * Loads a file from a blob
  98877. * @param fileToLoad defines the blob to use
  98878. * @param callback defines the callback to call when data is loaded
  98879. * @param progressCallback defines the callback to call during loading process
  98880. * @returns a file request object
  98881. */
  98882. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98883. /**
  98884. * Loads a file
  98885. * @param fileToLoad defines the file to load
  98886. * @param callback defines the callback to call when data is loaded
  98887. * @param progressCallBack defines the callback to call during loading process
  98888. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98889. * @returns a file request object
  98890. */
  98891. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98892. /**
  98893. * Creates a data url from a given string content
  98894. * @param content defines the content to convert
  98895. * @returns the new data url link
  98896. */
  98897. static FileAsURL(content: string): string;
  98898. /**
  98899. * Format the given number to a specific decimal format
  98900. * @param value defines the number to format
  98901. * @param decimals defines the number of decimals to use
  98902. * @returns the formatted string
  98903. */
  98904. static Format(value: number, decimals?: number): string;
  98905. /**
  98906. * Tries to copy an object by duplicating every property
  98907. * @param source defines the source object
  98908. * @param destination defines the target object
  98909. * @param doNotCopyList defines a list of properties to avoid
  98910. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98911. */
  98912. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98913. /**
  98914. * Gets a boolean indicating if the given object has no own property
  98915. * @param obj defines the object to test
  98916. * @returns true if object has no own property
  98917. */
  98918. static IsEmpty(obj: any): boolean;
  98919. /**
  98920. * Function used to register events at window level
  98921. * @param windowElement defines the Window object to use
  98922. * @param events defines the events to register
  98923. */
  98924. static RegisterTopRootEvents(windowElement: Window, events: {
  98925. name: string;
  98926. handler: Nullable<(e: FocusEvent) => any>;
  98927. }[]): void;
  98928. /**
  98929. * Function used to unregister events from window level
  98930. * @param windowElement defines the Window object to use
  98931. * @param events defines the events to unregister
  98932. */
  98933. static UnregisterTopRootEvents(windowElement: Window, events: {
  98934. name: string;
  98935. handler: Nullable<(e: FocusEvent) => any>;
  98936. }[]): void;
  98937. /**
  98938. * @ignore
  98939. */
  98940. static _ScreenshotCanvas: HTMLCanvasElement;
  98941. /**
  98942. * Dumps the current bound framebuffer
  98943. * @param width defines the rendering width
  98944. * @param height defines the rendering height
  98945. * @param engine defines the hosting engine
  98946. * @param successCallback defines the callback triggered once the data are available
  98947. * @param mimeType defines the mime type of the result
  98948. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98949. */
  98950. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98951. /**
  98952. * Converts the canvas data to blob.
  98953. * This acts as a polyfill for browsers not supporting the to blob function.
  98954. * @param canvas Defines the canvas to extract the data from
  98955. * @param successCallback Defines the callback triggered once the data are available
  98956. * @param mimeType Defines the mime type of the result
  98957. */
  98958. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98959. /**
  98960. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98961. * @param successCallback defines the callback triggered once the data are available
  98962. * @param mimeType defines the mime type of the result
  98963. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98964. */
  98965. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98966. /**
  98967. * Downloads a blob in the browser
  98968. * @param blob defines the blob to download
  98969. * @param fileName defines the name of the downloaded file
  98970. */
  98971. static Download(blob: Blob, fileName: string): void;
  98972. /**
  98973. * Captures a screenshot of the current rendering
  98974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98975. * @param engine defines the rendering engine
  98976. * @param camera defines the source camera
  98977. * @param size This parameter can be set to a single number or to an object with the
  98978. * following (optional) properties: precision, width, height. If a single number is passed,
  98979. * it will be used for both width and height. If an object is passed, the screenshot size
  98980. * will be derived from the parameters. The precision property is a multiplier allowing
  98981. * rendering at a higher or lower resolution
  98982. * @param successCallback defines the callback receives a single parameter which contains the
  98983. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98984. * src parameter of an <img> to display it
  98985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98986. * Check your browser for supported MIME types
  98987. */
  98988. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98989. /**
  98990. * Captures a screenshot of the current rendering
  98991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98992. * @param engine defines the rendering engine
  98993. * @param camera defines the source camera
  98994. * @param size This parameter can be set to a single number or to an object with the
  98995. * following (optional) properties: precision, width, height. If a single number is passed,
  98996. * it will be used for both width and height. If an object is passed, the screenshot size
  98997. * will be derived from the parameters. The precision property is a multiplier allowing
  98998. * rendering at a higher or lower resolution
  98999. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99000. * Check your browser for supported MIME types
  99001. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99002. * to the src parameter of an <img> to display it
  99003. */
  99004. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99005. /**
  99006. * Generates an image screenshot from the specified camera.
  99007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99008. * @param engine The engine to use for rendering
  99009. * @param camera The camera to use for rendering
  99010. * @param size This parameter can be set to a single number or to an object with the
  99011. * following (optional) properties: precision, width, height. If a single number is passed,
  99012. * it will be used for both width and height. If an object is passed, the screenshot size
  99013. * will be derived from the parameters. The precision property is a multiplier allowing
  99014. * rendering at a higher or lower resolution
  99015. * @param successCallback The callback receives a single parameter which contains the
  99016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99017. * src parameter of an <img> to display it
  99018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99019. * Check your browser for supported MIME types
  99020. * @param samples Texture samples (default: 1)
  99021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99022. * @param fileName A name for for the downloaded file.
  99023. */
  99024. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99025. /**
  99026. * Generates an image screenshot from the specified camera.
  99027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99028. * @param engine The engine to use for rendering
  99029. * @param camera The camera to use for rendering
  99030. * @param size This parameter can be set to a single number or to an object with the
  99031. * following (optional) properties: precision, width, height. If a single number is passed,
  99032. * it will be used for both width and height. If an object is passed, the screenshot size
  99033. * will be derived from the parameters. The precision property is a multiplier allowing
  99034. * rendering at a higher or lower resolution
  99035. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99036. * Check your browser for supported MIME types
  99037. * @param samples Texture samples (default: 1)
  99038. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99039. * @param fileName A name for for the downloaded file.
  99040. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99041. * to the src parameter of an <img> to display it
  99042. */
  99043. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99044. /**
  99045. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99046. * Be aware Math.random() could cause collisions, but:
  99047. * "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"
  99048. * @returns a pseudo random id
  99049. */
  99050. static RandomId(): string;
  99051. /**
  99052. * Test if the given uri is a base64 string
  99053. * @param uri The uri to test
  99054. * @return True if the uri is a base64 string or false otherwise
  99055. */
  99056. static IsBase64(uri: string): boolean;
  99057. /**
  99058. * Decode the given base64 uri.
  99059. * @param uri The uri to decode
  99060. * @return The decoded base64 data.
  99061. */
  99062. static DecodeBase64(uri: string): ArrayBuffer;
  99063. /**
  99064. * Gets the absolute url.
  99065. * @param url the input url
  99066. * @return the absolute url
  99067. */
  99068. static GetAbsoluteUrl(url: string): string;
  99069. /**
  99070. * No log
  99071. */
  99072. static readonly NoneLogLevel: number;
  99073. /**
  99074. * Only message logs
  99075. */
  99076. static readonly MessageLogLevel: number;
  99077. /**
  99078. * Only warning logs
  99079. */
  99080. static readonly WarningLogLevel: number;
  99081. /**
  99082. * Only error logs
  99083. */
  99084. static readonly ErrorLogLevel: number;
  99085. /**
  99086. * All logs
  99087. */
  99088. static readonly AllLogLevel: number;
  99089. /**
  99090. * Gets a value indicating the number of loading errors
  99091. * @ignorenaming
  99092. */
  99093. static readonly errorsCount: number;
  99094. /**
  99095. * Callback called when a new log is added
  99096. */
  99097. static OnNewCacheEntry: (entry: string) => void;
  99098. /**
  99099. * Log a message to the console
  99100. * @param message defines the message to log
  99101. */
  99102. static Log(message: string): void;
  99103. /**
  99104. * Write a warning message to the console
  99105. * @param message defines the message to log
  99106. */
  99107. static Warn(message: string): void;
  99108. /**
  99109. * Write an error message to the console
  99110. * @param message defines the message to log
  99111. */
  99112. static Error(message: string): void;
  99113. /**
  99114. * Gets current log cache (list of logs)
  99115. */
  99116. static readonly LogCache: string;
  99117. /**
  99118. * Clears the log cache
  99119. */
  99120. static ClearLogCache(): void;
  99121. /**
  99122. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99123. */
  99124. static LogLevels: number;
  99125. /**
  99126. * Checks if the window object exists
  99127. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99128. */
  99129. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99130. /**
  99131. * No performance log
  99132. */
  99133. static readonly PerformanceNoneLogLevel: number;
  99134. /**
  99135. * Use user marks to log performance
  99136. */
  99137. static readonly PerformanceUserMarkLogLevel: number;
  99138. /**
  99139. * Log performance to the console
  99140. */
  99141. static readonly PerformanceConsoleLogLevel: number;
  99142. private static _performance;
  99143. /**
  99144. * Sets the current performance log level
  99145. */
  99146. static PerformanceLogLevel: number;
  99147. private static _StartPerformanceCounterDisabled;
  99148. private static _EndPerformanceCounterDisabled;
  99149. private static _StartUserMark;
  99150. private static _EndUserMark;
  99151. private static _StartPerformanceConsole;
  99152. private static _EndPerformanceConsole;
  99153. /**
  99154. * Starts a performance counter
  99155. */
  99156. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99157. /**
  99158. * Ends a specific performance coutner
  99159. */
  99160. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99161. /**
  99162. * Gets either window.performance.now() if supported or Date.now() else
  99163. */
  99164. static readonly Now: number;
  99165. /**
  99166. * This method will return the name of the class used to create the instance of the given object.
  99167. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99168. * @param object the object to get the class name from
  99169. * @param isType defines if the object is actually a type
  99170. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99171. */
  99172. static GetClassName(object: any, isType?: boolean): string;
  99173. /**
  99174. * Gets the first element of an array satisfying a given predicate
  99175. * @param array defines the array to browse
  99176. * @param predicate defines the predicate to use
  99177. * @returns null if not found or the element
  99178. */
  99179. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99180. /**
  99181. * This method will return the name of the full name of the class, including its owning module (if any).
  99182. * 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).
  99183. * @param object the object to get the class name from
  99184. * @param isType defines if the object is actually a type
  99185. * @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.
  99186. * @ignorenaming
  99187. */
  99188. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99189. /**
  99190. * Returns a promise that resolves after the given amount of time.
  99191. * @param delay Number of milliseconds to delay
  99192. * @returns Promise that resolves after the given amount of time
  99193. */
  99194. static DelayAsync(delay: number): Promise<void>;
  99195. }
  99196. /**
  99197. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99198. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99199. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99200. * @param name The name of the class, case should be preserved
  99201. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99202. */
  99203. export function className(name: string, module?: string): (target: Object) => void;
  99204. /**
  99205. * An implementation of a loop for asynchronous functions.
  99206. */
  99207. export class AsyncLoop {
  99208. /**
  99209. * Defines the number of iterations for the loop
  99210. */
  99211. iterations: number;
  99212. /**
  99213. * Defines the current index of the loop.
  99214. */
  99215. index: number;
  99216. private _done;
  99217. private _fn;
  99218. private _successCallback;
  99219. /**
  99220. * Constructor.
  99221. * @param iterations the number of iterations.
  99222. * @param func the function to run each iteration
  99223. * @param successCallback the callback that will be called upon succesful execution
  99224. * @param offset starting offset.
  99225. */
  99226. constructor(
  99227. /**
  99228. * Defines the number of iterations for the loop
  99229. */
  99230. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99231. /**
  99232. * Execute the next iteration. Must be called after the last iteration was finished.
  99233. */
  99234. executeNext(): void;
  99235. /**
  99236. * Break the loop and run the success callback.
  99237. */
  99238. breakLoop(): void;
  99239. /**
  99240. * Create and run an async loop.
  99241. * @param iterations the number of iterations.
  99242. * @param fn the function to run each iteration
  99243. * @param successCallback the callback that will be called upon succesful execution
  99244. * @param offset starting offset.
  99245. * @returns the created async loop object
  99246. */
  99247. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99248. /**
  99249. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99250. * @param iterations total number of iterations
  99251. * @param syncedIterations number of synchronous iterations in each async iteration.
  99252. * @param fn the function to call each iteration.
  99253. * @param callback a success call back that will be called when iterating stops.
  99254. * @param breakFunction a break condition (optional)
  99255. * @param timeout timeout settings for the setTimeout function. default - 0.
  99256. * @returns the created async loop object
  99257. */
  99258. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99259. }
  99260. }
  99261. declare module BABYLON {
  99262. /**
  99263. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99264. * The underlying implementation relies on an associative array to ensure the best performances.
  99265. * The value can be anything including 'null' but except 'undefined'
  99266. */
  99267. export class StringDictionary<T> {
  99268. /**
  99269. * This will clear this dictionary and copy the content from the 'source' one.
  99270. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99271. * @param source the dictionary to take the content from and copy to this dictionary
  99272. */
  99273. copyFrom(source: StringDictionary<T>): void;
  99274. /**
  99275. * Get a value based from its key
  99276. * @param key the given key to get the matching value from
  99277. * @return the value if found, otherwise undefined is returned
  99278. */
  99279. get(key: string): T | undefined;
  99280. /**
  99281. * Get a value from its key or add it if it doesn't exist.
  99282. * This method will ensure you that a given key/data will be present in the dictionary.
  99283. * @param key the given key to get the matching value from
  99284. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99285. * The factory will only be invoked if there's no data for the given key.
  99286. * @return the value corresponding to the key.
  99287. */
  99288. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99289. /**
  99290. * Get a value from its key if present in the dictionary otherwise add it
  99291. * @param key the key to get the value from
  99292. * @param val if there's no such key/value pair in the dictionary add it with this value
  99293. * @return the value corresponding to the key
  99294. */
  99295. getOrAdd(key: string, val: T): T;
  99296. /**
  99297. * Check if there's a given key in the dictionary
  99298. * @param key the key to check for
  99299. * @return true if the key is present, false otherwise
  99300. */
  99301. contains(key: string): boolean;
  99302. /**
  99303. * Add a new key and its corresponding value
  99304. * @param key the key to add
  99305. * @param value the value corresponding to the key
  99306. * @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
  99307. */
  99308. add(key: string, value: T): boolean;
  99309. /**
  99310. * Update a specific value associated to a key
  99311. * @param key defines the key to use
  99312. * @param value defines the value to store
  99313. * @returns true if the value was updated (or false if the key was not found)
  99314. */
  99315. set(key: string, value: T): boolean;
  99316. /**
  99317. * Get the element of the given key and remove it from the dictionary
  99318. * @param key defines the key to search
  99319. * @returns the value associated with the key or null if not found
  99320. */
  99321. getAndRemove(key: string): Nullable<T>;
  99322. /**
  99323. * Remove a key/value from the dictionary.
  99324. * @param key the key to remove
  99325. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99326. */
  99327. remove(key: string): boolean;
  99328. /**
  99329. * Clear the whole content of the dictionary
  99330. */
  99331. clear(): void;
  99332. /**
  99333. * Gets the current count
  99334. */
  99335. readonly count: number;
  99336. /**
  99337. * Execute a callback on each key/val of the dictionary.
  99338. * Note that you can remove any element in this dictionary in the callback implementation
  99339. * @param callback the callback to execute on a given key/value pair
  99340. */
  99341. forEach(callback: (key: string, val: T) => void): void;
  99342. /**
  99343. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99344. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99345. * Note that you can remove any element in this dictionary in the callback implementation
  99346. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99347. * @returns the first item
  99348. */
  99349. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99350. private _count;
  99351. private _data;
  99352. }
  99353. }
  99354. declare module BABYLON {
  99355. /** @hidden */
  99356. export interface ICollisionCoordinator {
  99357. createCollider(): Collider;
  99358. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99359. init(scene: Scene): void;
  99360. }
  99361. /** @hidden */
  99362. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99363. private _scene;
  99364. private _scaledPosition;
  99365. private _scaledVelocity;
  99366. private _finalPosition;
  99367. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99368. createCollider(): Collider;
  99369. init(scene: Scene): void;
  99370. private _collideWithWorld;
  99371. }
  99372. }
  99373. declare module BABYLON {
  99374. /**
  99375. * Class used to manage all inputs for the scene.
  99376. */
  99377. export class InputManager {
  99378. /** The distance in pixel that you have to move to prevent some events */
  99379. static DragMovementThreshold: number;
  99380. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99381. static LongPressDelay: number;
  99382. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99383. static DoubleClickDelay: number;
  99384. /** If you need to check double click without raising a single click at first click, enable this flag */
  99385. static ExclusiveDoubleClickMode: boolean;
  99386. private _wheelEventName;
  99387. private _onPointerMove;
  99388. private _onPointerDown;
  99389. private _onPointerUp;
  99390. private _initClickEvent;
  99391. private _initActionManager;
  99392. private _delayedSimpleClick;
  99393. private _delayedSimpleClickTimeout;
  99394. private _previousDelayedSimpleClickTimeout;
  99395. private _meshPickProceed;
  99396. private _previousButtonPressed;
  99397. private _currentPickResult;
  99398. private _previousPickResult;
  99399. private _totalPointersPressed;
  99400. private _doubleClickOccured;
  99401. private _pointerOverMesh;
  99402. private _pickedDownMesh;
  99403. private _pickedUpMesh;
  99404. private _pointerX;
  99405. private _pointerY;
  99406. private _unTranslatedPointerX;
  99407. private _unTranslatedPointerY;
  99408. private _startingPointerPosition;
  99409. private _previousStartingPointerPosition;
  99410. private _startingPointerTime;
  99411. private _previousStartingPointerTime;
  99412. private _pointerCaptures;
  99413. private _onKeyDown;
  99414. private _onKeyUp;
  99415. private _onCanvasFocusObserver;
  99416. private _onCanvasBlurObserver;
  99417. private _scene;
  99418. /**
  99419. * Creates a new InputManager
  99420. * @param scene defines the hosting scene
  99421. */
  99422. constructor(scene: Scene);
  99423. /**
  99424. * Gets the mesh that is currently under the pointer
  99425. */
  99426. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99427. /**
  99428. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99429. */
  99430. readonly unTranslatedPointer: Vector2;
  99431. /**
  99432. * Gets or sets the current on-screen X position of the pointer
  99433. */
  99434. pointerX: number;
  99435. /**
  99436. * Gets or sets the current on-screen Y position of the pointer
  99437. */
  99438. pointerY: number;
  99439. private _updatePointerPosition;
  99440. private _processPointerMove;
  99441. private _setRayOnPointerInfo;
  99442. private _checkPrePointerObservable;
  99443. /**
  99444. * Use this method to simulate a pointer move on a mesh
  99445. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99446. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99447. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99448. */
  99449. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99450. /**
  99451. * Use this method to simulate a pointer down on a mesh
  99452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99455. */
  99456. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99457. private _processPointerDown;
  99458. /** @hidden */
  99459. _isPointerSwiping(): boolean;
  99460. /**
  99461. * Use this method to simulate a pointer up on a mesh
  99462. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99463. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99464. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99465. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99466. */
  99467. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99468. private _processPointerUp;
  99469. /**
  99470. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99471. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99472. * @returns true if the pointer was captured
  99473. */
  99474. isPointerCaptured(pointerId?: number): boolean;
  99475. /**
  99476. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99477. * @param attachUp defines if you want to attach events to pointerup
  99478. * @param attachDown defines if you want to attach events to pointerdown
  99479. * @param attachMove defines if you want to attach events to pointermove
  99480. */
  99481. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99482. /**
  99483. * Detaches all event handlers
  99484. */
  99485. detachControl(): void;
  99486. /**
  99487. * Force the value of meshUnderPointer
  99488. * @param mesh defines the mesh to use
  99489. */
  99490. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99491. /**
  99492. * Gets the mesh under the pointer
  99493. * @returns a Mesh or null if no mesh is under the pointer
  99494. */
  99495. getPointerOverMesh(): Nullable<AbstractMesh>;
  99496. }
  99497. }
  99498. declare module BABYLON {
  99499. /**
  99500. * Helper class used to generate session unique ID
  99501. */
  99502. export class UniqueIdGenerator {
  99503. private static _UniqueIdCounter;
  99504. /**
  99505. * Gets an unique (relatively to the current scene) Id
  99506. */
  99507. static readonly UniqueId: number;
  99508. }
  99509. }
  99510. declare module BABYLON {
  99511. /**
  99512. * This class defines the direct association between an animation and a target
  99513. */
  99514. export class TargetedAnimation {
  99515. /**
  99516. * Animation to perform
  99517. */
  99518. animation: Animation;
  99519. /**
  99520. * Target to animate
  99521. */
  99522. target: any;
  99523. /**
  99524. * Serialize the object
  99525. * @returns the JSON object representing the current entity
  99526. */
  99527. serialize(): any;
  99528. }
  99529. /**
  99530. * Use this class to create coordinated animations on multiple targets
  99531. */
  99532. export class AnimationGroup implements IDisposable {
  99533. /** The name of the animation group */
  99534. name: string;
  99535. private _scene;
  99536. private _targetedAnimations;
  99537. private _animatables;
  99538. private _from;
  99539. private _to;
  99540. private _isStarted;
  99541. private _isPaused;
  99542. private _speedRatio;
  99543. private _loopAnimation;
  99544. /**
  99545. * Gets or sets the unique id of the node
  99546. */
  99547. uniqueId: number;
  99548. /**
  99549. * This observable will notify when one animation have ended
  99550. */
  99551. onAnimationEndObservable: Observable<TargetedAnimation>;
  99552. /**
  99553. * Observer raised when one animation loops
  99554. */
  99555. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99556. /**
  99557. * This observable will notify when all animations have ended.
  99558. */
  99559. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99560. /**
  99561. * This observable will notify when all animations have paused.
  99562. */
  99563. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99564. /**
  99565. * This observable will notify when all animations are playing.
  99566. */
  99567. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99568. /**
  99569. * Gets the first frame
  99570. */
  99571. readonly from: number;
  99572. /**
  99573. * Gets the last frame
  99574. */
  99575. readonly to: number;
  99576. /**
  99577. * Define if the animations are started
  99578. */
  99579. readonly isStarted: boolean;
  99580. /**
  99581. * Gets a value indicating that the current group is playing
  99582. */
  99583. readonly isPlaying: boolean;
  99584. /**
  99585. * Gets or sets the speed ratio to use for all animations
  99586. */
  99587. /**
  99588. * Gets or sets the speed ratio to use for all animations
  99589. */
  99590. speedRatio: number;
  99591. /**
  99592. * Gets or sets if all animations should loop or not
  99593. */
  99594. loopAnimation: boolean;
  99595. /**
  99596. * Gets the targeted animations for this animation group
  99597. */
  99598. readonly targetedAnimations: Array<TargetedAnimation>;
  99599. /**
  99600. * returning the list of animatables controlled by this animation group.
  99601. */
  99602. readonly animatables: Array<Animatable>;
  99603. /**
  99604. * Instantiates a new Animation Group.
  99605. * This helps managing several animations at once.
  99606. * @see http://doc.babylonjs.com/how_to/group
  99607. * @param name Defines the name of the group
  99608. * @param scene Defines the scene the group belongs to
  99609. */
  99610. constructor(
  99611. /** The name of the animation group */
  99612. name: string, scene?: Nullable<Scene>);
  99613. /**
  99614. * Add an animation (with its target) in the group
  99615. * @param animation defines the animation we want to add
  99616. * @param target defines the target of the animation
  99617. * @returns the TargetedAnimation object
  99618. */
  99619. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99620. /**
  99621. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99622. * It can add constant keys at begin or end
  99623. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99624. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99625. * @returns the animation group
  99626. */
  99627. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99628. /**
  99629. * Start all animations on given targets
  99630. * @param loop defines if animations must loop
  99631. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99632. * @param from defines the from key (optional)
  99633. * @param to defines the to key (optional)
  99634. * @returns the current animation group
  99635. */
  99636. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99637. /**
  99638. * Pause all animations
  99639. * @returns the animation group
  99640. */
  99641. pause(): AnimationGroup;
  99642. /**
  99643. * Play all animations to initial state
  99644. * This function will start() the animations if they were not started or will restart() them if they were paused
  99645. * @param loop defines if animations must loop
  99646. * @returns the animation group
  99647. */
  99648. play(loop?: boolean): AnimationGroup;
  99649. /**
  99650. * Reset all animations to initial state
  99651. * @returns the animation group
  99652. */
  99653. reset(): AnimationGroup;
  99654. /**
  99655. * Restart animations from key 0
  99656. * @returns the animation group
  99657. */
  99658. restart(): AnimationGroup;
  99659. /**
  99660. * Stop all animations
  99661. * @returns the animation group
  99662. */
  99663. stop(): AnimationGroup;
  99664. /**
  99665. * Set animation weight for all animatables
  99666. * @param weight defines the weight to use
  99667. * @return the animationGroup
  99668. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99669. */
  99670. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99671. /**
  99672. * Synchronize and normalize all animatables with a source animatable
  99673. * @param root defines the root animatable to synchronize with
  99674. * @return the animationGroup
  99675. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99676. */
  99677. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99678. /**
  99679. * Goes to a specific frame in this animation group
  99680. * @param frame the frame number to go to
  99681. * @return the animationGroup
  99682. */
  99683. goToFrame(frame: number): AnimationGroup;
  99684. /**
  99685. * Dispose all associated resources
  99686. */
  99687. dispose(): void;
  99688. private _checkAnimationGroupEnded;
  99689. /**
  99690. * Clone the current animation group and returns a copy
  99691. * @param newName defines the name of the new group
  99692. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99693. * @returns the new aniamtion group
  99694. */
  99695. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99696. /**
  99697. * Serializes the animationGroup to an object
  99698. * @returns Serialized object
  99699. */
  99700. serialize(): any;
  99701. /**
  99702. * Returns a new AnimationGroup object parsed from the source provided.
  99703. * @param parsedAnimationGroup defines the source
  99704. * @param scene defines the scene that will receive the animationGroup
  99705. * @returns a new AnimationGroup
  99706. */
  99707. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99708. /**
  99709. * Returns the string "AnimationGroup"
  99710. * @returns "AnimationGroup"
  99711. */
  99712. getClassName(): string;
  99713. /**
  99714. * Creates a detailled string about the object
  99715. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99716. * @returns a string representing the object
  99717. */
  99718. toString(fullDetails?: boolean): string;
  99719. }
  99720. }
  99721. declare module BABYLON {
  99722. /**
  99723. * Define an interface for all classes that will hold resources
  99724. */
  99725. export interface IDisposable {
  99726. /**
  99727. * Releases all held resources
  99728. */
  99729. dispose(): void;
  99730. }
  99731. /** Interface defining initialization parameters for Scene class */
  99732. export interface SceneOptions {
  99733. /**
  99734. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99735. * It will improve performance when the number of geometries becomes important.
  99736. */
  99737. useGeometryUniqueIdsMap?: boolean;
  99738. /**
  99739. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99740. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99741. */
  99742. useMaterialMeshMap?: boolean;
  99743. /**
  99744. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99745. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99746. */
  99747. useClonedMeshhMap?: boolean;
  99748. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99749. virtual?: boolean;
  99750. }
  99751. /**
  99752. * Represents a scene to be rendered by the engine.
  99753. * @see http://doc.babylonjs.com/features/scene
  99754. */
  99755. export class Scene extends AbstractScene implements IAnimatable {
  99756. /** The fog is deactivated */
  99757. static readonly FOGMODE_NONE: number;
  99758. /** The fog density is following an exponential function */
  99759. static readonly FOGMODE_EXP: number;
  99760. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99761. static readonly FOGMODE_EXP2: number;
  99762. /** The fog density is following a linear function. */
  99763. static readonly FOGMODE_LINEAR: number;
  99764. /**
  99765. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99766. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99767. */
  99768. static MinDeltaTime: number;
  99769. /**
  99770. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99771. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99772. */
  99773. static MaxDeltaTime: number;
  99774. /**
  99775. * Factory used to create the default material.
  99776. * @param name The name of the material to create
  99777. * @param scene The scene to create the material for
  99778. * @returns The default material
  99779. */
  99780. static DefaultMaterialFactory(scene: Scene): Material;
  99781. /**
  99782. * Factory used to create the a collision coordinator.
  99783. * @returns The collision coordinator
  99784. */
  99785. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99786. /** @hidden */
  99787. _inputManager: InputManager;
  99788. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99789. cameraToUseForPointers: Nullable<Camera>;
  99790. /** @hidden */
  99791. readonly _isScene: boolean;
  99792. /**
  99793. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99794. */
  99795. autoClear: boolean;
  99796. /**
  99797. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99798. */
  99799. autoClearDepthAndStencil: boolean;
  99800. /**
  99801. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99802. */
  99803. clearColor: Color4;
  99804. /**
  99805. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99806. */
  99807. ambientColor: Color3;
  99808. /**
  99809. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99810. * It should only be one of the following (if not the default embedded one):
  99811. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99812. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99813. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99814. * The material properties need to be setup according to the type of texture in use.
  99815. */
  99816. environmentBRDFTexture: BaseTexture;
  99817. /** @hidden */
  99818. protected _environmentTexture: Nullable<BaseTexture>;
  99819. /**
  99820. * Texture used in all pbr material as the reflection texture.
  99821. * As in the majority of the scene they are the same (exception for multi room and so on),
  99822. * this is easier to reference from here than from all the materials.
  99823. */
  99824. /**
  99825. * Texture used in all pbr material as the reflection texture.
  99826. * As in the majority of the scene they are the same (exception for multi room and so on),
  99827. * this is easier to set here than in all the materials.
  99828. */
  99829. environmentTexture: Nullable<BaseTexture>;
  99830. /** @hidden */
  99831. protected _environmentIntensity: number;
  99832. /**
  99833. * Intensity of the environment in all pbr material.
  99834. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99835. * As in the majority of the scene they are the same (exception for multi room and so on),
  99836. * this is easier to reference from here than from all the materials.
  99837. */
  99838. /**
  99839. * Intensity of the environment in all pbr material.
  99840. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99841. * As in the majority of the scene they are the same (exception for multi room and so on),
  99842. * this is easier to set here than in all the materials.
  99843. */
  99844. environmentIntensity: number;
  99845. /** @hidden */
  99846. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99847. /**
  99848. * Default image processing configuration used either in the rendering
  99849. * Forward main pass or through the imageProcessingPostProcess if present.
  99850. * As in the majority of the scene they are the same (exception for multi camera),
  99851. * this is easier to reference from here than from all the materials and post process.
  99852. *
  99853. * No setter as we it is a shared configuration, you can set the values instead.
  99854. */
  99855. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99856. private _forceWireframe;
  99857. /**
  99858. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99859. */
  99860. forceWireframe: boolean;
  99861. private _forcePointsCloud;
  99862. /**
  99863. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99864. */
  99865. forcePointsCloud: boolean;
  99866. /**
  99867. * Gets or sets the active clipplane 1
  99868. */
  99869. clipPlane: Nullable<Plane>;
  99870. /**
  99871. * Gets or sets the active clipplane 2
  99872. */
  99873. clipPlane2: Nullable<Plane>;
  99874. /**
  99875. * Gets or sets the active clipplane 3
  99876. */
  99877. clipPlane3: Nullable<Plane>;
  99878. /**
  99879. * Gets or sets the active clipplane 4
  99880. */
  99881. clipPlane4: Nullable<Plane>;
  99882. /**
  99883. * Gets or sets a boolean indicating if animations are enabled
  99884. */
  99885. animationsEnabled: boolean;
  99886. private _animationPropertiesOverride;
  99887. /**
  99888. * Gets or sets the animation properties override
  99889. */
  99890. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99891. /**
  99892. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99893. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99894. */
  99895. useConstantAnimationDeltaTime: boolean;
  99896. /**
  99897. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99898. * Please note that it requires to run a ray cast through the scene on every frame
  99899. */
  99900. constantlyUpdateMeshUnderPointer: boolean;
  99901. /**
  99902. * Defines the HTML cursor to use when hovering over interactive elements
  99903. */
  99904. hoverCursor: string;
  99905. /**
  99906. * Defines the HTML default cursor to use (empty by default)
  99907. */
  99908. defaultCursor: string;
  99909. /**
  99910. * This is used to call preventDefault() on pointer down
  99911. * in order to block unwanted artifacts like system double clicks
  99912. */
  99913. preventDefaultOnPointerDown: boolean;
  99914. /**
  99915. * This is used to call preventDefault() on pointer up
  99916. * in order to block unwanted artifacts like system double clicks
  99917. */
  99918. preventDefaultOnPointerUp: boolean;
  99919. /**
  99920. * Gets or sets user defined metadata
  99921. */
  99922. metadata: any;
  99923. /**
  99924. * For internal use only. Please do not use.
  99925. */
  99926. reservedDataStore: any;
  99927. /**
  99928. * Gets the name of the plugin used to load this scene (null by default)
  99929. */
  99930. loadingPluginName: string;
  99931. /**
  99932. * Use this array to add regular expressions used to disable offline support for specific urls
  99933. */
  99934. disableOfflineSupportExceptionRules: RegExp[];
  99935. /**
  99936. * An event triggered when the scene is disposed.
  99937. */
  99938. onDisposeObservable: Observable<Scene>;
  99939. private _onDisposeObserver;
  99940. /** Sets a function to be executed when this scene is disposed. */
  99941. onDispose: () => void;
  99942. /**
  99943. * An event triggered before rendering the scene (right after animations and physics)
  99944. */
  99945. onBeforeRenderObservable: Observable<Scene>;
  99946. private _onBeforeRenderObserver;
  99947. /** Sets a function to be executed before rendering this scene */
  99948. beforeRender: Nullable<() => void>;
  99949. /**
  99950. * An event triggered after rendering the scene
  99951. */
  99952. onAfterRenderObservable: Observable<Scene>;
  99953. /**
  99954. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99955. */
  99956. onAfterRenderCameraObservable: Observable<Camera>;
  99957. private _onAfterRenderObserver;
  99958. /** Sets a function to be executed after rendering this scene */
  99959. afterRender: Nullable<() => void>;
  99960. /**
  99961. * An event triggered before animating the scene
  99962. */
  99963. onBeforeAnimationsObservable: Observable<Scene>;
  99964. /**
  99965. * An event triggered after animations processing
  99966. */
  99967. onAfterAnimationsObservable: Observable<Scene>;
  99968. /**
  99969. * An event triggered before draw calls are ready to be sent
  99970. */
  99971. onBeforeDrawPhaseObservable: Observable<Scene>;
  99972. /**
  99973. * An event triggered after draw calls have been sent
  99974. */
  99975. onAfterDrawPhaseObservable: Observable<Scene>;
  99976. /**
  99977. * An event triggered when the scene is ready
  99978. */
  99979. onReadyObservable: Observable<Scene>;
  99980. /**
  99981. * An event triggered before rendering a camera
  99982. */
  99983. onBeforeCameraRenderObservable: Observable<Camera>;
  99984. private _onBeforeCameraRenderObserver;
  99985. /** Sets a function to be executed before rendering a camera*/
  99986. beforeCameraRender: () => void;
  99987. /**
  99988. * An event triggered after rendering a camera
  99989. */
  99990. onAfterCameraRenderObservable: Observable<Camera>;
  99991. private _onAfterCameraRenderObserver;
  99992. /** Sets a function to be executed after rendering a camera*/
  99993. afterCameraRender: () => void;
  99994. /**
  99995. * An event triggered when active meshes evaluation is about to start
  99996. */
  99997. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99998. /**
  99999. * An event triggered when active meshes evaluation is done
  100000. */
  100001. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100002. /**
  100003. * An event triggered when particles rendering is about to start
  100004. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100005. */
  100006. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100007. /**
  100008. * An event triggered when particles rendering is done
  100009. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100010. */
  100011. onAfterParticlesRenderingObservable: Observable<Scene>;
  100012. /**
  100013. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100014. */
  100015. onDataLoadedObservable: Observable<Scene>;
  100016. /**
  100017. * An event triggered when a camera is created
  100018. */
  100019. onNewCameraAddedObservable: Observable<Camera>;
  100020. /**
  100021. * An event triggered when a camera is removed
  100022. */
  100023. onCameraRemovedObservable: Observable<Camera>;
  100024. /**
  100025. * An event triggered when a light is created
  100026. */
  100027. onNewLightAddedObservable: Observable<Light>;
  100028. /**
  100029. * An event triggered when a light is removed
  100030. */
  100031. onLightRemovedObservable: Observable<Light>;
  100032. /**
  100033. * An event triggered when a geometry is created
  100034. */
  100035. onNewGeometryAddedObservable: Observable<Geometry>;
  100036. /**
  100037. * An event triggered when a geometry is removed
  100038. */
  100039. onGeometryRemovedObservable: Observable<Geometry>;
  100040. /**
  100041. * An event triggered when a transform node is created
  100042. */
  100043. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100044. /**
  100045. * An event triggered when a transform node is removed
  100046. */
  100047. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100048. /**
  100049. * An event triggered when a mesh is created
  100050. */
  100051. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100052. /**
  100053. * An event triggered when a mesh is removed
  100054. */
  100055. onMeshRemovedObservable: Observable<AbstractMesh>;
  100056. /**
  100057. * An event triggered when a skeleton is created
  100058. */
  100059. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100060. /**
  100061. * An event triggered when a skeleton is removed
  100062. */
  100063. onSkeletonRemovedObservable: Observable<Skeleton>;
  100064. /**
  100065. * An event triggered when a material is created
  100066. */
  100067. onNewMaterialAddedObservable: Observable<Material>;
  100068. /**
  100069. * An event triggered when a material is removed
  100070. */
  100071. onMaterialRemovedObservable: Observable<Material>;
  100072. /**
  100073. * An event triggered when a texture is created
  100074. */
  100075. onNewTextureAddedObservable: Observable<BaseTexture>;
  100076. /**
  100077. * An event triggered when a texture is removed
  100078. */
  100079. onTextureRemovedObservable: Observable<BaseTexture>;
  100080. /**
  100081. * An event triggered when render targets are about to be rendered
  100082. * Can happen multiple times per frame.
  100083. */
  100084. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100085. /**
  100086. * An event triggered when render targets were rendered.
  100087. * Can happen multiple times per frame.
  100088. */
  100089. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100090. /**
  100091. * An event triggered before calculating deterministic simulation step
  100092. */
  100093. onBeforeStepObservable: Observable<Scene>;
  100094. /**
  100095. * An event triggered after calculating deterministic simulation step
  100096. */
  100097. onAfterStepObservable: Observable<Scene>;
  100098. /**
  100099. * An event triggered when the activeCamera property is updated
  100100. */
  100101. onActiveCameraChanged: Observable<Scene>;
  100102. /**
  100103. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100104. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100105. * 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)
  100106. */
  100107. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100108. /**
  100109. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100110. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100111. * 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)
  100112. */
  100113. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100114. /**
  100115. * This Observable will when a mesh has been imported into the scene.
  100116. */
  100117. onMeshImportedObservable: Observable<AbstractMesh>;
  100118. /**
  100119. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100120. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100121. */
  100122. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100123. /** @hidden */
  100124. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100125. /**
  100126. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100127. */
  100128. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100129. /**
  100130. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100131. */
  100132. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100133. /**
  100134. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100135. */
  100136. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100137. /** Callback called when a pointer move is detected */
  100138. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100139. /** Callback called when a pointer down is detected */
  100140. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100141. /** Callback called when a pointer up is detected */
  100142. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100143. /** Callback called when a pointer pick is detected */
  100144. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100145. /**
  100146. * 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).
  100147. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100148. */
  100149. onPrePointerObservable: Observable<PointerInfoPre>;
  100150. /**
  100151. * Observable event triggered each time an input event is received from the rendering canvas
  100152. */
  100153. onPointerObservable: Observable<PointerInfo>;
  100154. /**
  100155. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100156. */
  100157. readonly unTranslatedPointer: Vector2;
  100158. /**
  100159. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100160. */
  100161. static DragMovementThreshold: number;
  100162. /**
  100163. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100164. */
  100165. static LongPressDelay: number;
  100166. /**
  100167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100168. */
  100169. static DoubleClickDelay: number;
  100170. /** If you need to check double click without raising a single click at first click, enable this flag */
  100171. static ExclusiveDoubleClickMode: boolean;
  100172. /** @hidden */
  100173. _mirroredCameraPosition: Nullable<Vector3>;
  100174. /**
  100175. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100176. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100177. */
  100178. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100179. /**
  100180. * Observable event triggered each time an keyboard event is received from the hosting window
  100181. */
  100182. onKeyboardObservable: Observable<KeyboardInfo>;
  100183. private _useRightHandedSystem;
  100184. /**
  100185. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100186. */
  100187. useRightHandedSystem: boolean;
  100188. private _timeAccumulator;
  100189. private _currentStepId;
  100190. private _currentInternalStep;
  100191. /**
  100192. * Sets the step Id used by deterministic lock step
  100193. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100194. * @param newStepId defines the step Id
  100195. */
  100196. setStepId(newStepId: number): void;
  100197. /**
  100198. * Gets the step Id used by deterministic lock step
  100199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100200. * @returns the step Id
  100201. */
  100202. getStepId(): number;
  100203. /**
  100204. * Gets the internal step used by deterministic lock step
  100205. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100206. * @returns the internal step
  100207. */
  100208. getInternalStep(): number;
  100209. private _fogEnabled;
  100210. /**
  100211. * Gets or sets a boolean indicating if fog is enabled on this scene
  100212. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100213. * (Default is true)
  100214. */
  100215. fogEnabled: boolean;
  100216. private _fogMode;
  100217. /**
  100218. * Gets or sets the fog mode to use
  100219. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100220. * | mode | value |
  100221. * | --- | --- |
  100222. * | FOGMODE_NONE | 0 |
  100223. * | FOGMODE_EXP | 1 |
  100224. * | FOGMODE_EXP2 | 2 |
  100225. * | FOGMODE_LINEAR | 3 |
  100226. */
  100227. fogMode: number;
  100228. /**
  100229. * Gets or sets the fog color to use
  100230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100231. * (Default is Color3(0.2, 0.2, 0.3))
  100232. */
  100233. fogColor: Color3;
  100234. /**
  100235. * Gets or sets the fog density to use
  100236. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100237. * (Default is 0.1)
  100238. */
  100239. fogDensity: number;
  100240. /**
  100241. * Gets or sets the fog start distance to use
  100242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100243. * (Default is 0)
  100244. */
  100245. fogStart: number;
  100246. /**
  100247. * Gets or sets the fog end distance to use
  100248. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100249. * (Default is 1000)
  100250. */
  100251. fogEnd: number;
  100252. private _shadowsEnabled;
  100253. /**
  100254. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100255. */
  100256. shadowsEnabled: boolean;
  100257. private _lightsEnabled;
  100258. /**
  100259. * Gets or sets a boolean indicating if lights are enabled on this scene
  100260. */
  100261. lightsEnabled: boolean;
  100262. /** All of the active cameras added to this scene. */
  100263. activeCameras: Camera[];
  100264. /** @hidden */
  100265. _activeCamera: Nullable<Camera>;
  100266. /** Gets or sets the current active camera */
  100267. activeCamera: Nullable<Camera>;
  100268. private _defaultMaterial;
  100269. /** The default material used on meshes when no material is affected */
  100270. /** The default material used on meshes when no material is affected */
  100271. defaultMaterial: Material;
  100272. private _texturesEnabled;
  100273. /**
  100274. * Gets or sets a boolean indicating if textures are enabled on this scene
  100275. */
  100276. texturesEnabled: boolean;
  100277. /**
  100278. * Gets or sets a boolean indicating if particles are enabled on this scene
  100279. */
  100280. particlesEnabled: boolean;
  100281. /**
  100282. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100283. */
  100284. spritesEnabled: boolean;
  100285. private _skeletonsEnabled;
  100286. /**
  100287. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100288. */
  100289. skeletonsEnabled: boolean;
  100290. /**
  100291. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100292. */
  100293. lensFlaresEnabled: boolean;
  100294. /**
  100295. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100297. */
  100298. collisionsEnabled: boolean;
  100299. private _collisionCoordinator;
  100300. /** @hidden */
  100301. readonly collisionCoordinator: ICollisionCoordinator;
  100302. /**
  100303. * Defines the gravity applied to this scene (used only for collisions)
  100304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100305. */
  100306. gravity: Vector3;
  100307. /**
  100308. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100309. */
  100310. postProcessesEnabled: boolean;
  100311. /**
  100312. * The list of postprocesses added to the scene
  100313. */
  100314. postProcesses: PostProcess[];
  100315. /**
  100316. * Gets the current postprocess manager
  100317. */
  100318. postProcessManager: PostProcessManager;
  100319. /**
  100320. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100321. */
  100322. renderTargetsEnabled: boolean;
  100323. /**
  100324. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100325. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100326. */
  100327. dumpNextRenderTargets: boolean;
  100328. /**
  100329. * The list of user defined render targets added to the scene
  100330. */
  100331. customRenderTargets: RenderTargetTexture[];
  100332. /**
  100333. * Defines if texture loading must be delayed
  100334. * If true, textures will only be loaded when they need to be rendered
  100335. */
  100336. useDelayedTextureLoading: boolean;
  100337. /**
  100338. * Gets the list of meshes imported to the scene through SceneLoader
  100339. */
  100340. importedMeshesFiles: String[];
  100341. /**
  100342. * Gets or sets a boolean indicating if probes are enabled on this scene
  100343. */
  100344. probesEnabled: boolean;
  100345. /**
  100346. * Gets or sets the current offline provider to use to store scene data
  100347. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100348. */
  100349. offlineProvider: IOfflineProvider;
  100350. /**
  100351. * Gets or sets the action manager associated with the scene
  100352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100353. */
  100354. actionManager: AbstractActionManager;
  100355. private _meshesForIntersections;
  100356. /**
  100357. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100358. */
  100359. proceduralTexturesEnabled: boolean;
  100360. private _engine;
  100361. private _totalVertices;
  100362. /** @hidden */
  100363. _activeIndices: PerfCounter;
  100364. /** @hidden */
  100365. _activeParticles: PerfCounter;
  100366. /** @hidden */
  100367. _activeBones: PerfCounter;
  100368. private _animationRatio;
  100369. /** @hidden */
  100370. _animationTimeLast: number;
  100371. /** @hidden */
  100372. _animationTime: number;
  100373. /**
  100374. * Gets or sets a general scale for animation speed
  100375. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100376. */
  100377. animationTimeScale: number;
  100378. /** @hidden */
  100379. _cachedMaterial: Nullable<Material>;
  100380. /** @hidden */
  100381. _cachedEffect: Nullable<Effect>;
  100382. /** @hidden */
  100383. _cachedVisibility: Nullable<number>;
  100384. private _renderId;
  100385. private _frameId;
  100386. private _executeWhenReadyTimeoutId;
  100387. private _intermediateRendering;
  100388. private _viewUpdateFlag;
  100389. private _projectionUpdateFlag;
  100390. /** @hidden */
  100391. _toBeDisposed: Nullable<IDisposable>[];
  100392. private _activeRequests;
  100393. /** @hidden */
  100394. _pendingData: any[];
  100395. private _isDisposed;
  100396. /**
  100397. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100398. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100399. */
  100400. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100401. private _activeMeshes;
  100402. private _processedMaterials;
  100403. private _renderTargets;
  100404. /** @hidden */
  100405. _activeParticleSystems: SmartArray<IParticleSystem>;
  100406. private _activeSkeletons;
  100407. private _softwareSkinnedMeshes;
  100408. private _renderingManager;
  100409. /** @hidden */
  100410. _activeAnimatables: Animatable[];
  100411. private _transformMatrix;
  100412. private _sceneUbo;
  100413. /** @hidden */
  100414. _viewMatrix: Matrix;
  100415. private _projectionMatrix;
  100416. /** @hidden */
  100417. _forcedViewPosition: Nullable<Vector3>;
  100418. /** @hidden */
  100419. _frustumPlanes: Plane[];
  100420. /**
  100421. * Gets the list of frustum planes (built from the active camera)
  100422. */
  100423. readonly frustumPlanes: Plane[];
  100424. /**
  100425. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100426. * This is useful if there are more lights that the maximum simulteanous authorized
  100427. */
  100428. requireLightSorting: boolean;
  100429. /** @hidden */
  100430. readonly useMaterialMeshMap: boolean;
  100431. /** @hidden */
  100432. readonly useClonedMeshhMap: boolean;
  100433. private _externalData;
  100434. private _uid;
  100435. /**
  100436. * @hidden
  100437. * Backing store of defined scene components.
  100438. */
  100439. _components: ISceneComponent[];
  100440. /**
  100441. * @hidden
  100442. * Backing store of defined scene components.
  100443. */
  100444. _serializableComponents: ISceneSerializableComponent[];
  100445. /**
  100446. * List of components to register on the next registration step.
  100447. */
  100448. private _transientComponents;
  100449. /**
  100450. * Registers the transient components if needed.
  100451. */
  100452. private _registerTransientComponents;
  100453. /**
  100454. * @hidden
  100455. * Add a component to the scene.
  100456. * Note that the ccomponent could be registered on th next frame if this is called after
  100457. * the register component stage.
  100458. * @param component Defines the component to add to the scene
  100459. */
  100460. _addComponent(component: ISceneComponent): void;
  100461. /**
  100462. * @hidden
  100463. * Gets a component from the scene.
  100464. * @param name defines the name of the component to retrieve
  100465. * @returns the component or null if not present
  100466. */
  100467. _getComponent(name: string): Nullable<ISceneComponent>;
  100468. /**
  100469. * @hidden
  100470. * Defines the actions happening before camera updates.
  100471. */
  100472. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100473. /**
  100474. * @hidden
  100475. * Defines the actions happening before clear the canvas.
  100476. */
  100477. _beforeClearStage: Stage<SimpleStageAction>;
  100478. /**
  100479. * @hidden
  100480. * Defines the actions when collecting render targets for the frame.
  100481. */
  100482. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100483. /**
  100484. * @hidden
  100485. * Defines the actions happening for one camera in the frame.
  100486. */
  100487. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100488. /**
  100489. * @hidden
  100490. * Defines the actions happening during the per mesh ready checks.
  100491. */
  100492. _isReadyForMeshStage: Stage<MeshStageAction>;
  100493. /**
  100494. * @hidden
  100495. * Defines the actions happening before evaluate active mesh checks.
  100496. */
  100497. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100498. /**
  100499. * @hidden
  100500. * Defines the actions happening during the evaluate sub mesh checks.
  100501. */
  100502. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100503. /**
  100504. * @hidden
  100505. * Defines the actions happening during the active mesh stage.
  100506. */
  100507. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100508. /**
  100509. * @hidden
  100510. * Defines the actions happening during the per camera render target step.
  100511. */
  100512. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100513. /**
  100514. * @hidden
  100515. * Defines the actions happening just before the active camera is drawing.
  100516. */
  100517. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100518. /**
  100519. * @hidden
  100520. * Defines the actions happening just before a render target is drawing.
  100521. */
  100522. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100523. /**
  100524. * @hidden
  100525. * Defines the actions happening just before a rendering group is drawing.
  100526. */
  100527. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100528. /**
  100529. * @hidden
  100530. * Defines the actions happening just before a mesh is drawing.
  100531. */
  100532. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100533. /**
  100534. * @hidden
  100535. * Defines the actions happening just after a mesh has been drawn.
  100536. */
  100537. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100538. /**
  100539. * @hidden
  100540. * Defines the actions happening just after a rendering group has been drawn.
  100541. */
  100542. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100543. /**
  100544. * @hidden
  100545. * Defines the actions happening just after the active camera has been drawn.
  100546. */
  100547. _afterCameraDrawStage: Stage<CameraStageAction>;
  100548. /**
  100549. * @hidden
  100550. * Defines the actions happening just after a render target has been drawn.
  100551. */
  100552. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100553. /**
  100554. * @hidden
  100555. * Defines the actions happening just after rendering all cameras and computing intersections.
  100556. */
  100557. _afterRenderStage: Stage<SimpleStageAction>;
  100558. /**
  100559. * @hidden
  100560. * Defines the actions happening when a pointer move event happens.
  100561. */
  100562. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100563. /**
  100564. * @hidden
  100565. * Defines the actions happening when a pointer down event happens.
  100566. */
  100567. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100568. /**
  100569. * @hidden
  100570. * Defines the actions happening when a pointer up event happens.
  100571. */
  100572. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100573. /**
  100574. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100575. */
  100576. private geometriesByUniqueId;
  100577. /**
  100578. * Creates a new Scene
  100579. * @param engine defines the engine to use to render this scene
  100580. * @param options defines the scene options
  100581. */
  100582. constructor(engine: Engine, options?: SceneOptions);
  100583. /**
  100584. * Gets a string idenfifying the name of the class
  100585. * @returns "Scene" string
  100586. */
  100587. getClassName(): string;
  100588. private _defaultMeshCandidates;
  100589. /**
  100590. * @hidden
  100591. */
  100592. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100593. private _defaultSubMeshCandidates;
  100594. /**
  100595. * @hidden
  100596. */
  100597. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100598. /**
  100599. * Sets the default candidate providers for the scene.
  100600. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100601. * and getCollidingSubMeshCandidates to their default function
  100602. */
  100603. setDefaultCandidateProviders(): void;
  100604. /**
  100605. * Gets the mesh that is currently under the pointer
  100606. */
  100607. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100608. /**
  100609. * Gets or sets the current on-screen X position of the pointer
  100610. */
  100611. pointerX: number;
  100612. /**
  100613. * Gets or sets the current on-screen Y position of the pointer
  100614. */
  100615. pointerY: number;
  100616. /**
  100617. * Gets the cached material (ie. the latest rendered one)
  100618. * @returns the cached material
  100619. */
  100620. getCachedMaterial(): Nullable<Material>;
  100621. /**
  100622. * Gets the cached effect (ie. the latest rendered one)
  100623. * @returns the cached effect
  100624. */
  100625. getCachedEffect(): Nullable<Effect>;
  100626. /**
  100627. * Gets the cached visibility state (ie. the latest rendered one)
  100628. * @returns the cached visibility state
  100629. */
  100630. getCachedVisibility(): Nullable<number>;
  100631. /**
  100632. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100633. * @param material defines the current material
  100634. * @param effect defines the current effect
  100635. * @param visibility defines the current visibility state
  100636. * @returns true if one parameter is not cached
  100637. */
  100638. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100639. /**
  100640. * Gets the engine associated with the scene
  100641. * @returns an Engine
  100642. */
  100643. getEngine(): Engine;
  100644. /**
  100645. * Gets the total number of vertices rendered per frame
  100646. * @returns the total number of vertices rendered per frame
  100647. */
  100648. getTotalVertices(): number;
  100649. /**
  100650. * Gets the performance counter for total vertices
  100651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100652. */
  100653. readonly totalVerticesPerfCounter: PerfCounter;
  100654. /**
  100655. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100656. * @returns the total number of active indices rendered per frame
  100657. */
  100658. getActiveIndices(): number;
  100659. /**
  100660. * Gets the performance counter for active indices
  100661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100662. */
  100663. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100664. /**
  100665. * Gets the total number of active particles rendered per frame
  100666. * @returns the total number of active particles rendered per frame
  100667. */
  100668. getActiveParticles(): number;
  100669. /**
  100670. * Gets the performance counter for active particles
  100671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100672. */
  100673. readonly activeParticlesPerfCounter: PerfCounter;
  100674. /**
  100675. * Gets the total number of active bones rendered per frame
  100676. * @returns the total number of active bones rendered per frame
  100677. */
  100678. getActiveBones(): number;
  100679. /**
  100680. * Gets the performance counter for active bones
  100681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100682. */
  100683. readonly activeBonesPerfCounter: PerfCounter;
  100684. /**
  100685. * Gets the array of active meshes
  100686. * @returns an array of AbstractMesh
  100687. */
  100688. getActiveMeshes(): SmartArray<AbstractMesh>;
  100689. /**
  100690. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100691. * @returns a number
  100692. */
  100693. getAnimationRatio(): number;
  100694. /**
  100695. * Gets an unique Id for the current render phase
  100696. * @returns a number
  100697. */
  100698. getRenderId(): number;
  100699. /**
  100700. * Gets an unique Id for the current frame
  100701. * @returns a number
  100702. */
  100703. getFrameId(): number;
  100704. /** Call this function if you want to manually increment the render Id*/
  100705. incrementRenderId(): void;
  100706. private _createUbo;
  100707. /**
  100708. * Use this method to simulate a pointer move on a mesh
  100709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100712. * @returns the current scene
  100713. */
  100714. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100715. /**
  100716. * Use this method to simulate a pointer down on a mesh
  100717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100720. * @returns the current scene
  100721. */
  100722. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100723. /**
  100724. * Use this method to simulate a pointer up on a mesh
  100725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100728. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100729. * @returns the current scene
  100730. */
  100731. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100732. /**
  100733. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100734. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100735. * @returns true if the pointer was captured
  100736. */
  100737. isPointerCaptured(pointerId?: number): boolean;
  100738. /**
  100739. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100740. * @param attachUp defines if you want to attach events to pointerup
  100741. * @param attachDown defines if you want to attach events to pointerdown
  100742. * @param attachMove defines if you want to attach events to pointermove
  100743. */
  100744. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100745. /** Detaches all event handlers*/
  100746. detachControl(): void;
  100747. /**
  100748. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100749. * Delay loaded resources are not taking in account
  100750. * @return true if all required resources are ready
  100751. */
  100752. isReady(): boolean;
  100753. /** Resets all cached information relative to material (including effect and visibility) */
  100754. resetCachedMaterial(): void;
  100755. /**
  100756. * Registers a function to be called before every frame render
  100757. * @param func defines the function to register
  100758. */
  100759. registerBeforeRender(func: () => void): void;
  100760. /**
  100761. * Unregisters a function called before every frame render
  100762. * @param func defines the function to unregister
  100763. */
  100764. unregisterBeforeRender(func: () => void): void;
  100765. /**
  100766. * Registers a function to be called after every frame render
  100767. * @param func defines the function to register
  100768. */
  100769. registerAfterRender(func: () => void): void;
  100770. /**
  100771. * Unregisters a function called after every frame render
  100772. * @param func defines the function to unregister
  100773. */
  100774. unregisterAfterRender(func: () => void): void;
  100775. private _executeOnceBeforeRender;
  100776. /**
  100777. * The provided function will run before render once and will be disposed afterwards.
  100778. * A timeout delay can be provided so that the function will be executed in N ms.
  100779. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100780. * @param func The function to be executed.
  100781. * @param timeout optional delay in ms
  100782. */
  100783. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100784. /** @hidden */
  100785. _addPendingData(data: any): void;
  100786. /** @hidden */
  100787. _removePendingData(data: any): void;
  100788. /**
  100789. * Returns the number of items waiting to be loaded
  100790. * @returns the number of items waiting to be loaded
  100791. */
  100792. getWaitingItemsCount(): number;
  100793. /**
  100794. * Returns a boolean indicating if the scene is still loading data
  100795. */
  100796. readonly isLoading: boolean;
  100797. /**
  100798. * Registers a function to be executed when the scene is ready
  100799. * @param {Function} func - the function to be executed
  100800. */
  100801. executeWhenReady(func: () => void): void;
  100802. /**
  100803. * Returns a promise that resolves when the scene is ready
  100804. * @returns A promise that resolves when the scene is ready
  100805. */
  100806. whenReadyAsync(): Promise<void>;
  100807. /** @hidden */
  100808. _checkIsReady(): void;
  100809. /**
  100810. * Gets all animatable attached to the scene
  100811. */
  100812. readonly animatables: Animatable[];
  100813. /**
  100814. * Resets the last animation time frame.
  100815. * Useful to override when animations start running when loading a scene for the first time.
  100816. */
  100817. resetLastAnimationTimeFrame(): void;
  100818. /**
  100819. * Gets the current view matrix
  100820. * @returns a Matrix
  100821. */
  100822. getViewMatrix(): Matrix;
  100823. /**
  100824. * Gets the current projection matrix
  100825. * @returns a Matrix
  100826. */
  100827. getProjectionMatrix(): Matrix;
  100828. /**
  100829. * Gets the current transform matrix
  100830. * @returns a Matrix made of View * Projection
  100831. */
  100832. getTransformMatrix(): Matrix;
  100833. /**
  100834. * Sets the current transform matrix
  100835. * @param viewL defines the View matrix to use
  100836. * @param projectionL defines the Projection matrix to use
  100837. * @param viewR defines the right View matrix to use (if provided)
  100838. * @param projectionR defines the right Projection matrix to use (if provided)
  100839. */
  100840. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100841. /**
  100842. * Gets the uniform buffer used to store scene data
  100843. * @returns a UniformBuffer
  100844. */
  100845. getSceneUniformBuffer(): UniformBuffer;
  100846. /**
  100847. * Gets an unique (relatively to the current scene) Id
  100848. * @returns an unique number for the scene
  100849. */
  100850. getUniqueId(): number;
  100851. /**
  100852. * Add a mesh to the list of scene's meshes
  100853. * @param newMesh defines the mesh to add
  100854. * @param recursive if all child meshes should also be added to the scene
  100855. */
  100856. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100857. /**
  100858. * Remove a mesh for the list of scene's meshes
  100859. * @param toRemove defines the mesh to remove
  100860. * @param recursive if all child meshes should also be removed from the scene
  100861. * @returns the index where the mesh was in the mesh list
  100862. */
  100863. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100864. /**
  100865. * Add a transform node to the list of scene's transform nodes
  100866. * @param newTransformNode defines the transform node to add
  100867. */
  100868. addTransformNode(newTransformNode: TransformNode): void;
  100869. /**
  100870. * Remove a transform node for the list of scene's transform nodes
  100871. * @param toRemove defines the transform node to remove
  100872. * @returns the index where the transform node was in the transform node list
  100873. */
  100874. removeTransformNode(toRemove: TransformNode): number;
  100875. /**
  100876. * Remove a skeleton for the list of scene's skeletons
  100877. * @param toRemove defines the skeleton to remove
  100878. * @returns the index where the skeleton was in the skeleton list
  100879. */
  100880. removeSkeleton(toRemove: Skeleton): number;
  100881. /**
  100882. * Remove a morph target for the list of scene's morph targets
  100883. * @param toRemove defines the morph target to remove
  100884. * @returns the index where the morph target was in the morph target list
  100885. */
  100886. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100887. /**
  100888. * Remove a light for the list of scene's lights
  100889. * @param toRemove defines the light to remove
  100890. * @returns the index where the light was in the light list
  100891. */
  100892. removeLight(toRemove: Light): number;
  100893. /**
  100894. * Remove a camera for the list of scene's cameras
  100895. * @param toRemove defines the camera to remove
  100896. * @returns the index where the camera was in the camera list
  100897. */
  100898. removeCamera(toRemove: Camera): number;
  100899. /**
  100900. * Remove a particle system for the list of scene's particle systems
  100901. * @param toRemove defines the particle system to remove
  100902. * @returns the index where the particle system was in the particle system list
  100903. */
  100904. removeParticleSystem(toRemove: IParticleSystem): number;
  100905. /**
  100906. * Remove a animation for the list of scene's animations
  100907. * @param toRemove defines the animation to remove
  100908. * @returns the index where the animation was in the animation list
  100909. */
  100910. removeAnimation(toRemove: Animation): number;
  100911. /**
  100912. * Will stop the animation of the given target
  100913. * @param target - the target
  100914. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100915. * @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)
  100916. */
  100917. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100918. /**
  100919. * Removes the given animation group from this scene.
  100920. * @param toRemove The animation group to remove
  100921. * @returns The index of the removed animation group
  100922. */
  100923. removeAnimationGroup(toRemove: AnimationGroup): number;
  100924. /**
  100925. * Removes the given multi-material from this scene.
  100926. * @param toRemove The multi-material to remove
  100927. * @returns The index of the removed multi-material
  100928. */
  100929. removeMultiMaterial(toRemove: MultiMaterial): number;
  100930. /**
  100931. * Removes the given material from this scene.
  100932. * @param toRemove The material to remove
  100933. * @returns The index of the removed material
  100934. */
  100935. removeMaterial(toRemove: Material): number;
  100936. /**
  100937. * Removes the given action manager from this scene.
  100938. * @param toRemove The action manager to remove
  100939. * @returns The index of the removed action manager
  100940. */
  100941. removeActionManager(toRemove: AbstractActionManager): number;
  100942. /**
  100943. * Removes the given texture from this scene.
  100944. * @param toRemove The texture to remove
  100945. * @returns The index of the removed texture
  100946. */
  100947. removeTexture(toRemove: BaseTexture): number;
  100948. /**
  100949. * Adds the given light to this scene
  100950. * @param newLight The light to add
  100951. */
  100952. addLight(newLight: Light): void;
  100953. /**
  100954. * Sorts the list list based on light priorities
  100955. */
  100956. sortLightsByPriority(): void;
  100957. /**
  100958. * Adds the given camera to this scene
  100959. * @param newCamera The camera to add
  100960. */
  100961. addCamera(newCamera: Camera): void;
  100962. /**
  100963. * Adds the given skeleton to this scene
  100964. * @param newSkeleton The skeleton to add
  100965. */
  100966. addSkeleton(newSkeleton: Skeleton): void;
  100967. /**
  100968. * Adds the given particle system to this scene
  100969. * @param newParticleSystem The particle system to add
  100970. */
  100971. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100972. /**
  100973. * Adds the given animation to this scene
  100974. * @param newAnimation The animation to add
  100975. */
  100976. addAnimation(newAnimation: Animation): void;
  100977. /**
  100978. * Adds the given animation group to this scene.
  100979. * @param newAnimationGroup The animation group to add
  100980. */
  100981. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100982. /**
  100983. * Adds the given multi-material to this scene
  100984. * @param newMultiMaterial The multi-material to add
  100985. */
  100986. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100987. /**
  100988. * Adds the given material to this scene
  100989. * @param newMaterial The material to add
  100990. */
  100991. addMaterial(newMaterial: Material): void;
  100992. /**
  100993. * Adds the given morph target to this scene
  100994. * @param newMorphTargetManager The morph target to add
  100995. */
  100996. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100997. /**
  100998. * Adds the given geometry to this scene
  100999. * @param newGeometry The geometry to add
  101000. */
  101001. addGeometry(newGeometry: Geometry): void;
  101002. /**
  101003. * Adds the given action manager to this scene
  101004. * @param newActionManager The action manager to add
  101005. */
  101006. addActionManager(newActionManager: AbstractActionManager): void;
  101007. /**
  101008. * Adds the given texture to this scene.
  101009. * @param newTexture The texture to add
  101010. */
  101011. addTexture(newTexture: BaseTexture): void;
  101012. /**
  101013. * Switch active camera
  101014. * @param newCamera defines the new active camera
  101015. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101016. */
  101017. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101018. /**
  101019. * sets the active camera of the scene using its ID
  101020. * @param id defines the camera's ID
  101021. * @return the new active camera or null if none found.
  101022. */
  101023. setActiveCameraByID(id: string): Nullable<Camera>;
  101024. /**
  101025. * sets the active camera of the scene using its name
  101026. * @param name defines the camera's name
  101027. * @returns the new active camera or null if none found.
  101028. */
  101029. setActiveCameraByName(name: string): Nullable<Camera>;
  101030. /**
  101031. * get an animation group using its name
  101032. * @param name defines the material's name
  101033. * @return the animation group or null if none found.
  101034. */
  101035. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101036. /**
  101037. * Get a material using its unique id
  101038. * @param uniqueId defines the material's unique id
  101039. * @return the material or null if none found.
  101040. */
  101041. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101042. /**
  101043. * get a material using its id
  101044. * @param id defines the material's ID
  101045. * @return the material or null if none found.
  101046. */
  101047. getMaterialByID(id: string): Nullable<Material>;
  101048. /**
  101049. * Gets a the last added material using a given id
  101050. * @param id defines the material's ID
  101051. * @return the last material with the given id or null if none found.
  101052. */
  101053. getLastMaterialByID(id: string): Nullable<Material>;
  101054. /**
  101055. * Gets a material using its name
  101056. * @param name defines the material's name
  101057. * @return the material or null if none found.
  101058. */
  101059. getMaterialByName(name: string): Nullable<Material>;
  101060. /**
  101061. * Get a texture using its unique id
  101062. * @param uniqueId defines the texture's unique id
  101063. * @return the texture or null if none found.
  101064. */
  101065. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101066. /**
  101067. * Gets a camera using its id
  101068. * @param id defines the id to look for
  101069. * @returns the camera or null if not found
  101070. */
  101071. getCameraByID(id: string): Nullable<Camera>;
  101072. /**
  101073. * Gets a camera using its unique id
  101074. * @param uniqueId defines the unique id to look for
  101075. * @returns the camera or null if not found
  101076. */
  101077. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101078. /**
  101079. * Gets a camera using its name
  101080. * @param name defines the camera's name
  101081. * @return the camera or null if none found.
  101082. */
  101083. getCameraByName(name: string): Nullable<Camera>;
  101084. /**
  101085. * Gets a bone using its id
  101086. * @param id defines the bone's id
  101087. * @return the bone or null if not found
  101088. */
  101089. getBoneByID(id: string): Nullable<Bone>;
  101090. /**
  101091. * Gets a bone using its id
  101092. * @param name defines the bone's name
  101093. * @return the bone or null if not found
  101094. */
  101095. getBoneByName(name: string): Nullable<Bone>;
  101096. /**
  101097. * Gets a light node using its name
  101098. * @param name defines the the light's name
  101099. * @return the light or null if none found.
  101100. */
  101101. getLightByName(name: string): Nullable<Light>;
  101102. /**
  101103. * Gets a light node using its id
  101104. * @param id defines the light's id
  101105. * @return the light or null if none found.
  101106. */
  101107. getLightByID(id: string): Nullable<Light>;
  101108. /**
  101109. * Gets a light node using its scene-generated unique ID
  101110. * @param uniqueId defines the light's unique id
  101111. * @return the light or null if none found.
  101112. */
  101113. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101114. /**
  101115. * Gets a particle system by id
  101116. * @param id defines the particle system id
  101117. * @return the corresponding system or null if none found
  101118. */
  101119. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101120. /**
  101121. * Gets a geometry using its ID
  101122. * @param id defines the geometry's id
  101123. * @return the geometry or null if none found.
  101124. */
  101125. getGeometryByID(id: string): Nullable<Geometry>;
  101126. private _getGeometryByUniqueID;
  101127. /**
  101128. * Add a new geometry to this scene
  101129. * @param geometry defines the geometry to be added to the scene.
  101130. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101131. * @return a boolean defining if the geometry was added or not
  101132. */
  101133. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101134. /**
  101135. * Removes an existing geometry
  101136. * @param geometry defines the geometry to be removed from the scene
  101137. * @return a boolean defining if the geometry was removed or not
  101138. */
  101139. removeGeometry(geometry: Geometry): boolean;
  101140. /**
  101141. * Gets the list of geometries attached to the scene
  101142. * @returns an array of Geometry
  101143. */
  101144. getGeometries(): Geometry[];
  101145. /**
  101146. * Gets the first added mesh found of a given ID
  101147. * @param id defines the id to search for
  101148. * @return the mesh found or null if not found at all
  101149. */
  101150. getMeshByID(id: string): Nullable<AbstractMesh>;
  101151. /**
  101152. * Gets a list of meshes using their id
  101153. * @param id defines the id to search for
  101154. * @returns a list of meshes
  101155. */
  101156. getMeshesByID(id: string): Array<AbstractMesh>;
  101157. /**
  101158. * Gets the first added transform node found of a given ID
  101159. * @param id defines the id to search for
  101160. * @return the found transform node or null if not found at all.
  101161. */
  101162. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101163. /**
  101164. * Gets a transform node with its auto-generated unique id
  101165. * @param uniqueId efines the unique id to search for
  101166. * @return the found transform node or null if not found at all.
  101167. */
  101168. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101169. /**
  101170. * Gets a list of transform nodes using their id
  101171. * @param id defines the id to search for
  101172. * @returns a list of transform nodes
  101173. */
  101174. getTransformNodesByID(id: string): Array<TransformNode>;
  101175. /**
  101176. * Gets a mesh with its auto-generated unique id
  101177. * @param uniqueId defines the unique id to search for
  101178. * @return the found mesh or null if not found at all.
  101179. */
  101180. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101181. /**
  101182. * Gets a the last added mesh using a given id
  101183. * @param id defines the id to search for
  101184. * @return the found mesh or null if not found at all.
  101185. */
  101186. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101187. /**
  101188. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101189. * @param id defines the id to search for
  101190. * @return the found node or null if not found at all
  101191. */
  101192. getLastEntryByID(id: string): Nullable<Node>;
  101193. /**
  101194. * Gets a node (Mesh, Camera, Light) using a given id
  101195. * @param id defines the id to search for
  101196. * @return the found node or null if not found at all
  101197. */
  101198. getNodeByID(id: string): Nullable<Node>;
  101199. /**
  101200. * Gets a node (Mesh, Camera, Light) using a given name
  101201. * @param name defines the name to search for
  101202. * @return the found node or null if not found at all.
  101203. */
  101204. getNodeByName(name: string): Nullable<Node>;
  101205. /**
  101206. * Gets a mesh using a given name
  101207. * @param name defines the name to search for
  101208. * @return the found mesh or null if not found at all.
  101209. */
  101210. getMeshByName(name: string): Nullable<AbstractMesh>;
  101211. /**
  101212. * Gets a transform node using a given name
  101213. * @param name defines the name to search for
  101214. * @return the found transform node or null if not found at all.
  101215. */
  101216. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101217. /**
  101218. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101219. * @param id defines the id to search for
  101220. * @return the found skeleton or null if not found at all.
  101221. */
  101222. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101223. /**
  101224. * Gets a skeleton using a given auto generated unique id
  101225. * @param uniqueId defines the unique id to search for
  101226. * @return the found skeleton or null if not found at all.
  101227. */
  101228. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101229. /**
  101230. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101231. * @param id defines the id to search for
  101232. * @return the found skeleton or null if not found at all.
  101233. */
  101234. getSkeletonById(id: string): Nullable<Skeleton>;
  101235. /**
  101236. * Gets a skeleton using a given name
  101237. * @param name defines the name to search for
  101238. * @return the found skeleton or null if not found at all.
  101239. */
  101240. getSkeletonByName(name: string): Nullable<Skeleton>;
  101241. /**
  101242. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101243. * @param id defines the id to search for
  101244. * @return the found morph target manager or null if not found at all.
  101245. */
  101246. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101247. /**
  101248. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101249. * @param id defines the id to search for
  101250. * @return the found morph target or null if not found at all.
  101251. */
  101252. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101253. /**
  101254. * Gets a boolean indicating if the given mesh is active
  101255. * @param mesh defines the mesh to look for
  101256. * @returns true if the mesh is in the active list
  101257. */
  101258. isActiveMesh(mesh: AbstractMesh): boolean;
  101259. /**
  101260. * Return a unique id as a string which can serve as an identifier for the scene
  101261. */
  101262. readonly uid: string;
  101263. /**
  101264. * Add an externaly attached data from its key.
  101265. * This method call will fail and return false, if such key already exists.
  101266. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101267. * @param key the unique key that identifies the data
  101268. * @param data the data object to associate to the key for this Engine instance
  101269. * @return true if no such key were already present and the data was added successfully, false otherwise
  101270. */
  101271. addExternalData<T>(key: string, data: T): boolean;
  101272. /**
  101273. * Get an externaly attached data from its key
  101274. * @param key the unique key that identifies the data
  101275. * @return the associated data, if present (can be null), or undefined if not present
  101276. */
  101277. getExternalData<T>(key: string): Nullable<T>;
  101278. /**
  101279. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101280. * @param key the unique key that identifies the data
  101281. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101282. * @return the associated data, can be null if the factory returned null.
  101283. */
  101284. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101285. /**
  101286. * Remove an externaly attached data from the Engine instance
  101287. * @param key the unique key that identifies the data
  101288. * @return true if the data was successfully removed, false if it doesn't exist
  101289. */
  101290. removeExternalData(key: string): boolean;
  101291. private _evaluateSubMesh;
  101292. /**
  101293. * Clear the processed materials smart array preventing retention point in material dispose.
  101294. */
  101295. freeProcessedMaterials(): void;
  101296. private _preventFreeActiveMeshesAndRenderingGroups;
  101297. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101298. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101299. * when disposing several meshes in a row or a hierarchy of meshes.
  101300. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101301. */
  101302. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101303. /**
  101304. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101305. */
  101306. freeActiveMeshes(): void;
  101307. /**
  101308. * Clear the info related to rendering groups preventing retention points during dispose.
  101309. */
  101310. freeRenderingGroups(): void;
  101311. /** @hidden */
  101312. _isInIntermediateRendering(): boolean;
  101313. /**
  101314. * Lambda returning the list of potentially active meshes.
  101315. */
  101316. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101317. /**
  101318. * Lambda returning the list of potentially active sub meshes.
  101319. */
  101320. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101321. /**
  101322. * Lambda returning the list of potentially intersecting sub meshes.
  101323. */
  101324. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101325. /**
  101326. * Lambda returning the list of potentially colliding sub meshes.
  101327. */
  101328. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101329. private _activeMeshesFrozen;
  101330. /**
  101331. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101332. * @returns the current scene
  101333. */
  101334. freezeActiveMeshes(): Scene;
  101335. /**
  101336. * Use this function to restart evaluating active meshes on every frame
  101337. * @returns the current scene
  101338. */
  101339. unfreezeActiveMeshes(): Scene;
  101340. private _evaluateActiveMeshes;
  101341. private _activeMesh;
  101342. /**
  101343. * Update the transform matrix to update from the current active camera
  101344. * @param force defines a boolean used to force the update even if cache is up to date
  101345. */
  101346. updateTransformMatrix(force?: boolean): void;
  101347. private _bindFrameBuffer;
  101348. /** @hidden */
  101349. _allowPostProcessClearColor: boolean;
  101350. /** @hidden */
  101351. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101352. private _processSubCameras;
  101353. private _checkIntersections;
  101354. /** @hidden */
  101355. _advancePhysicsEngineStep(step: number): void;
  101356. /**
  101357. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101358. */
  101359. getDeterministicFrameTime: () => number;
  101360. /** @hidden */
  101361. _animate(): void;
  101362. /** Execute all animations (for a frame) */
  101363. animate(): void;
  101364. /**
  101365. * Render the scene
  101366. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101367. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101368. */
  101369. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101370. /**
  101371. * Freeze all materials
  101372. * A frozen material will not be updatable but should be faster to render
  101373. */
  101374. freezeMaterials(): void;
  101375. /**
  101376. * Unfreeze all materials
  101377. * A frozen material will not be updatable but should be faster to render
  101378. */
  101379. unfreezeMaterials(): void;
  101380. /**
  101381. * Releases all held ressources
  101382. */
  101383. dispose(): void;
  101384. /**
  101385. * Gets if the scene is already disposed
  101386. */
  101387. readonly isDisposed: boolean;
  101388. /**
  101389. * Call this function to reduce memory footprint of the scene.
  101390. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101391. */
  101392. clearCachedVertexData(): void;
  101393. /**
  101394. * This function will remove the local cached buffer data from texture.
  101395. * It will save memory but will prevent the texture from being rebuilt
  101396. */
  101397. cleanCachedTextureBuffer(): void;
  101398. /**
  101399. * Get the world extend vectors with an optional filter
  101400. *
  101401. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101402. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101403. */
  101404. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101405. min: Vector3;
  101406. max: Vector3;
  101407. };
  101408. /**
  101409. * Creates a ray that can be used to pick in the scene
  101410. * @param x defines the x coordinate of the origin (on-screen)
  101411. * @param y defines the y coordinate of the origin (on-screen)
  101412. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101413. * @param camera defines the camera to use for the picking
  101414. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101415. * @returns a Ray
  101416. */
  101417. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101418. /**
  101419. * Creates a ray that can be used to pick in the scene
  101420. * @param x defines the x coordinate of the origin (on-screen)
  101421. * @param y defines the y coordinate of the origin (on-screen)
  101422. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101423. * @param result defines the ray where to store the picking ray
  101424. * @param camera defines the camera to use for the picking
  101425. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101426. * @returns the current scene
  101427. */
  101428. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101429. /**
  101430. * Creates a ray that can be used to pick in the scene
  101431. * @param x defines the x coordinate of the origin (on-screen)
  101432. * @param y defines the y coordinate of the origin (on-screen)
  101433. * @param camera defines the camera to use for the picking
  101434. * @returns a Ray
  101435. */
  101436. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101437. /**
  101438. * Creates a ray that can be used to pick in the scene
  101439. * @param x defines the x coordinate of the origin (on-screen)
  101440. * @param y defines the y coordinate of the origin (on-screen)
  101441. * @param result defines the ray where to store the picking ray
  101442. * @param camera defines the camera to use for the picking
  101443. * @returns the current scene
  101444. */
  101445. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101446. /** Launch a ray to try to pick a mesh in the scene
  101447. * @param x position on screen
  101448. * @param y position on screen
  101449. * @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
  101450. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101451. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101453. * @returns a PickingInfo
  101454. */
  101455. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101456. /** Use the given ray to pick a mesh in the scene
  101457. * @param ray The ray to use to pick meshes
  101458. * @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
  101459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101461. * @returns a PickingInfo
  101462. */
  101463. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101464. /**
  101465. * Launch a ray to try to pick a mesh in the scene
  101466. * @param x X position on screen
  101467. * @param y Y position on screen
  101468. * @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
  101469. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101471. * @returns an array of PickingInfo
  101472. */
  101473. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101474. /**
  101475. * Launch a ray to try to pick a mesh in the scene
  101476. * @param ray Ray to use
  101477. * @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
  101478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101479. * @returns an array of PickingInfo
  101480. */
  101481. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101482. /**
  101483. * Force the value of meshUnderPointer
  101484. * @param mesh defines the mesh to use
  101485. */
  101486. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101487. /**
  101488. * Gets the mesh under the pointer
  101489. * @returns a Mesh or null if no mesh is under the pointer
  101490. */
  101491. getPointerOverMesh(): Nullable<AbstractMesh>;
  101492. /** @hidden */
  101493. _rebuildGeometries(): void;
  101494. /** @hidden */
  101495. _rebuildTextures(): void;
  101496. private _getByTags;
  101497. /**
  101498. * Get a list of meshes by tags
  101499. * @param tagsQuery defines the tags query to use
  101500. * @param forEach defines a predicate used to filter results
  101501. * @returns an array of Mesh
  101502. */
  101503. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101504. /**
  101505. * Get a list of cameras by tags
  101506. * @param tagsQuery defines the tags query to use
  101507. * @param forEach defines a predicate used to filter results
  101508. * @returns an array of Camera
  101509. */
  101510. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101511. /**
  101512. * Get a list of lights by tags
  101513. * @param tagsQuery defines the tags query to use
  101514. * @param forEach defines a predicate used to filter results
  101515. * @returns an array of Light
  101516. */
  101517. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101518. /**
  101519. * Get a list of materials by tags
  101520. * @param tagsQuery defines the tags query to use
  101521. * @param forEach defines a predicate used to filter results
  101522. * @returns an array of Material
  101523. */
  101524. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101525. /**
  101526. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101527. * This allowed control for front to back rendering or reversly depending of the special needs.
  101528. *
  101529. * @param renderingGroupId The rendering group id corresponding to its index
  101530. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101531. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101532. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101533. */
  101534. 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;
  101535. /**
  101536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101537. *
  101538. * @param renderingGroupId The rendering group id corresponding to its index
  101539. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101540. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101541. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101542. */
  101543. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101544. /**
  101545. * Gets the current auto clear configuration for one rendering group of the rendering
  101546. * manager.
  101547. * @param index the rendering group index to get the information for
  101548. * @returns The auto clear setup for the requested rendering group
  101549. */
  101550. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101551. private _blockMaterialDirtyMechanism;
  101552. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101553. blockMaterialDirtyMechanism: boolean;
  101554. /**
  101555. * Will flag all materials as dirty to trigger new shader compilation
  101556. * @param flag defines the flag used to specify which material part must be marked as dirty
  101557. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101558. */
  101559. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101560. /** @hidden */
  101561. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  101562. /** @hidden */
  101563. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101564. }
  101565. }
  101566. declare module BABYLON {
  101567. /**
  101568. * Set of assets to keep when moving a scene into an asset container.
  101569. */
  101570. export class KeepAssets extends AbstractScene {
  101571. }
  101572. /**
  101573. * Container with a set of assets that can be added or removed from a scene.
  101574. */
  101575. export class AssetContainer extends AbstractScene {
  101576. /**
  101577. * The scene the AssetContainer belongs to.
  101578. */
  101579. scene: Scene;
  101580. /**
  101581. * Instantiates an AssetContainer.
  101582. * @param scene The scene the AssetContainer belongs to.
  101583. */
  101584. constructor(scene: Scene);
  101585. /**
  101586. * Adds all the assets from the container to the scene.
  101587. */
  101588. addAllToScene(): void;
  101589. /**
  101590. * Removes all the assets in the container from the scene
  101591. */
  101592. removeAllFromScene(): void;
  101593. /**
  101594. * Disposes all the assets in the container
  101595. */
  101596. dispose(): void;
  101597. private _moveAssets;
  101598. /**
  101599. * Removes all the assets contained in the scene and adds them to the container.
  101600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101601. */
  101602. moveAllFromScene(keepAssets?: KeepAssets): void;
  101603. /**
  101604. * 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.
  101605. * @returns the root mesh
  101606. */
  101607. createRootMesh(): Mesh;
  101608. }
  101609. }
  101610. declare module BABYLON {
  101611. /**
  101612. * Defines how the parser contract is defined.
  101613. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101614. */
  101615. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101616. /**
  101617. * Defines how the individual parser contract is defined.
  101618. * These parser can parse an individual asset
  101619. */
  101620. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101621. /**
  101622. * Base class of the scene acting as a container for the different elements composing a scene.
  101623. * This class is dynamically extended by the different components of the scene increasing
  101624. * flexibility and reducing coupling
  101625. */
  101626. export abstract class AbstractScene {
  101627. /**
  101628. * Stores the list of available parsers in the application.
  101629. */
  101630. private static _BabylonFileParsers;
  101631. /**
  101632. * Stores the list of available individual parsers in the application.
  101633. */
  101634. private static _IndividualBabylonFileParsers;
  101635. /**
  101636. * Adds a parser in the list of available ones
  101637. * @param name Defines the name of the parser
  101638. * @param parser Defines the parser to add
  101639. */
  101640. static AddParser(name: string, parser: BabylonFileParser): void;
  101641. /**
  101642. * Gets a general parser from the list of avaialble ones
  101643. * @param name Defines the name of the parser
  101644. * @returns the requested parser or null
  101645. */
  101646. static GetParser(name: string): Nullable<BabylonFileParser>;
  101647. /**
  101648. * Adds n individual parser in the list of available ones
  101649. * @param name Defines the name of the parser
  101650. * @param parser Defines the parser to add
  101651. */
  101652. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101653. /**
  101654. * Gets an individual parser from the list of avaialble ones
  101655. * @param name Defines the name of the parser
  101656. * @returns the requested parser or null
  101657. */
  101658. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101659. /**
  101660. * Parser json data and populate both a scene and its associated container object
  101661. * @param jsonData Defines the data to parse
  101662. * @param scene Defines the scene to parse the data for
  101663. * @param container Defines the container attached to the parsing sequence
  101664. * @param rootUrl Defines the root url of the data
  101665. */
  101666. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101667. /**
  101668. * Gets the list of root nodes (ie. nodes with no parent)
  101669. */
  101670. rootNodes: Node[];
  101671. /** All of the cameras added to this scene
  101672. * @see http://doc.babylonjs.com/babylon101/cameras
  101673. */
  101674. cameras: Camera[];
  101675. /**
  101676. * All of the lights added to this scene
  101677. * @see http://doc.babylonjs.com/babylon101/lights
  101678. */
  101679. lights: Light[];
  101680. /**
  101681. * All of the (abstract) meshes added to this scene
  101682. */
  101683. meshes: AbstractMesh[];
  101684. /**
  101685. * The list of skeletons added to the scene
  101686. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101687. */
  101688. skeletons: Skeleton[];
  101689. /**
  101690. * All of the particle systems added to this scene
  101691. * @see http://doc.babylonjs.com/babylon101/particles
  101692. */
  101693. particleSystems: IParticleSystem[];
  101694. /**
  101695. * Gets a list of Animations associated with the scene
  101696. */
  101697. animations: Animation[];
  101698. /**
  101699. * All of the animation groups added to this scene
  101700. * @see http://doc.babylonjs.com/how_to/group
  101701. */
  101702. animationGroups: AnimationGroup[];
  101703. /**
  101704. * All of the multi-materials added to this scene
  101705. * @see http://doc.babylonjs.com/how_to/multi_materials
  101706. */
  101707. multiMaterials: MultiMaterial[];
  101708. /**
  101709. * All of the materials added to this scene
  101710. * In the context of a Scene, it is not supposed to be modified manually.
  101711. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101712. * Note also that the order of the Material wihin the array is not significant and might change.
  101713. * @see http://doc.babylonjs.com/babylon101/materials
  101714. */
  101715. materials: Material[];
  101716. /**
  101717. * The list of morph target managers added to the scene
  101718. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101719. */
  101720. morphTargetManagers: MorphTargetManager[];
  101721. /**
  101722. * The list of geometries used in the scene.
  101723. */
  101724. geometries: Geometry[];
  101725. /**
  101726. * All of the tranform nodes added to this scene
  101727. * In the context of a Scene, it is not supposed to be modified manually.
  101728. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101729. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101730. * @see http://doc.babylonjs.com/how_to/transformnode
  101731. */
  101732. transformNodes: TransformNode[];
  101733. /**
  101734. * ActionManagers available on the scene.
  101735. */
  101736. actionManagers: AbstractActionManager[];
  101737. /**
  101738. * Textures to keep.
  101739. */
  101740. textures: BaseTexture[];
  101741. /**
  101742. * Environment texture for the scene
  101743. */
  101744. environmentTexture: Nullable<BaseTexture>;
  101745. }
  101746. }
  101747. declare module BABYLON {
  101748. /**
  101749. * Interface used to define options for Sound class
  101750. */
  101751. export interface ISoundOptions {
  101752. /**
  101753. * Does the sound autoplay once loaded.
  101754. */
  101755. autoplay?: boolean;
  101756. /**
  101757. * Does the sound loop after it finishes playing once.
  101758. */
  101759. loop?: boolean;
  101760. /**
  101761. * Sound's volume
  101762. */
  101763. volume?: number;
  101764. /**
  101765. * Is it a spatial sound?
  101766. */
  101767. spatialSound?: boolean;
  101768. /**
  101769. * Maximum distance to hear that sound
  101770. */
  101771. maxDistance?: number;
  101772. /**
  101773. * Uses user defined attenuation function
  101774. */
  101775. useCustomAttenuation?: boolean;
  101776. /**
  101777. * Define the roll off factor of spatial sounds.
  101778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101779. */
  101780. rolloffFactor?: number;
  101781. /**
  101782. * Define the reference distance the sound should be heard perfectly.
  101783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101784. */
  101785. refDistance?: number;
  101786. /**
  101787. * Define the distance attenuation model the sound will follow.
  101788. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101789. */
  101790. distanceModel?: string;
  101791. /**
  101792. * Defines the playback speed (1 by default)
  101793. */
  101794. playbackRate?: number;
  101795. /**
  101796. * Defines if the sound is from a streaming source
  101797. */
  101798. streaming?: boolean;
  101799. /**
  101800. * Defines an optional length (in seconds) inside the sound file
  101801. */
  101802. length?: number;
  101803. /**
  101804. * Defines an optional offset (in seconds) inside the sound file
  101805. */
  101806. offset?: number;
  101807. /**
  101808. * If true, URLs will not be required to state the audio file codec to use.
  101809. */
  101810. skipCodecCheck?: boolean;
  101811. }
  101812. /**
  101813. * Defines a sound that can be played in the application.
  101814. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101816. */
  101817. export class Sound {
  101818. /**
  101819. * The name of the sound in the scene.
  101820. */
  101821. name: string;
  101822. /**
  101823. * Does the sound autoplay once loaded.
  101824. */
  101825. autoplay: boolean;
  101826. /**
  101827. * Does the sound loop after it finishes playing once.
  101828. */
  101829. loop: boolean;
  101830. /**
  101831. * Does the sound use a custom attenuation curve to simulate the falloff
  101832. * happening when the source gets further away from the camera.
  101833. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101834. */
  101835. useCustomAttenuation: boolean;
  101836. /**
  101837. * The sound track id this sound belongs to.
  101838. */
  101839. soundTrackId: number;
  101840. /**
  101841. * Is this sound currently played.
  101842. */
  101843. isPlaying: boolean;
  101844. /**
  101845. * Is this sound currently paused.
  101846. */
  101847. isPaused: boolean;
  101848. /**
  101849. * Does this sound enables spatial sound.
  101850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101851. */
  101852. spatialSound: boolean;
  101853. /**
  101854. * Define the reference distance the sound should be heard perfectly.
  101855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101856. */
  101857. refDistance: number;
  101858. /**
  101859. * Define the roll off factor of spatial sounds.
  101860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101861. */
  101862. rolloffFactor: number;
  101863. /**
  101864. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101866. */
  101867. maxDistance: number;
  101868. /**
  101869. * Define the distance attenuation model the sound will follow.
  101870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101871. */
  101872. distanceModel: string;
  101873. /**
  101874. * @hidden
  101875. * Back Compat
  101876. **/
  101877. onended: () => any;
  101878. /**
  101879. * Observable event when the current playing sound finishes.
  101880. */
  101881. onEndedObservable: Observable<Sound>;
  101882. private _panningModel;
  101883. private _playbackRate;
  101884. private _streaming;
  101885. private _startTime;
  101886. private _startOffset;
  101887. private _position;
  101888. /** @hidden */
  101889. _positionInEmitterSpace: boolean;
  101890. private _localDirection;
  101891. private _volume;
  101892. private _isReadyToPlay;
  101893. private _isDirectional;
  101894. private _readyToPlayCallback;
  101895. private _audioBuffer;
  101896. private _soundSource;
  101897. private _streamingSource;
  101898. private _soundPanner;
  101899. private _soundGain;
  101900. private _inputAudioNode;
  101901. private _outputAudioNode;
  101902. private _coneInnerAngle;
  101903. private _coneOuterAngle;
  101904. private _coneOuterGain;
  101905. private _scene;
  101906. private _connectedTransformNode;
  101907. private _customAttenuationFunction;
  101908. private _registerFunc;
  101909. private _isOutputConnected;
  101910. private _htmlAudioElement;
  101911. private _urlType;
  101912. private _length?;
  101913. private _offset?;
  101914. /** @hidden */
  101915. static _SceneComponentInitialization: (scene: Scene) => void;
  101916. /**
  101917. * Create a sound and attach it to a scene
  101918. * @param name Name of your sound
  101919. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101920. * @param scene defines the scene the sound belongs to
  101921. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101922. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101923. */
  101924. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101925. /**
  101926. * Release the sound and its associated resources
  101927. */
  101928. dispose(): void;
  101929. /**
  101930. * Gets if the sounds is ready to be played or not.
  101931. * @returns true if ready, otherwise false
  101932. */
  101933. isReady(): boolean;
  101934. private _soundLoaded;
  101935. /**
  101936. * Sets the data of the sound from an audiobuffer
  101937. * @param audioBuffer The audioBuffer containing the data
  101938. */
  101939. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101940. /**
  101941. * Updates the current sounds options such as maxdistance, loop...
  101942. * @param options A JSON object containing values named as the object properties
  101943. */
  101944. updateOptions(options: ISoundOptions): void;
  101945. private _createSpatialParameters;
  101946. private _updateSpatialParameters;
  101947. /**
  101948. * Switch the panning model to HRTF:
  101949. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101950. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101951. */
  101952. switchPanningModelToHRTF(): void;
  101953. /**
  101954. * Switch the panning model to Equal Power:
  101955. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101957. */
  101958. switchPanningModelToEqualPower(): void;
  101959. private _switchPanningModel;
  101960. /**
  101961. * Connect this sound to a sound track audio node like gain...
  101962. * @param soundTrackAudioNode the sound track audio node to connect to
  101963. */
  101964. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101965. /**
  101966. * Transform this sound into a directional source
  101967. * @param coneInnerAngle Size of the inner cone in degree
  101968. * @param coneOuterAngle Size of the outer cone in degree
  101969. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101970. */
  101971. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101972. /**
  101973. * Gets or sets the inner angle for the directional cone.
  101974. */
  101975. /**
  101976. * Gets or sets the inner angle for the directional cone.
  101977. */
  101978. directionalConeInnerAngle: number;
  101979. /**
  101980. * Gets or sets the outer angle for the directional cone.
  101981. */
  101982. /**
  101983. * Gets or sets the outer angle for the directional cone.
  101984. */
  101985. directionalConeOuterAngle: number;
  101986. /**
  101987. * Sets the position of the emitter if spatial sound is enabled
  101988. * @param newPosition Defines the new posisiton
  101989. */
  101990. setPosition(newPosition: Vector3): void;
  101991. /**
  101992. * Sets the local direction of the emitter if spatial sound is enabled
  101993. * @param newLocalDirection Defines the new local direction
  101994. */
  101995. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101996. private _updateDirection;
  101997. /** @hidden */
  101998. updateDistanceFromListener(): void;
  101999. /**
  102000. * Sets a new custom attenuation function for the sound.
  102001. * @param callback Defines the function used for the attenuation
  102002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102003. */
  102004. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102005. /**
  102006. * Play the sound
  102007. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102008. * @param offset (optional) Start the sound at a specific time in seconds
  102009. * @param length (optional) Sound duration (in seconds)
  102010. */
  102011. play(time?: number, offset?: number, length?: number): void;
  102012. private _onended;
  102013. /**
  102014. * Stop the sound
  102015. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102016. */
  102017. stop(time?: number): void;
  102018. /**
  102019. * Put the sound in pause
  102020. */
  102021. pause(): void;
  102022. /**
  102023. * Sets a dedicated volume for this sounds
  102024. * @param newVolume Define the new volume of the sound
  102025. * @param time Define time for gradual change to new volume
  102026. */
  102027. setVolume(newVolume: number, time?: number): void;
  102028. /**
  102029. * Set the sound play back rate
  102030. * @param newPlaybackRate Define the playback rate the sound should be played at
  102031. */
  102032. setPlaybackRate(newPlaybackRate: number): void;
  102033. /**
  102034. * Gets the volume of the sound.
  102035. * @returns the volume of the sound
  102036. */
  102037. getVolume(): number;
  102038. /**
  102039. * Attach the sound to a dedicated mesh
  102040. * @param transformNode The transform node to connect the sound with
  102041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102042. */
  102043. attachToMesh(transformNode: TransformNode): void;
  102044. /**
  102045. * Detach the sound from the previously attached mesh
  102046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102047. */
  102048. detachFromMesh(): void;
  102049. private _onRegisterAfterWorldMatrixUpdate;
  102050. /**
  102051. * Clone the current sound in the scene.
  102052. * @returns the new sound clone
  102053. */
  102054. clone(): Nullable<Sound>;
  102055. /**
  102056. * Gets the current underlying audio buffer containing the data
  102057. * @returns the audio buffer
  102058. */
  102059. getAudioBuffer(): Nullable<AudioBuffer>;
  102060. /**
  102061. * Serializes the Sound in a JSON representation
  102062. * @returns the JSON representation of the sound
  102063. */
  102064. serialize(): any;
  102065. /**
  102066. * Parse a JSON representation of a sound to innstantiate in a given scene
  102067. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102068. * @param scene Define the scene the new parsed sound should be created in
  102069. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102070. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102071. * @returns the newly parsed sound
  102072. */
  102073. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102074. }
  102075. }
  102076. declare module BABYLON {
  102077. /**
  102078. * This defines an action helpful to play a defined sound on a triggered action.
  102079. */
  102080. export class PlaySoundAction extends Action {
  102081. private _sound;
  102082. /**
  102083. * Instantiate the action
  102084. * @param triggerOptions defines the trigger options
  102085. * @param sound defines the sound to play
  102086. * @param condition defines the trigger related conditions
  102087. */
  102088. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102089. /** @hidden */
  102090. _prepare(): void;
  102091. /**
  102092. * Execute the action and play the sound.
  102093. */
  102094. execute(): void;
  102095. /**
  102096. * Serializes the actions and its related information.
  102097. * @param parent defines the object to serialize in
  102098. * @returns the serialized object
  102099. */
  102100. serialize(parent: any): any;
  102101. }
  102102. /**
  102103. * This defines an action helpful to stop a defined sound on a triggered action.
  102104. */
  102105. export class StopSoundAction extends Action {
  102106. private _sound;
  102107. /**
  102108. * Instantiate the action
  102109. * @param triggerOptions defines the trigger options
  102110. * @param sound defines the sound to stop
  102111. * @param condition defines the trigger related conditions
  102112. */
  102113. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102114. /** @hidden */
  102115. _prepare(): void;
  102116. /**
  102117. * Execute the action and stop the sound.
  102118. */
  102119. execute(): void;
  102120. /**
  102121. * Serializes the actions and its related information.
  102122. * @param parent defines the object to serialize in
  102123. * @returns the serialized object
  102124. */
  102125. serialize(parent: any): any;
  102126. }
  102127. }
  102128. declare module BABYLON {
  102129. /**
  102130. * This defines an action responsible to change the value of a property
  102131. * by interpolating between its current value and the newly set one once triggered.
  102132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102133. */
  102134. export class InterpolateValueAction extends Action {
  102135. /**
  102136. * Defines the path of the property where the value should be interpolated
  102137. */
  102138. propertyPath: string;
  102139. /**
  102140. * Defines the target value at the end of the interpolation.
  102141. */
  102142. value: any;
  102143. /**
  102144. * Defines the time it will take for the property to interpolate to the value.
  102145. */
  102146. duration: number;
  102147. /**
  102148. * Defines if the other scene animations should be stopped when the action has been triggered
  102149. */
  102150. stopOtherAnimations?: boolean;
  102151. /**
  102152. * Defines a callback raised once the interpolation animation has been done.
  102153. */
  102154. onInterpolationDone?: () => void;
  102155. /**
  102156. * Observable triggered once the interpolation animation has been done.
  102157. */
  102158. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102159. private _target;
  102160. private _effectiveTarget;
  102161. private _property;
  102162. /**
  102163. * Instantiate the action
  102164. * @param triggerOptions defines the trigger options
  102165. * @param target defines the object containing the value to interpolate
  102166. * @param propertyPath defines the path to the property in the target object
  102167. * @param value defines the target value at the end of the interpolation
  102168. * @param duration deines the time it will take for the property to interpolate to the value.
  102169. * @param condition defines the trigger related conditions
  102170. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102171. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102172. */
  102173. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102174. /** @hidden */
  102175. _prepare(): void;
  102176. /**
  102177. * Execute the action starts the value interpolation.
  102178. */
  102179. execute(): void;
  102180. /**
  102181. * Serializes the actions and its related information.
  102182. * @param parent defines the object to serialize in
  102183. * @returns the serialized object
  102184. */
  102185. serialize(parent: any): any;
  102186. }
  102187. }
  102188. declare module BABYLON {
  102189. /**
  102190. * Options allowed during the creation of a sound track.
  102191. */
  102192. export interface ISoundTrackOptions {
  102193. /**
  102194. * The volume the sound track should take during creation
  102195. */
  102196. volume?: number;
  102197. /**
  102198. * Define if the sound track is the main sound track of the scene
  102199. */
  102200. mainTrack?: boolean;
  102201. }
  102202. /**
  102203. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102204. * It will be also used in a future release to apply effects on a specific track.
  102205. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102206. */
  102207. export class SoundTrack {
  102208. /**
  102209. * The unique identifier of the sound track in the scene.
  102210. */
  102211. id: number;
  102212. /**
  102213. * The list of sounds included in the sound track.
  102214. */
  102215. soundCollection: Array<Sound>;
  102216. private _outputAudioNode;
  102217. private _scene;
  102218. private _isMainTrack;
  102219. private _connectedAnalyser;
  102220. private _options;
  102221. private _isInitialized;
  102222. /**
  102223. * Creates a new sound track.
  102224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102225. * @param scene Define the scene the sound track belongs to
  102226. * @param options
  102227. */
  102228. constructor(scene: Scene, options?: ISoundTrackOptions);
  102229. private _initializeSoundTrackAudioGraph;
  102230. /**
  102231. * Release the sound track and its associated resources
  102232. */
  102233. dispose(): void;
  102234. /**
  102235. * Adds a sound to this sound track
  102236. * @param sound define the cound to add
  102237. * @ignoreNaming
  102238. */
  102239. AddSound(sound: Sound): void;
  102240. /**
  102241. * Removes a sound to this sound track
  102242. * @param sound define the cound to remove
  102243. * @ignoreNaming
  102244. */
  102245. RemoveSound(sound: Sound): void;
  102246. /**
  102247. * Set a global volume for the full sound track.
  102248. * @param newVolume Define the new volume of the sound track
  102249. */
  102250. setVolume(newVolume: number): void;
  102251. /**
  102252. * Switch the panning model to HRTF:
  102253. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102255. */
  102256. switchPanningModelToHRTF(): void;
  102257. /**
  102258. * Switch the panning model to Equal Power:
  102259. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102261. */
  102262. switchPanningModelToEqualPower(): void;
  102263. /**
  102264. * Connect the sound track to an audio analyser allowing some amazing
  102265. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102267. * @param analyser The analyser to connect to the engine
  102268. */
  102269. connectToAnalyser(analyser: Analyser): void;
  102270. }
  102271. }
  102272. declare module BABYLON {
  102273. interface AbstractScene {
  102274. /**
  102275. * The list of sounds used in the scene.
  102276. */
  102277. sounds: Nullable<Array<Sound>>;
  102278. }
  102279. interface Scene {
  102280. /**
  102281. * @hidden
  102282. * Backing field
  102283. */
  102284. _mainSoundTrack: SoundTrack;
  102285. /**
  102286. * The main sound track played by the scene.
  102287. * It cotains your primary collection of sounds.
  102288. */
  102289. mainSoundTrack: SoundTrack;
  102290. /**
  102291. * The list of sound tracks added to the scene
  102292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102293. */
  102294. soundTracks: Nullable<Array<SoundTrack>>;
  102295. /**
  102296. * Gets a sound using a given name
  102297. * @param name defines the name to search for
  102298. * @return the found sound or null if not found at all.
  102299. */
  102300. getSoundByName(name: string): Nullable<Sound>;
  102301. /**
  102302. * Gets or sets if audio support is enabled
  102303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102304. */
  102305. audioEnabled: boolean;
  102306. /**
  102307. * Gets or sets if audio will be output to headphones
  102308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102309. */
  102310. headphone: boolean;
  102311. /**
  102312. * Gets or sets custom audio listener position provider
  102313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102314. */
  102315. audioListenerPositionProvider: Nullable<() => Vector3>;
  102316. }
  102317. /**
  102318. * Defines the sound scene component responsible to manage any sounds
  102319. * in a given scene.
  102320. */
  102321. export class AudioSceneComponent implements ISceneSerializableComponent {
  102322. /**
  102323. * The component name helpfull to identify the component in the list of scene components.
  102324. */
  102325. readonly name: string;
  102326. /**
  102327. * The scene the component belongs to.
  102328. */
  102329. scene: Scene;
  102330. private _audioEnabled;
  102331. /**
  102332. * Gets whether audio is enabled or not.
  102333. * Please use related enable/disable method to switch state.
  102334. */
  102335. readonly audioEnabled: boolean;
  102336. private _headphone;
  102337. /**
  102338. * Gets whether audio is outputing to headphone or not.
  102339. * Please use the according Switch methods to change output.
  102340. */
  102341. readonly headphone: boolean;
  102342. private _audioListenerPositionProvider;
  102343. /**
  102344. * Gets the current audio listener position provider
  102345. */
  102346. /**
  102347. * Sets a custom listener position for all sounds in the scene
  102348. * By default, this is the position of the first active camera
  102349. */
  102350. audioListenerPositionProvider: Nullable<() => Vector3>;
  102351. /**
  102352. * Creates a new instance of the component for the given scene
  102353. * @param scene Defines the scene to register the component in
  102354. */
  102355. constructor(scene: Scene);
  102356. /**
  102357. * Registers the component in a given scene
  102358. */
  102359. register(): void;
  102360. /**
  102361. * Rebuilds the elements related to this component in case of
  102362. * context lost for instance.
  102363. */
  102364. rebuild(): void;
  102365. /**
  102366. * Serializes the component data to the specified json object
  102367. * @param serializationObject The object to serialize to
  102368. */
  102369. serialize(serializationObject: any): void;
  102370. /**
  102371. * Adds all the elements from the container to the scene
  102372. * @param container the container holding the elements
  102373. */
  102374. addFromContainer(container: AbstractScene): void;
  102375. /**
  102376. * Removes all the elements in the container from the scene
  102377. * @param container contains the elements to remove
  102378. * @param dispose if the removed element should be disposed (default: false)
  102379. */
  102380. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102381. /**
  102382. * Disposes the component and the associated ressources.
  102383. */
  102384. dispose(): void;
  102385. /**
  102386. * Disables audio in the associated scene.
  102387. */
  102388. disableAudio(): void;
  102389. /**
  102390. * Enables audio in the associated scene.
  102391. */
  102392. enableAudio(): void;
  102393. /**
  102394. * Switch audio to headphone output.
  102395. */
  102396. switchAudioModeForHeadphones(): void;
  102397. /**
  102398. * Switch audio to normal speakers.
  102399. */
  102400. switchAudioModeForNormalSpeakers(): void;
  102401. private _afterRender;
  102402. }
  102403. }
  102404. declare module BABYLON {
  102405. /**
  102406. * Wraps one or more Sound objects and selects one with random weight for playback.
  102407. */
  102408. export class WeightedSound {
  102409. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102410. loop: boolean;
  102411. private _coneInnerAngle;
  102412. private _coneOuterAngle;
  102413. private _volume;
  102414. /** A Sound is currently playing. */
  102415. isPlaying: boolean;
  102416. /** A Sound is currently paused. */
  102417. isPaused: boolean;
  102418. private _sounds;
  102419. private _weights;
  102420. private _currentIndex?;
  102421. /**
  102422. * Creates a new WeightedSound from the list of sounds given.
  102423. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102424. * @param sounds Array of Sounds that will be selected from.
  102425. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102426. */
  102427. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102428. /**
  102429. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102430. */
  102431. /**
  102432. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102433. */
  102434. directionalConeInnerAngle: number;
  102435. /**
  102436. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102437. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102438. */
  102439. /**
  102440. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102441. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102442. */
  102443. directionalConeOuterAngle: number;
  102444. /**
  102445. * Playback volume.
  102446. */
  102447. /**
  102448. * Playback volume.
  102449. */
  102450. volume: number;
  102451. private _onended;
  102452. /**
  102453. * Suspend playback
  102454. */
  102455. pause(): void;
  102456. /**
  102457. * Stop playback
  102458. */
  102459. stop(): void;
  102460. /**
  102461. * Start playback.
  102462. * @param startOffset Position the clip head at a specific time in seconds.
  102463. */
  102464. play(startOffset?: number): void;
  102465. }
  102466. }
  102467. declare module BABYLON {
  102468. /**
  102469. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102470. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102471. */
  102472. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102473. /**
  102474. * Gets the name of the behavior.
  102475. */
  102476. readonly name: string;
  102477. /**
  102478. * The easing function used by animations
  102479. */
  102480. static EasingFunction: BackEase;
  102481. /**
  102482. * The easing mode used by animations
  102483. */
  102484. static EasingMode: number;
  102485. /**
  102486. * The duration of the animation, in milliseconds
  102487. */
  102488. transitionDuration: number;
  102489. /**
  102490. * Length of the distance animated by the transition when lower radius is reached
  102491. */
  102492. lowerRadiusTransitionRange: number;
  102493. /**
  102494. * Length of the distance animated by the transition when upper radius is reached
  102495. */
  102496. upperRadiusTransitionRange: number;
  102497. private _autoTransitionRange;
  102498. /**
  102499. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102500. */
  102501. /**
  102502. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102503. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102504. */
  102505. autoTransitionRange: boolean;
  102506. private _attachedCamera;
  102507. private _onAfterCheckInputsObserver;
  102508. private _onMeshTargetChangedObserver;
  102509. /**
  102510. * Initializes the behavior.
  102511. */
  102512. init(): void;
  102513. /**
  102514. * Attaches the behavior to its arc rotate camera.
  102515. * @param camera Defines the camera to attach the behavior to
  102516. */
  102517. attach(camera: ArcRotateCamera): void;
  102518. /**
  102519. * Detaches the behavior from its current arc rotate camera.
  102520. */
  102521. detach(): void;
  102522. private _radiusIsAnimating;
  102523. private _radiusBounceTransition;
  102524. private _animatables;
  102525. private _cachedWheelPrecision;
  102526. /**
  102527. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102528. * @param radiusLimit The limit to check against.
  102529. * @return Bool to indicate if at limit.
  102530. */
  102531. private _isRadiusAtLimit;
  102532. /**
  102533. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102534. * @param radiusDelta The delta by which to animate to. Can be negative.
  102535. */
  102536. private _applyBoundRadiusAnimation;
  102537. /**
  102538. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102539. */
  102540. protected _clearAnimationLocks(): void;
  102541. /**
  102542. * Stops and removes all animations that have been applied to the camera
  102543. */
  102544. stopAllAnimations(): void;
  102545. }
  102546. }
  102547. declare module BABYLON {
  102548. /**
  102549. * 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.
  102550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102551. */
  102552. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102553. /**
  102554. * Gets the name of the behavior.
  102555. */
  102556. readonly name: string;
  102557. private _mode;
  102558. private _radiusScale;
  102559. private _positionScale;
  102560. private _defaultElevation;
  102561. private _elevationReturnTime;
  102562. private _elevationReturnWaitTime;
  102563. private _zoomStopsAnimation;
  102564. private _framingTime;
  102565. /**
  102566. * The easing function used by animations
  102567. */
  102568. static EasingFunction: ExponentialEase;
  102569. /**
  102570. * The easing mode used by animations
  102571. */
  102572. static EasingMode: number;
  102573. /**
  102574. * Sets the current mode used by the behavior
  102575. */
  102576. /**
  102577. * Gets current mode used by the behavior.
  102578. */
  102579. mode: number;
  102580. /**
  102581. * Sets the scale applied to the radius (1 by default)
  102582. */
  102583. /**
  102584. * Gets the scale applied to the radius
  102585. */
  102586. radiusScale: number;
  102587. /**
  102588. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102589. */
  102590. /**
  102591. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102592. */
  102593. positionScale: number;
  102594. /**
  102595. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102596. * behaviour is triggered, in radians.
  102597. */
  102598. /**
  102599. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102600. * behaviour is triggered, in radians.
  102601. */
  102602. defaultElevation: number;
  102603. /**
  102604. * Sets the time (in milliseconds) taken to return to the default beta position.
  102605. * Negative value indicates camera should not return to default.
  102606. */
  102607. /**
  102608. * Gets the time (in milliseconds) taken to return to the default beta position.
  102609. * Negative value indicates camera should not return to default.
  102610. */
  102611. elevationReturnTime: number;
  102612. /**
  102613. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102614. */
  102615. /**
  102616. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102617. */
  102618. elevationReturnWaitTime: number;
  102619. /**
  102620. * Sets the flag that indicates if user zooming should stop animation.
  102621. */
  102622. /**
  102623. * Gets the flag that indicates if user zooming should stop animation.
  102624. */
  102625. zoomStopsAnimation: boolean;
  102626. /**
  102627. * Sets the transition time when framing the mesh, in milliseconds
  102628. */
  102629. /**
  102630. * Gets the transition time when framing the mesh, in milliseconds
  102631. */
  102632. framingTime: number;
  102633. /**
  102634. * Define if the behavior should automatically change the configured
  102635. * camera limits and sensibilities.
  102636. */
  102637. autoCorrectCameraLimitsAndSensibility: boolean;
  102638. private _onPrePointerObservableObserver;
  102639. private _onAfterCheckInputsObserver;
  102640. private _onMeshTargetChangedObserver;
  102641. private _attachedCamera;
  102642. private _isPointerDown;
  102643. private _lastInteractionTime;
  102644. /**
  102645. * Initializes the behavior.
  102646. */
  102647. init(): void;
  102648. /**
  102649. * Attaches the behavior to its arc rotate camera.
  102650. * @param camera Defines the camera to attach the behavior to
  102651. */
  102652. attach(camera: ArcRotateCamera): void;
  102653. /**
  102654. * Detaches the behavior from its current arc rotate camera.
  102655. */
  102656. detach(): void;
  102657. private _animatables;
  102658. private _betaIsAnimating;
  102659. private _betaTransition;
  102660. private _radiusTransition;
  102661. private _vectorTransition;
  102662. /**
  102663. * Targets the given mesh and updates zoom level accordingly.
  102664. * @param mesh The mesh to target.
  102665. * @param radius Optional. If a cached radius position already exists, overrides default.
  102666. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102667. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102668. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102669. */
  102670. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102671. /**
  102672. * Targets the given mesh with its children and updates zoom level accordingly.
  102673. * @param mesh The mesh to target.
  102674. * @param radius Optional. If a cached radius position already exists, overrides default.
  102675. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102676. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102677. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102678. */
  102679. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102680. /**
  102681. * Targets the given meshes with their children and updates zoom level accordingly.
  102682. * @param meshes The mesh to target.
  102683. * @param radius Optional. If a cached radius position already exists, overrides default.
  102684. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102685. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102686. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102687. */
  102688. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102689. /**
  102690. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102691. * @param minimumWorld Determines the smaller position of the bounding box extend
  102692. * @param maximumWorld Determines the bigger position of the bounding box extend
  102693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102695. */
  102696. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102697. /**
  102698. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102699. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102700. * frustum width.
  102701. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102702. * to fully enclose the mesh in the viewing frustum.
  102703. */
  102704. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102705. /**
  102706. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102707. * is automatically returned to its default position (expected to be above ground plane).
  102708. */
  102709. private _maintainCameraAboveGround;
  102710. /**
  102711. * Returns the frustum slope based on the canvas ratio and camera FOV
  102712. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102713. */
  102714. private _getFrustumSlope;
  102715. /**
  102716. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102717. */
  102718. private _clearAnimationLocks;
  102719. /**
  102720. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102721. */
  102722. private _applyUserInteraction;
  102723. /**
  102724. * Stops and removes all animations that have been applied to the camera
  102725. */
  102726. stopAllAnimations(): void;
  102727. /**
  102728. * Gets a value indicating if the user is moving the camera
  102729. */
  102730. readonly isUserIsMoving: boolean;
  102731. /**
  102732. * The camera can move all the way towards the mesh.
  102733. */
  102734. static IgnoreBoundsSizeMode: number;
  102735. /**
  102736. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102737. */
  102738. static FitFrustumSidesMode: number;
  102739. }
  102740. }
  102741. declare module BABYLON {
  102742. /**
  102743. * Base class for Camera Pointer Inputs.
  102744. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102745. * for example usage.
  102746. */
  102747. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102748. /**
  102749. * Defines the camera the input is attached to.
  102750. */
  102751. abstract camera: Camera;
  102752. /**
  102753. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102754. */
  102755. protected _altKey: boolean;
  102756. protected _ctrlKey: boolean;
  102757. protected _metaKey: boolean;
  102758. protected _shiftKey: boolean;
  102759. /**
  102760. * Which mouse buttons were pressed at time of last mouse event.
  102761. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102762. */
  102763. protected _buttonsPressed: number;
  102764. /**
  102765. * Defines the buttons associated with the input to handle camera move.
  102766. */
  102767. buttons: number[];
  102768. /**
  102769. * Attach the input controls to a specific dom element to get the input from.
  102770. * @param element Defines the element the controls should be listened from
  102771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102772. */
  102773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102774. /**
  102775. * Detach the current controls from the specified dom element.
  102776. * @param element Defines the element to stop listening the inputs from
  102777. */
  102778. detachControl(element: Nullable<HTMLElement>): void;
  102779. /**
  102780. * Gets the class name of the current input.
  102781. * @returns the class name
  102782. */
  102783. getClassName(): string;
  102784. /**
  102785. * Get the friendly name associated with the input class.
  102786. * @returns the input friendly name
  102787. */
  102788. getSimpleName(): string;
  102789. /**
  102790. * Called on pointer POINTERDOUBLETAP event.
  102791. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102792. */
  102793. protected onDoubleTap(type: string): void;
  102794. /**
  102795. * Called on pointer POINTERMOVE event if only a single touch is active.
  102796. * Override this method to provide functionality.
  102797. */
  102798. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102799. /**
  102800. * Called on pointer POINTERMOVE event if multiple touches are active.
  102801. * Override this method to provide functionality.
  102802. */
  102803. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102804. /**
  102805. * Called on JS contextmenu event.
  102806. * Override this method to provide functionality.
  102807. */
  102808. protected onContextMenu(evt: PointerEvent): void;
  102809. /**
  102810. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102811. * press.
  102812. * Override this method to provide functionality.
  102813. */
  102814. protected onButtonDown(evt: PointerEvent): void;
  102815. /**
  102816. * Called each time a new POINTERUP event occurs. Ie, for each button
  102817. * release.
  102818. * Override this method to provide functionality.
  102819. */
  102820. protected onButtonUp(evt: PointerEvent): void;
  102821. /**
  102822. * Called when window becomes inactive.
  102823. * Override this method to provide functionality.
  102824. */
  102825. protected onLostFocus(): void;
  102826. private _pointerInput;
  102827. private _observer;
  102828. private _onLostFocus;
  102829. private pointA;
  102830. private pointB;
  102831. }
  102832. }
  102833. declare module BABYLON {
  102834. /**
  102835. * Manage the pointers inputs to control an arc rotate camera.
  102836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102837. */
  102838. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102839. /**
  102840. * Defines the camera the input is attached to.
  102841. */
  102842. camera: ArcRotateCamera;
  102843. /**
  102844. * Gets the class name of the current input.
  102845. * @returns the class name
  102846. */
  102847. getClassName(): string;
  102848. /**
  102849. * Defines the buttons associated with the input to handle camera move.
  102850. */
  102851. buttons: number[];
  102852. /**
  102853. * Defines the pointer angular sensibility along the X axis or how fast is
  102854. * the camera rotating.
  102855. */
  102856. angularSensibilityX: number;
  102857. /**
  102858. * Defines the pointer angular sensibility along the Y axis or how fast is
  102859. * the camera rotating.
  102860. */
  102861. angularSensibilityY: number;
  102862. /**
  102863. * Defines the pointer pinch precision or how fast is the camera zooming.
  102864. */
  102865. pinchPrecision: number;
  102866. /**
  102867. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102868. * from 0.
  102869. * It defines the percentage of current camera.radius to use as delta when
  102870. * pinch zoom is used.
  102871. */
  102872. pinchDeltaPercentage: number;
  102873. /**
  102874. * Defines the pointer panning sensibility or how fast is the camera moving.
  102875. */
  102876. panningSensibility: number;
  102877. /**
  102878. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102879. */
  102880. multiTouchPanning: boolean;
  102881. /**
  102882. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102883. * zoom (pinch) through multitouch.
  102884. */
  102885. multiTouchPanAndZoom: boolean;
  102886. /**
  102887. * Revers pinch action direction.
  102888. */
  102889. pinchInwards: boolean;
  102890. private _isPanClick;
  102891. private _twoFingerActivityCount;
  102892. private _isPinching;
  102893. /**
  102894. * Called on pointer POINTERMOVE event if only a single touch is active.
  102895. */
  102896. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102897. /**
  102898. * Called on pointer POINTERDOUBLETAP event.
  102899. */
  102900. protected onDoubleTap(type: string): void;
  102901. /**
  102902. * Called on pointer POINTERMOVE event if multiple touches are active.
  102903. */
  102904. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102905. /**
  102906. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102907. * press.
  102908. */
  102909. protected onButtonDown(evt: PointerEvent): void;
  102910. /**
  102911. * Called each time a new POINTERUP event occurs. Ie, for each button
  102912. * release.
  102913. */
  102914. protected onButtonUp(evt: PointerEvent): void;
  102915. /**
  102916. * Called when window becomes inactive.
  102917. */
  102918. protected onLostFocus(): void;
  102919. }
  102920. }
  102921. declare module BABYLON {
  102922. /**
  102923. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102924. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102925. */
  102926. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102927. /**
  102928. * Defines the camera the input is attached to.
  102929. */
  102930. camera: ArcRotateCamera;
  102931. /**
  102932. * Defines the list of key codes associated with the up action (increase alpha)
  102933. */
  102934. keysUp: number[];
  102935. /**
  102936. * Defines the list of key codes associated with the down action (decrease alpha)
  102937. */
  102938. keysDown: number[];
  102939. /**
  102940. * Defines the list of key codes associated with the left action (increase beta)
  102941. */
  102942. keysLeft: number[];
  102943. /**
  102944. * Defines the list of key codes associated with the right action (decrease beta)
  102945. */
  102946. keysRight: number[];
  102947. /**
  102948. * Defines the list of key codes associated with the reset action.
  102949. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102950. */
  102951. keysReset: number[];
  102952. /**
  102953. * Defines the panning sensibility of the inputs.
  102954. * (How fast is the camera paning)
  102955. */
  102956. panningSensibility: number;
  102957. /**
  102958. * Defines the zooming sensibility of the inputs.
  102959. * (How fast is the camera zooming)
  102960. */
  102961. zoomingSensibility: number;
  102962. /**
  102963. * Defines wether maintaining the alt key down switch the movement mode from
  102964. * orientation to zoom.
  102965. */
  102966. useAltToZoom: boolean;
  102967. /**
  102968. * Rotation speed of the camera
  102969. */
  102970. angularSpeed: number;
  102971. private _keys;
  102972. private _ctrlPressed;
  102973. private _altPressed;
  102974. private _onCanvasBlurObserver;
  102975. private _onKeyboardObserver;
  102976. private _engine;
  102977. private _scene;
  102978. /**
  102979. * Attach the input controls to a specific dom element to get the input from.
  102980. * @param element Defines the element the controls should be listened from
  102981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102982. */
  102983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102984. /**
  102985. * Detach the current controls from the specified dom element.
  102986. * @param element Defines the element to stop listening the inputs from
  102987. */
  102988. detachControl(element: Nullable<HTMLElement>): void;
  102989. /**
  102990. * Update the current camera state depending on the inputs that have been used this frame.
  102991. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102992. */
  102993. checkInputs(): void;
  102994. /**
  102995. * Gets the class name of the current intput.
  102996. * @returns the class name
  102997. */
  102998. getClassName(): string;
  102999. /**
  103000. * Get the friendly name associated with the input class.
  103001. * @returns the input friendly name
  103002. */
  103003. getSimpleName(): string;
  103004. }
  103005. }
  103006. declare module BABYLON {
  103007. /**
  103008. * Manage the mouse wheel inputs to control an arc rotate camera.
  103009. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103010. */
  103011. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103012. /**
  103013. * Defines the camera the input is attached to.
  103014. */
  103015. camera: ArcRotateCamera;
  103016. /**
  103017. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103018. */
  103019. wheelPrecision: number;
  103020. /**
  103021. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103022. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103023. */
  103024. wheelDeltaPercentage: number;
  103025. private _wheel;
  103026. private _observer;
  103027. private computeDeltaFromMouseWheelLegacyEvent;
  103028. /**
  103029. * Attach the input controls to a specific dom element to get the input from.
  103030. * @param element Defines the element the controls should be listened from
  103031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103032. */
  103033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103034. /**
  103035. * Detach the current controls from the specified dom element.
  103036. * @param element Defines the element to stop listening the inputs from
  103037. */
  103038. detachControl(element: Nullable<HTMLElement>): void;
  103039. /**
  103040. * Gets the class name of the current intput.
  103041. * @returns the class name
  103042. */
  103043. getClassName(): string;
  103044. /**
  103045. * Get the friendly name associated with the input class.
  103046. * @returns the input friendly name
  103047. */
  103048. getSimpleName(): string;
  103049. }
  103050. }
  103051. declare module BABYLON {
  103052. /**
  103053. * Default Inputs manager for the ArcRotateCamera.
  103054. * It groups all the default supported inputs for ease of use.
  103055. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103056. */
  103057. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103058. /**
  103059. * Instantiates a new ArcRotateCameraInputsManager.
  103060. * @param camera Defines the camera the inputs belong to
  103061. */
  103062. constructor(camera: ArcRotateCamera);
  103063. /**
  103064. * Add mouse wheel input support to the input manager.
  103065. * @returns the current input manager
  103066. */
  103067. addMouseWheel(): ArcRotateCameraInputsManager;
  103068. /**
  103069. * Add pointers input support to the input manager.
  103070. * @returns the current input manager
  103071. */
  103072. addPointers(): ArcRotateCameraInputsManager;
  103073. /**
  103074. * Add keyboard input support to the input manager.
  103075. * @returns the current input manager
  103076. */
  103077. addKeyboard(): ArcRotateCameraInputsManager;
  103078. }
  103079. }
  103080. declare module BABYLON {
  103081. /**
  103082. * This represents an orbital type of camera.
  103083. *
  103084. * 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.
  103085. * 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.
  103086. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103087. */
  103088. export class ArcRotateCamera extends TargetCamera {
  103089. /**
  103090. * Defines the rotation angle of the camera along the longitudinal axis.
  103091. */
  103092. alpha: number;
  103093. /**
  103094. * Defines the rotation angle of the camera along the latitudinal axis.
  103095. */
  103096. beta: number;
  103097. /**
  103098. * Defines the radius of the camera from it s target point.
  103099. */
  103100. radius: number;
  103101. protected _target: Vector3;
  103102. protected _targetHost: Nullable<AbstractMesh>;
  103103. /**
  103104. * Defines the target point of the camera.
  103105. * The camera looks towards it form the radius distance.
  103106. */
  103107. target: Vector3;
  103108. /**
  103109. * Define the current local position of the camera in the scene
  103110. */
  103111. position: Vector3;
  103112. protected _upVector: Vector3;
  103113. protected _upToYMatrix: Matrix;
  103114. protected _YToUpMatrix: Matrix;
  103115. /**
  103116. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103117. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103118. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103119. */
  103120. upVector: Vector3;
  103121. /**
  103122. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103123. */
  103124. setMatUp(): void;
  103125. /**
  103126. * Current inertia value on the longitudinal axis.
  103127. * The bigger this number the longer it will take for the camera to stop.
  103128. */
  103129. inertialAlphaOffset: number;
  103130. /**
  103131. * Current inertia value on the latitudinal axis.
  103132. * The bigger this number the longer it will take for the camera to stop.
  103133. */
  103134. inertialBetaOffset: number;
  103135. /**
  103136. * Current inertia value on the radius axis.
  103137. * The bigger this number the longer it will take for the camera to stop.
  103138. */
  103139. inertialRadiusOffset: number;
  103140. /**
  103141. * Minimum allowed angle on the longitudinal axis.
  103142. * This can help limiting how the Camera is able to move in the scene.
  103143. */
  103144. lowerAlphaLimit: Nullable<number>;
  103145. /**
  103146. * Maximum allowed angle on the longitudinal axis.
  103147. * This can help limiting how the Camera is able to move in the scene.
  103148. */
  103149. upperAlphaLimit: Nullable<number>;
  103150. /**
  103151. * Minimum allowed angle on the latitudinal axis.
  103152. * This can help limiting how the Camera is able to move in the scene.
  103153. */
  103154. lowerBetaLimit: number;
  103155. /**
  103156. * Maximum allowed angle on the latitudinal axis.
  103157. * This can help limiting how the Camera is able to move in the scene.
  103158. */
  103159. upperBetaLimit: number;
  103160. /**
  103161. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103162. * This can help limiting how the Camera is able to move in the scene.
  103163. */
  103164. lowerRadiusLimit: Nullable<number>;
  103165. /**
  103166. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103167. * This can help limiting how the Camera is able to move in the scene.
  103168. */
  103169. upperRadiusLimit: Nullable<number>;
  103170. /**
  103171. * Defines the current inertia value used during panning of the camera along the X axis.
  103172. */
  103173. inertialPanningX: number;
  103174. /**
  103175. * Defines the current inertia value used during panning of the camera along the Y axis.
  103176. */
  103177. inertialPanningY: number;
  103178. /**
  103179. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103180. * Basically if your fingers moves away from more than this distance you will be considered
  103181. * in pinch mode.
  103182. */
  103183. pinchToPanMaxDistance: number;
  103184. /**
  103185. * Defines the maximum distance the camera can pan.
  103186. * This could help keeping the cammera always in your scene.
  103187. */
  103188. panningDistanceLimit: Nullable<number>;
  103189. /**
  103190. * Defines the target of the camera before paning.
  103191. */
  103192. panningOriginTarget: Vector3;
  103193. /**
  103194. * Defines the value of the inertia used during panning.
  103195. * 0 would mean stop inertia and one would mean no decelleration at all.
  103196. */
  103197. panningInertia: number;
  103198. /**
  103199. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103200. */
  103201. angularSensibilityX: number;
  103202. /**
  103203. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103204. */
  103205. angularSensibilityY: number;
  103206. /**
  103207. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103208. */
  103209. pinchPrecision: number;
  103210. /**
  103211. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103212. * It will be used instead of pinchDeltaPrecision if different from 0.
  103213. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103214. */
  103215. pinchDeltaPercentage: number;
  103216. /**
  103217. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103218. */
  103219. panningSensibility: number;
  103220. /**
  103221. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103222. */
  103223. keysUp: number[];
  103224. /**
  103225. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103226. */
  103227. keysDown: number[];
  103228. /**
  103229. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103230. */
  103231. keysLeft: number[];
  103232. /**
  103233. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103234. */
  103235. keysRight: number[];
  103236. /**
  103237. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103238. */
  103239. wheelPrecision: number;
  103240. /**
  103241. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103242. * It will be used instead of pinchDeltaPrecision if different from 0.
  103243. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103244. */
  103245. wheelDeltaPercentage: number;
  103246. /**
  103247. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103248. */
  103249. zoomOnFactor: number;
  103250. /**
  103251. * Defines a screen offset for the camera position.
  103252. */
  103253. targetScreenOffset: Vector2;
  103254. /**
  103255. * Allows the camera to be completely reversed.
  103256. * If false the camera can not arrive upside down.
  103257. */
  103258. allowUpsideDown: boolean;
  103259. /**
  103260. * Define if double tap/click is used to restore the previously saved state of the camera.
  103261. */
  103262. useInputToRestoreState: boolean;
  103263. /** @hidden */
  103264. _viewMatrix: Matrix;
  103265. /** @hidden */
  103266. _useCtrlForPanning: boolean;
  103267. /** @hidden */
  103268. _panningMouseButton: number;
  103269. /**
  103270. * Defines the input associated to the camera.
  103271. */
  103272. inputs: ArcRotateCameraInputsManager;
  103273. /** @hidden */
  103274. _reset: () => void;
  103275. /**
  103276. * Defines the allowed panning axis.
  103277. */
  103278. panningAxis: Vector3;
  103279. protected _localDirection: Vector3;
  103280. protected _transformedDirection: Vector3;
  103281. private _bouncingBehavior;
  103282. /**
  103283. * Gets the bouncing behavior of the camera if it has been enabled.
  103284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103285. */
  103286. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103287. /**
  103288. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103289. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103290. */
  103291. useBouncingBehavior: boolean;
  103292. private _framingBehavior;
  103293. /**
  103294. * Gets the framing behavior of the camera if it has been enabled.
  103295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103296. */
  103297. readonly framingBehavior: Nullable<FramingBehavior>;
  103298. /**
  103299. * Defines if the framing behavior of the camera is enabled on the camera.
  103300. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103301. */
  103302. useFramingBehavior: boolean;
  103303. private _autoRotationBehavior;
  103304. /**
  103305. * Gets the auto rotation behavior of the camera if it has been enabled.
  103306. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103307. */
  103308. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103309. /**
  103310. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103311. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103312. */
  103313. useAutoRotationBehavior: boolean;
  103314. /**
  103315. * Observable triggered when the mesh target has been changed on the camera.
  103316. */
  103317. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103318. /**
  103319. * Event raised when the camera is colliding with a mesh.
  103320. */
  103321. onCollide: (collidedMesh: AbstractMesh) => void;
  103322. /**
  103323. * Defines whether the camera should check collision with the objects oh the scene.
  103324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103325. */
  103326. checkCollisions: boolean;
  103327. /**
  103328. * Defines the collision radius of the camera.
  103329. * This simulates a sphere around the camera.
  103330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103331. */
  103332. collisionRadius: Vector3;
  103333. protected _collider: Collider;
  103334. protected _previousPosition: Vector3;
  103335. protected _collisionVelocity: Vector3;
  103336. protected _newPosition: Vector3;
  103337. protected _previousAlpha: number;
  103338. protected _previousBeta: number;
  103339. protected _previousRadius: number;
  103340. protected _collisionTriggered: boolean;
  103341. protected _targetBoundingCenter: Nullable<Vector3>;
  103342. private _computationVector;
  103343. /**
  103344. * Instantiates a new ArcRotateCamera in a given scene
  103345. * @param name Defines the name of the camera
  103346. * @param alpha Defines the camera rotation along the logitudinal axis
  103347. * @param beta Defines the camera rotation along the latitudinal axis
  103348. * @param radius Defines the camera distance from its target
  103349. * @param target Defines the camera target
  103350. * @param scene Defines the scene the camera belongs to
  103351. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103352. */
  103353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103354. /** @hidden */
  103355. _initCache(): void;
  103356. /** @hidden */
  103357. _updateCache(ignoreParentClass?: boolean): void;
  103358. protected _getTargetPosition(): Vector3;
  103359. private _storedAlpha;
  103360. private _storedBeta;
  103361. private _storedRadius;
  103362. private _storedTarget;
  103363. private _storedTargetScreenOffset;
  103364. /**
  103365. * Stores the current state of the camera (alpha, beta, radius and target)
  103366. * @returns the camera itself
  103367. */
  103368. storeState(): Camera;
  103369. /**
  103370. * @hidden
  103371. * Restored camera state. You must call storeState() first
  103372. */
  103373. _restoreStateValues(): boolean;
  103374. /** @hidden */
  103375. _isSynchronizedViewMatrix(): boolean;
  103376. /**
  103377. * Attached controls to the current camera.
  103378. * @param element Defines the element the controls should be listened from
  103379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103380. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103381. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103382. */
  103383. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103384. /**
  103385. * Detach the current controls from the camera.
  103386. * The camera will stop reacting to inputs.
  103387. * @param element Defines the element to stop listening the inputs from
  103388. */
  103389. detachControl(element: HTMLElement): void;
  103390. /** @hidden */
  103391. _checkInputs(): void;
  103392. protected _checkLimits(): void;
  103393. /**
  103394. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103395. */
  103396. rebuildAnglesAndRadius(): void;
  103397. /**
  103398. * Use a position to define the current camera related information like alpha, beta and radius
  103399. * @param position Defines the position to set the camera at
  103400. */
  103401. setPosition(position: Vector3): void;
  103402. /**
  103403. * Defines the target the camera should look at.
  103404. * This will automatically adapt alpha beta and radius to fit within the new target.
  103405. * @param target Defines the new target as a Vector or a mesh
  103406. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103407. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103408. */
  103409. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103410. /** @hidden */
  103411. _getViewMatrix(): Matrix;
  103412. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103413. /**
  103414. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103415. * @param meshes Defines the mesh to zoom on
  103416. * @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)
  103417. */
  103418. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103419. /**
  103420. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103421. * The target will be changed but the radius
  103422. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103423. * @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)
  103424. */
  103425. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103426. min: Vector3;
  103427. max: Vector3;
  103428. distance: number;
  103429. }, doNotUpdateMaxZ?: boolean): void;
  103430. /**
  103431. * @override
  103432. * Override Camera.createRigCamera
  103433. */
  103434. createRigCamera(name: string, cameraIndex: number): Camera;
  103435. /**
  103436. * @hidden
  103437. * @override
  103438. * Override Camera._updateRigCameras
  103439. */
  103440. _updateRigCameras(): void;
  103441. /**
  103442. * Destroy the camera and release the current resources hold by it.
  103443. */
  103444. dispose(): void;
  103445. /**
  103446. * Gets the current object class name.
  103447. * @return the class name
  103448. */
  103449. getClassName(): string;
  103450. }
  103451. }
  103452. declare module BABYLON {
  103453. /**
  103454. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103455. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103456. */
  103457. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103458. /**
  103459. * Gets the name of the behavior.
  103460. */
  103461. readonly name: string;
  103462. private _zoomStopsAnimation;
  103463. private _idleRotationSpeed;
  103464. private _idleRotationWaitTime;
  103465. private _idleRotationSpinupTime;
  103466. /**
  103467. * Sets the flag that indicates if user zooming should stop animation.
  103468. */
  103469. /**
  103470. * Gets the flag that indicates if user zooming should stop animation.
  103471. */
  103472. zoomStopsAnimation: boolean;
  103473. /**
  103474. * Sets the default speed at which the camera rotates around the model.
  103475. */
  103476. /**
  103477. * Gets the default speed at which the camera rotates around the model.
  103478. */
  103479. idleRotationSpeed: number;
  103480. /**
  103481. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103482. */
  103483. /**
  103484. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103485. */
  103486. idleRotationWaitTime: number;
  103487. /**
  103488. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103489. */
  103490. /**
  103491. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103492. */
  103493. idleRotationSpinupTime: number;
  103494. /**
  103495. * Gets a value indicating if the camera is currently rotating because of this behavior
  103496. */
  103497. readonly rotationInProgress: boolean;
  103498. private _onPrePointerObservableObserver;
  103499. private _onAfterCheckInputsObserver;
  103500. private _attachedCamera;
  103501. private _isPointerDown;
  103502. private _lastFrameTime;
  103503. private _lastInteractionTime;
  103504. private _cameraRotationSpeed;
  103505. /**
  103506. * Initializes the behavior.
  103507. */
  103508. init(): void;
  103509. /**
  103510. * Attaches the behavior to its arc rotate camera.
  103511. * @param camera Defines the camera to attach the behavior to
  103512. */
  103513. attach(camera: ArcRotateCamera): void;
  103514. /**
  103515. * Detaches the behavior from its current arc rotate camera.
  103516. */
  103517. detach(): void;
  103518. /**
  103519. * Returns true if user is scrolling.
  103520. * @return true if user is scrolling.
  103521. */
  103522. private _userIsZooming;
  103523. private _lastFrameRadius;
  103524. private _shouldAnimationStopForInteraction;
  103525. /**
  103526. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103527. */
  103528. private _applyUserInteraction;
  103529. private _userIsMoving;
  103530. }
  103531. }
  103532. declare module BABYLON {
  103533. /**
  103534. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103535. */
  103536. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103537. private ui;
  103538. /**
  103539. * The name of the behavior
  103540. */
  103541. name: string;
  103542. /**
  103543. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103544. */
  103545. distanceAwayFromFace: number;
  103546. /**
  103547. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103548. */
  103549. distanceAwayFromBottomOfFace: number;
  103550. private _faceVectors;
  103551. private _target;
  103552. private _scene;
  103553. private _onRenderObserver;
  103554. private _tmpMatrix;
  103555. private _tmpVector;
  103556. /**
  103557. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103558. * @param ui The transform node that should be attched to the mesh
  103559. */
  103560. constructor(ui: TransformNode);
  103561. /**
  103562. * Initializes the behavior
  103563. */
  103564. init(): void;
  103565. private _closestFace;
  103566. private _zeroVector;
  103567. private _lookAtTmpMatrix;
  103568. private _lookAtToRef;
  103569. /**
  103570. * Attaches the AttachToBoxBehavior to the passed in mesh
  103571. * @param target The mesh that the specified node will be attached to
  103572. */
  103573. attach(target: Mesh): void;
  103574. /**
  103575. * Detaches the behavior from the mesh
  103576. */
  103577. detach(): void;
  103578. }
  103579. }
  103580. declare module BABYLON {
  103581. /**
  103582. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103583. */
  103584. export class FadeInOutBehavior implements Behavior<Mesh> {
  103585. /**
  103586. * Time in milliseconds to delay before fading in (Default: 0)
  103587. */
  103588. delay: number;
  103589. /**
  103590. * Time in milliseconds for the mesh to fade in (Default: 300)
  103591. */
  103592. fadeInTime: number;
  103593. private _millisecondsPerFrame;
  103594. private _hovered;
  103595. private _hoverValue;
  103596. private _ownerNode;
  103597. /**
  103598. * Instatiates the FadeInOutBehavior
  103599. */
  103600. constructor();
  103601. /**
  103602. * The name of the behavior
  103603. */
  103604. readonly name: string;
  103605. /**
  103606. * Initializes the behavior
  103607. */
  103608. init(): void;
  103609. /**
  103610. * Attaches the fade behavior on the passed in mesh
  103611. * @param ownerNode The mesh that will be faded in/out once attached
  103612. */
  103613. attach(ownerNode: Mesh): void;
  103614. /**
  103615. * Detaches the behavior from the mesh
  103616. */
  103617. detach(): void;
  103618. /**
  103619. * Triggers the mesh to begin fading in or out
  103620. * @param value if the object should fade in or out (true to fade in)
  103621. */
  103622. fadeIn(value: boolean): void;
  103623. private _update;
  103624. private _setAllVisibility;
  103625. }
  103626. }
  103627. declare module BABYLON {
  103628. /**
  103629. * Class containing a set of static utilities functions for managing Pivots
  103630. * @hidden
  103631. */
  103632. export class PivotTools {
  103633. private static _PivotCached;
  103634. private static _OldPivotPoint;
  103635. private static _PivotTranslation;
  103636. private static _PivotTmpVector;
  103637. /** @hidden */
  103638. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103639. /** @hidden */
  103640. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103641. }
  103642. }
  103643. declare module BABYLON {
  103644. /**
  103645. * Class containing static functions to help procedurally build meshes
  103646. */
  103647. export class PlaneBuilder {
  103648. /**
  103649. * Creates a plane mesh
  103650. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103651. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103652. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103656. * @param name defines the name of the mesh
  103657. * @param options defines the options used to create the mesh
  103658. * @param scene defines the hosting scene
  103659. * @returns the plane mesh
  103660. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103661. */
  103662. static CreatePlane(name: string, options: {
  103663. size?: number;
  103664. width?: number;
  103665. height?: number;
  103666. sideOrientation?: number;
  103667. frontUVs?: Vector4;
  103668. backUVs?: Vector4;
  103669. updatable?: boolean;
  103670. sourcePlane?: Plane;
  103671. }, scene?: Nullable<Scene>): Mesh;
  103672. }
  103673. }
  103674. declare module BABYLON {
  103675. /**
  103676. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103677. */
  103678. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103679. private static _AnyMouseID;
  103680. /**
  103681. * Abstract mesh the behavior is set on
  103682. */
  103683. attachedNode: AbstractMesh;
  103684. private _dragPlane;
  103685. private _scene;
  103686. private _pointerObserver;
  103687. private _beforeRenderObserver;
  103688. private static _planeScene;
  103689. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103690. /**
  103691. * 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)
  103692. */
  103693. maxDragAngle: number;
  103694. /**
  103695. * @hidden
  103696. */
  103697. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103698. /**
  103699. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103700. */
  103701. currentDraggingPointerID: number;
  103702. /**
  103703. * The last position where the pointer hit the drag plane in world space
  103704. */
  103705. lastDragPosition: Vector3;
  103706. /**
  103707. * If the behavior is currently in a dragging state
  103708. */
  103709. dragging: boolean;
  103710. /**
  103711. * 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)
  103712. */
  103713. dragDeltaRatio: number;
  103714. /**
  103715. * If the drag plane orientation should be updated during the dragging (Default: true)
  103716. */
  103717. updateDragPlane: boolean;
  103718. private _debugMode;
  103719. private _moving;
  103720. /**
  103721. * Fires each time the attached mesh is dragged with the pointer
  103722. * * delta between last drag position and current drag position in world space
  103723. * * dragDistance along the drag axis
  103724. * * dragPlaneNormal normal of the current drag plane used during the drag
  103725. * * dragPlanePoint in world space where the drag intersects the drag plane
  103726. */
  103727. onDragObservable: Observable<{
  103728. delta: Vector3;
  103729. dragPlanePoint: Vector3;
  103730. dragPlaneNormal: Vector3;
  103731. dragDistance: number;
  103732. pointerId: number;
  103733. }>;
  103734. /**
  103735. * Fires each time a drag begins (eg. mouse down on mesh)
  103736. */
  103737. onDragStartObservable: Observable<{
  103738. dragPlanePoint: Vector3;
  103739. pointerId: number;
  103740. }>;
  103741. /**
  103742. * Fires each time a drag ends (eg. mouse release after drag)
  103743. */
  103744. onDragEndObservable: Observable<{
  103745. dragPlanePoint: Vector3;
  103746. pointerId: number;
  103747. }>;
  103748. /**
  103749. * If the attached mesh should be moved when dragged
  103750. */
  103751. moveAttached: boolean;
  103752. /**
  103753. * If the drag behavior will react to drag events (Default: true)
  103754. */
  103755. enabled: boolean;
  103756. /**
  103757. * If pointer events should start and release the drag (Default: true)
  103758. */
  103759. startAndReleaseDragOnPointerEvents: boolean;
  103760. /**
  103761. * If camera controls should be detached during the drag
  103762. */
  103763. detachCameraControls: boolean;
  103764. /**
  103765. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103766. */
  103767. useObjectOrienationForDragging: boolean;
  103768. private _options;
  103769. /**
  103770. * Creates a pointer drag behavior that can be attached to a mesh
  103771. * @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)
  103772. */
  103773. constructor(options?: {
  103774. dragAxis?: Vector3;
  103775. dragPlaneNormal?: Vector3;
  103776. });
  103777. /**
  103778. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103779. */
  103780. validateDrag: (targetPosition: Vector3) => boolean;
  103781. /**
  103782. * The name of the behavior
  103783. */
  103784. readonly name: string;
  103785. /**
  103786. * Initializes the behavior
  103787. */
  103788. init(): void;
  103789. private _tmpVector;
  103790. private _alternatePickedPoint;
  103791. private _worldDragAxis;
  103792. private _targetPosition;
  103793. private _attachedElement;
  103794. /**
  103795. * Attaches the drag behavior the passed in mesh
  103796. * @param ownerNode The mesh that will be dragged around once attached
  103797. * @param predicate Predicate to use for pick filtering
  103798. */
  103799. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103800. /**
  103801. * Force relase the drag action by code.
  103802. */
  103803. releaseDrag(): void;
  103804. private _startDragRay;
  103805. private _lastPointerRay;
  103806. /**
  103807. * Simulates the start of a pointer drag event on the behavior
  103808. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103809. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103810. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103811. */
  103812. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103813. private _startDrag;
  103814. private _dragDelta;
  103815. private _moveDrag;
  103816. private _pickWithRayOnDragPlane;
  103817. private _pointA;
  103818. private _pointB;
  103819. private _pointC;
  103820. private _lineA;
  103821. private _lineB;
  103822. private _localAxis;
  103823. private _lookAt;
  103824. private _updateDragPlanePosition;
  103825. /**
  103826. * Detaches the behavior from the mesh
  103827. */
  103828. detach(): void;
  103829. }
  103830. }
  103831. declare module BABYLON {
  103832. /**
  103833. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103834. */
  103835. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103836. private _dragBehaviorA;
  103837. private _dragBehaviorB;
  103838. private _startDistance;
  103839. private _initialScale;
  103840. private _targetScale;
  103841. private _ownerNode;
  103842. private _sceneRenderObserver;
  103843. /**
  103844. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103845. */
  103846. constructor();
  103847. /**
  103848. * The name of the behavior
  103849. */
  103850. readonly name: string;
  103851. /**
  103852. * Initializes the behavior
  103853. */
  103854. init(): void;
  103855. private _getCurrentDistance;
  103856. /**
  103857. * Attaches the scale behavior the passed in mesh
  103858. * @param ownerNode The mesh that will be scaled around once attached
  103859. */
  103860. attach(ownerNode: Mesh): void;
  103861. /**
  103862. * Detaches the behavior from the mesh
  103863. */
  103864. detach(): void;
  103865. }
  103866. }
  103867. declare module BABYLON {
  103868. /**
  103869. * 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
  103870. */
  103871. export class SixDofDragBehavior implements Behavior<Mesh> {
  103872. private static _virtualScene;
  103873. private _ownerNode;
  103874. private _sceneRenderObserver;
  103875. private _scene;
  103876. private _targetPosition;
  103877. private _virtualOriginMesh;
  103878. private _virtualDragMesh;
  103879. private _pointerObserver;
  103880. private _moving;
  103881. private _startingOrientation;
  103882. /**
  103883. * 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)
  103884. */
  103885. private zDragFactor;
  103886. /**
  103887. * If the object should rotate to face the drag origin
  103888. */
  103889. rotateDraggedObject: boolean;
  103890. /**
  103891. * If the behavior is currently in a dragging state
  103892. */
  103893. dragging: boolean;
  103894. /**
  103895. * 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)
  103896. */
  103897. dragDeltaRatio: number;
  103898. /**
  103899. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103900. */
  103901. currentDraggingPointerID: number;
  103902. /**
  103903. * If camera controls should be detached during the drag
  103904. */
  103905. detachCameraControls: boolean;
  103906. /**
  103907. * Fires each time a drag starts
  103908. */
  103909. onDragStartObservable: Observable<{}>;
  103910. /**
  103911. * Fires each time a drag ends (eg. mouse release after drag)
  103912. */
  103913. onDragEndObservable: Observable<{}>;
  103914. /**
  103915. * 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
  103916. */
  103917. constructor();
  103918. /**
  103919. * The name of the behavior
  103920. */
  103921. readonly name: string;
  103922. /**
  103923. * Initializes the behavior
  103924. */
  103925. init(): void;
  103926. /**
  103927. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103928. */
  103929. private readonly _pointerCamera;
  103930. /**
  103931. * Attaches the scale behavior the passed in mesh
  103932. * @param ownerNode The mesh that will be scaled around once attached
  103933. */
  103934. attach(ownerNode: Mesh): void;
  103935. /**
  103936. * Detaches the behavior from the mesh
  103937. */
  103938. detach(): void;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. /**
  103943. * Class used to apply inverse kinematics to bones
  103944. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103945. */
  103946. export class BoneIKController {
  103947. private static _tmpVecs;
  103948. private static _tmpQuat;
  103949. private static _tmpMats;
  103950. /**
  103951. * Gets or sets the target mesh
  103952. */
  103953. targetMesh: AbstractMesh;
  103954. /** Gets or sets the mesh used as pole */
  103955. poleTargetMesh: AbstractMesh;
  103956. /**
  103957. * Gets or sets the bone used as pole
  103958. */
  103959. poleTargetBone: Nullable<Bone>;
  103960. /**
  103961. * Gets or sets the target position
  103962. */
  103963. targetPosition: Vector3;
  103964. /**
  103965. * Gets or sets the pole target position
  103966. */
  103967. poleTargetPosition: Vector3;
  103968. /**
  103969. * Gets or sets the pole target local offset
  103970. */
  103971. poleTargetLocalOffset: Vector3;
  103972. /**
  103973. * Gets or sets the pole angle
  103974. */
  103975. poleAngle: number;
  103976. /**
  103977. * Gets or sets the mesh associated with the controller
  103978. */
  103979. mesh: AbstractMesh;
  103980. /**
  103981. * 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)
  103982. */
  103983. slerpAmount: number;
  103984. private _bone1Quat;
  103985. private _bone1Mat;
  103986. private _bone2Ang;
  103987. private _bone1;
  103988. private _bone2;
  103989. private _bone1Length;
  103990. private _bone2Length;
  103991. private _maxAngle;
  103992. private _maxReach;
  103993. private _rightHandedSystem;
  103994. private _bendAxis;
  103995. private _slerping;
  103996. private _adjustRoll;
  103997. /**
  103998. * Gets or sets maximum allowed angle
  103999. */
  104000. maxAngle: number;
  104001. /**
  104002. * Creates a new BoneIKController
  104003. * @param mesh defines the mesh to control
  104004. * @param bone defines the bone to control
  104005. * @param options defines options to set up the controller
  104006. */
  104007. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104008. targetMesh?: AbstractMesh;
  104009. poleTargetMesh?: AbstractMesh;
  104010. poleTargetBone?: Bone;
  104011. poleTargetLocalOffset?: Vector3;
  104012. poleAngle?: number;
  104013. bendAxis?: Vector3;
  104014. maxAngle?: number;
  104015. slerpAmount?: number;
  104016. });
  104017. private _setMaxAngle;
  104018. /**
  104019. * Force the controller to update the bones
  104020. */
  104021. update(): void;
  104022. }
  104023. }
  104024. declare module BABYLON {
  104025. /**
  104026. * Class used to make a bone look toward a point in space
  104027. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104028. */
  104029. export class BoneLookController {
  104030. private static _tmpVecs;
  104031. private static _tmpQuat;
  104032. private static _tmpMats;
  104033. /**
  104034. * The target Vector3 that the bone will look at
  104035. */
  104036. target: Vector3;
  104037. /**
  104038. * The mesh that the bone is attached to
  104039. */
  104040. mesh: AbstractMesh;
  104041. /**
  104042. * The bone that will be looking to the target
  104043. */
  104044. bone: Bone;
  104045. /**
  104046. * The up axis of the coordinate system that is used when the bone is rotated
  104047. */
  104048. upAxis: Vector3;
  104049. /**
  104050. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104051. */
  104052. upAxisSpace: Space;
  104053. /**
  104054. * Used to make an adjustment to the yaw of the bone
  104055. */
  104056. adjustYaw: number;
  104057. /**
  104058. * Used to make an adjustment to the pitch of the bone
  104059. */
  104060. adjustPitch: number;
  104061. /**
  104062. * Used to make an adjustment to the roll of the bone
  104063. */
  104064. adjustRoll: number;
  104065. /**
  104066. * 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)
  104067. */
  104068. slerpAmount: number;
  104069. private _minYaw;
  104070. private _maxYaw;
  104071. private _minPitch;
  104072. private _maxPitch;
  104073. private _minYawSin;
  104074. private _minYawCos;
  104075. private _maxYawSin;
  104076. private _maxYawCos;
  104077. private _midYawConstraint;
  104078. private _minPitchTan;
  104079. private _maxPitchTan;
  104080. private _boneQuat;
  104081. private _slerping;
  104082. private _transformYawPitch;
  104083. private _transformYawPitchInv;
  104084. private _firstFrameSkipped;
  104085. private _yawRange;
  104086. private _fowardAxis;
  104087. /**
  104088. * Gets or sets the minimum yaw angle that the bone can look to
  104089. */
  104090. minYaw: number;
  104091. /**
  104092. * Gets or sets the maximum yaw angle that the bone can look to
  104093. */
  104094. maxYaw: number;
  104095. /**
  104096. * Gets or sets the minimum pitch angle that the bone can look to
  104097. */
  104098. minPitch: number;
  104099. /**
  104100. * Gets or sets the maximum pitch angle that the bone can look to
  104101. */
  104102. maxPitch: number;
  104103. /**
  104104. * Create a BoneLookController
  104105. * @param mesh the mesh that the bone belongs to
  104106. * @param bone the bone that will be looking to the target
  104107. * @param target the target Vector3 to look at
  104108. * @param options optional settings:
  104109. * * maxYaw: the maximum angle the bone will yaw to
  104110. * * minYaw: the minimum angle the bone will yaw to
  104111. * * maxPitch: the maximum angle the bone will pitch to
  104112. * * minPitch: the minimum angle the bone will yaw to
  104113. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104114. * * upAxis: the up axis of the coordinate system
  104115. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104116. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104117. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104118. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104119. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104120. * * adjustRoll: used to make an adjustment to the roll of the bone
  104121. **/
  104122. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104123. maxYaw?: number;
  104124. minYaw?: number;
  104125. maxPitch?: number;
  104126. minPitch?: number;
  104127. slerpAmount?: number;
  104128. upAxis?: Vector3;
  104129. upAxisSpace?: Space;
  104130. yawAxis?: Vector3;
  104131. pitchAxis?: Vector3;
  104132. adjustYaw?: number;
  104133. adjustPitch?: number;
  104134. adjustRoll?: number;
  104135. });
  104136. /**
  104137. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104138. */
  104139. update(): void;
  104140. private _getAngleDiff;
  104141. private _getAngleBetween;
  104142. private _isAngleBetween;
  104143. }
  104144. }
  104145. declare module BABYLON {
  104146. /**
  104147. * Manage the gamepad inputs to control an arc rotate camera.
  104148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104149. */
  104150. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104151. /**
  104152. * Defines the camera the input is attached to.
  104153. */
  104154. camera: ArcRotateCamera;
  104155. /**
  104156. * Defines the gamepad the input is gathering event from.
  104157. */
  104158. gamepad: Nullable<Gamepad>;
  104159. /**
  104160. * Defines the gamepad rotation sensiblity.
  104161. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104162. */
  104163. gamepadRotationSensibility: number;
  104164. /**
  104165. * Defines the gamepad move sensiblity.
  104166. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104167. */
  104168. gamepadMoveSensibility: number;
  104169. private _yAxisScale;
  104170. /**
  104171. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104172. */
  104173. invertYAxis: boolean;
  104174. private _onGamepadConnectedObserver;
  104175. private _onGamepadDisconnectedObserver;
  104176. /**
  104177. * Attach the input controls to a specific dom element to get the input from.
  104178. * @param element Defines the element the controls should be listened from
  104179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104180. */
  104181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104182. /**
  104183. * Detach the current controls from the specified dom element.
  104184. * @param element Defines the element to stop listening the inputs from
  104185. */
  104186. detachControl(element: Nullable<HTMLElement>): void;
  104187. /**
  104188. * Update the current camera state depending on the inputs that have been used this frame.
  104189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104190. */
  104191. checkInputs(): void;
  104192. /**
  104193. * Gets the class name of the current intput.
  104194. * @returns the class name
  104195. */
  104196. getClassName(): string;
  104197. /**
  104198. * Get the friendly name associated with the input class.
  104199. * @returns the input friendly name
  104200. */
  104201. getSimpleName(): string;
  104202. }
  104203. }
  104204. declare module BABYLON {
  104205. interface ArcRotateCameraInputsManager {
  104206. /**
  104207. * Add orientation input support to the input manager.
  104208. * @returns the current input manager
  104209. */
  104210. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104211. }
  104212. /**
  104213. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104215. */
  104216. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104217. /**
  104218. * Defines the camera the input is attached to.
  104219. */
  104220. camera: ArcRotateCamera;
  104221. /**
  104222. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104223. */
  104224. alphaCorrection: number;
  104225. /**
  104226. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104227. */
  104228. gammaCorrection: number;
  104229. private _alpha;
  104230. private _gamma;
  104231. private _dirty;
  104232. private _deviceOrientationHandler;
  104233. /**
  104234. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104235. */
  104236. constructor();
  104237. /**
  104238. * Attach the input controls to a specific dom element to get the input from.
  104239. * @param element Defines the element the controls should be listened from
  104240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104241. */
  104242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104243. /** @hidden */
  104244. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104245. /**
  104246. * Update the current camera state depending on the inputs that have been used this frame.
  104247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104248. */
  104249. checkInputs(): void;
  104250. /**
  104251. * Detach the current controls from the specified dom element.
  104252. * @param element Defines the element to stop listening the inputs from
  104253. */
  104254. detachControl(element: Nullable<HTMLElement>): void;
  104255. /**
  104256. * Gets the class name of the current intput.
  104257. * @returns the class name
  104258. */
  104259. getClassName(): string;
  104260. /**
  104261. * Get the friendly name associated with the input class.
  104262. * @returns the input friendly name
  104263. */
  104264. getSimpleName(): string;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. /**
  104269. * Listen to mouse events to control the camera.
  104270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104271. */
  104272. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104273. /**
  104274. * Defines the camera the input is attached to.
  104275. */
  104276. camera: FlyCamera;
  104277. /**
  104278. * Defines if touch is enabled. (Default is true.)
  104279. */
  104280. touchEnabled: boolean;
  104281. /**
  104282. * Defines the buttons associated with the input to handle camera rotation.
  104283. */
  104284. buttons: number[];
  104285. /**
  104286. * Assign buttons for Yaw control.
  104287. */
  104288. buttonsYaw: number[];
  104289. /**
  104290. * Assign buttons for Pitch control.
  104291. */
  104292. buttonsPitch: number[];
  104293. /**
  104294. * Assign buttons for Roll control.
  104295. */
  104296. buttonsRoll: number[];
  104297. /**
  104298. * Detect if any button is being pressed while mouse is moved.
  104299. * -1 = Mouse locked.
  104300. * 0 = Left button.
  104301. * 1 = Middle Button.
  104302. * 2 = Right Button.
  104303. */
  104304. activeButton: number;
  104305. /**
  104306. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104307. * Higher values reduce its sensitivity.
  104308. */
  104309. angularSensibility: number;
  104310. private _mousemoveCallback;
  104311. private _observer;
  104312. private _rollObserver;
  104313. private previousPosition;
  104314. private noPreventDefault;
  104315. private element;
  104316. /**
  104317. * Listen to mouse events to control the camera.
  104318. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104320. */
  104321. constructor(touchEnabled?: boolean);
  104322. /**
  104323. * Attach the mouse control to the HTML DOM element.
  104324. * @param element Defines the element that listens to the input events.
  104325. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104326. */
  104327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104328. /**
  104329. * Detach the current controls from the specified dom element.
  104330. * @param element Defines the element to stop listening the inputs from
  104331. */
  104332. detachControl(element: Nullable<HTMLElement>): void;
  104333. /**
  104334. * Gets the class name of the current input.
  104335. * @returns the class name.
  104336. */
  104337. getClassName(): string;
  104338. /**
  104339. * Get the friendly name associated with the input class.
  104340. * @returns the input's friendly name.
  104341. */
  104342. getSimpleName(): string;
  104343. private _pointerInput;
  104344. private _onMouseMove;
  104345. /**
  104346. * Rotate camera by mouse offset.
  104347. */
  104348. private rotateCamera;
  104349. }
  104350. }
  104351. declare module BABYLON {
  104352. /**
  104353. * Default Inputs manager for the FlyCamera.
  104354. * It groups all the default supported inputs for ease of use.
  104355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104356. */
  104357. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104358. /**
  104359. * Instantiates a new FlyCameraInputsManager.
  104360. * @param camera Defines the camera the inputs belong to.
  104361. */
  104362. constructor(camera: FlyCamera);
  104363. /**
  104364. * Add keyboard input support to the input manager.
  104365. * @returns the new FlyCameraKeyboardMoveInput().
  104366. */
  104367. addKeyboard(): FlyCameraInputsManager;
  104368. /**
  104369. * Add mouse input support to the input manager.
  104370. * @param touchEnabled Enable touch screen support.
  104371. * @returns the new FlyCameraMouseInput().
  104372. */
  104373. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104374. }
  104375. }
  104376. declare module BABYLON {
  104377. /**
  104378. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104379. * such as in a 3D Space Shooter or a Flight Simulator.
  104380. */
  104381. export class FlyCamera extends TargetCamera {
  104382. /**
  104383. * Define the collision ellipsoid of the camera.
  104384. * This is helpful for simulating a camera body, like a player's body.
  104385. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104386. */
  104387. ellipsoid: Vector3;
  104388. /**
  104389. * Define an offset for the position of the ellipsoid around the camera.
  104390. * This can be helpful if the camera is attached away from the player's body center,
  104391. * such as at its head.
  104392. */
  104393. ellipsoidOffset: Vector3;
  104394. /**
  104395. * Enable or disable collisions of the camera with the rest of the scene objects.
  104396. */
  104397. checkCollisions: boolean;
  104398. /**
  104399. * Enable or disable gravity on the camera.
  104400. */
  104401. applyGravity: boolean;
  104402. /**
  104403. * Define the current direction the camera is moving to.
  104404. */
  104405. cameraDirection: Vector3;
  104406. /**
  104407. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104408. * This overrides and empties cameraRotation.
  104409. */
  104410. rotationQuaternion: Quaternion;
  104411. /**
  104412. * Track Roll to maintain the wanted Rolling when looking around.
  104413. */
  104414. _trackRoll: number;
  104415. /**
  104416. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104417. */
  104418. rollCorrect: number;
  104419. /**
  104420. * Mimic a banked turn, Rolling the camera when Yawing.
  104421. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104422. */
  104423. bankedTurn: boolean;
  104424. /**
  104425. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104426. */
  104427. bankedTurnLimit: number;
  104428. /**
  104429. * Value of 0 disables the banked Roll.
  104430. * Value of 1 is equal to the Yaw angle in radians.
  104431. */
  104432. bankedTurnMultiplier: number;
  104433. /**
  104434. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104435. */
  104436. inputs: FlyCameraInputsManager;
  104437. /**
  104438. * Gets the input sensibility for mouse input.
  104439. * Higher values reduce sensitivity.
  104440. */
  104441. /**
  104442. * Sets the input sensibility for a mouse input.
  104443. * Higher values reduce sensitivity.
  104444. */
  104445. angularSensibility: number;
  104446. /**
  104447. * Get the keys for camera movement forward.
  104448. */
  104449. /**
  104450. * Set the keys for camera movement forward.
  104451. */
  104452. keysForward: number[];
  104453. /**
  104454. * Get the keys for camera movement backward.
  104455. */
  104456. keysBackward: number[];
  104457. /**
  104458. * Get the keys for camera movement up.
  104459. */
  104460. /**
  104461. * Set the keys for camera movement up.
  104462. */
  104463. keysUp: number[];
  104464. /**
  104465. * Get the keys for camera movement down.
  104466. */
  104467. /**
  104468. * Set the keys for camera movement down.
  104469. */
  104470. keysDown: number[];
  104471. /**
  104472. * Get the keys for camera movement left.
  104473. */
  104474. /**
  104475. * Set the keys for camera movement left.
  104476. */
  104477. keysLeft: number[];
  104478. /**
  104479. * Set the keys for camera movement right.
  104480. */
  104481. /**
  104482. * Set the keys for camera movement right.
  104483. */
  104484. keysRight: number[];
  104485. /**
  104486. * Event raised when the camera collides with a mesh in the scene.
  104487. */
  104488. onCollide: (collidedMesh: AbstractMesh) => void;
  104489. private _collider;
  104490. private _needMoveForGravity;
  104491. private _oldPosition;
  104492. private _diffPosition;
  104493. private _newPosition;
  104494. /** @hidden */
  104495. _localDirection: Vector3;
  104496. /** @hidden */
  104497. _transformedDirection: Vector3;
  104498. /**
  104499. * Instantiates a FlyCamera.
  104500. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104501. * such as in a 3D Space Shooter or a Flight Simulator.
  104502. * @param name Define the name of the camera in the scene.
  104503. * @param position Define the starting position of the camera in the scene.
  104504. * @param scene Define the scene the camera belongs to.
  104505. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104506. */
  104507. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104508. /**
  104509. * Attach a control to the HTML DOM element.
  104510. * @param element Defines the element that listens to the input events.
  104511. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104512. */
  104513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104514. /**
  104515. * Detach a control from the HTML DOM element.
  104516. * The camera will stop reacting to that input.
  104517. * @param element Defines the element that listens to the input events.
  104518. */
  104519. detachControl(element: HTMLElement): void;
  104520. private _collisionMask;
  104521. /**
  104522. * Get the mask that the camera ignores in collision events.
  104523. */
  104524. /**
  104525. * Set the mask that the camera ignores in collision events.
  104526. */
  104527. collisionMask: number;
  104528. /** @hidden */
  104529. _collideWithWorld(displacement: Vector3): void;
  104530. /** @hidden */
  104531. private _onCollisionPositionChange;
  104532. /** @hidden */
  104533. _checkInputs(): void;
  104534. /** @hidden */
  104535. _decideIfNeedsToMove(): boolean;
  104536. /** @hidden */
  104537. _updatePosition(): void;
  104538. /**
  104539. * Restore the Roll to its target value at the rate specified.
  104540. * @param rate - Higher means slower restoring.
  104541. * @hidden
  104542. */
  104543. restoreRoll(rate: number): void;
  104544. /**
  104545. * Destroy the camera and release the current resources held by it.
  104546. */
  104547. dispose(): void;
  104548. /**
  104549. * Get the current object class name.
  104550. * @returns the class name.
  104551. */
  104552. getClassName(): string;
  104553. }
  104554. }
  104555. declare module BABYLON {
  104556. /**
  104557. * Listen to keyboard events to control the camera.
  104558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104559. */
  104560. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104561. /**
  104562. * Defines the camera the input is attached to.
  104563. */
  104564. camera: FlyCamera;
  104565. /**
  104566. * The list of keyboard keys used to control the forward move of the camera.
  104567. */
  104568. keysForward: number[];
  104569. /**
  104570. * The list of keyboard keys used to control the backward move of the camera.
  104571. */
  104572. keysBackward: number[];
  104573. /**
  104574. * The list of keyboard keys used to control the forward move of the camera.
  104575. */
  104576. keysUp: number[];
  104577. /**
  104578. * The list of keyboard keys used to control the backward move of the camera.
  104579. */
  104580. keysDown: number[];
  104581. /**
  104582. * The list of keyboard keys used to control the right strafe move of the camera.
  104583. */
  104584. keysRight: number[];
  104585. /**
  104586. * The list of keyboard keys used to control the left strafe move of the camera.
  104587. */
  104588. keysLeft: number[];
  104589. private _keys;
  104590. private _onCanvasBlurObserver;
  104591. private _onKeyboardObserver;
  104592. private _engine;
  104593. private _scene;
  104594. /**
  104595. * Attach the input controls to a specific dom element to get the input from.
  104596. * @param element Defines the element the controls should be listened from
  104597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104598. */
  104599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104600. /**
  104601. * Detach the current controls from the specified dom element.
  104602. * @param element Defines the element to stop listening the inputs from
  104603. */
  104604. detachControl(element: Nullable<HTMLElement>): void;
  104605. /**
  104606. * Gets the class name of the current intput.
  104607. * @returns the class name
  104608. */
  104609. getClassName(): string;
  104610. /** @hidden */
  104611. _onLostFocus(e: FocusEvent): void;
  104612. /**
  104613. * Get the friendly name associated with the input class.
  104614. * @returns the input friendly name
  104615. */
  104616. getSimpleName(): string;
  104617. /**
  104618. * Update the current camera state depending on the inputs that have been used this frame.
  104619. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104620. */
  104621. checkInputs(): void;
  104622. }
  104623. }
  104624. declare module BABYLON {
  104625. /**
  104626. * Manage the mouse wheel inputs to control a follow camera.
  104627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104628. */
  104629. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104630. /**
  104631. * Defines the camera the input is attached to.
  104632. */
  104633. camera: FollowCamera;
  104634. /**
  104635. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104636. */
  104637. axisControlRadius: boolean;
  104638. /**
  104639. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104640. */
  104641. axisControlHeight: boolean;
  104642. /**
  104643. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104644. */
  104645. axisControlRotation: boolean;
  104646. /**
  104647. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104648. * relation to mouseWheel events.
  104649. */
  104650. wheelPrecision: number;
  104651. /**
  104652. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104653. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104654. */
  104655. wheelDeltaPercentage: number;
  104656. private _wheel;
  104657. private _observer;
  104658. /**
  104659. * Attach the input controls to a specific dom element to get the input from.
  104660. * @param element Defines the element the controls should be listened from
  104661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104662. */
  104663. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104664. /**
  104665. * Detach the current controls from the specified dom element.
  104666. * @param element Defines the element to stop listening the inputs from
  104667. */
  104668. detachControl(element: Nullable<HTMLElement>): void;
  104669. /**
  104670. * Gets the class name of the current intput.
  104671. * @returns the class name
  104672. */
  104673. getClassName(): string;
  104674. /**
  104675. * Get the friendly name associated with the input class.
  104676. * @returns the input friendly name
  104677. */
  104678. getSimpleName(): string;
  104679. }
  104680. }
  104681. declare module BABYLON {
  104682. /**
  104683. * Manage the pointers inputs to control an follow camera.
  104684. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104685. */
  104686. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104687. /**
  104688. * Defines the camera the input is attached to.
  104689. */
  104690. camera: FollowCamera;
  104691. /**
  104692. * Gets the class name of the current input.
  104693. * @returns the class name
  104694. */
  104695. getClassName(): string;
  104696. /**
  104697. * Defines the pointer angular sensibility along the X axis or how fast is
  104698. * the camera rotating.
  104699. * A negative number will reverse the axis direction.
  104700. */
  104701. angularSensibilityX: number;
  104702. /**
  104703. * Defines the pointer angular sensibility along the Y axis or how fast is
  104704. * the camera rotating.
  104705. * A negative number will reverse the axis direction.
  104706. */
  104707. angularSensibilityY: number;
  104708. /**
  104709. * Defines the pointer pinch precision or how fast is the camera zooming.
  104710. * A negative number will reverse the axis direction.
  104711. */
  104712. pinchPrecision: number;
  104713. /**
  104714. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104715. * from 0.
  104716. * It defines the percentage of current camera.radius to use as delta when
  104717. * pinch zoom is used.
  104718. */
  104719. pinchDeltaPercentage: number;
  104720. /**
  104721. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104722. */
  104723. axisXControlRadius: boolean;
  104724. /**
  104725. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104726. */
  104727. axisXControlHeight: boolean;
  104728. /**
  104729. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104730. */
  104731. axisXControlRotation: boolean;
  104732. /**
  104733. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104734. */
  104735. axisYControlRadius: boolean;
  104736. /**
  104737. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104738. */
  104739. axisYControlHeight: boolean;
  104740. /**
  104741. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104742. */
  104743. axisYControlRotation: boolean;
  104744. /**
  104745. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104746. */
  104747. axisPinchControlRadius: boolean;
  104748. /**
  104749. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104750. */
  104751. axisPinchControlHeight: boolean;
  104752. /**
  104753. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104754. */
  104755. axisPinchControlRotation: boolean;
  104756. /**
  104757. * Log error messages if basic misconfiguration has occurred.
  104758. */
  104759. warningEnable: boolean;
  104760. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104761. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104762. private _warningCounter;
  104763. private _warning;
  104764. }
  104765. }
  104766. declare module BABYLON {
  104767. /**
  104768. * Default Inputs manager for the FollowCamera.
  104769. * It groups all the default supported inputs for ease of use.
  104770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104771. */
  104772. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104773. /**
  104774. * Instantiates a new FollowCameraInputsManager.
  104775. * @param camera Defines the camera the inputs belong to
  104776. */
  104777. constructor(camera: FollowCamera);
  104778. /**
  104779. * Add keyboard input support to the input manager.
  104780. * @returns the current input manager
  104781. */
  104782. addKeyboard(): FollowCameraInputsManager;
  104783. /**
  104784. * Add mouse wheel input support to the input manager.
  104785. * @returns the current input manager
  104786. */
  104787. addMouseWheel(): FollowCameraInputsManager;
  104788. /**
  104789. * Add pointers input support to the input manager.
  104790. * @returns the current input manager
  104791. */
  104792. addPointers(): FollowCameraInputsManager;
  104793. /**
  104794. * Add orientation input support to the input manager.
  104795. * @returns the current input manager
  104796. */
  104797. addVRDeviceOrientation(): FollowCameraInputsManager;
  104798. }
  104799. }
  104800. declare module BABYLON {
  104801. /**
  104802. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104803. * an arc rotate version arcFollowCamera are available.
  104804. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104805. */
  104806. export class FollowCamera extends TargetCamera {
  104807. /**
  104808. * Distance the follow camera should follow an object at
  104809. */
  104810. radius: number;
  104811. /**
  104812. * Minimum allowed distance of the camera to the axis of rotation
  104813. * (The camera can not get closer).
  104814. * This can help limiting how the Camera is able to move in the scene.
  104815. */
  104816. lowerRadiusLimit: Nullable<number>;
  104817. /**
  104818. * Maximum allowed distance of the camera to the axis of rotation
  104819. * (The camera can not get further).
  104820. * This can help limiting how the Camera is able to move in the scene.
  104821. */
  104822. upperRadiusLimit: Nullable<number>;
  104823. /**
  104824. * Define a rotation offset between the camera and the object it follows
  104825. */
  104826. rotationOffset: number;
  104827. /**
  104828. * Minimum allowed angle to camera position relative to target object.
  104829. * This can help limiting how the Camera is able to move in the scene.
  104830. */
  104831. lowerRotationOffsetLimit: Nullable<number>;
  104832. /**
  104833. * Maximum allowed angle to camera position relative to target object.
  104834. * This can help limiting how the Camera is able to move in the scene.
  104835. */
  104836. upperRotationOffsetLimit: Nullable<number>;
  104837. /**
  104838. * Define a height offset between the camera and the object it follows.
  104839. * It can help following an object from the top (like a car chaing a plane)
  104840. */
  104841. heightOffset: number;
  104842. /**
  104843. * Minimum allowed height of camera position relative to target object.
  104844. * This can help limiting how the Camera is able to move in the scene.
  104845. */
  104846. lowerHeightOffsetLimit: Nullable<number>;
  104847. /**
  104848. * Maximum allowed height of camera position relative to target object.
  104849. * This can help limiting how the Camera is able to move in the scene.
  104850. */
  104851. upperHeightOffsetLimit: Nullable<number>;
  104852. /**
  104853. * Define how fast the camera can accelerate to follow it s target.
  104854. */
  104855. cameraAcceleration: number;
  104856. /**
  104857. * Define the speed limit of the camera following an object.
  104858. */
  104859. maxCameraSpeed: number;
  104860. /**
  104861. * Define the target of the camera.
  104862. */
  104863. lockedTarget: Nullable<AbstractMesh>;
  104864. /**
  104865. * Defines the input associated with the camera.
  104866. */
  104867. inputs: FollowCameraInputsManager;
  104868. /**
  104869. * Instantiates the follow camera.
  104870. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104871. * @param name Define the name of the camera in the scene
  104872. * @param position Define the position of the camera
  104873. * @param scene Define the scene the camera belong to
  104874. * @param lockedTarget Define the target of the camera
  104875. */
  104876. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104877. private _follow;
  104878. /**
  104879. * Attached controls to the current camera.
  104880. * @param element Defines the element the controls should be listened from
  104881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104882. */
  104883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104884. /**
  104885. * Detach the current controls from the camera.
  104886. * The camera will stop reacting to inputs.
  104887. * @param element Defines the element to stop listening the inputs from
  104888. */
  104889. detachControl(element: HTMLElement): void;
  104890. /** @hidden */
  104891. _checkInputs(): void;
  104892. private _checkLimits;
  104893. /**
  104894. * Gets the camera class name.
  104895. * @returns the class name
  104896. */
  104897. getClassName(): string;
  104898. }
  104899. /**
  104900. * Arc Rotate version of the follow camera.
  104901. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104902. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104903. */
  104904. export class ArcFollowCamera extends TargetCamera {
  104905. /** The longitudinal angle of the camera */
  104906. alpha: number;
  104907. /** The latitudinal angle of the camera */
  104908. beta: number;
  104909. /** The radius of the camera from its target */
  104910. radius: number;
  104911. /** Define the camera target (the messh it should follow) */
  104912. target: Nullable<AbstractMesh>;
  104913. private _cartesianCoordinates;
  104914. /**
  104915. * Instantiates a new ArcFollowCamera
  104916. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104917. * @param name Define the name of the camera
  104918. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104919. * @param beta Define the rotation angle of the camera around the elevation axis
  104920. * @param radius Define the radius of the camera from its target point
  104921. * @param target Define the target of the camera
  104922. * @param scene Define the scene the camera belongs to
  104923. */
  104924. constructor(name: string,
  104925. /** The longitudinal angle of the camera */
  104926. alpha: number,
  104927. /** The latitudinal angle of the camera */
  104928. beta: number,
  104929. /** The radius of the camera from its target */
  104930. radius: number,
  104931. /** Define the camera target (the messh it should follow) */
  104932. target: Nullable<AbstractMesh>, scene: Scene);
  104933. private _follow;
  104934. /** @hidden */
  104935. _checkInputs(): void;
  104936. /**
  104937. * Returns the class name of the object.
  104938. * It is mostly used internally for serialization purposes.
  104939. */
  104940. getClassName(): string;
  104941. }
  104942. }
  104943. declare module BABYLON {
  104944. /**
  104945. * Manage the keyboard inputs to control the movement of a follow camera.
  104946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104947. */
  104948. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104949. /**
  104950. * Defines the camera the input is attached to.
  104951. */
  104952. camera: FollowCamera;
  104953. /**
  104954. * Defines the list of key codes associated with the up action (increase heightOffset)
  104955. */
  104956. keysHeightOffsetIncr: number[];
  104957. /**
  104958. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104959. */
  104960. keysHeightOffsetDecr: number[];
  104961. /**
  104962. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104963. */
  104964. keysHeightOffsetModifierAlt: boolean;
  104965. /**
  104966. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104967. */
  104968. keysHeightOffsetModifierCtrl: boolean;
  104969. /**
  104970. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104971. */
  104972. keysHeightOffsetModifierShift: boolean;
  104973. /**
  104974. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104975. */
  104976. keysRotationOffsetIncr: number[];
  104977. /**
  104978. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104979. */
  104980. keysRotationOffsetDecr: number[];
  104981. /**
  104982. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104983. */
  104984. keysRotationOffsetModifierAlt: boolean;
  104985. /**
  104986. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104987. */
  104988. keysRotationOffsetModifierCtrl: boolean;
  104989. /**
  104990. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104991. */
  104992. keysRotationOffsetModifierShift: boolean;
  104993. /**
  104994. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104995. */
  104996. keysRadiusIncr: number[];
  104997. /**
  104998. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104999. */
  105000. keysRadiusDecr: number[];
  105001. /**
  105002. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105003. */
  105004. keysRadiusModifierAlt: boolean;
  105005. /**
  105006. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105007. */
  105008. keysRadiusModifierCtrl: boolean;
  105009. /**
  105010. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105011. */
  105012. keysRadiusModifierShift: boolean;
  105013. /**
  105014. * Defines the rate of change of heightOffset.
  105015. */
  105016. heightSensibility: number;
  105017. /**
  105018. * Defines the rate of change of rotationOffset.
  105019. */
  105020. rotationSensibility: number;
  105021. /**
  105022. * Defines the rate of change of radius.
  105023. */
  105024. radiusSensibility: number;
  105025. private _keys;
  105026. private _ctrlPressed;
  105027. private _altPressed;
  105028. private _shiftPressed;
  105029. private _onCanvasBlurObserver;
  105030. private _onKeyboardObserver;
  105031. private _engine;
  105032. private _scene;
  105033. /**
  105034. * Attach the input controls to a specific dom element to get the input from.
  105035. * @param element Defines the element the controls should be listened from
  105036. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105037. */
  105038. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105039. /**
  105040. * Detach the current controls from the specified dom element.
  105041. * @param element Defines the element to stop listening the inputs from
  105042. */
  105043. detachControl(element: Nullable<HTMLElement>): void;
  105044. /**
  105045. * Update the current camera state depending on the inputs that have been used this frame.
  105046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105047. */
  105048. checkInputs(): void;
  105049. /**
  105050. * Gets the class name of the current input.
  105051. * @returns the class name
  105052. */
  105053. getClassName(): string;
  105054. /**
  105055. * Get the friendly name associated with the input class.
  105056. * @returns the input friendly name
  105057. */
  105058. getSimpleName(): string;
  105059. /**
  105060. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105061. * allow modification of the heightOffset value.
  105062. */
  105063. private _modifierHeightOffset;
  105064. /**
  105065. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105066. * allow modification of the rotationOffset value.
  105067. */
  105068. private _modifierRotationOffset;
  105069. /**
  105070. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105071. * allow modification of the radius value.
  105072. */
  105073. private _modifierRadius;
  105074. }
  105075. }
  105076. declare module BABYLON {
  105077. interface FreeCameraInputsManager {
  105078. /**
  105079. * @hidden
  105080. */
  105081. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105082. /**
  105083. * Add orientation input support to the input manager.
  105084. * @returns the current input manager
  105085. */
  105086. addDeviceOrientation(): FreeCameraInputsManager;
  105087. }
  105088. /**
  105089. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105090. * Screen rotation is taken into account.
  105091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105092. */
  105093. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105094. private _camera;
  105095. private _screenOrientationAngle;
  105096. private _constantTranform;
  105097. private _screenQuaternion;
  105098. private _alpha;
  105099. private _beta;
  105100. private _gamma;
  105101. /**
  105102. * Can be used to detect if a device orientation sensor is availible on a device
  105103. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105104. * @returns a promise that will resolve on orientation change
  105105. */
  105106. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105107. /**
  105108. * @hidden
  105109. */
  105110. _onDeviceOrientationChangedObservable: Observable<void>;
  105111. /**
  105112. * Instantiates a new input
  105113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105114. */
  105115. constructor();
  105116. /**
  105117. * Define the camera controlled by the input.
  105118. */
  105119. camera: FreeCamera;
  105120. /**
  105121. * Attach the input controls to a specific dom element to get the input from.
  105122. * @param element Defines the element the controls should be listened from
  105123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105124. */
  105125. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105126. private _orientationChanged;
  105127. private _deviceOrientation;
  105128. /**
  105129. * Detach the current controls from the specified dom element.
  105130. * @param element Defines the element to stop listening the inputs from
  105131. */
  105132. detachControl(element: Nullable<HTMLElement>): void;
  105133. /**
  105134. * Update the current camera state depending on the inputs that have been used this frame.
  105135. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105136. */
  105137. checkInputs(): void;
  105138. /**
  105139. * Gets the class name of the current intput.
  105140. * @returns the class name
  105141. */
  105142. getClassName(): string;
  105143. /**
  105144. * Get the friendly name associated with the input class.
  105145. * @returns the input friendly name
  105146. */
  105147. getSimpleName(): string;
  105148. }
  105149. }
  105150. declare module BABYLON {
  105151. /**
  105152. * Manage the gamepad inputs to control a free camera.
  105153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105154. */
  105155. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105156. /**
  105157. * Define the camera the input is attached to.
  105158. */
  105159. camera: FreeCamera;
  105160. /**
  105161. * Define the Gamepad controlling the input
  105162. */
  105163. gamepad: Nullable<Gamepad>;
  105164. /**
  105165. * Defines the gamepad rotation sensiblity.
  105166. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105167. */
  105168. gamepadAngularSensibility: number;
  105169. /**
  105170. * Defines the gamepad move sensiblity.
  105171. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105172. */
  105173. gamepadMoveSensibility: number;
  105174. private _yAxisScale;
  105175. /**
  105176. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105177. */
  105178. invertYAxis: boolean;
  105179. private _onGamepadConnectedObserver;
  105180. private _onGamepadDisconnectedObserver;
  105181. private _cameraTransform;
  105182. private _deltaTransform;
  105183. private _vector3;
  105184. private _vector2;
  105185. /**
  105186. * Attach the input controls to a specific dom element to get the input from.
  105187. * @param element Defines the element the controls should be listened from
  105188. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105189. */
  105190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105191. /**
  105192. * Detach the current controls from the specified dom element.
  105193. * @param element Defines the element to stop listening the inputs from
  105194. */
  105195. detachControl(element: Nullable<HTMLElement>): void;
  105196. /**
  105197. * Update the current camera state depending on the inputs that have been used this frame.
  105198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105199. */
  105200. checkInputs(): void;
  105201. /**
  105202. * Gets the class name of the current intput.
  105203. * @returns the class name
  105204. */
  105205. getClassName(): string;
  105206. /**
  105207. * Get the friendly name associated with the input class.
  105208. * @returns the input friendly name
  105209. */
  105210. getSimpleName(): string;
  105211. }
  105212. }
  105213. declare module BABYLON {
  105214. /**
  105215. * Defines the potential axis of a Joystick
  105216. */
  105217. export enum JoystickAxis {
  105218. /** X axis */
  105219. X = 0,
  105220. /** Y axis */
  105221. Y = 1,
  105222. /** Z axis */
  105223. Z = 2
  105224. }
  105225. /**
  105226. * Class used to define virtual joystick (used in touch mode)
  105227. */
  105228. export class VirtualJoystick {
  105229. /**
  105230. * Gets or sets a boolean indicating that left and right values must be inverted
  105231. */
  105232. reverseLeftRight: boolean;
  105233. /**
  105234. * Gets or sets a boolean indicating that up and down values must be inverted
  105235. */
  105236. reverseUpDown: boolean;
  105237. /**
  105238. * Gets the offset value for the position (ie. the change of the position value)
  105239. */
  105240. deltaPosition: Vector3;
  105241. /**
  105242. * Gets a boolean indicating if the virtual joystick was pressed
  105243. */
  105244. pressed: boolean;
  105245. /**
  105246. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105247. */
  105248. static Canvas: Nullable<HTMLCanvasElement>;
  105249. private static _globalJoystickIndex;
  105250. private static vjCanvasContext;
  105251. private static vjCanvasWidth;
  105252. private static vjCanvasHeight;
  105253. private static halfWidth;
  105254. private _action;
  105255. private _axisTargetedByLeftAndRight;
  105256. private _axisTargetedByUpAndDown;
  105257. private _joystickSensibility;
  105258. private _inversedSensibility;
  105259. private _joystickPointerID;
  105260. private _joystickColor;
  105261. private _joystickPointerPos;
  105262. private _joystickPreviousPointerPos;
  105263. private _joystickPointerStartPos;
  105264. private _deltaJoystickVector;
  105265. private _leftJoystick;
  105266. private _touches;
  105267. private _onPointerDownHandlerRef;
  105268. private _onPointerMoveHandlerRef;
  105269. private _onPointerUpHandlerRef;
  105270. private _onResize;
  105271. /**
  105272. * Creates a new virtual joystick
  105273. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105274. */
  105275. constructor(leftJoystick?: boolean);
  105276. /**
  105277. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105278. * @param newJoystickSensibility defines the new sensibility
  105279. */
  105280. setJoystickSensibility(newJoystickSensibility: number): void;
  105281. private _onPointerDown;
  105282. private _onPointerMove;
  105283. private _onPointerUp;
  105284. /**
  105285. * Change the color of the virtual joystick
  105286. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105287. */
  105288. setJoystickColor(newColor: string): void;
  105289. /**
  105290. * Defines a callback to call when the joystick is touched
  105291. * @param action defines the callback
  105292. */
  105293. setActionOnTouch(action: () => any): void;
  105294. /**
  105295. * Defines which axis you'd like to control for left & right
  105296. * @param axis defines the axis to use
  105297. */
  105298. setAxisForLeftRight(axis: JoystickAxis): void;
  105299. /**
  105300. * Defines which axis you'd like to control for up & down
  105301. * @param axis defines the axis to use
  105302. */
  105303. setAxisForUpDown(axis: JoystickAxis): void;
  105304. private _drawVirtualJoystick;
  105305. /**
  105306. * Release internal HTML canvas
  105307. */
  105308. releaseCanvas(): void;
  105309. }
  105310. }
  105311. declare module BABYLON {
  105312. interface FreeCameraInputsManager {
  105313. /**
  105314. * Add virtual joystick input support to the input manager.
  105315. * @returns the current input manager
  105316. */
  105317. addVirtualJoystick(): FreeCameraInputsManager;
  105318. }
  105319. /**
  105320. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105321. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105322. */
  105323. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105324. /**
  105325. * Defines the camera the input is attached to.
  105326. */
  105327. camera: FreeCamera;
  105328. private _leftjoystick;
  105329. private _rightjoystick;
  105330. /**
  105331. * Gets the left stick of the virtual joystick.
  105332. * @returns The virtual Joystick
  105333. */
  105334. getLeftJoystick(): VirtualJoystick;
  105335. /**
  105336. * Gets the right stick of the virtual joystick.
  105337. * @returns The virtual Joystick
  105338. */
  105339. getRightJoystick(): VirtualJoystick;
  105340. /**
  105341. * Update the current camera state depending on the inputs that have been used this frame.
  105342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105343. */
  105344. checkInputs(): void;
  105345. /**
  105346. * Attach the input controls to a specific dom element to get the input from.
  105347. * @param element Defines the element the controls should be listened from
  105348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105349. */
  105350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105351. /**
  105352. * Detach the current controls from the specified dom element.
  105353. * @param element Defines the element to stop listening the inputs from
  105354. */
  105355. detachControl(element: Nullable<HTMLElement>): void;
  105356. /**
  105357. * Gets the class name of the current intput.
  105358. * @returns the class name
  105359. */
  105360. getClassName(): string;
  105361. /**
  105362. * Get the friendly name associated with the input class.
  105363. * @returns the input friendly name
  105364. */
  105365. getSimpleName(): string;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * This represents a FPS type of camera controlled by touch.
  105371. * This is like a universal camera minus the Gamepad controls.
  105372. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105373. */
  105374. export class TouchCamera extends FreeCamera {
  105375. /**
  105376. * Defines the touch sensibility for rotation.
  105377. * The higher the faster.
  105378. */
  105379. touchAngularSensibility: number;
  105380. /**
  105381. * Defines the touch sensibility for move.
  105382. * The higher the faster.
  105383. */
  105384. touchMoveSensibility: number;
  105385. /**
  105386. * Instantiates a new touch camera.
  105387. * This represents a FPS type of camera controlled by touch.
  105388. * This is like a universal camera minus the Gamepad controls.
  105389. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105390. * @param name Define the name of the camera in the scene
  105391. * @param position Define the start position of the camera in the scene
  105392. * @param scene Define the scene the camera belongs to
  105393. */
  105394. constructor(name: string, position: Vector3, scene: Scene);
  105395. /**
  105396. * Gets the current object class name.
  105397. * @return the class name
  105398. */
  105399. getClassName(): string;
  105400. /** @hidden */
  105401. _setupInputs(): void;
  105402. }
  105403. }
  105404. declare module BABYLON {
  105405. /**
  105406. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105407. * being tilted forward or back and left or right.
  105408. */
  105409. export class DeviceOrientationCamera extends FreeCamera {
  105410. private _initialQuaternion;
  105411. private _quaternionCache;
  105412. private _tmpDragQuaternion;
  105413. private _disablePointerInputWhenUsingDeviceOrientation;
  105414. /**
  105415. * Creates a new device orientation camera
  105416. * @param name The name of the camera
  105417. * @param position The start position camera
  105418. * @param scene The scene the camera belongs to
  105419. */
  105420. constructor(name: string, position: Vector3, scene: Scene);
  105421. /**
  105422. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105423. */
  105424. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105425. private _dragFactor;
  105426. /**
  105427. * Enabled turning on the y axis when the orientation sensor is active
  105428. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105429. */
  105430. enableHorizontalDragging(dragFactor?: number): void;
  105431. /**
  105432. * Gets the current instance class name ("DeviceOrientationCamera").
  105433. * This helps avoiding instanceof at run time.
  105434. * @returns the class name
  105435. */
  105436. getClassName(): string;
  105437. /**
  105438. * @hidden
  105439. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105440. */
  105441. _checkInputs(): void;
  105442. /**
  105443. * Reset the camera to its default orientation on the specified axis only.
  105444. * @param axis The axis to reset
  105445. */
  105446. resetToCurrentRotation(axis?: Axis): void;
  105447. }
  105448. }
  105449. declare module BABYLON {
  105450. /**
  105451. * Defines supported buttons for XBox360 compatible gamepads
  105452. */
  105453. export enum Xbox360Button {
  105454. /** A */
  105455. A = 0,
  105456. /** B */
  105457. B = 1,
  105458. /** X */
  105459. X = 2,
  105460. /** Y */
  105461. Y = 3,
  105462. /** Start */
  105463. Start = 4,
  105464. /** Back */
  105465. Back = 5,
  105466. /** Left button */
  105467. LB = 6,
  105468. /** Right button */
  105469. RB = 7,
  105470. /** Left stick */
  105471. LeftStick = 8,
  105472. /** Right stick */
  105473. RightStick = 9
  105474. }
  105475. /** Defines values for XBox360 DPad */
  105476. export enum Xbox360Dpad {
  105477. /** Up */
  105478. Up = 0,
  105479. /** Down */
  105480. Down = 1,
  105481. /** Left */
  105482. Left = 2,
  105483. /** Right */
  105484. Right = 3
  105485. }
  105486. /**
  105487. * Defines a XBox360 gamepad
  105488. */
  105489. export class Xbox360Pad extends Gamepad {
  105490. private _leftTrigger;
  105491. private _rightTrigger;
  105492. private _onlefttriggerchanged;
  105493. private _onrighttriggerchanged;
  105494. private _onbuttondown;
  105495. private _onbuttonup;
  105496. private _ondpaddown;
  105497. private _ondpadup;
  105498. /** Observable raised when a button is pressed */
  105499. onButtonDownObservable: Observable<Xbox360Button>;
  105500. /** Observable raised when a button is released */
  105501. onButtonUpObservable: Observable<Xbox360Button>;
  105502. /** Observable raised when a pad is pressed */
  105503. onPadDownObservable: Observable<Xbox360Dpad>;
  105504. /** Observable raised when a pad is released */
  105505. onPadUpObservable: Observable<Xbox360Dpad>;
  105506. private _buttonA;
  105507. private _buttonB;
  105508. private _buttonX;
  105509. private _buttonY;
  105510. private _buttonBack;
  105511. private _buttonStart;
  105512. private _buttonLB;
  105513. private _buttonRB;
  105514. private _buttonLeftStick;
  105515. private _buttonRightStick;
  105516. private _dPadUp;
  105517. private _dPadDown;
  105518. private _dPadLeft;
  105519. private _dPadRight;
  105520. private _isXboxOnePad;
  105521. /**
  105522. * Creates a new XBox360 gamepad object
  105523. * @param id defines the id of this gamepad
  105524. * @param index defines its index
  105525. * @param gamepad defines the internal HTML gamepad object
  105526. * @param xboxOne defines if it is a XBox One gamepad
  105527. */
  105528. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105529. /**
  105530. * Defines the callback to call when left trigger is pressed
  105531. * @param callback defines the callback to use
  105532. */
  105533. onlefttriggerchanged(callback: (value: number) => void): void;
  105534. /**
  105535. * Defines the callback to call when right trigger is pressed
  105536. * @param callback defines the callback to use
  105537. */
  105538. onrighttriggerchanged(callback: (value: number) => void): void;
  105539. /**
  105540. * Gets the left trigger value
  105541. */
  105542. /**
  105543. * Sets the left trigger value
  105544. */
  105545. leftTrigger: number;
  105546. /**
  105547. * Gets the right trigger value
  105548. */
  105549. /**
  105550. * Sets the right trigger value
  105551. */
  105552. rightTrigger: number;
  105553. /**
  105554. * Defines the callback to call when a button is pressed
  105555. * @param callback defines the callback to use
  105556. */
  105557. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105558. /**
  105559. * Defines the callback to call when a button is released
  105560. * @param callback defines the callback to use
  105561. */
  105562. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105563. /**
  105564. * Defines the callback to call when a pad is pressed
  105565. * @param callback defines the callback to use
  105566. */
  105567. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105568. /**
  105569. * Defines the callback to call when a pad is released
  105570. * @param callback defines the callback to use
  105571. */
  105572. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105573. private _setButtonValue;
  105574. private _setDPadValue;
  105575. /**
  105576. * Gets the value of the `A` button
  105577. */
  105578. /**
  105579. * Sets the value of the `A` button
  105580. */
  105581. buttonA: number;
  105582. /**
  105583. * Gets the value of the `B` button
  105584. */
  105585. /**
  105586. * Sets the value of the `B` button
  105587. */
  105588. buttonB: number;
  105589. /**
  105590. * Gets the value of the `X` button
  105591. */
  105592. /**
  105593. * Sets the value of the `X` button
  105594. */
  105595. buttonX: number;
  105596. /**
  105597. * Gets the value of the `Y` button
  105598. */
  105599. /**
  105600. * Sets the value of the `Y` button
  105601. */
  105602. buttonY: number;
  105603. /**
  105604. * Gets the value of the `Start` button
  105605. */
  105606. /**
  105607. * Sets the value of the `Start` button
  105608. */
  105609. buttonStart: number;
  105610. /**
  105611. * Gets the value of the `Back` button
  105612. */
  105613. /**
  105614. * Sets the value of the `Back` button
  105615. */
  105616. buttonBack: number;
  105617. /**
  105618. * Gets the value of the `Left` button
  105619. */
  105620. /**
  105621. * Sets the value of the `Left` button
  105622. */
  105623. buttonLB: number;
  105624. /**
  105625. * Gets the value of the `Right` button
  105626. */
  105627. /**
  105628. * Sets the value of the `Right` button
  105629. */
  105630. buttonRB: number;
  105631. /**
  105632. * Gets the value of the Left joystick
  105633. */
  105634. /**
  105635. * Sets the value of the Left joystick
  105636. */
  105637. buttonLeftStick: number;
  105638. /**
  105639. * Gets the value of the Right joystick
  105640. */
  105641. /**
  105642. * Sets the value of the Right joystick
  105643. */
  105644. buttonRightStick: number;
  105645. /**
  105646. * Gets the value of D-pad up
  105647. */
  105648. /**
  105649. * Sets the value of D-pad up
  105650. */
  105651. dPadUp: number;
  105652. /**
  105653. * Gets the value of D-pad down
  105654. */
  105655. /**
  105656. * Sets the value of D-pad down
  105657. */
  105658. dPadDown: number;
  105659. /**
  105660. * Gets the value of D-pad left
  105661. */
  105662. /**
  105663. * Sets the value of D-pad left
  105664. */
  105665. dPadLeft: number;
  105666. /**
  105667. * Gets the value of D-pad right
  105668. */
  105669. /**
  105670. * Sets the value of D-pad right
  105671. */
  105672. dPadRight: number;
  105673. /**
  105674. * Force the gamepad to synchronize with device values
  105675. */
  105676. update(): void;
  105677. /**
  105678. * Disposes the gamepad
  105679. */
  105680. dispose(): void;
  105681. }
  105682. }
  105683. declare module BABYLON {
  105684. /**
  105685. * Defines supported buttons for DualShock compatible gamepads
  105686. */
  105687. export enum DualShockButton {
  105688. /** Cross */
  105689. Cross = 0,
  105690. /** Circle */
  105691. Circle = 1,
  105692. /** Square */
  105693. Square = 2,
  105694. /** Triangle */
  105695. Triangle = 3,
  105696. /** Options */
  105697. Options = 4,
  105698. /** Share */
  105699. Share = 5,
  105700. /** L1 */
  105701. L1 = 6,
  105702. /** R1 */
  105703. R1 = 7,
  105704. /** Left stick */
  105705. LeftStick = 8,
  105706. /** Right stick */
  105707. RightStick = 9
  105708. }
  105709. /** Defines values for DualShock DPad */
  105710. export enum DualShockDpad {
  105711. /** Up */
  105712. Up = 0,
  105713. /** Down */
  105714. Down = 1,
  105715. /** Left */
  105716. Left = 2,
  105717. /** Right */
  105718. Right = 3
  105719. }
  105720. /**
  105721. * Defines a DualShock gamepad
  105722. */
  105723. export class DualShockPad extends Gamepad {
  105724. private _leftTrigger;
  105725. private _rightTrigger;
  105726. private _onlefttriggerchanged;
  105727. private _onrighttriggerchanged;
  105728. private _onbuttondown;
  105729. private _onbuttonup;
  105730. private _ondpaddown;
  105731. private _ondpadup;
  105732. /** Observable raised when a button is pressed */
  105733. onButtonDownObservable: Observable<DualShockButton>;
  105734. /** Observable raised when a button is released */
  105735. onButtonUpObservable: Observable<DualShockButton>;
  105736. /** Observable raised when a pad is pressed */
  105737. onPadDownObservable: Observable<DualShockDpad>;
  105738. /** Observable raised when a pad is released */
  105739. onPadUpObservable: Observable<DualShockDpad>;
  105740. private _buttonCross;
  105741. private _buttonCircle;
  105742. private _buttonSquare;
  105743. private _buttonTriangle;
  105744. private _buttonShare;
  105745. private _buttonOptions;
  105746. private _buttonL1;
  105747. private _buttonR1;
  105748. private _buttonLeftStick;
  105749. private _buttonRightStick;
  105750. private _dPadUp;
  105751. private _dPadDown;
  105752. private _dPadLeft;
  105753. private _dPadRight;
  105754. /**
  105755. * Creates a new DualShock gamepad object
  105756. * @param id defines the id of this gamepad
  105757. * @param index defines its index
  105758. * @param gamepad defines the internal HTML gamepad object
  105759. */
  105760. constructor(id: string, index: number, gamepad: any);
  105761. /**
  105762. * Defines the callback to call when left trigger is pressed
  105763. * @param callback defines the callback to use
  105764. */
  105765. onlefttriggerchanged(callback: (value: number) => void): void;
  105766. /**
  105767. * Defines the callback to call when right trigger is pressed
  105768. * @param callback defines the callback to use
  105769. */
  105770. onrighttriggerchanged(callback: (value: number) => void): void;
  105771. /**
  105772. * Gets the left trigger value
  105773. */
  105774. /**
  105775. * Sets the left trigger value
  105776. */
  105777. leftTrigger: number;
  105778. /**
  105779. * Gets the right trigger value
  105780. */
  105781. /**
  105782. * Sets the right trigger value
  105783. */
  105784. rightTrigger: number;
  105785. /**
  105786. * Defines the callback to call when a button is pressed
  105787. * @param callback defines the callback to use
  105788. */
  105789. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105790. /**
  105791. * Defines the callback to call when a button is released
  105792. * @param callback defines the callback to use
  105793. */
  105794. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105795. /**
  105796. * Defines the callback to call when a pad is pressed
  105797. * @param callback defines the callback to use
  105798. */
  105799. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105800. /**
  105801. * Defines the callback to call when a pad is released
  105802. * @param callback defines the callback to use
  105803. */
  105804. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105805. private _setButtonValue;
  105806. private _setDPadValue;
  105807. /**
  105808. * Gets the value of the `Cross` button
  105809. */
  105810. /**
  105811. * Sets the value of the `Cross` button
  105812. */
  105813. buttonCross: number;
  105814. /**
  105815. * Gets the value of the `Circle` button
  105816. */
  105817. /**
  105818. * Sets the value of the `Circle` button
  105819. */
  105820. buttonCircle: number;
  105821. /**
  105822. * Gets the value of the `Square` button
  105823. */
  105824. /**
  105825. * Sets the value of the `Square` button
  105826. */
  105827. buttonSquare: number;
  105828. /**
  105829. * Gets the value of the `Triangle` button
  105830. */
  105831. /**
  105832. * Sets the value of the `Triangle` button
  105833. */
  105834. buttonTriangle: number;
  105835. /**
  105836. * Gets the value of the `Options` button
  105837. */
  105838. /**
  105839. * Sets the value of the `Options` button
  105840. */
  105841. buttonOptions: number;
  105842. /**
  105843. * Gets the value of the `Share` button
  105844. */
  105845. /**
  105846. * Sets the value of the `Share` button
  105847. */
  105848. buttonShare: number;
  105849. /**
  105850. * Gets the value of the `L1` button
  105851. */
  105852. /**
  105853. * Sets the value of the `L1` button
  105854. */
  105855. buttonL1: number;
  105856. /**
  105857. * Gets the value of the `R1` button
  105858. */
  105859. /**
  105860. * Sets the value of the `R1` button
  105861. */
  105862. buttonR1: number;
  105863. /**
  105864. * Gets the value of the Left joystick
  105865. */
  105866. /**
  105867. * Sets the value of the Left joystick
  105868. */
  105869. buttonLeftStick: number;
  105870. /**
  105871. * Gets the value of the Right joystick
  105872. */
  105873. /**
  105874. * Sets the value of the Right joystick
  105875. */
  105876. buttonRightStick: number;
  105877. /**
  105878. * Gets the value of D-pad up
  105879. */
  105880. /**
  105881. * Sets the value of D-pad up
  105882. */
  105883. dPadUp: number;
  105884. /**
  105885. * Gets the value of D-pad down
  105886. */
  105887. /**
  105888. * Sets the value of D-pad down
  105889. */
  105890. dPadDown: number;
  105891. /**
  105892. * Gets the value of D-pad left
  105893. */
  105894. /**
  105895. * Sets the value of D-pad left
  105896. */
  105897. dPadLeft: number;
  105898. /**
  105899. * Gets the value of D-pad right
  105900. */
  105901. /**
  105902. * Sets the value of D-pad right
  105903. */
  105904. dPadRight: number;
  105905. /**
  105906. * Force the gamepad to synchronize with device values
  105907. */
  105908. update(): void;
  105909. /**
  105910. * Disposes the gamepad
  105911. */
  105912. dispose(): void;
  105913. }
  105914. }
  105915. declare module BABYLON {
  105916. /**
  105917. * Manager for handling gamepads
  105918. */
  105919. export class GamepadManager {
  105920. private _scene?;
  105921. private _babylonGamepads;
  105922. private _oneGamepadConnected;
  105923. /** @hidden */
  105924. _isMonitoring: boolean;
  105925. private _gamepadEventSupported;
  105926. private _gamepadSupport;
  105927. /**
  105928. * observable to be triggered when the gamepad controller has been connected
  105929. */
  105930. onGamepadConnectedObservable: Observable<Gamepad>;
  105931. /**
  105932. * observable to be triggered when the gamepad controller has been disconnected
  105933. */
  105934. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105935. private _onGamepadConnectedEvent;
  105936. private _onGamepadDisconnectedEvent;
  105937. /**
  105938. * Initializes the gamepad manager
  105939. * @param _scene BabylonJS scene
  105940. */
  105941. constructor(_scene?: Scene | undefined);
  105942. /**
  105943. * The gamepads in the game pad manager
  105944. */
  105945. readonly gamepads: Gamepad[];
  105946. /**
  105947. * Get the gamepad controllers based on type
  105948. * @param type The type of gamepad controller
  105949. * @returns Nullable gamepad
  105950. */
  105951. getGamepadByType(type?: number): Nullable<Gamepad>;
  105952. /**
  105953. * Disposes the gamepad manager
  105954. */
  105955. dispose(): void;
  105956. private _addNewGamepad;
  105957. private _startMonitoringGamepads;
  105958. private _stopMonitoringGamepads;
  105959. /** @hidden */
  105960. _checkGamepadsStatus(): void;
  105961. private _updateGamepadObjects;
  105962. }
  105963. }
  105964. declare module BABYLON {
  105965. interface Scene {
  105966. /** @hidden */
  105967. _gamepadManager: Nullable<GamepadManager>;
  105968. /**
  105969. * Gets the gamepad manager associated with the scene
  105970. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105971. */
  105972. gamepadManager: GamepadManager;
  105973. }
  105974. /**
  105975. * Interface representing a free camera inputs manager
  105976. */
  105977. interface FreeCameraInputsManager {
  105978. /**
  105979. * Adds gamepad input support to the FreeCameraInputsManager.
  105980. * @returns the FreeCameraInputsManager
  105981. */
  105982. addGamepad(): FreeCameraInputsManager;
  105983. }
  105984. /**
  105985. * Interface representing an arc rotate camera inputs manager
  105986. */
  105987. interface ArcRotateCameraInputsManager {
  105988. /**
  105989. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105990. * @returns the camera inputs manager
  105991. */
  105992. addGamepad(): ArcRotateCameraInputsManager;
  105993. }
  105994. /**
  105995. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105996. */
  105997. export class GamepadSystemSceneComponent implements ISceneComponent {
  105998. /**
  105999. * The component name helpfull to identify the component in the list of scene components.
  106000. */
  106001. readonly name: string;
  106002. /**
  106003. * The scene the component belongs to.
  106004. */
  106005. scene: Scene;
  106006. /**
  106007. * Creates a new instance of the component for the given scene
  106008. * @param scene Defines the scene to register the component in
  106009. */
  106010. constructor(scene: Scene);
  106011. /**
  106012. * Registers the component in a given scene
  106013. */
  106014. register(): void;
  106015. /**
  106016. * Rebuilds the elements related to this component in case of
  106017. * context lost for instance.
  106018. */
  106019. rebuild(): void;
  106020. /**
  106021. * Disposes the component and the associated ressources
  106022. */
  106023. dispose(): void;
  106024. private _beforeCameraUpdate;
  106025. }
  106026. }
  106027. declare module BABYLON {
  106028. /**
  106029. * 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,
  106030. * which still works and will still be found in many Playgrounds.
  106031. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106032. */
  106033. export class UniversalCamera extends TouchCamera {
  106034. /**
  106035. * Defines the gamepad rotation sensiblity.
  106036. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106037. */
  106038. gamepadAngularSensibility: number;
  106039. /**
  106040. * Defines the gamepad move sensiblity.
  106041. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106042. */
  106043. gamepadMoveSensibility: number;
  106044. /**
  106045. * 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,
  106046. * which still works and will still be found in many Playgrounds.
  106047. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106048. * @param name Define the name of the camera in the scene
  106049. * @param position Define the start position of the camera in the scene
  106050. * @param scene Define the scene the camera belongs to
  106051. */
  106052. constructor(name: string, position: Vector3, scene: Scene);
  106053. /**
  106054. * Gets the current object class name.
  106055. * @return the class name
  106056. */
  106057. getClassName(): string;
  106058. }
  106059. }
  106060. declare module BABYLON {
  106061. /**
  106062. * This represents a FPS type of camera. This is only here for back compat purpose.
  106063. * Please use the UniversalCamera instead as both are identical.
  106064. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106065. */
  106066. export class GamepadCamera extends UniversalCamera {
  106067. /**
  106068. * Instantiates a new Gamepad Camera
  106069. * This represents a FPS type of camera. This is only here for back compat purpose.
  106070. * Please use the UniversalCamera instead as both are identical.
  106071. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106072. * @param name Define the name of the camera in the scene
  106073. * @param position Define the start position of the camera in the scene
  106074. * @param scene Define the scene the camera belongs to
  106075. */
  106076. constructor(name: string, position: Vector3, scene: Scene);
  106077. /**
  106078. * Gets the current object class name.
  106079. * @return the class name
  106080. */
  106081. getClassName(): string;
  106082. }
  106083. }
  106084. declare module BABYLON {
  106085. /** @hidden */
  106086. export var passPixelShader: {
  106087. name: string;
  106088. shader: string;
  106089. };
  106090. }
  106091. declare module BABYLON {
  106092. /** @hidden */
  106093. export var passCubePixelShader: {
  106094. name: string;
  106095. shader: string;
  106096. };
  106097. }
  106098. declare module BABYLON {
  106099. /**
  106100. * PassPostProcess which produces an output the same as it's input
  106101. */
  106102. export class PassPostProcess extends PostProcess {
  106103. /**
  106104. * Creates the PassPostProcess
  106105. * @param name The name of the effect.
  106106. * @param options The required width/height ratio to downsize to before computing the render pass.
  106107. * @param camera The camera to apply the render pass to.
  106108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106109. * @param engine The engine which the post process will be applied. (default: current engine)
  106110. * @param reusable If the post process can be reused on the same frame. (default: false)
  106111. * @param textureType The type of texture to be used when performing the post processing.
  106112. * @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)
  106113. */
  106114. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106115. }
  106116. /**
  106117. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106118. */
  106119. export class PassCubePostProcess extends PostProcess {
  106120. private _face;
  106121. /**
  106122. * Gets or sets the cube face to display.
  106123. * * 0 is +X
  106124. * * 1 is -X
  106125. * * 2 is +Y
  106126. * * 3 is -Y
  106127. * * 4 is +Z
  106128. * * 5 is -Z
  106129. */
  106130. face: number;
  106131. /**
  106132. * Creates the PassCubePostProcess
  106133. * @param name The name of the effect.
  106134. * @param options The required width/height ratio to downsize to before computing the render pass.
  106135. * @param camera The camera to apply the render pass to.
  106136. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106137. * @param engine The engine which the post process will be applied. (default: current engine)
  106138. * @param reusable If the post process can be reused on the same frame. (default: false)
  106139. * @param textureType The type of texture to be used when performing the post processing.
  106140. * @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)
  106141. */
  106142. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106143. }
  106144. }
  106145. declare module BABYLON {
  106146. /** @hidden */
  106147. export var anaglyphPixelShader: {
  106148. name: string;
  106149. shader: string;
  106150. };
  106151. }
  106152. declare module BABYLON {
  106153. /**
  106154. * Postprocess used to generate anaglyphic rendering
  106155. */
  106156. export class AnaglyphPostProcess extends PostProcess {
  106157. private _passedProcess;
  106158. /**
  106159. * Creates a new AnaglyphPostProcess
  106160. * @param name defines postprocess name
  106161. * @param options defines creation options or target ratio scale
  106162. * @param rigCameras defines cameras using this postprocess
  106163. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106164. * @param engine defines hosting engine
  106165. * @param reusable defines if the postprocess will be reused multiple times per frame
  106166. */
  106167. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106168. }
  106169. }
  106170. declare module BABYLON {
  106171. /**
  106172. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106173. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106174. */
  106175. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106176. /**
  106177. * Creates a new AnaglyphArcRotateCamera
  106178. * @param name defines camera name
  106179. * @param alpha defines alpha angle (in radians)
  106180. * @param beta defines beta angle (in radians)
  106181. * @param radius defines radius
  106182. * @param target defines camera target
  106183. * @param interaxialDistance defines distance between each color axis
  106184. * @param scene defines the hosting scene
  106185. */
  106186. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106187. /**
  106188. * Gets camera class name
  106189. * @returns AnaglyphArcRotateCamera
  106190. */
  106191. getClassName(): string;
  106192. }
  106193. }
  106194. declare module BABYLON {
  106195. /**
  106196. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106197. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106198. */
  106199. export class AnaglyphFreeCamera extends FreeCamera {
  106200. /**
  106201. * Creates a new AnaglyphFreeCamera
  106202. * @param name defines camera name
  106203. * @param position defines initial position
  106204. * @param interaxialDistance defines distance between each color axis
  106205. * @param scene defines the hosting scene
  106206. */
  106207. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106208. /**
  106209. * Gets camera class name
  106210. * @returns AnaglyphFreeCamera
  106211. */
  106212. getClassName(): string;
  106213. }
  106214. }
  106215. declare module BABYLON {
  106216. /**
  106217. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106218. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106219. */
  106220. export class AnaglyphGamepadCamera extends GamepadCamera {
  106221. /**
  106222. * Creates a new AnaglyphGamepadCamera
  106223. * @param name defines camera name
  106224. * @param position defines initial position
  106225. * @param interaxialDistance defines distance between each color axis
  106226. * @param scene defines the hosting scene
  106227. */
  106228. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106229. /**
  106230. * Gets camera class name
  106231. * @returns AnaglyphGamepadCamera
  106232. */
  106233. getClassName(): string;
  106234. }
  106235. }
  106236. declare module BABYLON {
  106237. /**
  106238. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106239. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106240. */
  106241. export class AnaglyphUniversalCamera extends UniversalCamera {
  106242. /**
  106243. * Creates a new AnaglyphUniversalCamera
  106244. * @param name defines camera name
  106245. * @param position defines initial position
  106246. * @param interaxialDistance defines distance between each color axis
  106247. * @param scene defines the hosting scene
  106248. */
  106249. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106250. /**
  106251. * Gets camera class name
  106252. * @returns AnaglyphUniversalCamera
  106253. */
  106254. getClassName(): string;
  106255. }
  106256. }
  106257. declare module BABYLON {
  106258. /** @hidden */
  106259. export var stereoscopicInterlacePixelShader: {
  106260. name: string;
  106261. shader: string;
  106262. };
  106263. }
  106264. declare module BABYLON {
  106265. /**
  106266. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106267. */
  106268. export class StereoscopicInterlacePostProcess extends PostProcess {
  106269. private _stepSize;
  106270. private _passedProcess;
  106271. /**
  106272. * Initializes a StereoscopicInterlacePostProcess
  106273. * @param name The name of the effect.
  106274. * @param rigCameras The rig cameras to be appled to the post process
  106275. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106277. * @param engine The engine which the post process will be applied. (default: current engine)
  106278. * @param reusable If the post process can be reused on the same frame. (default: false)
  106279. */
  106280. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106281. }
  106282. }
  106283. declare module BABYLON {
  106284. /**
  106285. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106286. * @see http://doc.babylonjs.com/features/cameras
  106287. */
  106288. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106289. /**
  106290. * Creates a new StereoscopicArcRotateCamera
  106291. * @param name defines camera name
  106292. * @param alpha defines alpha angle (in radians)
  106293. * @param beta defines beta angle (in radians)
  106294. * @param radius defines radius
  106295. * @param target defines camera target
  106296. * @param interaxialDistance defines distance between each color axis
  106297. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106298. * @param scene defines the hosting scene
  106299. */
  106300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106301. /**
  106302. * Gets camera class name
  106303. * @returns StereoscopicArcRotateCamera
  106304. */
  106305. getClassName(): string;
  106306. }
  106307. }
  106308. declare module BABYLON {
  106309. /**
  106310. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106311. * @see http://doc.babylonjs.com/features/cameras
  106312. */
  106313. export class StereoscopicFreeCamera extends FreeCamera {
  106314. /**
  106315. * Creates a new StereoscopicFreeCamera
  106316. * @param name defines camera name
  106317. * @param position defines initial position
  106318. * @param interaxialDistance defines distance between each color axis
  106319. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106320. * @param scene defines the hosting scene
  106321. */
  106322. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106323. /**
  106324. * Gets camera class name
  106325. * @returns StereoscopicFreeCamera
  106326. */
  106327. getClassName(): string;
  106328. }
  106329. }
  106330. declare module BABYLON {
  106331. /**
  106332. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106333. * @see http://doc.babylonjs.com/features/cameras
  106334. */
  106335. export class StereoscopicGamepadCamera extends GamepadCamera {
  106336. /**
  106337. * Creates a new StereoscopicGamepadCamera
  106338. * @param name defines camera name
  106339. * @param position defines initial position
  106340. * @param interaxialDistance defines distance between each color axis
  106341. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106342. * @param scene defines the hosting scene
  106343. */
  106344. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106345. /**
  106346. * Gets camera class name
  106347. * @returns StereoscopicGamepadCamera
  106348. */
  106349. getClassName(): string;
  106350. }
  106351. }
  106352. declare module BABYLON {
  106353. /**
  106354. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106355. * @see http://doc.babylonjs.com/features/cameras
  106356. */
  106357. export class StereoscopicUniversalCamera extends UniversalCamera {
  106358. /**
  106359. * Creates a new StereoscopicUniversalCamera
  106360. * @param name defines camera name
  106361. * @param position defines initial position
  106362. * @param interaxialDistance defines distance between each color axis
  106363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106364. * @param scene defines the hosting scene
  106365. */
  106366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106367. /**
  106368. * Gets camera class name
  106369. * @returns StereoscopicUniversalCamera
  106370. */
  106371. getClassName(): string;
  106372. }
  106373. }
  106374. declare module BABYLON {
  106375. /**
  106376. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106377. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106378. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106379. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106380. */
  106381. export class VirtualJoysticksCamera extends FreeCamera {
  106382. /**
  106383. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106384. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106385. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106386. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106387. * @param name Define the name of the camera in the scene
  106388. * @param position Define the start position of the camera in the scene
  106389. * @param scene Define the scene the camera belongs to
  106390. */
  106391. constructor(name: string, position: Vector3, scene: Scene);
  106392. /**
  106393. * Gets the current object class name.
  106394. * @return the class name
  106395. */
  106396. getClassName(): string;
  106397. }
  106398. }
  106399. declare module BABYLON {
  106400. /**
  106401. * This represents all the required metrics to create a VR camera.
  106402. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106403. */
  106404. export class VRCameraMetrics {
  106405. /**
  106406. * Define the horizontal resolution off the screen.
  106407. */
  106408. hResolution: number;
  106409. /**
  106410. * Define the vertical resolution off the screen.
  106411. */
  106412. vResolution: number;
  106413. /**
  106414. * Define the horizontal screen size.
  106415. */
  106416. hScreenSize: number;
  106417. /**
  106418. * Define the vertical screen size.
  106419. */
  106420. vScreenSize: number;
  106421. /**
  106422. * Define the vertical screen center position.
  106423. */
  106424. vScreenCenter: number;
  106425. /**
  106426. * Define the distance of the eyes to the screen.
  106427. */
  106428. eyeToScreenDistance: number;
  106429. /**
  106430. * Define the distance between both lenses
  106431. */
  106432. lensSeparationDistance: number;
  106433. /**
  106434. * Define the distance between both viewer's eyes.
  106435. */
  106436. interpupillaryDistance: number;
  106437. /**
  106438. * Define the distortion factor of the VR postprocess.
  106439. * Please, touch with care.
  106440. */
  106441. distortionK: number[];
  106442. /**
  106443. * Define the chromatic aberration correction factors for the VR post process.
  106444. */
  106445. chromaAbCorrection: number[];
  106446. /**
  106447. * Define the scale factor of the post process.
  106448. * The smaller the better but the slower.
  106449. */
  106450. postProcessScaleFactor: number;
  106451. /**
  106452. * Define an offset for the lens center.
  106453. */
  106454. lensCenterOffset: number;
  106455. /**
  106456. * Define if the current vr camera should compensate the distortion of the lense or not.
  106457. */
  106458. compensateDistortion: boolean;
  106459. /**
  106460. * Defines if multiview should be enabled when rendering (Default: false)
  106461. */
  106462. multiviewEnabled: boolean;
  106463. /**
  106464. * Gets the rendering aspect ratio based on the provided resolutions.
  106465. */
  106466. readonly aspectRatio: number;
  106467. /**
  106468. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106469. */
  106470. readonly aspectRatioFov: number;
  106471. /**
  106472. * @hidden
  106473. */
  106474. readonly leftHMatrix: Matrix;
  106475. /**
  106476. * @hidden
  106477. */
  106478. readonly rightHMatrix: Matrix;
  106479. /**
  106480. * @hidden
  106481. */
  106482. readonly leftPreViewMatrix: Matrix;
  106483. /**
  106484. * @hidden
  106485. */
  106486. readonly rightPreViewMatrix: Matrix;
  106487. /**
  106488. * Get the default VRMetrics based on the most generic setup.
  106489. * @returns the default vr metrics
  106490. */
  106491. static GetDefault(): VRCameraMetrics;
  106492. }
  106493. }
  106494. declare module BABYLON {
  106495. /** @hidden */
  106496. export var vrDistortionCorrectionPixelShader: {
  106497. name: string;
  106498. shader: string;
  106499. };
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * VRDistortionCorrectionPostProcess used for mobile VR
  106504. */
  106505. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106506. private _isRightEye;
  106507. private _distortionFactors;
  106508. private _postProcessScaleFactor;
  106509. private _lensCenterOffset;
  106510. private _scaleIn;
  106511. private _scaleFactor;
  106512. private _lensCenter;
  106513. /**
  106514. * Initializes the VRDistortionCorrectionPostProcess
  106515. * @param name The name of the effect.
  106516. * @param camera The camera to apply the render pass to.
  106517. * @param isRightEye If this is for the right eye distortion
  106518. * @param vrMetrics All the required metrics for the VR camera
  106519. */
  106520. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106521. }
  106522. }
  106523. declare module BABYLON {
  106524. /**
  106525. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106526. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106527. */
  106528. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106529. /**
  106530. * Creates a new VRDeviceOrientationArcRotateCamera
  106531. * @param name defines camera name
  106532. * @param alpha defines the camera rotation along the logitudinal axis
  106533. * @param beta defines the camera rotation along the latitudinal axis
  106534. * @param radius defines the camera distance from its target
  106535. * @param target defines the camera target
  106536. * @param scene defines the scene the camera belongs to
  106537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106539. */
  106540. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106541. /**
  106542. * Gets camera class name
  106543. * @returns VRDeviceOrientationArcRotateCamera
  106544. */
  106545. getClassName(): string;
  106546. }
  106547. }
  106548. declare module BABYLON {
  106549. /**
  106550. * Camera used to simulate VR rendering (based on FreeCamera)
  106551. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106552. */
  106553. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106554. /**
  106555. * Creates a new VRDeviceOrientationFreeCamera
  106556. * @param name defines camera name
  106557. * @param position defines the start position of the camera
  106558. * @param scene defines the scene the camera belongs to
  106559. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106560. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106561. */
  106562. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106563. /**
  106564. * Gets camera class name
  106565. * @returns VRDeviceOrientationFreeCamera
  106566. */
  106567. getClassName(): string;
  106568. }
  106569. }
  106570. declare module BABYLON {
  106571. /**
  106572. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106573. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106574. */
  106575. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106576. /**
  106577. * Creates a new VRDeviceOrientationGamepadCamera
  106578. * @param name defines camera name
  106579. * @param position defines the start position of the camera
  106580. * @param scene defines the scene the camera belongs to
  106581. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106582. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106583. */
  106584. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106585. /**
  106586. * Gets camera class name
  106587. * @returns VRDeviceOrientationGamepadCamera
  106588. */
  106589. getClassName(): string;
  106590. }
  106591. }
  106592. declare module BABYLON {
  106593. /**
  106594. * Base class of materials working in push mode in babylon JS
  106595. * @hidden
  106596. */
  106597. export class PushMaterial extends Material {
  106598. protected _activeEffect: Effect;
  106599. protected _normalMatrix: Matrix;
  106600. /**
  106601. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106602. * This means that the material can keep using a previous shader while a new one is being compiled.
  106603. * This is mostly used when shader parallel compilation is supported (true by default)
  106604. */
  106605. allowShaderHotSwapping: boolean;
  106606. constructor(name: string, scene: Scene);
  106607. getEffect(): Effect;
  106608. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106609. /**
  106610. * Binds the given world matrix to the active effect
  106611. *
  106612. * @param world the matrix to bind
  106613. */
  106614. bindOnlyWorldMatrix(world: Matrix): void;
  106615. /**
  106616. * Binds the given normal matrix to the active effect
  106617. *
  106618. * @param normalMatrix the matrix to bind
  106619. */
  106620. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106621. bind(world: Matrix, mesh?: Mesh): void;
  106622. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106623. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106624. }
  106625. }
  106626. declare module BABYLON {
  106627. /**
  106628. * This groups all the flags used to control the materials channel.
  106629. */
  106630. export class MaterialFlags {
  106631. private static _DiffuseTextureEnabled;
  106632. /**
  106633. * Are diffuse textures enabled in the application.
  106634. */
  106635. static DiffuseTextureEnabled: boolean;
  106636. private static _AmbientTextureEnabled;
  106637. /**
  106638. * Are ambient textures enabled in the application.
  106639. */
  106640. static AmbientTextureEnabled: boolean;
  106641. private static _OpacityTextureEnabled;
  106642. /**
  106643. * Are opacity textures enabled in the application.
  106644. */
  106645. static OpacityTextureEnabled: boolean;
  106646. private static _ReflectionTextureEnabled;
  106647. /**
  106648. * Are reflection textures enabled in the application.
  106649. */
  106650. static ReflectionTextureEnabled: boolean;
  106651. private static _EmissiveTextureEnabled;
  106652. /**
  106653. * Are emissive textures enabled in the application.
  106654. */
  106655. static EmissiveTextureEnabled: boolean;
  106656. private static _SpecularTextureEnabled;
  106657. /**
  106658. * Are specular textures enabled in the application.
  106659. */
  106660. static SpecularTextureEnabled: boolean;
  106661. private static _BumpTextureEnabled;
  106662. /**
  106663. * Are bump textures enabled in the application.
  106664. */
  106665. static BumpTextureEnabled: boolean;
  106666. private static _LightmapTextureEnabled;
  106667. /**
  106668. * Are lightmap textures enabled in the application.
  106669. */
  106670. static LightmapTextureEnabled: boolean;
  106671. private static _RefractionTextureEnabled;
  106672. /**
  106673. * Are refraction textures enabled in the application.
  106674. */
  106675. static RefractionTextureEnabled: boolean;
  106676. private static _ColorGradingTextureEnabled;
  106677. /**
  106678. * Are color grading textures enabled in the application.
  106679. */
  106680. static ColorGradingTextureEnabled: boolean;
  106681. private static _FresnelEnabled;
  106682. /**
  106683. * Are fresnels enabled in the application.
  106684. */
  106685. static FresnelEnabled: boolean;
  106686. private static _ClearCoatTextureEnabled;
  106687. /**
  106688. * Are clear coat textures enabled in the application.
  106689. */
  106690. static ClearCoatTextureEnabled: boolean;
  106691. private static _ClearCoatBumpTextureEnabled;
  106692. /**
  106693. * Are clear coat bump textures enabled in the application.
  106694. */
  106695. static ClearCoatBumpTextureEnabled: boolean;
  106696. private static _ClearCoatTintTextureEnabled;
  106697. /**
  106698. * Are clear coat tint textures enabled in the application.
  106699. */
  106700. static ClearCoatTintTextureEnabled: boolean;
  106701. private static _SheenTextureEnabled;
  106702. /**
  106703. * Are sheen textures enabled in the application.
  106704. */
  106705. static SheenTextureEnabled: boolean;
  106706. private static _AnisotropicTextureEnabled;
  106707. /**
  106708. * Are anisotropic textures enabled in the application.
  106709. */
  106710. static AnisotropicTextureEnabled: boolean;
  106711. private static _ThicknessTextureEnabled;
  106712. /**
  106713. * Are thickness textures enabled in the application.
  106714. */
  106715. static ThicknessTextureEnabled: boolean;
  106716. }
  106717. }
  106718. declare module BABYLON {
  106719. /** @hidden */
  106720. export var defaultFragmentDeclaration: {
  106721. name: string;
  106722. shader: string;
  106723. };
  106724. }
  106725. declare module BABYLON {
  106726. /** @hidden */
  106727. export var defaultUboDeclaration: {
  106728. name: string;
  106729. shader: string;
  106730. };
  106731. }
  106732. declare module BABYLON {
  106733. /** @hidden */
  106734. export var lightFragmentDeclaration: {
  106735. name: string;
  106736. shader: string;
  106737. };
  106738. }
  106739. declare module BABYLON {
  106740. /** @hidden */
  106741. export var lightUboDeclaration: {
  106742. name: string;
  106743. shader: string;
  106744. };
  106745. }
  106746. declare module BABYLON {
  106747. /** @hidden */
  106748. export var lightsFragmentFunctions: {
  106749. name: string;
  106750. shader: string;
  106751. };
  106752. }
  106753. declare module BABYLON {
  106754. /** @hidden */
  106755. export var shadowsFragmentFunctions: {
  106756. name: string;
  106757. shader: string;
  106758. };
  106759. }
  106760. declare module BABYLON {
  106761. /** @hidden */
  106762. export var fresnelFunction: {
  106763. name: string;
  106764. shader: string;
  106765. };
  106766. }
  106767. declare module BABYLON {
  106768. /** @hidden */
  106769. export var reflectionFunction: {
  106770. name: string;
  106771. shader: string;
  106772. };
  106773. }
  106774. declare module BABYLON {
  106775. /** @hidden */
  106776. export var bumpFragmentFunctions: {
  106777. name: string;
  106778. shader: string;
  106779. };
  106780. }
  106781. declare module BABYLON {
  106782. /** @hidden */
  106783. export var logDepthDeclaration: {
  106784. name: string;
  106785. shader: string;
  106786. };
  106787. }
  106788. declare module BABYLON {
  106789. /** @hidden */
  106790. export var bumpFragment: {
  106791. name: string;
  106792. shader: string;
  106793. };
  106794. }
  106795. declare module BABYLON {
  106796. /** @hidden */
  106797. export var depthPrePass: {
  106798. name: string;
  106799. shader: string;
  106800. };
  106801. }
  106802. declare module BABYLON {
  106803. /** @hidden */
  106804. export var lightFragment: {
  106805. name: string;
  106806. shader: string;
  106807. };
  106808. }
  106809. declare module BABYLON {
  106810. /** @hidden */
  106811. export var logDepthFragment: {
  106812. name: string;
  106813. shader: string;
  106814. };
  106815. }
  106816. declare module BABYLON {
  106817. /** @hidden */
  106818. export var defaultPixelShader: {
  106819. name: string;
  106820. shader: string;
  106821. };
  106822. }
  106823. declare module BABYLON {
  106824. /** @hidden */
  106825. export var defaultVertexDeclaration: {
  106826. name: string;
  106827. shader: string;
  106828. };
  106829. }
  106830. declare module BABYLON {
  106831. /** @hidden */
  106832. export var bumpVertexDeclaration: {
  106833. name: string;
  106834. shader: string;
  106835. };
  106836. }
  106837. declare module BABYLON {
  106838. /** @hidden */
  106839. export var bumpVertex: {
  106840. name: string;
  106841. shader: string;
  106842. };
  106843. }
  106844. declare module BABYLON {
  106845. /** @hidden */
  106846. export var fogVertex: {
  106847. name: string;
  106848. shader: string;
  106849. };
  106850. }
  106851. declare module BABYLON {
  106852. /** @hidden */
  106853. export var shadowsVertex: {
  106854. name: string;
  106855. shader: string;
  106856. };
  106857. }
  106858. declare module BABYLON {
  106859. /** @hidden */
  106860. export var pointCloudVertex: {
  106861. name: string;
  106862. shader: string;
  106863. };
  106864. }
  106865. declare module BABYLON {
  106866. /** @hidden */
  106867. export var logDepthVertex: {
  106868. name: string;
  106869. shader: string;
  106870. };
  106871. }
  106872. declare module BABYLON {
  106873. /** @hidden */
  106874. export var defaultVertexShader: {
  106875. name: string;
  106876. shader: string;
  106877. };
  106878. }
  106879. declare module BABYLON {
  106880. /** @hidden */
  106881. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106882. MAINUV1: boolean;
  106883. MAINUV2: boolean;
  106884. DIFFUSE: boolean;
  106885. DIFFUSEDIRECTUV: number;
  106886. AMBIENT: boolean;
  106887. AMBIENTDIRECTUV: number;
  106888. OPACITY: boolean;
  106889. OPACITYDIRECTUV: number;
  106890. OPACITYRGB: boolean;
  106891. REFLECTION: boolean;
  106892. EMISSIVE: boolean;
  106893. EMISSIVEDIRECTUV: number;
  106894. SPECULAR: boolean;
  106895. SPECULARDIRECTUV: number;
  106896. BUMP: boolean;
  106897. BUMPDIRECTUV: number;
  106898. PARALLAX: boolean;
  106899. PARALLAXOCCLUSION: boolean;
  106900. SPECULAROVERALPHA: boolean;
  106901. CLIPPLANE: boolean;
  106902. CLIPPLANE2: boolean;
  106903. CLIPPLANE3: boolean;
  106904. CLIPPLANE4: boolean;
  106905. ALPHATEST: boolean;
  106906. DEPTHPREPASS: boolean;
  106907. ALPHAFROMDIFFUSE: boolean;
  106908. POINTSIZE: boolean;
  106909. FOG: boolean;
  106910. SPECULARTERM: boolean;
  106911. DIFFUSEFRESNEL: boolean;
  106912. OPACITYFRESNEL: boolean;
  106913. REFLECTIONFRESNEL: boolean;
  106914. REFRACTIONFRESNEL: boolean;
  106915. EMISSIVEFRESNEL: boolean;
  106916. FRESNEL: boolean;
  106917. NORMAL: boolean;
  106918. UV1: boolean;
  106919. UV2: boolean;
  106920. VERTEXCOLOR: boolean;
  106921. VERTEXALPHA: boolean;
  106922. NUM_BONE_INFLUENCERS: number;
  106923. BonesPerMesh: number;
  106924. BONETEXTURE: boolean;
  106925. INSTANCES: boolean;
  106926. GLOSSINESS: boolean;
  106927. ROUGHNESS: boolean;
  106928. EMISSIVEASILLUMINATION: boolean;
  106929. LINKEMISSIVEWITHDIFFUSE: boolean;
  106930. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106931. LIGHTMAP: boolean;
  106932. LIGHTMAPDIRECTUV: number;
  106933. OBJECTSPACE_NORMALMAP: boolean;
  106934. USELIGHTMAPASSHADOWMAP: boolean;
  106935. REFLECTIONMAP_3D: boolean;
  106936. REFLECTIONMAP_SPHERICAL: boolean;
  106937. REFLECTIONMAP_PLANAR: boolean;
  106938. REFLECTIONMAP_CUBIC: boolean;
  106939. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106940. REFLECTIONMAP_PROJECTION: boolean;
  106941. REFLECTIONMAP_SKYBOX: boolean;
  106942. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106943. REFLECTIONMAP_EXPLICIT: boolean;
  106944. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106945. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106946. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106947. INVERTCUBICMAP: boolean;
  106948. LOGARITHMICDEPTH: boolean;
  106949. REFRACTION: boolean;
  106950. REFRACTIONMAP_3D: boolean;
  106951. REFLECTIONOVERALPHA: boolean;
  106952. TWOSIDEDLIGHTING: boolean;
  106953. SHADOWFLOAT: boolean;
  106954. MORPHTARGETS: boolean;
  106955. MORPHTARGETS_NORMAL: boolean;
  106956. MORPHTARGETS_TANGENT: boolean;
  106957. MORPHTARGETS_UV: boolean;
  106958. NUM_MORPH_INFLUENCERS: number;
  106959. NONUNIFORMSCALING: boolean;
  106960. PREMULTIPLYALPHA: boolean;
  106961. IMAGEPROCESSING: boolean;
  106962. VIGNETTE: boolean;
  106963. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106964. VIGNETTEBLENDMODEOPAQUE: boolean;
  106965. TONEMAPPING: boolean;
  106966. TONEMAPPING_ACES: boolean;
  106967. CONTRAST: boolean;
  106968. COLORCURVES: boolean;
  106969. COLORGRADING: boolean;
  106970. COLORGRADING3D: boolean;
  106971. SAMPLER3DGREENDEPTH: boolean;
  106972. SAMPLER3DBGRMAP: boolean;
  106973. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106974. MULTIVIEW: boolean;
  106975. /**
  106976. * If the reflection texture on this material is in linear color space
  106977. * @hidden
  106978. */
  106979. IS_REFLECTION_LINEAR: boolean;
  106980. /**
  106981. * If the refraction texture on this material is in linear color space
  106982. * @hidden
  106983. */
  106984. IS_REFRACTION_LINEAR: boolean;
  106985. EXPOSURE: boolean;
  106986. constructor();
  106987. setReflectionMode(modeToEnable: string): void;
  106988. }
  106989. /**
  106990. * This is the default material used in Babylon. It is the best trade off between quality
  106991. * and performances.
  106992. * @see http://doc.babylonjs.com/babylon101/materials
  106993. */
  106994. export class StandardMaterial extends PushMaterial {
  106995. private _diffuseTexture;
  106996. /**
  106997. * The basic texture of the material as viewed under a light.
  106998. */
  106999. diffuseTexture: Nullable<BaseTexture>;
  107000. private _ambientTexture;
  107001. /**
  107002. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107003. */
  107004. ambientTexture: Nullable<BaseTexture>;
  107005. private _opacityTexture;
  107006. /**
  107007. * Define the transparency of the material from a texture.
  107008. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107009. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107010. */
  107011. opacityTexture: Nullable<BaseTexture>;
  107012. private _reflectionTexture;
  107013. /**
  107014. * Define the texture used to display the reflection.
  107015. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107016. */
  107017. reflectionTexture: Nullable<BaseTexture>;
  107018. private _emissiveTexture;
  107019. /**
  107020. * Define texture of the material as if self lit.
  107021. * This will be mixed in the final result even in the absence of light.
  107022. */
  107023. emissiveTexture: Nullable<BaseTexture>;
  107024. private _specularTexture;
  107025. /**
  107026. * Define how the color and intensity of the highlight given by the light in the material.
  107027. */
  107028. specularTexture: Nullable<BaseTexture>;
  107029. private _bumpTexture;
  107030. /**
  107031. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107032. * 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.
  107033. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107034. */
  107035. bumpTexture: Nullable<BaseTexture>;
  107036. private _lightmapTexture;
  107037. /**
  107038. * Complex lighting can be computationally expensive to compute at runtime.
  107039. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107040. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107041. */
  107042. lightmapTexture: Nullable<BaseTexture>;
  107043. private _refractionTexture;
  107044. /**
  107045. * Define the texture used to display the refraction.
  107046. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107047. */
  107048. refractionTexture: Nullable<BaseTexture>;
  107049. /**
  107050. * The color of the material lit by the environmental background lighting.
  107051. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107052. */
  107053. ambientColor: Color3;
  107054. /**
  107055. * The basic color of the material as viewed under a light.
  107056. */
  107057. diffuseColor: Color3;
  107058. /**
  107059. * Define how the color and intensity of the highlight given by the light in the material.
  107060. */
  107061. specularColor: Color3;
  107062. /**
  107063. * Define the color of the material as if self lit.
  107064. * This will be mixed in the final result even in the absence of light.
  107065. */
  107066. emissiveColor: Color3;
  107067. /**
  107068. * Defines how sharp are the highlights in the material.
  107069. * The bigger the value the sharper giving a more glossy feeling to the result.
  107070. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107071. */
  107072. specularPower: number;
  107073. private _useAlphaFromDiffuseTexture;
  107074. /**
  107075. * Does the transparency come from the diffuse texture alpha channel.
  107076. */
  107077. useAlphaFromDiffuseTexture: boolean;
  107078. private _useEmissiveAsIllumination;
  107079. /**
  107080. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107081. */
  107082. useEmissiveAsIllumination: boolean;
  107083. private _linkEmissiveWithDiffuse;
  107084. /**
  107085. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107086. * the emissive level when the final color is close to one.
  107087. */
  107088. linkEmissiveWithDiffuse: boolean;
  107089. private _useSpecularOverAlpha;
  107090. /**
  107091. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107092. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107093. */
  107094. useSpecularOverAlpha: boolean;
  107095. private _useReflectionOverAlpha;
  107096. /**
  107097. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107098. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107099. */
  107100. useReflectionOverAlpha: boolean;
  107101. private _disableLighting;
  107102. /**
  107103. * Does lights from the scene impacts this material.
  107104. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107105. */
  107106. disableLighting: boolean;
  107107. private _useObjectSpaceNormalMap;
  107108. /**
  107109. * Allows using an object space normal map (instead of tangent space).
  107110. */
  107111. useObjectSpaceNormalMap: boolean;
  107112. private _useParallax;
  107113. /**
  107114. * Is parallax enabled or not.
  107115. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107116. */
  107117. useParallax: boolean;
  107118. private _useParallaxOcclusion;
  107119. /**
  107120. * Is parallax occlusion enabled or not.
  107121. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107122. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107123. */
  107124. useParallaxOcclusion: boolean;
  107125. /**
  107126. * 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.
  107127. */
  107128. parallaxScaleBias: number;
  107129. private _roughness;
  107130. /**
  107131. * Helps to define how blurry the reflections should appears in the material.
  107132. */
  107133. roughness: number;
  107134. /**
  107135. * In case of refraction, define the value of the index of refraction.
  107136. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107137. */
  107138. indexOfRefraction: number;
  107139. /**
  107140. * Invert the refraction texture alongside the y axis.
  107141. * It can be useful with procedural textures or probe for instance.
  107142. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107143. */
  107144. invertRefractionY: boolean;
  107145. /**
  107146. * Defines the alpha limits in alpha test mode.
  107147. */
  107148. alphaCutOff: number;
  107149. private _useLightmapAsShadowmap;
  107150. /**
  107151. * In case of light mapping, define whether the map contains light or shadow informations.
  107152. */
  107153. useLightmapAsShadowmap: boolean;
  107154. private _diffuseFresnelParameters;
  107155. /**
  107156. * Define the diffuse fresnel parameters of the material.
  107157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107158. */
  107159. diffuseFresnelParameters: FresnelParameters;
  107160. private _opacityFresnelParameters;
  107161. /**
  107162. * Define the opacity fresnel parameters of the material.
  107163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107164. */
  107165. opacityFresnelParameters: FresnelParameters;
  107166. private _reflectionFresnelParameters;
  107167. /**
  107168. * Define the reflection fresnel parameters of the material.
  107169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107170. */
  107171. reflectionFresnelParameters: FresnelParameters;
  107172. private _refractionFresnelParameters;
  107173. /**
  107174. * Define the refraction fresnel parameters of the material.
  107175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107176. */
  107177. refractionFresnelParameters: FresnelParameters;
  107178. private _emissiveFresnelParameters;
  107179. /**
  107180. * Define the emissive fresnel parameters of the material.
  107181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107182. */
  107183. emissiveFresnelParameters: FresnelParameters;
  107184. private _useReflectionFresnelFromSpecular;
  107185. /**
  107186. * If true automatically deducts the fresnels values from the material specularity.
  107187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107188. */
  107189. useReflectionFresnelFromSpecular: boolean;
  107190. private _useGlossinessFromSpecularMapAlpha;
  107191. /**
  107192. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107193. */
  107194. useGlossinessFromSpecularMapAlpha: boolean;
  107195. private _maxSimultaneousLights;
  107196. /**
  107197. * Defines the maximum number of lights that can be used in the material
  107198. */
  107199. maxSimultaneousLights: number;
  107200. private _invertNormalMapX;
  107201. /**
  107202. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107203. */
  107204. invertNormalMapX: boolean;
  107205. private _invertNormalMapY;
  107206. /**
  107207. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107208. */
  107209. invertNormalMapY: boolean;
  107210. private _twoSidedLighting;
  107211. /**
  107212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107213. */
  107214. twoSidedLighting: boolean;
  107215. /**
  107216. * Default configuration related to image processing available in the standard Material.
  107217. */
  107218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107219. /**
  107220. * Gets the image processing configuration used either in this material.
  107221. */
  107222. /**
  107223. * Sets the Default image processing configuration used either in the this material.
  107224. *
  107225. * If sets to null, the scene one is in use.
  107226. */
  107227. imageProcessingConfiguration: ImageProcessingConfiguration;
  107228. /**
  107229. * Keep track of the image processing observer to allow dispose and replace.
  107230. */
  107231. private _imageProcessingObserver;
  107232. /**
  107233. * Attaches a new image processing configuration to the Standard Material.
  107234. * @param configuration
  107235. */
  107236. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107237. /**
  107238. * Gets wether the color curves effect is enabled.
  107239. */
  107240. /**
  107241. * Sets wether the color curves effect is enabled.
  107242. */
  107243. cameraColorCurvesEnabled: boolean;
  107244. /**
  107245. * Gets wether the color grading effect is enabled.
  107246. */
  107247. /**
  107248. * Gets wether the color grading effect is enabled.
  107249. */
  107250. cameraColorGradingEnabled: boolean;
  107251. /**
  107252. * Gets wether tonemapping is enabled or not.
  107253. */
  107254. /**
  107255. * Sets wether tonemapping is enabled or not
  107256. */
  107257. cameraToneMappingEnabled: boolean;
  107258. /**
  107259. * The camera exposure used on this material.
  107260. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107261. * This corresponds to a photographic exposure.
  107262. */
  107263. /**
  107264. * The camera exposure used on this material.
  107265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107266. * This corresponds to a photographic exposure.
  107267. */
  107268. cameraExposure: number;
  107269. /**
  107270. * Gets The camera contrast used on this material.
  107271. */
  107272. /**
  107273. * Sets The camera contrast used on this material.
  107274. */
  107275. cameraContrast: number;
  107276. /**
  107277. * Gets the Color Grading 2D Lookup Texture.
  107278. */
  107279. /**
  107280. * Sets the Color Grading 2D Lookup Texture.
  107281. */
  107282. cameraColorGradingTexture: Nullable<BaseTexture>;
  107283. /**
  107284. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107285. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107286. * 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;
  107287. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107288. */
  107289. /**
  107290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107292. * 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;
  107293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107294. */
  107295. cameraColorCurves: Nullable<ColorCurves>;
  107296. /**
  107297. * Custom callback helping to override the default shader used in the material.
  107298. */
  107299. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107300. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107301. protected _worldViewProjectionMatrix: Matrix;
  107302. protected _globalAmbientColor: Color3;
  107303. protected _useLogarithmicDepth: boolean;
  107304. protected _rebuildInParallel: boolean;
  107305. /**
  107306. * Instantiates a new standard material.
  107307. * This is the default material used in Babylon. It is the best trade off between quality
  107308. * and performances.
  107309. * @see http://doc.babylonjs.com/babylon101/materials
  107310. * @param name Define the name of the material in the scene
  107311. * @param scene Define the scene the material belong to
  107312. */
  107313. constructor(name: string, scene: Scene);
  107314. /**
  107315. * Gets a boolean indicating that current material needs to register RTT
  107316. */
  107317. readonly hasRenderTargetTextures: boolean;
  107318. /**
  107319. * Gets the current class name of the material e.g. "StandardMaterial"
  107320. * Mainly use in serialization.
  107321. * @returns the class name
  107322. */
  107323. getClassName(): string;
  107324. /**
  107325. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107326. * You can try switching to logarithmic depth.
  107327. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107328. */
  107329. useLogarithmicDepth: boolean;
  107330. /**
  107331. * Specifies if the material will require alpha blending
  107332. * @returns a boolean specifying if alpha blending is needed
  107333. */
  107334. needAlphaBlending(): boolean;
  107335. /**
  107336. * Specifies if this material should be rendered in alpha test mode
  107337. * @returns a boolean specifying if an alpha test is needed.
  107338. */
  107339. needAlphaTesting(): boolean;
  107340. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107341. /**
  107342. * Get the texture used for alpha test purpose.
  107343. * @returns the diffuse texture in case of the standard material.
  107344. */
  107345. getAlphaTestTexture(): Nullable<BaseTexture>;
  107346. /**
  107347. * Get if the submesh is ready to be used and all its information available.
  107348. * Child classes can use it to update shaders
  107349. * @param mesh defines the mesh to check
  107350. * @param subMesh defines which submesh to check
  107351. * @param useInstances specifies that instances should be used
  107352. * @returns a boolean indicating that the submesh is ready or not
  107353. */
  107354. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107355. /**
  107356. * Builds the material UBO layouts.
  107357. * Used internally during the effect preparation.
  107358. */
  107359. buildUniformLayout(): void;
  107360. /**
  107361. * Unbinds the material from the mesh
  107362. */
  107363. unbind(): void;
  107364. /**
  107365. * Binds the submesh to this material by preparing the effect and shader to draw
  107366. * @param world defines the world transformation matrix
  107367. * @param mesh defines the mesh containing the submesh
  107368. * @param subMesh defines the submesh to bind the material to
  107369. */
  107370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107371. /**
  107372. * Get the list of animatables in the material.
  107373. * @returns the list of animatables object used in the material
  107374. */
  107375. getAnimatables(): IAnimatable[];
  107376. /**
  107377. * Gets the active textures from the material
  107378. * @returns an array of textures
  107379. */
  107380. getActiveTextures(): BaseTexture[];
  107381. /**
  107382. * Specifies if the material uses a texture
  107383. * @param texture defines the texture to check against the material
  107384. * @returns a boolean specifying if the material uses the texture
  107385. */
  107386. hasTexture(texture: BaseTexture): boolean;
  107387. /**
  107388. * Disposes the material
  107389. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107390. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107391. */
  107392. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107393. /**
  107394. * Makes a duplicate of the material, and gives it a new name
  107395. * @param name defines the new name for the duplicated material
  107396. * @returns the cloned material
  107397. */
  107398. clone(name: string): StandardMaterial;
  107399. /**
  107400. * Serializes this material in a JSON representation
  107401. * @returns the serialized material object
  107402. */
  107403. serialize(): any;
  107404. /**
  107405. * Creates a standard material from parsed material data
  107406. * @param source defines the JSON representation of the material
  107407. * @param scene defines the hosting scene
  107408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107409. * @returns a new standard material
  107410. */
  107411. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107412. /**
  107413. * Are diffuse textures enabled in the application.
  107414. */
  107415. static DiffuseTextureEnabled: boolean;
  107416. /**
  107417. * Are ambient textures enabled in the application.
  107418. */
  107419. static AmbientTextureEnabled: boolean;
  107420. /**
  107421. * Are opacity textures enabled in the application.
  107422. */
  107423. static OpacityTextureEnabled: boolean;
  107424. /**
  107425. * Are reflection textures enabled in the application.
  107426. */
  107427. static ReflectionTextureEnabled: boolean;
  107428. /**
  107429. * Are emissive textures enabled in the application.
  107430. */
  107431. static EmissiveTextureEnabled: boolean;
  107432. /**
  107433. * Are specular textures enabled in the application.
  107434. */
  107435. static SpecularTextureEnabled: boolean;
  107436. /**
  107437. * Are bump textures enabled in the application.
  107438. */
  107439. static BumpTextureEnabled: boolean;
  107440. /**
  107441. * Are lightmap textures enabled in the application.
  107442. */
  107443. static LightmapTextureEnabled: boolean;
  107444. /**
  107445. * Are refraction textures enabled in the application.
  107446. */
  107447. static RefractionTextureEnabled: boolean;
  107448. /**
  107449. * Are color grading textures enabled in the application.
  107450. */
  107451. static ColorGradingTextureEnabled: boolean;
  107452. /**
  107453. * Are fresnels enabled in the application.
  107454. */
  107455. static FresnelEnabled: boolean;
  107456. }
  107457. }
  107458. declare module BABYLON {
  107459. /** @hidden */
  107460. export var imageProcessingPixelShader: {
  107461. name: string;
  107462. shader: string;
  107463. };
  107464. }
  107465. declare module BABYLON {
  107466. /**
  107467. * ImageProcessingPostProcess
  107468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107469. */
  107470. export class ImageProcessingPostProcess extends PostProcess {
  107471. /**
  107472. * Default configuration related to image processing available in the PBR Material.
  107473. */
  107474. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107475. /**
  107476. * Gets the image processing configuration used either in this material.
  107477. */
  107478. /**
  107479. * Sets the Default image processing configuration used either in the this material.
  107480. *
  107481. * If sets to null, the scene one is in use.
  107482. */
  107483. imageProcessingConfiguration: ImageProcessingConfiguration;
  107484. /**
  107485. * Keep track of the image processing observer to allow dispose and replace.
  107486. */
  107487. private _imageProcessingObserver;
  107488. /**
  107489. * Attaches a new image processing configuration to the PBR Material.
  107490. * @param configuration
  107491. */
  107492. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107493. /**
  107494. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107495. */
  107496. /**
  107497. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107498. */
  107499. colorCurves: Nullable<ColorCurves>;
  107500. /**
  107501. * Gets wether the color curves effect is enabled.
  107502. */
  107503. /**
  107504. * Sets wether the color curves effect is enabled.
  107505. */
  107506. colorCurvesEnabled: boolean;
  107507. /**
  107508. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107509. */
  107510. /**
  107511. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107512. */
  107513. colorGradingTexture: Nullable<BaseTexture>;
  107514. /**
  107515. * Gets wether the color grading effect is enabled.
  107516. */
  107517. /**
  107518. * Gets wether the color grading effect is enabled.
  107519. */
  107520. colorGradingEnabled: boolean;
  107521. /**
  107522. * Gets exposure used in the effect.
  107523. */
  107524. /**
  107525. * Sets exposure used in the effect.
  107526. */
  107527. exposure: number;
  107528. /**
  107529. * Gets wether tonemapping is enabled or not.
  107530. */
  107531. /**
  107532. * Sets wether tonemapping is enabled or not
  107533. */
  107534. toneMappingEnabled: boolean;
  107535. /**
  107536. * Gets the type of tone mapping effect.
  107537. */
  107538. /**
  107539. * Sets the type of tone mapping effect.
  107540. */
  107541. toneMappingType: number;
  107542. /**
  107543. * Gets contrast used in the effect.
  107544. */
  107545. /**
  107546. * Sets contrast used in the effect.
  107547. */
  107548. contrast: number;
  107549. /**
  107550. * Gets Vignette stretch size.
  107551. */
  107552. /**
  107553. * Sets Vignette stretch size.
  107554. */
  107555. vignetteStretch: number;
  107556. /**
  107557. * Gets Vignette centre X Offset.
  107558. */
  107559. /**
  107560. * Sets Vignette centre X Offset.
  107561. */
  107562. vignetteCentreX: number;
  107563. /**
  107564. * Gets Vignette centre Y Offset.
  107565. */
  107566. /**
  107567. * Sets Vignette centre Y Offset.
  107568. */
  107569. vignetteCentreY: number;
  107570. /**
  107571. * Gets Vignette weight or intensity of the vignette effect.
  107572. */
  107573. /**
  107574. * Sets Vignette weight or intensity of the vignette effect.
  107575. */
  107576. vignetteWeight: number;
  107577. /**
  107578. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107579. * if vignetteEnabled is set to true.
  107580. */
  107581. /**
  107582. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107583. * if vignetteEnabled is set to true.
  107584. */
  107585. vignetteColor: Color4;
  107586. /**
  107587. * Gets Camera field of view used by the Vignette effect.
  107588. */
  107589. /**
  107590. * Sets Camera field of view used by the Vignette effect.
  107591. */
  107592. vignetteCameraFov: number;
  107593. /**
  107594. * Gets the vignette blend mode allowing different kind of effect.
  107595. */
  107596. /**
  107597. * Sets the vignette blend mode allowing different kind of effect.
  107598. */
  107599. vignetteBlendMode: number;
  107600. /**
  107601. * Gets wether the vignette effect is enabled.
  107602. */
  107603. /**
  107604. * Sets wether the vignette effect is enabled.
  107605. */
  107606. vignetteEnabled: boolean;
  107607. private _fromLinearSpace;
  107608. /**
  107609. * Gets wether the input of the processing is in Gamma or Linear Space.
  107610. */
  107611. /**
  107612. * Sets wether the input of the processing is in Gamma or Linear Space.
  107613. */
  107614. fromLinearSpace: boolean;
  107615. /**
  107616. * Defines cache preventing GC.
  107617. */
  107618. private _defines;
  107619. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107620. /**
  107621. * "ImageProcessingPostProcess"
  107622. * @returns "ImageProcessingPostProcess"
  107623. */
  107624. getClassName(): string;
  107625. protected _updateParameters(): void;
  107626. dispose(camera?: Camera): void;
  107627. }
  107628. }
  107629. declare module BABYLON {
  107630. /**
  107631. * Class containing static functions to help procedurally build meshes
  107632. */
  107633. export class GroundBuilder {
  107634. /**
  107635. * Creates a ground mesh
  107636. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107637. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107639. * @param name defines the name of the mesh
  107640. * @param options defines the options used to create the mesh
  107641. * @param scene defines the hosting scene
  107642. * @returns the ground mesh
  107643. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107644. */
  107645. static CreateGround(name: string, options: {
  107646. width?: number;
  107647. height?: number;
  107648. subdivisions?: number;
  107649. subdivisionsX?: number;
  107650. subdivisionsY?: number;
  107651. updatable?: boolean;
  107652. }, scene: any): Mesh;
  107653. /**
  107654. * Creates a tiled ground mesh
  107655. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107656. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107657. * * 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
  107658. * * 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
  107659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107660. * @param name defines the name of the mesh
  107661. * @param options defines the options used to create the mesh
  107662. * @param scene defines the hosting scene
  107663. * @returns the tiled ground mesh
  107664. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107665. */
  107666. static CreateTiledGround(name: string, options: {
  107667. xmin: number;
  107668. zmin: number;
  107669. xmax: number;
  107670. zmax: number;
  107671. subdivisions?: {
  107672. w: number;
  107673. h: number;
  107674. };
  107675. precision?: {
  107676. w: number;
  107677. h: number;
  107678. };
  107679. updatable?: boolean;
  107680. }, scene?: Nullable<Scene>): Mesh;
  107681. /**
  107682. * Creates a ground mesh from a height map
  107683. * * The parameter `url` sets the URL of the height map image resource.
  107684. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107685. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107686. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107687. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107688. * * 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.
  107689. * * 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).
  107690. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107692. * @param name defines the name of the mesh
  107693. * @param url defines the url to the height map
  107694. * @param options defines the options used to create the mesh
  107695. * @param scene defines the hosting scene
  107696. * @returns the ground mesh
  107697. * @see https://doc.babylonjs.com/babylon101/height_map
  107698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107699. */
  107700. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107701. width?: number;
  107702. height?: number;
  107703. subdivisions?: number;
  107704. minHeight?: number;
  107705. maxHeight?: number;
  107706. colorFilter?: Color3;
  107707. alphaFilter?: number;
  107708. updatable?: boolean;
  107709. onReady?: (mesh: GroundMesh) => void;
  107710. }, scene?: Nullable<Scene>): GroundMesh;
  107711. }
  107712. }
  107713. declare module BABYLON {
  107714. /**
  107715. * Class containing static functions to help procedurally build meshes
  107716. */
  107717. export class TorusBuilder {
  107718. /**
  107719. * Creates a torus mesh
  107720. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107721. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107722. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107726. * @param name defines the name of the mesh
  107727. * @param options defines the options used to create the mesh
  107728. * @param scene defines the hosting scene
  107729. * @returns the torus mesh
  107730. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107731. */
  107732. static CreateTorus(name: string, options: {
  107733. diameter?: number;
  107734. thickness?: number;
  107735. tessellation?: number;
  107736. updatable?: boolean;
  107737. sideOrientation?: number;
  107738. frontUVs?: Vector4;
  107739. backUVs?: Vector4;
  107740. }, scene: any): Mesh;
  107741. }
  107742. }
  107743. declare module BABYLON {
  107744. /**
  107745. * Class containing static functions to help procedurally build meshes
  107746. */
  107747. export class CylinderBuilder {
  107748. /**
  107749. * Creates a cylinder or a cone mesh
  107750. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107751. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107752. * * 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.
  107753. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107754. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107755. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107756. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107757. * * 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).
  107758. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107759. * * 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).
  107760. * * 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
  107761. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107762. * * 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
  107763. * * 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.
  107764. * * If `enclose` is false, a ring surface is one element.
  107765. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107766. * * 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
  107767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107770. * @param name defines the name of the mesh
  107771. * @param options defines the options used to create the mesh
  107772. * @param scene defines the hosting scene
  107773. * @returns the cylinder mesh
  107774. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107775. */
  107776. static CreateCylinder(name: string, options: {
  107777. height?: number;
  107778. diameterTop?: number;
  107779. diameterBottom?: number;
  107780. diameter?: number;
  107781. tessellation?: number;
  107782. subdivisions?: number;
  107783. arc?: number;
  107784. faceColors?: Color4[];
  107785. faceUV?: Vector4[];
  107786. updatable?: boolean;
  107787. hasRings?: boolean;
  107788. enclose?: boolean;
  107789. cap?: number;
  107790. sideOrientation?: number;
  107791. frontUVs?: Vector4;
  107792. backUVs?: Vector4;
  107793. }, scene: any): Mesh;
  107794. }
  107795. }
  107796. declare module BABYLON {
  107797. /**
  107798. * Options to modify the vr teleportation behavior.
  107799. */
  107800. export interface VRTeleportationOptions {
  107801. /**
  107802. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107803. */
  107804. floorMeshName?: string;
  107805. /**
  107806. * A list of meshes to be used as the teleportation floor. (default: empty)
  107807. */
  107808. floorMeshes?: Mesh[];
  107809. }
  107810. /**
  107811. * Options to modify the vr experience helper's behavior.
  107812. */
  107813. export interface VRExperienceHelperOptions extends WebVROptions {
  107814. /**
  107815. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107816. */
  107817. createDeviceOrientationCamera?: boolean;
  107818. /**
  107819. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107820. */
  107821. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107822. /**
  107823. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107824. */
  107825. laserToggle?: boolean;
  107826. /**
  107827. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107828. */
  107829. floorMeshes?: Mesh[];
  107830. /**
  107831. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107832. */
  107833. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107834. }
  107835. /**
  107836. * Event containing information after VR has been entered
  107837. */
  107838. export class OnAfterEnteringVRObservableEvent {
  107839. /**
  107840. * If entering vr was successful
  107841. */
  107842. success: boolean;
  107843. }
  107844. /**
  107845. * Helps to quickly add VR support to an existing scene.
  107846. * See http://doc.babylonjs.com/how_to/webvr_helper
  107847. */
  107848. export class VRExperienceHelper {
  107849. /** Options to modify the vr experience helper's behavior. */
  107850. webVROptions: VRExperienceHelperOptions;
  107851. private _scene;
  107852. private _position;
  107853. private _btnVR;
  107854. private _btnVRDisplayed;
  107855. private _webVRsupported;
  107856. private _webVRready;
  107857. private _webVRrequesting;
  107858. private _webVRpresenting;
  107859. private _hasEnteredVR;
  107860. private _fullscreenVRpresenting;
  107861. private _canvas;
  107862. private _webVRCamera;
  107863. private _vrDeviceOrientationCamera;
  107864. private _deviceOrientationCamera;
  107865. private _existingCamera;
  107866. private _onKeyDown;
  107867. private _onVrDisplayPresentChange;
  107868. private _onVRDisplayChanged;
  107869. private _onVRRequestPresentStart;
  107870. private _onVRRequestPresentComplete;
  107871. /**
  107872. * 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)
  107873. */
  107874. enableGazeEvenWhenNoPointerLock: boolean;
  107875. /**
  107876. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107877. */
  107878. exitVROnDoubleTap: boolean;
  107879. /**
  107880. * Observable raised right before entering VR.
  107881. */
  107882. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107883. /**
  107884. * Observable raised when entering VR has completed.
  107885. */
  107886. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107887. /**
  107888. * Observable raised when exiting VR.
  107889. */
  107890. onExitingVRObservable: Observable<VRExperienceHelper>;
  107891. /**
  107892. * Observable raised when controller mesh is loaded.
  107893. */
  107894. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107895. /** Return this.onEnteringVRObservable
  107896. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107897. */
  107898. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107899. /** Return this.onExitingVRObservable
  107900. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107901. */
  107902. readonly onExitingVR: Observable<VRExperienceHelper>;
  107903. /** Return this.onControllerMeshLoadedObservable
  107904. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107905. */
  107906. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107907. private _rayLength;
  107908. private _useCustomVRButton;
  107909. private _teleportationRequested;
  107910. private _teleportActive;
  107911. private _floorMeshName;
  107912. private _floorMeshesCollection;
  107913. private _rotationAllowed;
  107914. private _teleportBackwardsVector;
  107915. private _teleportationTarget;
  107916. private _isDefaultTeleportationTarget;
  107917. private _postProcessMove;
  107918. private _teleportationFillColor;
  107919. private _teleportationBorderColor;
  107920. private _rotationAngle;
  107921. private _haloCenter;
  107922. private _cameraGazer;
  107923. private _padSensibilityUp;
  107924. private _padSensibilityDown;
  107925. private _leftController;
  107926. private _rightController;
  107927. /**
  107928. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107929. */
  107930. onNewMeshSelected: Observable<AbstractMesh>;
  107931. /**
  107932. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107933. * This observable will provide the mesh and the controller used to select the mesh
  107934. */
  107935. onMeshSelectedWithController: Observable<{
  107936. mesh: AbstractMesh;
  107937. controller: WebVRController;
  107938. }>;
  107939. /**
  107940. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107941. */
  107942. onNewMeshPicked: Observable<PickingInfo>;
  107943. private _circleEase;
  107944. /**
  107945. * Observable raised before camera teleportation
  107946. */
  107947. onBeforeCameraTeleport: Observable<Vector3>;
  107948. /**
  107949. * Observable raised after camera teleportation
  107950. */
  107951. onAfterCameraTeleport: Observable<Vector3>;
  107952. /**
  107953. * Observable raised when current selected mesh gets unselected
  107954. */
  107955. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107956. private _raySelectionPredicate;
  107957. /**
  107958. * To be optionaly changed by user to define custom ray selection
  107959. */
  107960. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107961. /**
  107962. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107963. */
  107964. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107965. /**
  107966. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107967. */
  107968. teleportationEnabled: boolean;
  107969. private _defaultHeight;
  107970. private _teleportationInitialized;
  107971. private _interactionsEnabled;
  107972. private _interactionsRequested;
  107973. private _displayGaze;
  107974. private _displayLaserPointer;
  107975. /**
  107976. * The mesh used to display where the user is going to teleport.
  107977. */
  107978. /**
  107979. * Sets the mesh to be used to display where the user is going to teleport.
  107980. */
  107981. teleportationTarget: Mesh;
  107982. /**
  107983. * 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
  107984. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107985. * See http://doc.babylonjs.com/resources/baking_transformations
  107986. */
  107987. gazeTrackerMesh: Mesh;
  107988. /**
  107989. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107990. */
  107991. updateGazeTrackerScale: boolean;
  107992. /**
  107993. * If the gaze trackers color should be updated when selecting meshes
  107994. */
  107995. updateGazeTrackerColor: boolean;
  107996. /**
  107997. * If the controller laser color should be updated when selecting meshes
  107998. */
  107999. updateControllerLaserColor: boolean;
  108000. /**
  108001. * The gaze tracking mesh corresponding to the left controller
  108002. */
  108003. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108004. /**
  108005. * The gaze tracking mesh corresponding to the right controller
  108006. */
  108007. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108008. /**
  108009. * If the ray of the gaze should be displayed.
  108010. */
  108011. /**
  108012. * Sets if the ray of the gaze should be displayed.
  108013. */
  108014. displayGaze: boolean;
  108015. /**
  108016. * If the ray of the LaserPointer should be displayed.
  108017. */
  108018. /**
  108019. * Sets if the ray of the LaserPointer should be displayed.
  108020. */
  108021. displayLaserPointer: boolean;
  108022. /**
  108023. * The deviceOrientationCamera used as the camera when not in VR.
  108024. */
  108025. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108026. /**
  108027. * Based on the current WebVR support, returns the current VR camera used.
  108028. */
  108029. readonly currentVRCamera: Nullable<Camera>;
  108030. /**
  108031. * The webVRCamera which is used when in VR.
  108032. */
  108033. readonly webVRCamera: WebVRFreeCamera;
  108034. /**
  108035. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108036. */
  108037. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108038. /**
  108039. * The html button that is used to trigger entering into VR.
  108040. */
  108041. readonly vrButton: Nullable<HTMLButtonElement>;
  108042. private readonly _teleportationRequestInitiated;
  108043. /**
  108044. * Defines wether or not Pointer lock should be requested when switching to
  108045. * full screen.
  108046. */
  108047. requestPointerLockOnFullScreen: boolean;
  108048. /**
  108049. * Instantiates a VRExperienceHelper.
  108050. * Helps to quickly add VR support to an existing scene.
  108051. * @param scene The scene the VRExperienceHelper belongs to.
  108052. * @param webVROptions Options to modify the vr experience helper's behavior.
  108053. */
  108054. constructor(scene: Scene,
  108055. /** Options to modify the vr experience helper's behavior. */
  108056. webVROptions?: VRExperienceHelperOptions);
  108057. private _onDefaultMeshLoaded;
  108058. private _onResize;
  108059. private _onFullscreenChange;
  108060. /**
  108061. * Gets a value indicating if we are currently in VR mode.
  108062. */
  108063. readonly isInVRMode: boolean;
  108064. private onVrDisplayPresentChange;
  108065. private onVRDisplayChanged;
  108066. private moveButtonToBottomRight;
  108067. private displayVRButton;
  108068. private updateButtonVisibility;
  108069. private _cachedAngularSensibility;
  108070. /**
  108071. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108072. * Otherwise, will use the fullscreen API.
  108073. */
  108074. enterVR(): void;
  108075. /**
  108076. * Attempt to exit VR, or fullscreen.
  108077. */
  108078. exitVR(): void;
  108079. /**
  108080. * The position of the vr experience helper.
  108081. */
  108082. /**
  108083. * Sets the position of the vr experience helper.
  108084. */
  108085. position: Vector3;
  108086. /**
  108087. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108088. */
  108089. enableInteractions(): void;
  108090. private readonly _noControllerIsActive;
  108091. private beforeRender;
  108092. private _isTeleportationFloor;
  108093. /**
  108094. * Adds a floor mesh to be used for teleportation.
  108095. * @param floorMesh the mesh to be used for teleportation.
  108096. */
  108097. addFloorMesh(floorMesh: Mesh): void;
  108098. /**
  108099. * Removes a floor mesh from being used for teleportation.
  108100. * @param floorMesh the mesh to be removed.
  108101. */
  108102. removeFloorMesh(floorMesh: Mesh): void;
  108103. /**
  108104. * Enables interactions and teleportation using the VR controllers and gaze.
  108105. * @param vrTeleportationOptions options to modify teleportation behavior.
  108106. */
  108107. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108108. private _onNewGamepadConnected;
  108109. private _tryEnableInteractionOnController;
  108110. private _onNewGamepadDisconnected;
  108111. private _enableInteractionOnController;
  108112. private _checkTeleportWithRay;
  108113. private _checkRotate;
  108114. private _checkTeleportBackwards;
  108115. private _enableTeleportationOnController;
  108116. private _createTeleportationCircles;
  108117. private _displayTeleportationTarget;
  108118. private _hideTeleportationTarget;
  108119. private _rotateCamera;
  108120. private _moveTeleportationSelectorTo;
  108121. private _workingVector;
  108122. private _workingQuaternion;
  108123. private _workingMatrix;
  108124. /**
  108125. * Teleports the users feet to the desired location
  108126. * @param location The location where the user's feet should be placed
  108127. */
  108128. teleportCamera(location: Vector3): void;
  108129. private _convertNormalToDirectionOfRay;
  108130. private _castRayAndSelectObject;
  108131. private _notifySelectedMeshUnselected;
  108132. /**
  108133. * Sets the color of the laser ray from the vr controllers.
  108134. * @param color new color for the ray.
  108135. */
  108136. changeLaserColor(color: Color3): void;
  108137. /**
  108138. * Sets the color of the ray from the vr headsets gaze.
  108139. * @param color new color for the ray.
  108140. */
  108141. changeGazeColor(color: Color3): void;
  108142. /**
  108143. * Exits VR and disposes of the vr experience helper
  108144. */
  108145. dispose(): void;
  108146. /**
  108147. * Gets the name of the VRExperienceHelper class
  108148. * @returns "VRExperienceHelper"
  108149. */
  108150. getClassName(): string;
  108151. }
  108152. }
  108153. declare module BABYLON {
  108154. /**
  108155. * Manages an XRSession to work with Babylon's engine
  108156. * @see https://doc.babylonjs.com/how_to/webxr
  108157. */
  108158. export class WebXRSessionManager implements IDisposable {
  108159. private scene;
  108160. /**
  108161. * Fires every time a new xrFrame arrives which can be used to update the camera
  108162. */
  108163. onXRFrameObservable: Observable<any>;
  108164. /**
  108165. * Fires when the xr session is ended either by the device or manually done
  108166. */
  108167. onXRSessionEnded: Observable<any>;
  108168. /**
  108169. * Underlying xr session
  108170. */
  108171. session: XRSession;
  108172. /**
  108173. * Type of reference space used when creating the session
  108174. */
  108175. referenceSpace: XRReferenceSpace;
  108176. /** @hidden */
  108177. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108178. /**
  108179. * Current XR frame
  108180. */
  108181. currentFrame: Nullable<XRFrame>;
  108182. private _xrNavigator;
  108183. private baseLayer;
  108184. /**
  108185. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108186. * @param scene The scene which the session should be created for
  108187. */
  108188. constructor(scene: Scene);
  108189. /**
  108190. * Initializes the manager
  108191. * After initialization enterXR can be called to start an XR session
  108192. * @returns Promise which resolves after it is initialized
  108193. */
  108194. initializeAsync(): Promise<void>;
  108195. /**
  108196. * Initializes an xr session
  108197. * @param xrSessionMode mode to initialize
  108198. * @returns a promise which will resolve once the session has been initialized
  108199. */
  108200. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108201. /**
  108202. * Sets the reference space on the xr session
  108203. * @param referenceSpace space to set
  108204. * @returns a promise that will resolve once the reference space has been set
  108205. */
  108206. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108207. /**
  108208. * Updates the render state of the session
  108209. * @param state state to set
  108210. * @returns a promise that resolves once the render state has been updated
  108211. */
  108212. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108213. /**
  108214. * Starts rendering to the xr layer
  108215. * @returns a promise that will resolve once rendering has started
  108216. */
  108217. startRenderingToXRAsync(): Promise<void>;
  108218. /**
  108219. * Stops the xrSession and restores the renderloop
  108220. * @returns Promise which resolves after it exits XR
  108221. */
  108222. exitXRAsync(): Promise<unknown>;
  108223. /**
  108224. * Checks if a session would be supported for the creation options specified
  108225. * @param sessionMode session mode to check if supported eg. immersive-vr
  108226. * @returns true if supported
  108227. */
  108228. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108229. /**
  108230. * @hidden
  108231. * Converts the render layer of xrSession to a render target
  108232. * @param session session to create render target for
  108233. * @param scene scene the new render target should be created for
  108234. */
  108235. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108236. /**
  108237. * Disposes of the session manager
  108238. */
  108239. dispose(): void;
  108240. }
  108241. }
  108242. declare module BABYLON {
  108243. /**
  108244. * WebXR Camera which holds the views for the xrSession
  108245. * @see https://doc.babylonjs.com/how_to/webxr
  108246. */
  108247. export class WebXRCamera extends FreeCamera {
  108248. private static _TmpMatrix;
  108249. /**
  108250. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108251. * @param name the name of the camera
  108252. * @param scene the scene to add the camera to
  108253. */
  108254. constructor(name: string, scene: Scene);
  108255. private _updateNumberOfRigCameras;
  108256. /** @hidden */
  108257. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108258. /**
  108259. * Updates the cameras position from the current pose information of the XR session
  108260. * @param xrSessionManager the session containing pose information
  108261. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108262. */
  108263. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108264. }
  108265. }
  108266. declare module BABYLON {
  108267. /**
  108268. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108269. */
  108270. export class WebXRManagedOutputCanvas implements IDisposable {
  108271. private helper;
  108272. private _canvas;
  108273. /**
  108274. * xrpresent context of the canvas which can be used to display/mirror xr content
  108275. */
  108276. canvasContext: WebGLRenderingContext;
  108277. /**
  108278. * xr layer for the canvas
  108279. */
  108280. xrLayer: Nullable<XRWebGLLayer>;
  108281. /**
  108282. * Initializes the xr layer for the session
  108283. * @param xrSession xr session
  108284. * @returns a promise that will resolve once the XR Layer has been created
  108285. */
  108286. initializeXRLayerAsync(xrSession: any): any;
  108287. /**
  108288. * Initializes the canvas to be added/removed upon entering/exiting xr
  108289. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108290. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108291. */
  108292. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108293. /**
  108294. * Disposes of the object
  108295. */
  108296. dispose(): void;
  108297. private _setManagedOutputCanvas;
  108298. private _addCanvas;
  108299. private _removeCanvas;
  108300. }
  108301. }
  108302. declare module BABYLON {
  108303. /**
  108304. * States of the webXR experience
  108305. */
  108306. export enum WebXRState {
  108307. /**
  108308. * Transitioning to being in XR mode
  108309. */
  108310. ENTERING_XR = 0,
  108311. /**
  108312. * Transitioning to non XR mode
  108313. */
  108314. EXITING_XR = 1,
  108315. /**
  108316. * In XR mode and presenting
  108317. */
  108318. IN_XR = 2,
  108319. /**
  108320. * Not entered XR mode
  108321. */
  108322. NOT_IN_XR = 3
  108323. }
  108324. /**
  108325. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108326. * @see https://doc.babylonjs.com/how_to/webxr
  108327. */
  108328. export class WebXRExperienceHelper implements IDisposable {
  108329. private scene;
  108330. /**
  108331. * 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
  108332. */
  108333. container: AbstractMesh;
  108334. /**
  108335. * Camera used to render xr content
  108336. */
  108337. camera: WebXRCamera;
  108338. /**
  108339. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108340. */
  108341. state: WebXRState;
  108342. private _setState;
  108343. private static _TmpVector;
  108344. /**
  108345. * Fires when the state of the experience helper has changed
  108346. */
  108347. onStateChangedObservable: Observable<WebXRState>;
  108348. /** Session manager used to keep track of xr session */
  108349. sessionManager: WebXRSessionManager;
  108350. private _nonVRCamera;
  108351. private _originalSceneAutoClear;
  108352. private _supported;
  108353. /**
  108354. * Creates the experience helper
  108355. * @param scene the scene to attach the experience helper to
  108356. * @returns a promise for the experience helper
  108357. */
  108358. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108359. /**
  108360. * Creates a WebXRExperienceHelper
  108361. * @param scene The scene the helper should be created in
  108362. */
  108363. private constructor();
  108364. /**
  108365. * Exits XR mode and returns the scene to its original state
  108366. * @returns promise that resolves after xr mode has exited
  108367. */
  108368. exitXRAsync(): Promise<unknown>;
  108369. /**
  108370. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108371. * @param sessionCreationOptions options for the XR session
  108372. * @param referenceSpaceType frame of reference of the XR session
  108373. * @param outputCanvas the output canvas that will be used to enter XR mode
  108374. * @returns promise that resolves after xr mode has entered
  108375. */
  108376. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108377. /**
  108378. * Updates the global position of the camera by moving the camera's container
  108379. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108380. * @param position The desired global position of the camera
  108381. */
  108382. setPositionOfCameraUsingContainer(position: Vector3): void;
  108383. /**
  108384. * Rotates the xr camera by rotating the camera's container around the camera's position
  108385. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108386. * @param rotation the desired quaternion rotation to apply to the camera
  108387. */
  108388. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108389. /**
  108390. * Disposes of the experience helper
  108391. */
  108392. dispose(): void;
  108393. }
  108394. }
  108395. declare module BABYLON {
  108396. /**
  108397. * Button which can be used to enter a different mode of XR
  108398. */
  108399. export class WebXREnterExitUIButton {
  108400. /** button element */
  108401. element: HTMLElement;
  108402. /** XR initialization options for the button */
  108403. sessionMode: XRSessionMode;
  108404. /** Reference space type */
  108405. referenceSpaceType: XRReferenceSpaceType;
  108406. /**
  108407. * Creates a WebXREnterExitUIButton
  108408. * @param element button element
  108409. * @param sessionMode XR initialization session mode
  108410. * @param referenceSpaceType the type of reference space to be used
  108411. */
  108412. constructor(
  108413. /** button element */
  108414. element: HTMLElement,
  108415. /** XR initialization options for the button */
  108416. sessionMode: XRSessionMode,
  108417. /** Reference space type */
  108418. referenceSpaceType: XRReferenceSpaceType);
  108419. /**
  108420. * Overwritable function which can be used to update the button's visuals when the state changes
  108421. * @param activeButton the current active button in the UI
  108422. */
  108423. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108424. }
  108425. /**
  108426. * Options to create the webXR UI
  108427. */
  108428. export class WebXREnterExitUIOptions {
  108429. /**
  108430. * Context to enter xr with
  108431. */
  108432. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108433. /**
  108434. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108435. */
  108436. customButtons?: Array<WebXREnterExitUIButton>;
  108437. }
  108438. /**
  108439. * UI to allow the user to enter/exit XR mode
  108440. */
  108441. export class WebXREnterExitUI implements IDisposable {
  108442. private scene;
  108443. private _overlay;
  108444. private _buttons;
  108445. private _activeButton;
  108446. /**
  108447. * Fired every time the active button is changed.
  108448. *
  108449. * When xr is entered via a button that launches xr that button will be the callback parameter
  108450. *
  108451. * When exiting xr the callback parameter will be null)
  108452. */
  108453. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108454. /**
  108455. * Creates UI to allow the user to enter/exit XR mode
  108456. * @param scene the scene to add the ui to
  108457. * @param helper the xr experience helper to enter/exit xr with
  108458. * @param options options to configure the UI
  108459. * @returns the created ui
  108460. */
  108461. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108462. private constructor();
  108463. private _updateButtons;
  108464. /**
  108465. * Disposes of the object
  108466. */
  108467. dispose(): void;
  108468. }
  108469. }
  108470. declare module BABYLON {
  108471. /**
  108472. * Represents an XR input
  108473. */
  108474. export class WebXRController {
  108475. private scene;
  108476. /** The underlying input source for the controller */
  108477. inputSource: XRInputSource;
  108478. private parentContainer;
  108479. /**
  108480. * 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
  108481. */
  108482. grip?: AbstractMesh;
  108483. /**
  108484. * Pointer which can be used to select objects or attach a visible laser to
  108485. */
  108486. pointer: AbstractMesh;
  108487. /**
  108488. * Event that fires when the controller is removed/disposed
  108489. */
  108490. onDisposeObservable: Observable<{}>;
  108491. private _tmpMatrix;
  108492. private _tmpQuaternion;
  108493. private _tmpVector;
  108494. /**
  108495. * Creates the controller
  108496. * @see https://doc.babylonjs.com/how_to/webxr
  108497. * @param scene the scene which the controller should be associated to
  108498. * @param inputSource the underlying input source for the controller
  108499. * @param parentContainer parent that the controller meshes should be children of
  108500. */
  108501. constructor(scene: Scene,
  108502. /** The underlying input source for the controller */
  108503. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108504. /**
  108505. * Updates the controller pose based on the given XRFrame
  108506. * @param xrFrame xr frame to update the pose with
  108507. * @param referenceSpace reference space to use
  108508. */
  108509. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108510. /**
  108511. * Gets a world space ray coming from the controller
  108512. * @param result the resulting ray
  108513. */
  108514. getWorldPointerRayToRef(result: Ray): void;
  108515. /**
  108516. * Disposes of the object
  108517. */
  108518. dispose(): void;
  108519. }
  108520. }
  108521. declare module BABYLON {
  108522. /**
  108523. * XR input used to track XR inputs such as controllers/rays
  108524. */
  108525. export class WebXRInput implements IDisposable {
  108526. /**
  108527. * Base experience the input listens to
  108528. */
  108529. baseExperience: WebXRExperienceHelper;
  108530. /**
  108531. * XR controllers being tracked
  108532. */
  108533. controllers: Array<WebXRController>;
  108534. private _frameObserver;
  108535. private _stateObserver;
  108536. /**
  108537. * Event when a controller has been connected/added
  108538. */
  108539. onControllerAddedObservable: Observable<WebXRController>;
  108540. /**
  108541. * Event when a controller has been removed/disconnected
  108542. */
  108543. onControllerRemovedObservable: Observable<WebXRController>;
  108544. /**
  108545. * Initializes the WebXRInput
  108546. * @param baseExperience experience helper which the input should be created for
  108547. */
  108548. constructor(
  108549. /**
  108550. * Base experience the input listens to
  108551. */
  108552. baseExperience: WebXRExperienceHelper);
  108553. private _onInputSourcesChange;
  108554. private _addAndRemoveControllers;
  108555. /**
  108556. * Disposes of the object
  108557. */
  108558. dispose(): void;
  108559. }
  108560. }
  108561. declare module BABYLON {
  108562. /**
  108563. * Enables teleportation
  108564. */
  108565. export class WebXRControllerTeleportation {
  108566. private _teleportationFillColor;
  108567. private _teleportationBorderColor;
  108568. private _tmpRay;
  108569. private _tmpVector;
  108570. /**
  108571. * Creates a WebXRControllerTeleportation
  108572. * @param input input manager to add teleportation to
  108573. * @param floorMeshes floormeshes which can be teleported to
  108574. */
  108575. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108576. }
  108577. }
  108578. declare module BABYLON {
  108579. /**
  108580. * Handles pointer input automatically for the pointer of XR controllers
  108581. */
  108582. export class WebXRControllerPointerSelection {
  108583. private static _idCounter;
  108584. private _tmpRay;
  108585. /**
  108586. * Creates a WebXRControllerPointerSelection
  108587. * @param input input manager to setup pointer selection
  108588. */
  108589. constructor(input: WebXRInput);
  108590. private _convertNormalToDirectionOfRay;
  108591. private _updatePointerDistance;
  108592. }
  108593. }
  108594. declare module BABYLON {
  108595. /**
  108596. * Class used to represent data loading progression
  108597. */
  108598. export class SceneLoaderProgressEvent {
  108599. /** defines if data length to load can be evaluated */
  108600. readonly lengthComputable: boolean;
  108601. /** defines the loaded data length */
  108602. readonly loaded: number;
  108603. /** defines the data length to load */
  108604. readonly total: number;
  108605. /**
  108606. * Create a new progress event
  108607. * @param lengthComputable defines if data length to load can be evaluated
  108608. * @param loaded defines the loaded data length
  108609. * @param total defines the data length to load
  108610. */
  108611. constructor(
  108612. /** defines if data length to load can be evaluated */
  108613. lengthComputable: boolean,
  108614. /** defines the loaded data length */
  108615. loaded: number,
  108616. /** defines the data length to load */
  108617. total: number);
  108618. /**
  108619. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108620. * @param event defines the source event
  108621. * @returns a new SceneLoaderProgressEvent
  108622. */
  108623. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108624. }
  108625. /**
  108626. * Interface used by SceneLoader plugins to define supported file extensions
  108627. */
  108628. export interface ISceneLoaderPluginExtensions {
  108629. /**
  108630. * Defines the list of supported extensions
  108631. */
  108632. [extension: string]: {
  108633. isBinary: boolean;
  108634. };
  108635. }
  108636. /**
  108637. * Interface used by SceneLoader plugin factory
  108638. */
  108639. export interface ISceneLoaderPluginFactory {
  108640. /**
  108641. * Defines the name of the factory
  108642. */
  108643. name: string;
  108644. /**
  108645. * Function called to create a new plugin
  108646. * @return the new plugin
  108647. */
  108648. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108649. /**
  108650. * Boolean indicating if the plugin can direct load specific data
  108651. */
  108652. canDirectLoad?: (data: string) => boolean;
  108653. }
  108654. /**
  108655. * Interface used to define a SceneLoader plugin
  108656. */
  108657. export interface ISceneLoaderPlugin {
  108658. /**
  108659. * The friendly name of this plugin.
  108660. */
  108661. name: string;
  108662. /**
  108663. * The file extensions supported by this plugin.
  108664. */
  108665. extensions: string | ISceneLoaderPluginExtensions;
  108666. /**
  108667. * Import meshes into a scene.
  108668. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108669. * @param scene The scene to import into
  108670. * @param data The data to import
  108671. * @param rootUrl The root url for scene and resources
  108672. * @param meshes The meshes array to import into
  108673. * @param particleSystems The particle systems array to import into
  108674. * @param skeletons The skeletons array to import into
  108675. * @param onError The callback when import fails
  108676. * @returns True if successful or false otherwise
  108677. */
  108678. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108679. /**
  108680. * Load into a scene.
  108681. * @param scene The scene to load into
  108682. * @param data The data to import
  108683. * @param rootUrl The root url for scene and resources
  108684. * @param onError The callback when import fails
  108685. * @returns true if successful or false otherwise
  108686. */
  108687. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108688. /**
  108689. * The callback that returns true if the data can be directly loaded.
  108690. */
  108691. canDirectLoad?: (data: string) => boolean;
  108692. /**
  108693. * The callback that allows custom handling of the root url based on the response url.
  108694. */
  108695. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108696. /**
  108697. * Load into an asset container.
  108698. * @param scene The scene to load into
  108699. * @param data The data to import
  108700. * @param rootUrl The root url for scene and resources
  108701. * @param onError The callback when import fails
  108702. * @returns The loaded asset container
  108703. */
  108704. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108705. }
  108706. /**
  108707. * Interface used to define an async SceneLoader plugin
  108708. */
  108709. export interface ISceneLoaderPluginAsync {
  108710. /**
  108711. * The friendly name of this plugin.
  108712. */
  108713. name: string;
  108714. /**
  108715. * The file extensions supported by this plugin.
  108716. */
  108717. extensions: string | ISceneLoaderPluginExtensions;
  108718. /**
  108719. * Import meshes into a scene.
  108720. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108721. * @param scene The scene to import into
  108722. * @param data The data to import
  108723. * @param rootUrl The root url for scene and resources
  108724. * @param onProgress The callback when the load progresses
  108725. * @param fileName Defines the name of the file to load
  108726. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108727. */
  108728. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108729. meshes: AbstractMesh[];
  108730. particleSystems: IParticleSystem[];
  108731. skeletons: Skeleton[];
  108732. animationGroups: AnimationGroup[];
  108733. }>;
  108734. /**
  108735. * Load into a scene.
  108736. * @param scene The scene to load into
  108737. * @param data The data to import
  108738. * @param rootUrl The root url for scene and resources
  108739. * @param onProgress The callback when the load progresses
  108740. * @param fileName Defines the name of the file to load
  108741. * @returns Nothing
  108742. */
  108743. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108744. /**
  108745. * The callback that returns true if the data can be directly loaded.
  108746. */
  108747. canDirectLoad?: (data: string) => boolean;
  108748. /**
  108749. * The callback that allows custom handling of the root url based on the response url.
  108750. */
  108751. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108752. /**
  108753. * Load into an asset container.
  108754. * @param scene The scene to load into
  108755. * @param data The data to import
  108756. * @param rootUrl The root url for scene and resources
  108757. * @param onProgress The callback when the load progresses
  108758. * @param fileName Defines the name of the file to load
  108759. * @returns The loaded asset container
  108760. */
  108761. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108762. }
  108763. /**
  108764. * Class used to load scene from various file formats using registered plugins
  108765. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108766. */
  108767. export class SceneLoader {
  108768. /**
  108769. * No logging while loading
  108770. */
  108771. static readonly NO_LOGGING: number;
  108772. /**
  108773. * Minimal logging while loading
  108774. */
  108775. static readonly MINIMAL_LOGGING: number;
  108776. /**
  108777. * Summary logging while loading
  108778. */
  108779. static readonly SUMMARY_LOGGING: number;
  108780. /**
  108781. * Detailled logging while loading
  108782. */
  108783. static readonly DETAILED_LOGGING: number;
  108784. /**
  108785. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108786. */
  108787. static ForceFullSceneLoadingForIncremental: boolean;
  108788. /**
  108789. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108790. */
  108791. static ShowLoadingScreen: boolean;
  108792. /**
  108793. * Defines the current logging level (while loading the scene)
  108794. * @ignorenaming
  108795. */
  108796. static loggingLevel: number;
  108797. /**
  108798. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108799. */
  108800. static CleanBoneMatrixWeights: boolean;
  108801. /**
  108802. * Event raised when a plugin is used to load a scene
  108803. */
  108804. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108805. private static _registeredPlugins;
  108806. private static _getDefaultPlugin;
  108807. private static _getPluginForExtension;
  108808. private static _getPluginForDirectLoad;
  108809. private static _getPluginForFilename;
  108810. private static _getDirectLoad;
  108811. private static _loadData;
  108812. private static _getFileInfo;
  108813. /**
  108814. * Gets a plugin that can load the given extension
  108815. * @param extension defines the extension to load
  108816. * @returns a plugin or null if none works
  108817. */
  108818. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108819. /**
  108820. * Gets a boolean indicating that the given extension can be loaded
  108821. * @param extension defines the extension to load
  108822. * @returns true if the extension is supported
  108823. */
  108824. static IsPluginForExtensionAvailable(extension: string): boolean;
  108825. /**
  108826. * Adds a new plugin to the list of registered plugins
  108827. * @param plugin defines the plugin to add
  108828. */
  108829. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108830. /**
  108831. * Import meshes into a scene
  108832. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108833. * @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)
  108834. * @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)
  108835. * @param scene the instance of BABYLON.Scene to append to
  108836. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108837. * @param onProgress a callback with a progress event for each file being loaded
  108838. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108839. * @param pluginExtension the extension used to determine the plugin
  108840. * @returns The loaded plugin
  108841. */
  108842. 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>;
  108843. /**
  108844. * Import meshes into a scene
  108845. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108846. * @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)
  108847. * @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)
  108848. * @param scene the instance of BABYLON.Scene to append to
  108849. * @param onProgress a callback with a progress event for each file being loaded
  108850. * @param pluginExtension the extension used to determine the plugin
  108851. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108852. */
  108853. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108854. meshes: AbstractMesh[];
  108855. particleSystems: IParticleSystem[];
  108856. skeletons: Skeleton[];
  108857. animationGroups: AnimationGroup[];
  108858. }>;
  108859. /**
  108860. * Load a scene
  108861. * @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)
  108862. * @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)
  108863. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108864. * @param onSuccess a callback with the scene when import succeeds
  108865. * @param onProgress a callback with a progress event for each file being loaded
  108866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108867. * @param pluginExtension the extension used to determine the plugin
  108868. * @returns The loaded plugin
  108869. */
  108870. 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>;
  108871. /**
  108872. * Load a scene
  108873. * @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)
  108874. * @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)
  108875. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108876. * @param onProgress a callback with a progress event for each file being loaded
  108877. * @param pluginExtension the extension used to determine the plugin
  108878. * @returns The loaded scene
  108879. */
  108880. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108881. /**
  108882. * Append a scene
  108883. * @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)
  108884. * @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)
  108885. * @param scene is the instance of BABYLON.Scene to append to
  108886. * @param onSuccess a callback with the scene when import succeeds
  108887. * @param onProgress a callback with a progress event for each file being loaded
  108888. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108889. * @param pluginExtension the extension used to determine the plugin
  108890. * @returns The loaded plugin
  108891. */
  108892. 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>;
  108893. /**
  108894. * Append a scene
  108895. * @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)
  108896. * @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)
  108897. * @param scene is the instance of BABYLON.Scene to append to
  108898. * @param onProgress a callback with a progress event for each file being loaded
  108899. * @param pluginExtension the extension used to determine the plugin
  108900. * @returns The given scene
  108901. */
  108902. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108903. /**
  108904. * Load a scene into an asset container
  108905. * @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)
  108906. * @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)
  108907. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108908. * @param onSuccess a callback with the scene when import succeeds
  108909. * @param onProgress a callback with a progress event for each file being loaded
  108910. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108911. * @param pluginExtension the extension used to determine the plugin
  108912. * @returns The loaded plugin
  108913. */
  108914. 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>;
  108915. /**
  108916. * Load a scene into an asset container
  108917. * @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)
  108918. * @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)
  108919. * @param scene is the instance of Scene to append to
  108920. * @param onProgress a callback with a progress event for each file being loaded
  108921. * @param pluginExtension the extension used to determine the plugin
  108922. * @returns The loaded asset container
  108923. */
  108924. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108925. }
  108926. }
  108927. declare module BABYLON {
  108928. /**
  108929. * Generic Controller
  108930. */
  108931. export class GenericController extends WebVRController {
  108932. /**
  108933. * Base Url for the controller model.
  108934. */
  108935. static readonly MODEL_BASE_URL: string;
  108936. /**
  108937. * File name for the controller model.
  108938. */
  108939. static readonly MODEL_FILENAME: string;
  108940. /**
  108941. * Creates a new GenericController from a gamepad
  108942. * @param vrGamepad the gamepad that the controller should be created from
  108943. */
  108944. constructor(vrGamepad: any);
  108945. /**
  108946. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108947. * @param scene scene in which to add meshes
  108948. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108949. */
  108950. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108951. /**
  108952. * Called once for each button that changed state since the last frame
  108953. * @param buttonIdx Which button index changed
  108954. * @param state New state of the button
  108955. * @param changes Which properties on the state changed since last frame
  108956. */
  108957. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108958. }
  108959. }
  108960. declare module BABYLON {
  108961. /**
  108962. * Defines the WindowsMotionController object that the state of the windows motion controller
  108963. */
  108964. export class WindowsMotionController extends WebVRController {
  108965. /**
  108966. * The base url used to load the left and right controller models
  108967. */
  108968. static MODEL_BASE_URL: string;
  108969. /**
  108970. * The name of the left controller model file
  108971. */
  108972. static MODEL_LEFT_FILENAME: string;
  108973. /**
  108974. * The name of the right controller model file
  108975. */
  108976. static MODEL_RIGHT_FILENAME: string;
  108977. /**
  108978. * The controller name prefix for this controller type
  108979. */
  108980. static readonly GAMEPAD_ID_PREFIX: string;
  108981. /**
  108982. * The controller id pattern for this controller type
  108983. */
  108984. private static readonly GAMEPAD_ID_PATTERN;
  108985. private _loadedMeshInfo;
  108986. private readonly _mapping;
  108987. /**
  108988. * Fired when the trackpad on this controller is clicked
  108989. */
  108990. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108991. /**
  108992. * Fired when the trackpad on this controller is modified
  108993. */
  108994. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108995. /**
  108996. * The current x and y values of this controller's trackpad
  108997. */
  108998. trackpad: StickValues;
  108999. /**
  109000. * Creates a new WindowsMotionController from a gamepad
  109001. * @param vrGamepad the gamepad that the controller should be created from
  109002. */
  109003. constructor(vrGamepad: any);
  109004. /**
  109005. * Fired when the trigger on this controller is modified
  109006. */
  109007. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109008. /**
  109009. * Fired when the menu button on this controller is modified
  109010. */
  109011. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109012. /**
  109013. * Fired when the grip button on this controller is modified
  109014. */
  109015. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109016. /**
  109017. * Fired when the thumbstick button on this controller is modified
  109018. */
  109019. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109020. /**
  109021. * Fired when the touchpad button on this controller is modified
  109022. */
  109023. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109024. /**
  109025. * Fired when the touchpad values on this controller are modified
  109026. */
  109027. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109028. private _updateTrackpad;
  109029. /**
  109030. * Called once per frame by the engine.
  109031. */
  109032. update(): void;
  109033. /**
  109034. * Called once for each button that changed state since the last frame
  109035. * @param buttonIdx Which button index changed
  109036. * @param state New state of the button
  109037. * @param changes Which properties on the state changed since last frame
  109038. */
  109039. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109040. /**
  109041. * Moves the buttons on the controller mesh based on their current state
  109042. * @param buttonName the name of the button to move
  109043. * @param buttonValue the value of the button which determines the buttons new position
  109044. */
  109045. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109046. /**
  109047. * Moves the axis on the controller mesh based on its current state
  109048. * @param axis the index of the axis
  109049. * @param axisValue the value of the axis which determines the meshes new position
  109050. * @hidden
  109051. */
  109052. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109053. /**
  109054. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109055. * @param scene scene in which to add meshes
  109056. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109057. */
  109058. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109059. /**
  109060. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109061. * can be transformed by button presses and axes values, based on this._mapping.
  109062. *
  109063. * @param scene scene in which the meshes exist
  109064. * @param meshes list of meshes that make up the controller model to process
  109065. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109066. */
  109067. private processModel;
  109068. private createMeshInfo;
  109069. /**
  109070. * Gets the ray of the controller in the direction the controller is pointing
  109071. * @param length the length the resulting ray should be
  109072. * @returns a ray in the direction the controller is pointing
  109073. */
  109074. getForwardRay(length?: number): Ray;
  109075. /**
  109076. * Disposes of the controller
  109077. */
  109078. dispose(): void;
  109079. }
  109080. }
  109081. declare module BABYLON {
  109082. /**
  109083. * Oculus Touch Controller
  109084. */
  109085. export class OculusTouchController extends WebVRController {
  109086. /**
  109087. * Base Url for the controller model.
  109088. */
  109089. static MODEL_BASE_URL: string;
  109090. /**
  109091. * File name for the left controller model.
  109092. */
  109093. static MODEL_LEFT_FILENAME: string;
  109094. /**
  109095. * File name for the right controller model.
  109096. */
  109097. static MODEL_RIGHT_FILENAME: string;
  109098. /**
  109099. * Base Url for the Quest controller model.
  109100. */
  109101. static QUEST_MODEL_BASE_URL: string;
  109102. /**
  109103. * @hidden
  109104. * If the controllers are running on a device that needs the updated Quest controller models
  109105. */
  109106. static _IsQuest: boolean;
  109107. /**
  109108. * Fired when the secondary trigger on this controller is modified
  109109. */
  109110. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109111. /**
  109112. * Fired when the thumb rest on this controller is modified
  109113. */
  109114. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109115. /**
  109116. * Creates a new OculusTouchController from a gamepad
  109117. * @param vrGamepad the gamepad that the controller should be created from
  109118. */
  109119. constructor(vrGamepad: any);
  109120. /**
  109121. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109122. * @param scene scene in which to add meshes
  109123. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109124. */
  109125. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109126. /**
  109127. * Fired when the A button on this controller is modified
  109128. */
  109129. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109130. /**
  109131. * Fired when the B button on this controller is modified
  109132. */
  109133. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109134. /**
  109135. * Fired when the X button on this controller is modified
  109136. */
  109137. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109138. /**
  109139. * Fired when the Y button on this controller is modified
  109140. */
  109141. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109142. /**
  109143. * Called once for each button that changed state since the last frame
  109144. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109145. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109146. * 2) secondary trigger (same)
  109147. * 3) A (right) X (left), touch, pressed = value
  109148. * 4) B / Y
  109149. * 5) thumb rest
  109150. * @param buttonIdx Which button index changed
  109151. * @param state New state of the button
  109152. * @param changes Which properties on the state changed since last frame
  109153. */
  109154. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109155. }
  109156. }
  109157. declare module BABYLON {
  109158. /**
  109159. * Vive Controller
  109160. */
  109161. export class ViveController extends WebVRController {
  109162. /**
  109163. * Base Url for the controller model.
  109164. */
  109165. static MODEL_BASE_URL: string;
  109166. /**
  109167. * File name for the controller model.
  109168. */
  109169. static MODEL_FILENAME: string;
  109170. /**
  109171. * Creates a new ViveController from a gamepad
  109172. * @param vrGamepad the gamepad that the controller should be created from
  109173. */
  109174. constructor(vrGamepad: any);
  109175. /**
  109176. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109177. * @param scene scene in which to add meshes
  109178. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109179. */
  109180. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109181. /**
  109182. * Fired when the left button on this controller is modified
  109183. */
  109184. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109185. /**
  109186. * Fired when the right button on this controller is modified
  109187. */
  109188. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109189. /**
  109190. * Fired when the menu button on this controller is modified
  109191. */
  109192. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109193. /**
  109194. * Called once for each button that changed state since the last frame
  109195. * Vive mapping:
  109196. * 0: touchpad
  109197. * 1: trigger
  109198. * 2: left AND right buttons
  109199. * 3: menu button
  109200. * @param buttonIdx Which button index changed
  109201. * @param state New state of the button
  109202. * @param changes Which properties on the state changed since last frame
  109203. */
  109204. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109205. }
  109206. }
  109207. declare module BABYLON {
  109208. /**
  109209. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109210. */
  109211. export class WebXRControllerModelLoader {
  109212. /**
  109213. * Creates the WebXRControllerModelLoader
  109214. * @param input xr input that creates the controllers
  109215. */
  109216. constructor(input: WebXRInput);
  109217. }
  109218. }
  109219. declare module BABYLON {
  109220. /**
  109221. * Contains an array of blocks representing the octree
  109222. */
  109223. export interface IOctreeContainer<T> {
  109224. /**
  109225. * Blocks within the octree
  109226. */
  109227. blocks: Array<OctreeBlock<T>>;
  109228. }
  109229. /**
  109230. * Class used to store a cell in an octree
  109231. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109232. */
  109233. export class OctreeBlock<T> {
  109234. /**
  109235. * Gets the content of the current block
  109236. */
  109237. entries: T[];
  109238. /**
  109239. * Gets the list of block children
  109240. */
  109241. blocks: Array<OctreeBlock<T>>;
  109242. private _depth;
  109243. private _maxDepth;
  109244. private _capacity;
  109245. private _minPoint;
  109246. private _maxPoint;
  109247. private _boundingVectors;
  109248. private _creationFunc;
  109249. /**
  109250. * Creates a new block
  109251. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109252. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109253. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109254. * @param depth defines the current depth of this block in the octree
  109255. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109256. * @param creationFunc defines a callback to call when an element is added to the block
  109257. */
  109258. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109259. /**
  109260. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109261. */
  109262. readonly capacity: number;
  109263. /**
  109264. * Gets the minimum vector (in world space) of the block's bounding box
  109265. */
  109266. readonly minPoint: Vector3;
  109267. /**
  109268. * Gets the maximum vector (in world space) of the block's bounding box
  109269. */
  109270. readonly maxPoint: Vector3;
  109271. /**
  109272. * Add a new element to this block
  109273. * @param entry defines the element to add
  109274. */
  109275. addEntry(entry: T): void;
  109276. /**
  109277. * Remove an element from this block
  109278. * @param entry defines the element to remove
  109279. */
  109280. removeEntry(entry: T): void;
  109281. /**
  109282. * Add an array of elements to this block
  109283. * @param entries defines the array of elements to add
  109284. */
  109285. addEntries(entries: T[]): void;
  109286. /**
  109287. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109288. * @param frustumPlanes defines the frustum planes to test
  109289. * @param selection defines the array to store current content if selection is positive
  109290. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109291. */
  109292. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109293. /**
  109294. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109295. * @param sphereCenter defines the bounding sphere center
  109296. * @param sphereRadius defines the bounding sphere radius
  109297. * @param selection defines the array to store current content if selection is positive
  109298. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109299. */
  109300. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109301. /**
  109302. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109303. * @param ray defines the ray to test with
  109304. * @param selection defines the array to store current content if selection is positive
  109305. */
  109306. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109307. /**
  109308. * Subdivide the content into child blocks (this block will then be empty)
  109309. */
  109310. createInnerBlocks(): void;
  109311. /**
  109312. * @hidden
  109313. */
  109314. 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;
  109315. }
  109316. }
  109317. declare module BABYLON {
  109318. /**
  109319. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109320. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109321. */
  109322. export class Octree<T> {
  109323. /** 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.) */
  109324. maxDepth: number;
  109325. /**
  109326. * Blocks within the octree containing objects
  109327. */
  109328. blocks: Array<OctreeBlock<T>>;
  109329. /**
  109330. * Content stored in the octree
  109331. */
  109332. dynamicContent: T[];
  109333. private _maxBlockCapacity;
  109334. private _selectionContent;
  109335. private _creationFunc;
  109336. /**
  109337. * Creates a octree
  109338. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109339. * @param creationFunc function to be used to instatiate the octree
  109340. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109341. * @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.)
  109342. */
  109343. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109344. /** 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.) */
  109345. maxDepth?: number);
  109346. /**
  109347. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109348. * @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);
  109349. * @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);
  109350. * @param entries meshes to be added to the octree blocks
  109351. */
  109352. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109353. /**
  109354. * Adds a mesh to the octree
  109355. * @param entry Mesh to add to the octree
  109356. */
  109357. addMesh(entry: T): void;
  109358. /**
  109359. * Remove an element from the octree
  109360. * @param entry defines the element to remove
  109361. */
  109362. removeMesh(entry: T): void;
  109363. /**
  109364. * Selects an array of meshes within the frustum
  109365. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109366. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109367. * @returns array of meshes within the frustum
  109368. */
  109369. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109370. /**
  109371. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109372. * @param sphereCenter defines the bounding sphere center
  109373. * @param sphereRadius defines the bounding sphere radius
  109374. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109375. * @returns an array of objects that intersect the sphere
  109376. */
  109377. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109378. /**
  109379. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109380. * @param ray defines the ray to test with
  109381. * @returns array of intersected objects
  109382. */
  109383. intersectsRay(ray: Ray): SmartArray<T>;
  109384. /**
  109385. * Adds a mesh into the octree block if it intersects the block
  109386. */
  109387. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109388. /**
  109389. * Adds a submesh into the octree block if it intersects the block
  109390. */
  109391. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109392. }
  109393. }
  109394. declare module BABYLON {
  109395. interface Scene {
  109396. /**
  109397. * @hidden
  109398. * Backing Filed
  109399. */
  109400. _selectionOctree: Octree<AbstractMesh>;
  109401. /**
  109402. * Gets the octree used to boost mesh selection (picking)
  109403. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109404. */
  109405. selectionOctree: Octree<AbstractMesh>;
  109406. /**
  109407. * Creates or updates the octree used to boost selection (picking)
  109408. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109409. * @param maxCapacity defines the maximum capacity per leaf
  109410. * @param maxDepth defines the maximum depth of the octree
  109411. * @returns an octree of AbstractMesh
  109412. */
  109413. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109414. }
  109415. interface AbstractMesh {
  109416. /**
  109417. * @hidden
  109418. * Backing Field
  109419. */
  109420. _submeshesOctree: Octree<SubMesh>;
  109421. /**
  109422. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109423. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109424. * @param maxCapacity defines the maximum size of each block (64 by default)
  109425. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109426. * @returns the new octree
  109427. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109429. */
  109430. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109431. }
  109432. /**
  109433. * Defines the octree scene component responsible to manage any octrees
  109434. * in a given scene.
  109435. */
  109436. export class OctreeSceneComponent {
  109437. /**
  109438. * The component name help to identify the component in the list of scene components.
  109439. */
  109440. readonly name: string;
  109441. /**
  109442. * The scene the component belongs to.
  109443. */
  109444. scene: Scene;
  109445. /**
  109446. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109447. */
  109448. readonly checksIsEnabled: boolean;
  109449. /**
  109450. * Creates a new instance of the component for the given scene
  109451. * @param scene Defines the scene to register the component in
  109452. */
  109453. constructor(scene: Scene);
  109454. /**
  109455. * Registers the component in a given scene
  109456. */
  109457. register(): void;
  109458. /**
  109459. * Return the list of active meshes
  109460. * @returns the list of active meshes
  109461. */
  109462. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109463. /**
  109464. * Return the list of active sub meshes
  109465. * @param mesh The mesh to get the candidates sub meshes from
  109466. * @returns the list of active sub meshes
  109467. */
  109468. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109469. private _tempRay;
  109470. /**
  109471. * Return the list of sub meshes intersecting with a given local ray
  109472. * @param mesh defines the mesh to find the submesh for
  109473. * @param localRay defines the ray in local space
  109474. * @returns the list of intersecting sub meshes
  109475. */
  109476. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109477. /**
  109478. * Return the list of sub meshes colliding with a collider
  109479. * @param mesh defines the mesh to find the submesh for
  109480. * @param collider defines the collider to evaluate the collision against
  109481. * @returns the list of colliding sub meshes
  109482. */
  109483. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109484. /**
  109485. * Rebuilds the elements related to this component in case of
  109486. * context lost for instance.
  109487. */
  109488. rebuild(): void;
  109489. /**
  109490. * Disposes the component and the associated ressources.
  109491. */
  109492. dispose(): void;
  109493. }
  109494. }
  109495. declare module BABYLON {
  109496. /**
  109497. * Renders a layer on top of an existing scene
  109498. */
  109499. export class UtilityLayerRenderer implements IDisposable {
  109500. /** the original scene that will be rendered on top of */
  109501. originalScene: Scene;
  109502. private _pointerCaptures;
  109503. private _lastPointerEvents;
  109504. private static _DefaultUtilityLayer;
  109505. private static _DefaultKeepDepthUtilityLayer;
  109506. private _sharedGizmoLight;
  109507. private _renderCamera;
  109508. /**
  109509. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109510. * @returns the camera that is used when rendering the utility layer
  109511. */
  109512. getRenderCamera(): Nullable<Camera>;
  109513. /**
  109514. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109515. * @param cam the camera that should be used when rendering the utility layer
  109516. */
  109517. setRenderCamera(cam: Nullable<Camera>): void;
  109518. /**
  109519. * @hidden
  109520. * Light which used by gizmos to get light shading
  109521. */
  109522. _getSharedGizmoLight(): HemisphericLight;
  109523. /**
  109524. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109525. */
  109526. pickUtilitySceneFirst: boolean;
  109527. /**
  109528. * 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)
  109529. */
  109530. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109531. /**
  109532. * 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)
  109533. */
  109534. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109535. /**
  109536. * The scene that is rendered on top of the original scene
  109537. */
  109538. utilityLayerScene: Scene;
  109539. /**
  109540. * If the utility layer should automatically be rendered on top of existing scene
  109541. */
  109542. shouldRender: boolean;
  109543. /**
  109544. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109545. */
  109546. onlyCheckPointerDownEvents: boolean;
  109547. /**
  109548. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109549. */
  109550. processAllEvents: boolean;
  109551. /**
  109552. * Observable raised when the pointer move from the utility layer scene to the main scene
  109553. */
  109554. onPointerOutObservable: Observable<number>;
  109555. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109556. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109557. private _afterRenderObserver;
  109558. private _sceneDisposeObserver;
  109559. private _originalPointerObserver;
  109560. /**
  109561. * Instantiates a UtilityLayerRenderer
  109562. * @param originalScene the original scene that will be rendered on top of
  109563. * @param handleEvents boolean indicating if the utility layer should handle events
  109564. */
  109565. constructor(
  109566. /** the original scene that will be rendered on top of */
  109567. originalScene: Scene, handleEvents?: boolean);
  109568. private _notifyObservers;
  109569. /**
  109570. * Renders the utility layers scene on top of the original scene
  109571. */
  109572. render(): void;
  109573. /**
  109574. * Disposes of the renderer
  109575. */
  109576. dispose(): void;
  109577. private _updateCamera;
  109578. }
  109579. }
  109580. declare module BABYLON {
  109581. /**
  109582. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109583. */
  109584. export class Gizmo implements IDisposable {
  109585. /** The utility layer the gizmo will be added to */
  109586. gizmoLayer: UtilityLayerRenderer;
  109587. /**
  109588. * The root mesh of the gizmo
  109589. */
  109590. _rootMesh: Mesh;
  109591. private _attachedMesh;
  109592. /**
  109593. * Ratio for the scale of the gizmo (Default: 1)
  109594. */
  109595. scaleRatio: number;
  109596. /**
  109597. * If a custom mesh has been set (Default: false)
  109598. */
  109599. protected _customMeshSet: boolean;
  109600. /**
  109601. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109602. * * When set, interactions will be enabled
  109603. */
  109604. attachedMesh: Nullable<AbstractMesh>;
  109605. /**
  109606. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109607. * @param mesh The mesh to replace the default mesh of the gizmo
  109608. */
  109609. setCustomMesh(mesh: Mesh): void;
  109610. /**
  109611. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109612. */
  109613. updateGizmoRotationToMatchAttachedMesh: boolean;
  109614. /**
  109615. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109616. */
  109617. updateGizmoPositionToMatchAttachedMesh: boolean;
  109618. /**
  109619. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109620. */
  109621. updateScale: boolean;
  109622. protected _interactionsEnabled: boolean;
  109623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109624. private _beforeRenderObserver;
  109625. private _tempVector;
  109626. /**
  109627. * Creates a gizmo
  109628. * @param gizmoLayer The utility layer the gizmo will be added to
  109629. */
  109630. constructor(
  109631. /** The utility layer the gizmo will be added to */
  109632. gizmoLayer?: UtilityLayerRenderer);
  109633. /**
  109634. * Updates the gizmo to match the attached mesh's position/rotation
  109635. */
  109636. protected _update(): void;
  109637. /**
  109638. * Disposes of the gizmo
  109639. */
  109640. dispose(): void;
  109641. }
  109642. }
  109643. declare module BABYLON {
  109644. /**
  109645. * Single plane drag gizmo
  109646. */
  109647. export class PlaneDragGizmo extends Gizmo {
  109648. /**
  109649. * Drag behavior responsible for the gizmos dragging interactions
  109650. */
  109651. dragBehavior: PointerDragBehavior;
  109652. private _pointerObserver;
  109653. /**
  109654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109655. */
  109656. snapDistance: number;
  109657. /**
  109658. * Event that fires each time the gizmo snaps to a new location.
  109659. * * snapDistance is the the change in distance
  109660. */
  109661. onSnapObservable: Observable<{
  109662. snapDistance: number;
  109663. }>;
  109664. private _plane;
  109665. private _coloredMaterial;
  109666. private _hoverMaterial;
  109667. private _isEnabled;
  109668. private _parent;
  109669. /** @hidden */
  109670. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109671. /** @hidden */
  109672. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109673. /**
  109674. * Creates a PlaneDragGizmo
  109675. * @param gizmoLayer The utility layer the gizmo will be added to
  109676. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109677. * @param color The color of the gizmo
  109678. */
  109679. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109680. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109681. /**
  109682. * If the gizmo is enabled
  109683. */
  109684. isEnabled: boolean;
  109685. /**
  109686. * Disposes of the gizmo
  109687. */
  109688. dispose(): void;
  109689. }
  109690. }
  109691. declare module BABYLON {
  109692. /**
  109693. * Gizmo that enables dragging a mesh along 3 axis
  109694. */
  109695. export class PositionGizmo extends Gizmo {
  109696. /**
  109697. * Internal gizmo used for interactions on the x axis
  109698. */
  109699. xGizmo: AxisDragGizmo;
  109700. /**
  109701. * Internal gizmo used for interactions on the y axis
  109702. */
  109703. yGizmo: AxisDragGizmo;
  109704. /**
  109705. * Internal gizmo used for interactions on the z axis
  109706. */
  109707. zGizmo: AxisDragGizmo;
  109708. /**
  109709. * Internal gizmo used for interactions on the yz plane
  109710. */
  109711. xPlaneGizmo: PlaneDragGizmo;
  109712. /**
  109713. * Internal gizmo used for interactions on the xz plane
  109714. */
  109715. yPlaneGizmo: PlaneDragGizmo;
  109716. /**
  109717. * Internal gizmo used for interactions on the xy plane
  109718. */
  109719. zPlaneGizmo: PlaneDragGizmo;
  109720. /**
  109721. * private variables
  109722. */
  109723. private _meshAttached;
  109724. private _updateGizmoRotationToMatchAttachedMesh;
  109725. private _snapDistance;
  109726. private _scaleRatio;
  109727. /** Fires an event when any of it's sub gizmos are dragged */
  109728. onDragStartObservable: Observable<unknown>;
  109729. /** Fires an event when any of it's sub gizmos are released from dragging */
  109730. onDragEndObservable: Observable<unknown>;
  109731. /**
  109732. * If set to true, planar drag is enabled
  109733. */
  109734. private _planarGizmoEnabled;
  109735. attachedMesh: Nullable<AbstractMesh>;
  109736. /**
  109737. * Creates a PositionGizmo
  109738. * @param gizmoLayer The utility layer the gizmo will be added to
  109739. */
  109740. constructor(gizmoLayer?: UtilityLayerRenderer);
  109741. /**
  109742. * If the planar drag gizmo is enabled
  109743. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109744. */
  109745. planarGizmoEnabled: boolean;
  109746. updateGizmoRotationToMatchAttachedMesh: boolean;
  109747. /**
  109748. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109749. */
  109750. snapDistance: number;
  109751. /**
  109752. * Ratio for the scale of the gizmo (Default: 1)
  109753. */
  109754. scaleRatio: number;
  109755. /**
  109756. * Disposes of the gizmo
  109757. */
  109758. dispose(): void;
  109759. /**
  109760. * CustomMeshes are not supported by this gizmo
  109761. * @param mesh The mesh to replace the default mesh of the gizmo
  109762. */
  109763. setCustomMesh(mesh: Mesh): void;
  109764. }
  109765. }
  109766. declare module BABYLON {
  109767. /**
  109768. * Single axis drag gizmo
  109769. */
  109770. export class AxisDragGizmo extends Gizmo {
  109771. /**
  109772. * Drag behavior responsible for the gizmos dragging interactions
  109773. */
  109774. dragBehavior: PointerDragBehavior;
  109775. private _pointerObserver;
  109776. /**
  109777. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109778. */
  109779. snapDistance: number;
  109780. /**
  109781. * Event that fires each time the gizmo snaps to a new location.
  109782. * * snapDistance is the the change in distance
  109783. */
  109784. onSnapObservable: Observable<{
  109785. snapDistance: number;
  109786. }>;
  109787. private _isEnabled;
  109788. private _parent;
  109789. private _arrow;
  109790. private _coloredMaterial;
  109791. private _hoverMaterial;
  109792. /** @hidden */
  109793. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109794. /** @hidden */
  109795. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109796. /**
  109797. * Creates an AxisDragGizmo
  109798. * @param gizmoLayer The utility layer the gizmo will be added to
  109799. * @param dragAxis The axis which the gizmo will be able to drag on
  109800. * @param color The color of the gizmo
  109801. */
  109802. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109803. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109804. /**
  109805. * If the gizmo is enabled
  109806. */
  109807. isEnabled: boolean;
  109808. /**
  109809. * Disposes of the gizmo
  109810. */
  109811. dispose(): void;
  109812. }
  109813. }
  109814. declare module BABYLON.Debug {
  109815. /**
  109816. * The Axes viewer will show 3 axes in a specific point in space
  109817. */
  109818. export class AxesViewer {
  109819. private _xAxis;
  109820. private _yAxis;
  109821. private _zAxis;
  109822. private _scaleLinesFactor;
  109823. private _instanced;
  109824. /**
  109825. * Gets the hosting scene
  109826. */
  109827. scene: Scene;
  109828. /**
  109829. * Gets or sets a number used to scale line length
  109830. */
  109831. scaleLines: number;
  109832. /** Gets the node hierarchy used to render x-axis */
  109833. readonly xAxis: TransformNode;
  109834. /** Gets the node hierarchy used to render y-axis */
  109835. readonly yAxis: TransformNode;
  109836. /** Gets the node hierarchy used to render z-axis */
  109837. readonly zAxis: TransformNode;
  109838. /**
  109839. * Creates a new AxesViewer
  109840. * @param scene defines the hosting scene
  109841. * @param scaleLines defines a number used to scale line length (1 by default)
  109842. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109843. * @param xAxis defines the node hierarchy used to render the x-axis
  109844. * @param yAxis defines the node hierarchy used to render the y-axis
  109845. * @param zAxis defines the node hierarchy used to render the z-axis
  109846. */
  109847. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109848. /**
  109849. * Force the viewer to update
  109850. * @param position defines the position of the viewer
  109851. * @param xaxis defines the x axis of the viewer
  109852. * @param yaxis defines the y axis of the viewer
  109853. * @param zaxis defines the z axis of the viewer
  109854. */
  109855. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109856. /**
  109857. * Creates an instance of this axes viewer.
  109858. * @returns a new axes viewer with instanced meshes
  109859. */
  109860. createInstance(): AxesViewer;
  109861. /** Releases resources */
  109862. dispose(): void;
  109863. private static _SetRenderingGroupId;
  109864. }
  109865. }
  109866. declare module BABYLON.Debug {
  109867. /**
  109868. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109869. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109870. */
  109871. export class BoneAxesViewer extends AxesViewer {
  109872. /**
  109873. * Gets or sets the target mesh where to display the axes viewer
  109874. */
  109875. mesh: Nullable<Mesh>;
  109876. /**
  109877. * Gets or sets the target bone where to display the axes viewer
  109878. */
  109879. bone: Nullable<Bone>;
  109880. /** Gets current position */
  109881. pos: Vector3;
  109882. /** Gets direction of X axis */
  109883. xaxis: Vector3;
  109884. /** Gets direction of Y axis */
  109885. yaxis: Vector3;
  109886. /** Gets direction of Z axis */
  109887. zaxis: Vector3;
  109888. /**
  109889. * Creates a new BoneAxesViewer
  109890. * @param scene defines the hosting scene
  109891. * @param bone defines the target bone
  109892. * @param mesh defines the target mesh
  109893. * @param scaleLines defines a scaling factor for line length (1 by default)
  109894. */
  109895. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109896. /**
  109897. * Force the viewer to update
  109898. */
  109899. update(): void;
  109900. /** Releases resources */
  109901. dispose(): void;
  109902. }
  109903. }
  109904. declare module BABYLON {
  109905. /**
  109906. * Interface used to define scene explorer extensibility option
  109907. */
  109908. export interface IExplorerExtensibilityOption {
  109909. /**
  109910. * Define the option label
  109911. */
  109912. label: string;
  109913. /**
  109914. * Defines the action to execute on click
  109915. */
  109916. action: (entity: any) => void;
  109917. }
  109918. /**
  109919. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109920. */
  109921. export interface IExplorerExtensibilityGroup {
  109922. /**
  109923. * Defines a predicate to test if a given type mut be extended
  109924. */
  109925. predicate: (entity: any) => boolean;
  109926. /**
  109927. * Gets the list of options added to a type
  109928. */
  109929. entries: IExplorerExtensibilityOption[];
  109930. }
  109931. /**
  109932. * Interface used to define the options to use to create the Inspector
  109933. */
  109934. export interface IInspectorOptions {
  109935. /**
  109936. * Display in overlay mode (default: false)
  109937. */
  109938. overlay?: boolean;
  109939. /**
  109940. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109941. */
  109942. globalRoot?: HTMLElement;
  109943. /**
  109944. * Display the Scene explorer
  109945. */
  109946. showExplorer?: boolean;
  109947. /**
  109948. * Display the property inspector
  109949. */
  109950. showInspector?: boolean;
  109951. /**
  109952. * Display in embed mode (both panes on the right)
  109953. */
  109954. embedMode?: boolean;
  109955. /**
  109956. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109957. */
  109958. handleResize?: boolean;
  109959. /**
  109960. * Allow the panes to popup (default: true)
  109961. */
  109962. enablePopup?: boolean;
  109963. /**
  109964. * Allow the panes to be closed by users (default: true)
  109965. */
  109966. enableClose?: boolean;
  109967. /**
  109968. * Optional list of extensibility entries
  109969. */
  109970. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109971. /**
  109972. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109973. */
  109974. inspectorURL?: string;
  109975. }
  109976. interface Scene {
  109977. /**
  109978. * @hidden
  109979. * Backing field
  109980. */
  109981. _debugLayer: DebugLayer;
  109982. /**
  109983. * Gets the debug layer (aka Inspector) associated with the scene
  109984. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109985. */
  109986. debugLayer: DebugLayer;
  109987. }
  109988. /**
  109989. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109990. * what is happening in your scene
  109991. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109992. */
  109993. export class DebugLayer {
  109994. /**
  109995. * Define the url to get the inspector script from.
  109996. * By default it uses the babylonjs CDN.
  109997. * @ignoreNaming
  109998. */
  109999. static InspectorURL: string;
  110000. private _scene;
  110001. private BJSINSPECTOR;
  110002. private _onPropertyChangedObservable?;
  110003. /**
  110004. * Observable triggered when a property is changed through the inspector.
  110005. */
  110006. readonly onPropertyChangedObservable: any;
  110007. /**
  110008. * Instantiates a new debug layer.
  110009. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110010. * what is happening in your scene
  110011. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110012. * @param scene Defines the scene to inspect
  110013. */
  110014. constructor(scene: Scene);
  110015. /** Creates the inspector window. */
  110016. private _createInspector;
  110017. /**
  110018. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110019. * @param entity defines the entity to select
  110020. * @param lineContainerTitle defines the specific block to highlight
  110021. */
  110022. select(entity: any, lineContainerTitle?: string): void;
  110023. /** Get the inspector from bundle or global */
  110024. private _getGlobalInspector;
  110025. /**
  110026. * Get if the inspector is visible or not.
  110027. * @returns true if visible otherwise, false
  110028. */
  110029. isVisible(): boolean;
  110030. /**
  110031. * Hide the inspector and close its window.
  110032. */
  110033. hide(): void;
  110034. /**
  110035. * Launch the debugLayer.
  110036. * @param config Define the configuration of the inspector
  110037. * @return a promise fulfilled when the debug layer is visible
  110038. */
  110039. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110040. }
  110041. }
  110042. declare module BABYLON {
  110043. /**
  110044. * Class containing static functions to help procedurally build meshes
  110045. */
  110046. export class BoxBuilder {
  110047. /**
  110048. * Creates a box mesh
  110049. * * The parameter `size` sets the size (float) of each box side (default 1)
  110050. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110051. * * 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)
  110052. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110056. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110057. * @param name defines the name of the mesh
  110058. * @param options defines the options used to create the mesh
  110059. * @param scene defines the hosting scene
  110060. * @returns the box mesh
  110061. */
  110062. static CreateBox(name: string, options: {
  110063. size?: number;
  110064. width?: number;
  110065. height?: number;
  110066. depth?: number;
  110067. faceUV?: Vector4[];
  110068. faceColors?: Color4[];
  110069. sideOrientation?: number;
  110070. frontUVs?: Vector4;
  110071. backUVs?: Vector4;
  110072. wrap?: boolean;
  110073. topBaseAt?: number;
  110074. bottomBaseAt?: number;
  110075. updatable?: boolean;
  110076. }, scene?: Nullable<Scene>): Mesh;
  110077. }
  110078. }
  110079. declare module BABYLON {
  110080. /**
  110081. * Class containing static functions to help procedurally build meshes
  110082. */
  110083. export class SphereBuilder {
  110084. /**
  110085. * Creates a sphere mesh
  110086. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110087. * * 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`)
  110088. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110089. * * 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
  110090. * * 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)
  110091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110094. * @param name defines the name of the mesh
  110095. * @param options defines the options used to create the mesh
  110096. * @param scene defines the hosting scene
  110097. * @returns the sphere mesh
  110098. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110099. */
  110100. static CreateSphere(name: string, options: {
  110101. segments?: number;
  110102. diameter?: number;
  110103. diameterX?: number;
  110104. diameterY?: number;
  110105. diameterZ?: number;
  110106. arc?: number;
  110107. slice?: number;
  110108. sideOrientation?: number;
  110109. frontUVs?: Vector4;
  110110. backUVs?: Vector4;
  110111. updatable?: boolean;
  110112. }, scene?: Nullable<Scene>): Mesh;
  110113. }
  110114. }
  110115. declare module BABYLON.Debug {
  110116. /**
  110117. * Used to show the physics impostor around the specific mesh
  110118. */
  110119. export class PhysicsViewer {
  110120. /** @hidden */
  110121. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110122. /** @hidden */
  110123. protected _meshes: Array<Nullable<AbstractMesh>>;
  110124. /** @hidden */
  110125. protected _scene: Nullable<Scene>;
  110126. /** @hidden */
  110127. protected _numMeshes: number;
  110128. /** @hidden */
  110129. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110130. private _renderFunction;
  110131. private _utilityLayer;
  110132. private _debugBoxMesh;
  110133. private _debugSphereMesh;
  110134. private _debugCylinderMesh;
  110135. private _debugMaterial;
  110136. private _debugMeshMeshes;
  110137. /**
  110138. * Creates a new PhysicsViewer
  110139. * @param scene defines the hosting scene
  110140. */
  110141. constructor(scene: Scene);
  110142. /** @hidden */
  110143. protected _updateDebugMeshes(): void;
  110144. /**
  110145. * Renders a specified physic impostor
  110146. * @param impostor defines the impostor to render
  110147. * @param targetMesh defines the mesh represented by the impostor
  110148. * @returns the new debug mesh used to render the impostor
  110149. */
  110150. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110151. /**
  110152. * Hides a specified physic impostor
  110153. * @param impostor defines the impostor to hide
  110154. */
  110155. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110156. private _getDebugMaterial;
  110157. private _getDebugBoxMesh;
  110158. private _getDebugSphereMesh;
  110159. private _getDebugCylinderMesh;
  110160. private _getDebugMeshMesh;
  110161. private _getDebugMesh;
  110162. /** Releases all resources */
  110163. dispose(): void;
  110164. }
  110165. }
  110166. declare module BABYLON {
  110167. /**
  110168. * Class containing static functions to help procedurally build meshes
  110169. */
  110170. export class LinesBuilder {
  110171. /**
  110172. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110173. * * 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
  110174. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110175. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110176. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110177. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110178. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110179. * * 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
  110180. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110183. * @param name defines the name of the new line system
  110184. * @param options defines the options used to create the line system
  110185. * @param scene defines the hosting scene
  110186. * @returns a new line system mesh
  110187. */
  110188. static CreateLineSystem(name: string, options: {
  110189. lines: Vector3[][];
  110190. updatable?: boolean;
  110191. instance?: Nullable<LinesMesh>;
  110192. colors?: Nullable<Color4[][]>;
  110193. useVertexAlpha?: boolean;
  110194. }, scene: Nullable<Scene>): LinesMesh;
  110195. /**
  110196. * Creates a line mesh
  110197. * 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
  110198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110199. * * The parameter `points` is an array successive Vector3
  110200. * * 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
  110201. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110202. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110203. * * When updating an instance, remember that only point positions can change, not the number of points
  110204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110206. * @param name defines the name of the new line system
  110207. * @param options defines the options used to create the line system
  110208. * @param scene defines the hosting scene
  110209. * @returns a new line mesh
  110210. */
  110211. static CreateLines(name: string, options: {
  110212. points: Vector3[];
  110213. updatable?: boolean;
  110214. instance?: Nullable<LinesMesh>;
  110215. colors?: Color4[];
  110216. useVertexAlpha?: boolean;
  110217. }, scene?: Nullable<Scene>): LinesMesh;
  110218. /**
  110219. * Creates a dashed line mesh
  110220. * * 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
  110221. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110222. * * The parameter `points` is an array successive Vector3
  110223. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110224. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110225. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110226. * * 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
  110227. * * When updating an instance, remember that only point positions can change, not the number of points
  110228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110229. * @param name defines the name of the mesh
  110230. * @param options defines the options used to create the mesh
  110231. * @param scene defines the hosting scene
  110232. * @returns the dashed line mesh
  110233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110234. */
  110235. static CreateDashedLines(name: string, options: {
  110236. points: Vector3[];
  110237. dashSize?: number;
  110238. gapSize?: number;
  110239. dashNb?: number;
  110240. updatable?: boolean;
  110241. instance?: LinesMesh;
  110242. }, scene?: Nullable<Scene>): LinesMesh;
  110243. }
  110244. }
  110245. declare module BABYLON {
  110246. /**
  110247. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110248. * in order to better appreciate the issue one might have.
  110249. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110250. */
  110251. export class RayHelper {
  110252. /**
  110253. * Defines the ray we are currently tryin to visualize.
  110254. */
  110255. ray: Nullable<Ray>;
  110256. private _renderPoints;
  110257. private _renderLine;
  110258. private _renderFunction;
  110259. private _scene;
  110260. private _updateToMeshFunction;
  110261. private _attachedToMesh;
  110262. private _meshSpaceDirection;
  110263. private _meshSpaceOrigin;
  110264. /**
  110265. * Helper function to create a colored helper in a scene in one line.
  110266. * @param ray Defines the ray we are currently tryin to visualize
  110267. * @param scene Defines the scene the ray is used in
  110268. * @param color Defines the color we want to see the ray in
  110269. * @returns The newly created ray helper.
  110270. */
  110271. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110272. /**
  110273. * Instantiate a new ray helper.
  110274. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110275. * in order to better appreciate the issue one might have.
  110276. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110277. * @param ray Defines the ray we are currently tryin to visualize
  110278. */
  110279. constructor(ray: Ray);
  110280. /**
  110281. * Shows the ray we are willing to debug.
  110282. * @param scene Defines the scene the ray needs to be rendered in
  110283. * @param color Defines the color the ray needs to be rendered in
  110284. */
  110285. show(scene: Scene, color?: Color3): void;
  110286. /**
  110287. * Hides the ray we are debugging.
  110288. */
  110289. hide(): void;
  110290. private _render;
  110291. /**
  110292. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110293. * @param mesh Defines the mesh we want the helper attached to
  110294. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110295. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110296. * @param length Defines the length of the ray
  110297. */
  110298. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110299. /**
  110300. * Detach the ray helper from the mesh it has previously been attached to.
  110301. */
  110302. detachFromMesh(): void;
  110303. private _updateToMesh;
  110304. /**
  110305. * Dispose the helper and release its associated resources.
  110306. */
  110307. dispose(): void;
  110308. }
  110309. }
  110310. declare module BABYLON.Debug {
  110311. /**
  110312. * Class used to render a debug view of a given skeleton
  110313. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110314. */
  110315. export class SkeletonViewer {
  110316. /** defines the skeleton to render */
  110317. skeleton: Skeleton;
  110318. /** defines the mesh attached to the skeleton */
  110319. mesh: AbstractMesh;
  110320. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110321. autoUpdateBonesMatrices: boolean;
  110322. /** defines the rendering group id to use with the viewer */
  110323. renderingGroupId: number;
  110324. /** Gets or sets the color used to render the skeleton */
  110325. color: Color3;
  110326. private _scene;
  110327. private _debugLines;
  110328. private _debugMesh;
  110329. private _isEnabled;
  110330. private _renderFunction;
  110331. private _utilityLayer;
  110332. /**
  110333. * Returns the mesh used to render the bones
  110334. */
  110335. readonly debugMesh: Nullable<LinesMesh>;
  110336. /**
  110337. * Creates a new SkeletonViewer
  110338. * @param skeleton defines the skeleton to render
  110339. * @param mesh defines the mesh attached to the skeleton
  110340. * @param scene defines the hosting scene
  110341. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110342. * @param renderingGroupId defines the rendering group id to use with the viewer
  110343. */
  110344. constructor(
  110345. /** defines the skeleton to render */
  110346. skeleton: Skeleton,
  110347. /** defines the mesh attached to the skeleton */
  110348. mesh: AbstractMesh, scene: Scene,
  110349. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110350. autoUpdateBonesMatrices?: boolean,
  110351. /** defines the rendering group id to use with the viewer */
  110352. renderingGroupId?: number);
  110353. /** Gets or sets a boolean indicating if the viewer is enabled */
  110354. isEnabled: boolean;
  110355. private _getBonePosition;
  110356. private _getLinesForBonesWithLength;
  110357. private _getLinesForBonesNoLength;
  110358. /** Update the viewer to sync with current skeleton state */
  110359. update(): void;
  110360. /** Release associated resources */
  110361. dispose(): void;
  110362. }
  110363. }
  110364. declare module BABYLON {
  110365. /**
  110366. * Options to create the null engine
  110367. */
  110368. export class NullEngineOptions {
  110369. /**
  110370. * Render width (Default: 512)
  110371. */
  110372. renderWidth: number;
  110373. /**
  110374. * Render height (Default: 256)
  110375. */
  110376. renderHeight: number;
  110377. /**
  110378. * Texture size (Default: 512)
  110379. */
  110380. textureSize: number;
  110381. /**
  110382. * If delta time between frames should be constant
  110383. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110384. */
  110385. deterministicLockstep: boolean;
  110386. /**
  110387. * Maximum about of steps between frames (Default: 4)
  110388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110389. */
  110390. lockstepMaxSteps: number;
  110391. }
  110392. /**
  110393. * The null engine class provides support for headless version of babylon.js.
  110394. * This can be used in server side scenario or for testing purposes
  110395. */
  110396. export class NullEngine extends Engine {
  110397. private _options;
  110398. /**
  110399. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110400. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110401. * @returns true if engine is in deterministic lock step mode
  110402. */
  110403. isDeterministicLockStep(): boolean;
  110404. /**
  110405. * Gets the max steps when engine is running in deterministic lock step
  110406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110407. * @returns the max steps
  110408. */
  110409. getLockstepMaxSteps(): number;
  110410. /**
  110411. * Gets the current hardware scaling level.
  110412. * By default the hardware scaling level is computed from the window device ratio.
  110413. * 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.
  110414. * @returns a number indicating the current hardware scaling level
  110415. */
  110416. getHardwareScalingLevel(): number;
  110417. constructor(options?: NullEngineOptions);
  110418. /**
  110419. * Creates a vertex buffer
  110420. * @param vertices the data for the vertex buffer
  110421. * @returns the new WebGL static buffer
  110422. */
  110423. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110424. /**
  110425. * Creates a new index buffer
  110426. * @param indices defines the content of the index buffer
  110427. * @param updatable defines if the index buffer must be updatable
  110428. * @returns a new webGL buffer
  110429. */
  110430. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110431. /**
  110432. * Clear the current render buffer or the current render target (if any is set up)
  110433. * @param color defines the color to use
  110434. * @param backBuffer defines if the back buffer must be cleared
  110435. * @param depth defines if the depth buffer must be cleared
  110436. * @param stencil defines if the stencil buffer must be cleared
  110437. */
  110438. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110439. /**
  110440. * Gets the current render width
  110441. * @param useScreen defines if screen size must be used (or the current render target if any)
  110442. * @returns a number defining the current render width
  110443. */
  110444. getRenderWidth(useScreen?: boolean): number;
  110445. /**
  110446. * Gets the current render height
  110447. * @param useScreen defines if screen size must be used (or the current render target if any)
  110448. * @returns a number defining the current render height
  110449. */
  110450. getRenderHeight(useScreen?: boolean): number;
  110451. /**
  110452. * Set the WebGL's viewport
  110453. * @param viewport defines the viewport element to be used
  110454. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110455. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110456. */
  110457. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110458. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110459. /**
  110460. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110461. * @param pipelineContext defines the pipeline context to use
  110462. * @param uniformsNames defines the list of uniform names
  110463. * @returns an array of webGL uniform locations
  110464. */
  110465. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110466. /**
  110467. * Gets the lsit of active attributes for a given webGL program
  110468. * @param pipelineContext defines the pipeline context to use
  110469. * @param attributesNames defines the list of attribute names to get
  110470. * @returns an array of indices indicating the offset of each attribute
  110471. */
  110472. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110473. /**
  110474. * Binds an effect to the webGL context
  110475. * @param effect defines the effect to bind
  110476. */
  110477. bindSamplers(effect: Effect): void;
  110478. /**
  110479. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110480. * @param effect defines the effect to activate
  110481. */
  110482. enableEffect(effect: Effect): void;
  110483. /**
  110484. * Set various states to the webGL context
  110485. * @param culling defines backface culling state
  110486. * @param zOffset defines the value to apply to zOffset (0 by default)
  110487. * @param force defines if states must be applied even if cache is up to date
  110488. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110489. */
  110490. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110491. /**
  110492. * Set the value of an uniform to an array of int32
  110493. * @param uniform defines the webGL uniform location where to store the value
  110494. * @param array defines the array of int32 to store
  110495. */
  110496. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110497. /**
  110498. * Set the value of an uniform to an array of int32 (stored as vec2)
  110499. * @param uniform defines the webGL uniform location where to store the value
  110500. * @param array defines the array of int32 to store
  110501. */
  110502. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110503. /**
  110504. * Set the value of an uniform to an array of int32 (stored as vec3)
  110505. * @param uniform defines the webGL uniform location where to store the value
  110506. * @param array defines the array of int32 to store
  110507. */
  110508. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110509. /**
  110510. * Set the value of an uniform to an array of int32 (stored as vec4)
  110511. * @param uniform defines the webGL uniform location where to store the value
  110512. * @param array defines the array of int32 to store
  110513. */
  110514. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110515. /**
  110516. * Set the value of an uniform to an array of float32
  110517. * @param uniform defines the webGL uniform location where to store the value
  110518. * @param array defines the array of float32 to store
  110519. */
  110520. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110521. /**
  110522. * Set the value of an uniform to an array of float32 (stored as vec2)
  110523. * @param uniform defines the webGL uniform location where to store the value
  110524. * @param array defines the array of float32 to store
  110525. */
  110526. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110527. /**
  110528. * Set the value of an uniform to an array of float32 (stored as vec3)
  110529. * @param uniform defines the webGL uniform location where to store the value
  110530. * @param array defines the array of float32 to store
  110531. */
  110532. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110533. /**
  110534. * Set the value of an uniform to an array of float32 (stored as vec4)
  110535. * @param uniform defines the webGL uniform location where to store the value
  110536. * @param array defines the array of float32 to store
  110537. */
  110538. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110539. /**
  110540. * Set the value of an uniform to an array of number
  110541. * @param uniform defines the webGL uniform location where to store the value
  110542. * @param array defines the array of number to store
  110543. */
  110544. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110545. /**
  110546. * Set the value of an uniform to an array of number (stored as vec2)
  110547. * @param uniform defines the webGL uniform location where to store the value
  110548. * @param array defines the array of number to store
  110549. */
  110550. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110551. /**
  110552. * Set the value of an uniform to an array of number (stored as vec3)
  110553. * @param uniform defines the webGL uniform location where to store the value
  110554. * @param array defines the array of number to store
  110555. */
  110556. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110557. /**
  110558. * Set the value of an uniform to an array of number (stored as vec4)
  110559. * @param uniform defines the webGL uniform location where to store the value
  110560. * @param array defines the array of number to store
  110561. */
  110562. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110563. /**
  110564. * Set the value of an uniform to an array of float32 (stored as matrices)
  110565. * @param uniform defines the webGL uniform location where to store the value
  110566. * @param matrices defines the array of float32 to store
  110567. */
  110568. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110569. /**
  110570. * Set the value of an uniform to a matrix (3x3)
  110571. * @param uniform defines the webGL uniform location where to store the value
  110572. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110573. */
  110574. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110575. /**
  110576. * Set the value of an uniform to a matrix (2x2)
  110577. * @param uniform defines the webGL uniform location where to store the value
  110578. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110579. */
  110580. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110581. /**
  110582. * Set the value of an uniform to a number (float)
  110583. * @param uniform defines the webGL uniform location where to store the value
  110584. * @param value defines the float number to store
  110585. */
  110586. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110587. /**
  110588. * Set the value of an uniform to a vec2
  110589. * @param uniform defines the webGL uniform location where to store the value
  110590. * @param x defines the 1st component of the value
  110591. * @param y defines the 2nd component of the value
  110592. */
  110593. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110594. /**
  110595. * Set the value of an uniform to a vec3
  110596. * @param uniform defines the webGL uniform location where to store the value
  110597. * @param x defines the 1st component of the value
  110598. * @param y defines the 2nd component of the value
  110599. * @param z defines the 3rd component of the value
  110600. */
  110601. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110602. /**
  110603. * Set the value of an uniform to a boolean
  110604. * @param uniform defines the webGL uniform location where to store the value
  110605. * @param bool defines the boolean to store
  110606. */
  110607. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110608. /**
  110609. * Set the value of an uniform to a vec4
  110610. * @param uniform defines the webGL uniform location where to store the value
  110611. * @param x defines the 1st component of the value
  110612. * @param y defines the 2nd component of the value
  110613. * @param z defines the 3rd component of the value
  110614. * @param w defines the 4th component of the value
  110615. */
  110616. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110617. /**
  110618. * Sets the current alpha mode
  110619. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110620. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110622. */
  110623. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110624. /**
  110625. * Bind webGl buffers directly to the webGL context
  110626. * @param vertexBuffers defines the vertex buffer to bind
  110627. * @param indexBuffer defines the index buffer to bind
  110628. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110629. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110630. * @param effect defines the effect associated with the vertex buffer
  110631. */
  110632. bindBuffers(vertexBuffers: {
  110633. [key: string]: VertexBuffer;
  110634. }, indexBuffer: DataBuffer, effect: Effect): void;
  110635. /**
  110636. * Force the entire cache to be cleared
  110637. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110638. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110639. */
  110640. wipeCaches(bruteForce?: boolean): void;
  110641. /**
  110642. * Send a draw order
  110643. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110644. * @param indexStart defines the starting index
  110645. * @param indexCount defines the number of index to draw
  110646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110647. */
  110648. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110649. /**
  110650. * Draw a list of indexed primitives
  110651. * @param fillMode defines the primitive to use
  110652. * @param indexStart defines the starting index
  110653. * @param indexCount defines the number of index to draw
  110654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110655. */
  110656. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110657. /**
  110658. * Draw a list of unindexed primitives
  110659. * @param fillMode defines the primitive to use
  110660. * @param verticesStart defines the index of first vertex to draw
  110661. * @param verticesCount defines the count of vertices to draw
  110662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110663. */
  110664. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110665. /** @hidden */
  110666. _createTexture(): WebGLTexture;
  110667. /** @hidden */
  110668. _releaseTexture(texture: InternalTexture): void;
  110669. /**
  110670. * Usually called from Texture.ts.
  110671. * Passed information to create a WebGLTexture
  110672. * @param urlArg defines a value which contains one of the following:
  110673. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110674. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110675. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110677. * @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)
  110678. * @param scene needed for loading to the correct scene
  110679. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110680. * @param onLoad optional callback to be called upon successful completion
  110681. * @param onError optional callback to be called upon failure
  110682. * @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
  110683. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110684. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110685. * @param forcedExtension defines the extension to use to pick the right loader
  110686. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110687. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110688. */
  110689. 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;
  110690. /**
  110691. * Creates a new render target texture
  110692. * @param size defines the size of the texture
  110693. * @param options defines the options used to create the texture
  110694. * @returns a new render target texture stored in an InternalTexture
  110695. */
  110696. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110697. /**
  110698. * Update the sampling mode of a given texture
  110699. * @param samplingMode defines the required sampling mode
  110700. * @param texture defines the texture to update
  110701. */
  110702. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110703. /**
  110704. * Binds the frame buffer to the specified texture.
  110705. * @param texture The texture to render to or null for the default canvas
  110706. * @param faceIndex The face of the texture to render to in case of cube texture
  110707. * @param requiredWidth The width of the target to render to
  110708. * @param requiredHeight The height of the target to render to
  110709. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110710. * @param depthStencilTexture The depth stencil texture to use to render
  110711. * @param lodLevel defines le lod level to bind to the frame buffer
  110712. */
  110713. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110714. /**
  110715. * Unbind the current render target texture from the webGL context
  110716. * @param texture defines the render target texture to unbind
  110717. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110718. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110719. */
  110720. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110721. /**
  110722. * Creates a dynamic vertex buffer
  110723. * @param vertices the data for the dynamic vertex buffer
  110724. * @returns the new WebGL dynamic buffer
  110725. */
  110726. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110727. /**
  110728. * Update the content of a dynamic texture
  110729. * @param texture defines the texture to update
  110730. * @param canvas defines the canvas containing the source
  110731. * @param invertY defines if data must be stored with Y axis inverted
  110732. * @param premulAlpha defines if alpha is stored as premultiplied
  110733. * @param format defines the format of the data
  110734. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110735. */
  110736. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110737. /**
  110738. * Gets a boolean indicating if all created effects are ready
  110739. * @returns true if all effects are ready
  110740. */
  110741. areAllEffectsReady(): boolean;
  110742. /**
  110743. * @hidden
  110744. * Get the current error code of the webGL context
  110745. * @returns the error code
  110746. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110747. */
  110748. getError(): number;
  110749. /** @hidden */
  110750. _getUnpackAlignement(): number;
  110751. /** @hidden */
  110752. _unpackFlipY(value: boolean): void;
  110753. /**
  110754. * Update a dynamic index buffer
  110755. * @param indexBuffer defines the target index buffer
  110756. * @param indices defines the data to update
  110757. * @param offset defines the offset in the target index buffer where update should start
  110758. */
  110759. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110760. /**
  110761. * Updates a dynamic vertex buffer.
  110762. * @param vertexBuffer the vertex buffer to update
  110763. * @param vertices the data used to update the vertex buffer
  110764. * @param byteOffset the byte offset of the data (optional)
  110765. * @param byteLength the byte length of the data (optional)
  110766. */
  110767. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110768. /** @hidden */
  110769. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110770. /** @hidden */
  110771. _bindTexture(channel: number, texture: InternalTexture): void;
  110772. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110773. /**
  110774. * 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
  110775. */
  110776. releaseEffects(): void;
  110777. displayLoadingUI(): void;
  110778. hideLoadingUI(): void;
  110779. /** @hidden */
  110780. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110781. /** @hidden */
  110782. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110783. /** @hidden */
  110784. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110785. /** @hidden */
  110786. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110787. }
  110788. }
  110789. declare module BABYLON {
  110790. /** @hidden */
  110791. export class _OcclusionDataStorage {
  110792. /** @hidden */
  110793. occlusionInternalRetryCounter: number;
  110794. /** @hidden */
  110795. isOcclusionQueryInProgress: boolean;
  110796. /** @hidden */
  110797. isOccluded: boolean;
  110798. /** @hidden */
  110799. occlusionRetryCount: number;
  110800. /** @hidden */
  110801. occlusionType: number;
  110802. /** @hidden */
  110803. occlusionQueryAlgorithmType: number;
  110804. }
  110805. interface Engine {
  110806. /**
  110807. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110808. * @return the new query
  110809. */
  110810. createQuery(): WebGLQuery;
  110811. /**
  110812. * Delete and release a webGL query
  110813. * @param query defines the query to delete
  110814. * @return the current engine
  110815. */
  110816. deleteQuery(query: WebGLQuery): Engine;
  110817. /**
  110818. * Check if a given query has resolved and got its value
  110819. * @param query defines the query to check
  110820. * @returns true if the query got its value
  110821. */
  110822. isQueryResultAvailable(query: WebGLQuery): boolean;
  110823. /**
  110824. * Gets the value of a given query
  110825. * @param query defines the query to check
  110826. * @returns the value of the query
  110827. */
  110828. getQueryResult(query: WebGLQuery): number;
  110829. /**
  110830. * Initiates an occlusion query
  110831. * @param algorithmType defines the algorithm to use
  110832. * @param query defines the query to use
  110833. * @returns the current engine
  110834. * @see http://doc.babylonjs.com/features/occlusionquery
  110835. */
  110836. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110837. /**
  110838. * Ends an occlusion query
  110839. * @see http://doc.babylonjs.com/features/occlusionquery
  110840. * @param algorithmType defines the algorithm to use
  110841. * @returns the current engine
  110842. */
  110843. endOcclusionQuery(algorithmType: number): Engine;
  110844. /**
  110845. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110846. * Please note that only one query can be issued at a time
  110847. * @returns a time token used to track the time span
  110848. */
  110849. startTimeQuery(): Nullable<_TimeToken>;
  110850. /**
  110851. * Ends a time query
  110852. * @param token defines the token used to measure the time span
  110853. * @returns the time spent (in ns)
  110854. */
  110855. endTimeQuery(token: _TimeToken): int;
  110856. /** @hidden */
  110857. _currentNonTimestampToken: Nullable<_TimeToken>;
  110858. /** @hidden */
  110859. _createTimeQuery(): WebGLQuery;
  110860. /** @hidden */
  110861. _deleteTimeQuery(query: WebGLQuery): void;
  110862. /** @hidden */
  110863. _getGlAlgorithmType(algorithmType: number): number;
  110864. /** @hidden */
  110865. _getTimeQueryResult(query: WebGLQuery): any;
  110866. /** @hidden */
  110867. _getTimeQueryAvailability(query: WebGLQuery): any;
  110868. }
  110869. interface AbstractMesh {
  110870. /**
  110871. * Backing filed
  110872. * @hidden
  110873. */
  110874. __occlusionDataStorage: _OcclusionDataStorage;
  110875. /**
  110876. * Access property
  110877. * @hidden
  110878. */
  110879. _occlusionDataStorage: _OcclusionDataStorage;
  110880. /**
  110881. * 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.
  110882. * The default value is -1 which means don't break the query and wait till the result
  110883. * @see http://doc.babylonjs.com/features/occlusionquery
  110884. */
  110885. occlusionRetryCount: number;
  110886. /**
  110887. * 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:
  110888. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110889. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110890. * * 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.
  110891. * @see http://doc.babylonjs.com/features/occlusionquery
  110892. */
  110893. occlusionType: number;
  110894. /**
  110895. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110896. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110897. * * 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.
  110898. * @see http://doc.babylonjs.com/features/occlusionquery
  110899. */
  110900. occlusionQueryAlgorithmType: number;
  110901. /**
  110902. * 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
  110903. * @see http://doc.babylonjs.com/features/occlusionquery
  110904. */
  110905. isOccluded: boolean;
  110906. /**
  110907. * Flag to check the progress status of the query
  110908. * @see http://doc.babylonjs.com/features/occlusionquery
  110909. */
  110910. isOcclusionQueryInProgress: boolean;
  110911. }
  110912. }
  110913. declare module BABYLON {
  110914. /** @hidden */
  110915. export var _forceTransformFeedbackToBundle: boolean;
  110916. interface Engine {
  110917. /**
  110918. * Creates a webGL transform feedback object
  110919. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110920. * @returns the webGL transform feedback object
  110921. */
  110922. createTransformFeedback(): WebGLTransformFeedback;
  110923. /**
  110924. * Delete a webGL transform feedback object
  110925. * @param value defines the webGL transform feedback object to delete
  110926. */
  110927. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110928. /**
  110929. * Bind a webGL transform feedback object to the webgl context
  110930. * @param value defines the webGL transform feedback object to bind
  110931. */
  110932. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110933. /**
  110934. * Begins a transform feedback operation
  110935. * @param usePoints defines if points or triangles must be used
  110936. */
  110937. beginTransformFeedback(usePoints: boolean): void;
  110938. /**
  110939. * Ends a transform feedback operation
  110940. */
  110941. endTransformFeedback(): void;
  110942. /**
  110943. * Specify the varyings to use with transform feedback
  110944. * @param program defines the associated webGL program
  110945. * @param value defines the list of strings representing the varying names
  110946. */
  110947. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110948. /**
  110949. * Bind a webGL buffer for a transform feedback operation
  110950. * @param value defines the webGL buffer to bind
  110951. */
  110952. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110953. }
  110954. }
  110955. declare module BABYLON {
  110956. /**
  110957. * Creation options of the multi render target texture.
  110958. */
  110959. export interface IMultiRenderTargetOptions {
  110960. /**
  110961. * Define if the texture needs to create mip maps after render.
  110962. */
  110963. generateMipMaps?: boolean;
  110964. /**
  110965. * Define the types of all the draw buffers we want to create
  110966. */
  110967. types?: number[];
  110968. /**
  110969. * Define the sampling modes of all the draw buffers we want to create
  110970. */
  110971. samplingModes?: number[];
  110972. /**
  110973. * Define if a depth buffer is required
  110974. */
  110975. generateDepthBuffer?: boolean;
  110976. /**
  110977. * Define if a stencil buffer is required
  110978. */
  110979. generateStencilBuffer?: boolean;
  110980. /**
  110981. * Define if a depth texture is required instead of a depth buffer
  110982. */
  110983. generateDepthTexture?: boolean;
  110984. /**
  110985. * Define the number of desired draw buffers
  110986. */
  110987. textureCount?: number;
  110988. /**
  110989. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110990. */
  110991. doNotChangeAspectRatio?: boolean;
  110992. /**
  110993. * Define the default type of the buffers we are creating
  110994. */
  110995. defaultType?: number;
  110996. }
  110997. /**
  110998. * A multi render target, like a render target provides the ability to render to a texture.
  110999. * Unlike the render target, it can render to several draw buffers in one draw.
  111000. * This is specially interesting in deferred rendering or for any effects requiring more than
  111001. * just one color from a single pass.
  111002. */
  111003. export class MultiRenderTarget extends RenderTargetTexture {
  111004. private _internalTextures;
  111005. private _textures;
  111006. private _multiRenderTargetOptions;
  111007. /**
  111008. * Get if draw buffers are currently supported by the used hardware and browser.
  111009. */
  111010. readonly isSupported: boolean;
  111011. /**
  111012. * Get the list of textures generated by the multi render target.
  111013. */
  111014. readonly textures: Texture[];
  111015. /**
  111016. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111017. */
  111018. readonly depthTexture: Texture;
  111019. /**
  111020. * Set the wrapping mode on U of all the textures we are rendering to.
  111021. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111022. */
  111023. wrapU: number;
  111024. /**
  111025. * Set the wrapping mode on V of all the textures we are rendering to.
  111026. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111027. */
  111028. wrapV: number;
  111029. /**
  111030. * Instantiate a new multi render target texture.
  111031. * A multi render target, like a render target provides the ability to render to a texture.
  111032. * Unlike the render target, it can render to several draw buffers in one draw.
  111033. * This is specially interesting in deferred rendering or for any effects requiring more than
  111034. * just one color from a single pass.
  111035. * @param name Define the name of the texture
  111036. * @param size Define the size of the buffers to render to
  111037. * @param count Define the number of target we are rendering into
  111038. * @param scene Define the scene the texture belongs to
  111039. * @param options Define the options used to create the multi render target
  111040. */
  111041. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111042. /** @hidden */
  111043. _rebuild(): void;
  111044. private _createInternalTextures;
  111045. private _createTextures;
  111046. /**
  111047. * Define the number of samples used if MSAA is enabled.
  111048. */
  111049. samples: number;
  111050. /**
  111051. * Resize all the textures in the multi render target.
  111052. * Be carrefull as it will recreate all the data in the new texture.
  111053. * @param size Define the new size
  111054. */
  111055. resize(size: any): void;
  111056. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111057. /**
  111058. * Dispose the render targets and their associated resources
  111059. */
  111060. dispose(): void;
  111061. /**
  111062. * Release all the underlying texture used as draw buffers.
  111063. */
  111064. releaseInternalTextures(): void;
  111065. }
  111066. }
  111067. declare module BABYLON {
  111068. interface ThinEngine {
  111069. /**
  111070. * Unbind a list of render target textures from the webGL context
  111071. * This is used only when drawBuffer extension or webGL2 are active
  111072. * @param textures defines the render target textures to unbind
  111073. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111074. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111075. */
  111076. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111077. /**
  111078. * Create a multi render target texture
  111079. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111080. * @param size defines the size of the texture
  111081. * @param options defines the creation options
  111082. * @returns the cube texture as an InternalTexture
  111083. */
  111084. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111085. /**
  111086. * Update the sample count for a given multiple render target texture
  111087. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111088. * @param textures defines the textures to update
  111089. * @param samples defines the sample count to set
  111090. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111091. */
  111092. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111093. }
  111094. }
  111095. declare module BABYLON {
  111096. /**
  111097. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111098. */
  111099. export interface CubeMapInfo {
  111100. /**
  111101. * The pixel array for the front face.
  111102. * This is stored in format, left to right, up to down format.
  111103. */
  111104. front: Nullable<ArrayBufferView>;
  111105. /**
  111106. * The pixel array for the back face.
  111107. * This is stored in format, left to right, up to down format.
  111108. */
  111109. back: Nullable<ArrayBufferView>;
  111110. /**
  111111. * The pixel array for the left face.
  111112. * This is stored in format, left to right, up to down format.
  111113. */
  111114. left: Nullable<ArrayBufferView>;
  111115. /**
  111116. * The pixel array for the right face.
  111117. * This is stored in format, left to right, up to down format.
  111118. */
  111119. right: Nullable<ArrayBufferView>;
  111120. /**
  111121. * The pixel array for the up face.
  111122. * This is stored in format, left to right, up to down format.
  111123. */
  111124. up: Nullable<ArrayBufferView>;
  111125. /**
  111126. * The pixel array for the down face.
  111127. * This is stored in format, left to right, up to down format.
  111128. */
  111129. down: Nullable<ArrayBufferView>;
  111130. /**
  111131. * The size of the cubemap stored.
  111132. *
  111133. * Each faces will be size * size pixels.
  111134. */
  111135. size: number;
  111136. /**
  111137. * The format of the texture.
  111138. *
  111139. * RGBA, RGB.
  111140. */
  111141. format: number;
  111142. /**
  111143. * The type of the texture data.
  111144. *
  111145. * UNSIGNED_INT, FLOAT.
  111146. */
  111147. type: number;
  111148. /**
  111149. * Specifies whether the texture is in gamma space.
  111150. */
  111151. gammaSpace: boolean;
  111152. }
  111153. /**
  111154. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111155. */
  111156. export class PanoramaToCubeMapTools {
  111157. private static FACE_FRONT;
  111158. private static FACE_BACK;
  111159. private static FACE_RIGHT;
  111160. private static FACE_LEFT;
  111161. private static FACE_DOWN;
  111162. private static FACE_UP;
  111163. /**
  111164. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111165. *
  111166. * @param float32Array The source data.
  111167. * @param inputWidth The width of the input panorama.
  111168. * @param inputHeight The height of the input panorama.
  111169. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111170. * @return The cubemap data
  111171. */
  111172. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111173. private static CreateCubemapTexture;
  111174. private static CalcProjectionSpherical;
  111175. }
  111176. }
  111177. declare module BABYLON {
  111178. /**
  111179. * Helper class dealing with the extraction of spherical polynomial dataArray
  111180. * from a cube map.
  111181. */
  111182. export class CubeMapToSphericalPolynomialTools {
  111183. private static FileFaces;
  111184. /**
  111185. * Converts a texture to the according Spherical Polynomial data.
  111186. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111187. *
  111188. * @param texture The texture to extract the information from.
  111189. * @return The Spherical Polynomial data.
  111190. */
  111191. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111192. /**
  111193. * Converts a cubemap to the according Spherical Polynomial data.
  111194. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111195. *
  111196. * @param cubeInfo The Cube map to extract the information from.
  111197. * @return The Spherical Polynomial data.
  111198. */
  111199. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111200. }
  111201. }
  111202. declare module BABYLON {
  111203. interface BaseTexture {
  111204. /**
  111205. * Get the polynomial representation of the texture data.
  111206. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111207. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111208. */
  111209. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111210. }
  111211. }
  111212. declare module BABYLON {
  111213. /** @hidden */
  111214. export var rgbdEncodePixelShader: {
  111215. name: string;
  111216. shader: string;
  111217. };
  111218. }
  111219. declare module BABYLON {
  111220. /** @hidden */
  111221. export var rgbdDecodePixelShader: {
  111222. name: string;
  111223. shader: string;
  111224. };
  111225. }
  111226. declare module BABYLON {
  111227. /**
  111228. * Raw texture data and descriptor sufficient for WebGL texture upload
  111229. */
  111230. export interface EnvironmentTextureInfo {
  111231. /**
  111232. * Version of the environment map
  111233. */
  111234. version: number;
  111235. /**
  111236. * Width of image
  111237. */
  111238. width: number;
  111239. /**
  111240. * Irradiance information stored in the file.
  111241. */
  111242. irradiance: any;
  111243. /**
  111244. * Specular information stored in the file.
  111245. */
  111246. specular: any;
  111247. }
  111248. /**
  111249. * Defines One Image in the file. It requires only the position in the file
  111250. * as well as the length.
  111251. */
  111252. interface BufferImageData {
  111253. /**
  111254. * Length of the image data.
  111255. */
  111256. length: number;
  111257. /**
  111258. * Position of the data from the null terminator delimiting the end of the JSON.
  111259. */
  111260. position: number;
  111261. }
  111262. /**
  111263. * Defines the specular data enclosed in the file.
  111264. * This corresponds to the version 1 of the data.
  111265. */
  111266. export interface EnvironmentTextureSpecularInfoV1 {
  111267. /**
  111268. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111269. */
  111270. specularDataPosition?: number;
  111271. /**
  111272. * This contains all the images data needed to reconstruct the cubemap.
  111273. */
  111274. mipmaps: Array<BufferImageData>;
  111275. /**
  111276. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111277. */
  111278. lodGenerationScale: number;
  111279. }
  111280. /**
  111281. * Sets of helpers addressing the serialization and deserialization of environment texture
  111282. * stored in a BabylonJS env file.
  111283. * Those files are usually stored as .env files.
  111284. */
  111285. export class EnvironmentTextureTools {
  111286. /**
  111287. * Magic number identifying the env file.
  111288. */
  111289. private static _MagicBytes;
  111290. /**
  111291. * Gets the environment info from an env file.
  111292. * @param data The array buffer containing the .env bytes.
  111293. * @returns the environment file info (the json header) if successfully parsed.
  111294. */
  111295. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111296. /**
  111297. * Creates an environment texture from a loaded cube texture.
  111298. * @param texture defines the cube texture to convert in env file
  111299. * @return a promise containing the environment data if succesfull.
  111300. */
  111301. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111302. /**
  111303. * Creates a JSON representation of the spherical data.
  111304. * @param texture defines the texture containing the polynomials
  111305. * @return the JSON representation of the spherical info
  111306. */
  111307. private static _CreateEnvTextureIrradiance;
  111308. /**
  111309. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111310. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111311. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111312. * @return the views described by info providing access to the underlying buffer
  111313. */
  111314. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111315. /**
  111316. * Uploads the texture info contained in the env file to the GPU.
  111317. * @param texture defines the internal texture to upload to
  111318. * @param arrayBuffer defines the buffer cotaining the data to load
  111319. * @param info defines the texture info retrieved through the GetEnvInfo method
  111320. * @returns a promise
  111321. */
  111322. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111323. /**
  111324. * Uploads the levels of image data to the GPU.
  111325. * @param texture defines the internal texture to upload to
  111326. * @param imageData defines the array buffer views of image data [mipmap][face]
  111327. * @returns a promise
  111328. */
  111329. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111330. /**
  111331. * Uploads spherical polynomials information to the texture.
  111332. * @param texture defines the texture we are trying to upload the information to
  111333. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111334. */
  111335. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111336. /** @hidden */
  111337. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111338. }
  111339. }
  111340. declare module BABYLON {
  111341. /**
  111342. * Contains position and normal vectors for a vertex
  111343. */
  111344. export class PositionNormalVertex {
  111345. /** the position of the vertex (defaut: 0,0,0) */
  111346. position: Vector3;
  111347. /** the normal of the vertex (defaut: 0,1,0) */
  111348. normal: Vector3;
  111349. /**
  111350. * Creates a PositionNormalVertex
  111351. * @param position the position of the vertex (defaut: 0,0,0)
  111352. * @param normal the normal of the vertex (defaut: 0,1,0)
  111353. */
  111354. constructor(
  111355. /** the position of the vertex (defaut: 0,0,0) */
  111356. position?: Vector3,
  111357. /** the normal of the vertex (defaut: 0,1,0) */
  111358. normal?: Vector3);
  111359. /**
  111360. * Clones the PositionNormalVertex
  111361. * @returns the cloned PositionNormalVertex
  111362. */
  111363. clone(): PositionNormalVertex;
  111364. }
  111365. /**
  111366. * Contains position, normal and uv vectors for a vertex
  111367. */
  111368. export class PositionNormalTextureVertex {
  111369. /** the position of the vertex (defaut: 0,0,0) */
  111370. position: Vector3;
  111371. /** the normal of the vertex (defaut: 0,1,0) */
  111372. normal: Vector3;
  111373. /** the uv of the vertex (default: 0,0) */
  111374. uv: Vector2;
  111375. /**
  111376. * Creates a PositionNormalTextureVertex
  111377. * @param position the position of the vertex (defaut: 0,0,0)
  111378. * @param normal the normal of the vertex (defaut: 0,1,0)
  111379. * @param uv the uv of the vertex (default: 0,0)
  111380. */
  111381. constructor(
  111382. /** the position of the vertex (defaut: 0,0,0) */
  111383. position?: Vector3,
  111384. /** the normal of the vertex (defaut: 0,1,0) */
  111385. normal?: Vector3,
  111386. /** the uv of the vertex (default: 0,0) */
  111387. uv?: Vector2);
  111388. /**
  111389. * Clones the PositionNormalTextureVertex
  111390. * @returns the cloned PositionNormalTextureVertex
  111391. */
  111392. clone(): PositionNormalTextureVertex;
  111393. }
  111394. }
  111395. declare module BABYLON {
  111396. /** @hidden */
  111397. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111398. private _genericAttributeLocation;
  111399. private _varyingLocationCount;
  111400. private _varyingLocationMap;
  111401. private _replacements;
  111402. private _textureCount;
  111403. private _uniforms;
  111404. lineProcessor(line: string): string;
  111405. attributeProcessor(attribute: string): string;
  111406. varyingProcessor(varying: string, isFragment: boolean): string;
  111407. uniformProcessor(uniform: string): string;
  111408. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111409. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111410. }
  111411. }
  111412. declare module BABYLON {
  111413. /**
  111414. * Container for accessors for natively-stored mesh data buffers.
  111415. */
  111416. class NativeDataBuffer extends DataBuffer {
  111417. /**
  111418. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111419. */
  111420. nativeIndexBuffer?: any;
  111421. /**
  111422. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111423. */
  111424. nativeVertexBuffer?: any;
  111425. }
  111426. /** @hidden */
  111427. export class NativeEngine extends Engine {
  111428. private readonly _native;
  111429. getHardwareScalingLevel(): number;
  111430. constructor();
  111431. /**
  111432. * Can be used to override the current requestAnimationFrame requester.
  111433. * @hidden
  111434. */
  111435. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111436. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111437. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111438. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111439. recordVertexArrayObject(vertexBuffers: {
  111440. [key: string]: VertexBuffer;
  111441. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111442. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111443. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111444. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111445. /**
  111446. * Draw a list of indexed primitives
  111447. * @param fillMode defines the primitive to use
  111448. * @param indexStart defines the starting index
  111449. * @param indexCount defines the number of index to draw
  111450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111451. */
  111452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111453. /**
  111454. * Draw a list of unindexed primitives
  111455. * @param fillMode defines the primitive to use
  111456. * @param verticesStart defines the index of first vertex to draw
  111457. * @param verticesCount defines the count of vertices to draw
  111458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111459. */
  111460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111461. createPipelineContext(): IPipelineContext;
  111462. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111463. /** @hidden */
  111464. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111465. /** @hidden */
  111466. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111467. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111468. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111469. protected _setProgram(program: WebGLProgram): void;
  111470. _releaseEffect(effect: Effect): void;
  111471. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111472. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111473. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111474. bindSamplers(effect: Effect): void;
  111475. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111476. getRenderWidth(useScreen?: boolean): number;
  111477. getRenderHeight(useScreen?: boolean): number;
  111478. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111479. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111480. /**
  111481. * Set the z offset to apply to current rendering
  111482. * @param value defines the offset to apply
  111483. */
  111484. setZOffset(value: number): void;
  111485. /**
  111486. * Gets the current value of the zOffset
  111487. * @returns the current zOffset state
  111488. */
  111489. getZOffset(): number;
  111490. /**
  111491. * Enable or disable depth buffering
  111492. * @param enable defines the state to set
  111493. */
  111494. setDepthBuffer(enable: boolean): void;
  111495. /**
  111496. * Gets a boolean indicating if depth writing is enabled
  111497. * @returns the current depth writing state
  111498. */
  111499. getDepthWrite(): boolean;
  111500. /**
  111501. * Enable or disable depth writing
  111502. * @param enable defines the state to set
  111503. */
  111504. setDepthWrite(enable: boolean): void;
  111505. /**
  111506. * Enable or disable color writing
  111507. * @param enable defines the state to set
  111508. */
  111509. setColorWrite(enable: boolean): void;
  111510. /**
  111511. * Gets a boolean indicating if color writing is enabled
  111512. * @returns the current color writing state
  111513. */
  111514. getColorWrite(): boolean;
  111515. /**
  111516. * Sets alpha constants used by some alpha blending modes
  111517. * @param r defines the red component
  111518. * @param g defines the green component
  111519. * @param b defines the blue component
  111520. * @param a defines the alpha component
  111521. */
  111522. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111523. /**
  111524. * Sets the current alpha mode
  111525. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111526. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111527. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111528. */
  111529. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111530. /**
  111531. * Gets the current alpha mode
  111532. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111533. * @returns the current alpha mode
  111534. */
  111535. getAlphaMode(): number;
  111536. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111537. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111538. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111539. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111540. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111541. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111542. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111543. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111544. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111545. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111546. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111547. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111548. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111549. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111550. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111551. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111552. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111553. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111554. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111555. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111556. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111557. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111558. wipeCaches(bruteForce?: boolean): void;
  111559. _createTexture(): WebGLTexture;
  111560. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111561. /**
  111562. * Usually called from BABYLON.Texture.ts.
  111563. * Passed information to create a WebGLTexture
  111564. * @param urlArg defines a value which contains one of the following:
  111565. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111566. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111567. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111568. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111569. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111570. * @param scene needed for loading to the correct scene
  111571. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111572. * @param onLoad optional callback to be called upon successful completion
  111573. * @param onError optional callback to be called upon failure
  111574. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111575. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111576. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111577. * @param forcedExtension defines the extension to use to pick the right loader
  111578. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111579. */
  111580. 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;
  111581. /**
  111582. * Creates a cube texture
  111583. * @param rootUrl defines the url where the files to load is located
  111584. * @param scene defines the current scene
  111585. * @param files defines the list of files to load (1 per face)
  111586. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111587. * @param onLoad defines an optional callback raised when the texture is loaded
  111588. * @param onError defines an optional callback raised if there is an issue to load the texture
  111589. * @param format defines the format of the data
  111590. * @param forcedExtension defines the extension to use to pick the right loader
  111591. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111592. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111593. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111594. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111595. * @returns the cube texture as an InternalTexture
  111596. */
  111597. 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;
  111598. private _getSamplingFilter;
  111599. private static _GetNativeTextureFormat;
  111600. createRenderTargetTexture(size: number | {
  111601. width: number;
  111602. height: number;
  111603. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111604. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111605. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111606. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111607. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111608. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111609. /**
  111610. * Updates a dynamic vertex buffer.
  111611. * @param vertexBuffer the vertex buffer to update
  111612. * @param data the data used to update the vertex buffer
  111613. * @param byteOffset the byte offset of the data (optional)
  111614. * @param byteLength the byte length of the data (optional)
  111615. */
  111616. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111617. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111618. private _updateAnisotropicLevel;
  111619. private _getAddressMode;
  111620. /** @hidden */
  111621. _bindTexture(channel: number, texture: InternalTexture): void;
  111622. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111623. releaseEffects(): void;
  111624. /** @hidden */
  111625. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111626. /** @hidden */
  111627. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111628. /** @hidden */
  111629. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111630. /** @hidden */
  111631. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111632. }
  111633. }
  111634. declare module BABYLON {
  111635. /**
  111636. * Gather the list of clipboard event types as constants.
  111637. */
  111638. export class ClipboardEventTypes {
  111639. /**
  111640. * The clipboard event is fired when a copy command is active (pressed).
  111641. */
  111642. static readonly COPY: number;
  111643. /**
  111644. * The clipboard event is fired when a cut command is active (pressed).
  111645. */
  111646. static readonly CUT: number;
  111647. /**
  111648. * The clipboard event is fired when a paste command is active (pressed).
  111649. */
  111650. static readonly PASTE: number;
  111651. }
  111652. /**
  111653. * This class is used to store clipboard related info for the onClipboardObservable event.
  111654. */
  111655. export class ClipboardInfo {
  111656. /**
  111657. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111658. */
  111659. type: number;
  111660. /**
  111661. * Defines the related dom event
  111662. */
  111663. event: ClipboardEvent;
  111664. /**
  111665. *Creates an instance of ClipboardInfo.
  111666. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111667. * @param event Defines the related dom event
  111668. */
  111669. constructor(
  111670. /**
  111671. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111672. */
  111673. type: number,
  111674. /**
  111675. * Defines the related dom event
  111676. */
  111677. event: ClipboardEvent);
  111678. /**
  111679. * Get the clipboard event's type from the keycode.
  111680. * @param keyCode Defines the keyCode for the current keyboard event.
  111681. * @return {number}
  111682. */
  111683. static GetTypeFromCharacter(keyCode: number): number;
  111684. }
  111685. }
  111686. declare module BABYLON {
  111687. /**
  111688. * Google Daydream controller
  111689. */
  111690. export class DaydreamController extends WebVRController {
  111691. /**
  111692. * Base Url for the controller model.
  111693. */
  111694. static MODEL_BASE_URL: string;
  111695. /**
  111696. * File name for the controller model.
  111697. */
  111698. static MODEL_FILENAME: string;
  111699. /**
  111700. * Gamepad Id prefix used to identify Daydream Controller.
  111701. */
  111702. static readonly GAMEPAD_ID_PREFIX: string;
  111703. /**
  111704. * Creates a new DaydreamController from a gamepad
  111705. * @param vrGamepad the gamepad that the controller should be created from
  111706. */
  111707. constructor(vrGamepad: any);
  111708. /**
  111709. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111710. * @param scene scene in which to add meshes
  111711. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111712. */
  111713. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111714. /**
  111715. * Called once for each button that changed state since the last frame
  111716. * @param buttonIdx Which button index changed
  111717. * @param state New state of the button
  111718. * @param changes Which properties on the state changed since last frame
  111719. */
  111720. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111721. }
  111722. }
  111723. declare module BABYLON {
  111724. /**
  111725. * Gear VR Controller
  111726. */
  111727. export class GearVRController extends WebVRController {
  111728. /**
  111729. * Base Url for the controller model.
  111730. */
  111731. static MODEL_BASE_URL: string;
  111732. /**
  111733. * File name for the controller model.
  111734. */
  111735. static MODEL_FILENAME: string;
  111736. /**
  111737. * Gamepad Id prefix used to identify this controller.
  111738. */
  111739. static readonly GAMEPAD_ID_PREFIX: string;
  111740. private readonly _buttonIndexToObservableNameMap;
  111741. /**
  111742. * Creates a new GearVRController from a gamepad
  111743. * @param vrGamepad the gamepad that the controller should be created from
  111744. */
  111745. constructor(vrGamepad: any);
  111746. /**
  111747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111748. * @param scene scene in which to add meshes
  111749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111750. */
  111751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111752. /**
  111753. * Called once for each button that changed state since the last frame
  111754. * @param buttonIdx Which button index changed
  111755. * @param state New state of the button
  111756. * @param changes Which properties on the state changed since last frame
  111757. */
  111758. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111759. }
  111760. }
  111761. declare module BABYLON {
  111762. /**
  111763. * Class containing static functions to help procedurally build meshes
  111764. */
  111765. export class PolyhedronBuilder {
  111766. /**
  111767. * Creates a polyhedron mesh
  111768. * * 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
  111769. * * The parameter `size` (positive float, default 1) sets the polygon size
  111770. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111771. * * 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`
  111772. * * 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
  111773. * * 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)`)
  111774. * * 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
  111775. * * 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
  111776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111779. * @param name defines the name of the mesh
  111780. * @param options defines the options used to create the mesh
  111781. * @param scene defines the hosting scene
  111782. * @returns the polyhedron mesh
  111783. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111784. */
  111785. static CreatePolyhedron(name: string, options: {
  111786. type?: number;
  111787. size?: number;
  111788. sizeX?: number;
  111789. sizeY?: number;
  111790. sizeZ?: number;
  111791. custom?: any;
  111792. faceUV?: Vector4[];
  111793. faceColors?: Color4[];
  111794. flat?: boolean;
  111795. updatable?: boolean;
  111796. sideOrientation?: number;
  111797. frontUVs?: Vector4;
  111798. backUVs?: Vector4;
  111799. }, scene?: Nullable<Scene>): Mesh;
  111800. }
  111801. }
  111802. declare module BABYLON {
  111803. /**
  111804. * Gizmo that enables scaling a mesh along 3 axis
  111805. */
  111806. export class ScaleGizmo extends Gizmo {
  111807. /**
  111808. * Internal gizmo used for interactions on the x axis
  111809. */
  111810. xGizmo: AxisScaleGizmo;
  111811. /**
  111812. * Internal gizmo used for interactions on the y axis
  111813. */
  111814. yGizmo: AxisScaleGizmo;
  111815. /**
  111816. * Internal gizmo used for interactions on the z axis
  111817. */
  111818. zGizmo: AxisScaleGizmo;
  111819. /**
  111820. * Internal gizmo used to scale all axis equally
  111821. */
  111822. uniformScaleGizmo: AxisScaleGizmo;
  111823. private _meshAttached;
  111824. private _updateGizmoRotationToMatchAttachedMesh;
  111825. private _snapDistance;
  111826. private _scaleRatio;
  111827. private _uniformScalingMesh;
  111828. private _octahedron;
  111829. /** Fires an event when any of it's sub gizmos are dragged */
  111830. onDragStartObservable: Observable<unknown>;
  111831. /** Fires an event when any of it's sub gizmos are released from dragging */
  111832. onDragEndObservable: Observable<unknown>;
  111833. attachedMesh: Nullable<AbstractMesh>;
  111834. /**
  111835. * Creates a ScaleGizmo
  111836. * @param gizmoLayer The utility layer the gizmo will be added to
  111837. */
  111838. constructor(gizmoLayer?: UtilityLayerRenderer);
  111839. updateGizmoRotationToMatchAttachedMesh: boolean;
  111840. /**
  111841. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111842. */
  111843. snapDistance: number;
  111844. /**
  111845. * Ratio for the scale of the gizmo (Default: 1)
  111846. */
  111847. scaleRatio: number;
  111848. /**
  111849. * Disposes of the gizmo
  111850. */
  111851. dispose(): void;
  111852. }
  111853. }
  111854. declare module BABYLON {
  111855. /**
  111856. * Single axis scale gizmo
  111857. */
  111858. export class AxisScaleGizmo extends Gizmo {
  111859. /**
  111860. * Drag behavior responsible for the gizmos dragging interactions
  111861. */
  111862. dragBehavior: PointerDragBehavior;
  111863. private _pointerObserver;
  111864. /**
  111865. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111866. */
  111867. snapDistance: number;
  111868. /**
  111869. * Event that fires each time the gizmo snaps to a new location.
  111870. * * snapDistance is the the change in distance
  111871. */
  111872. onSnapObservable: Observable<{
  111873. snapDistance: number;
  111874. }>;
  111875. /**
  111876. * If the scaling operation should be done on all axis (default: false)
  111877. */
  111878. uniformScaling: boolean;
  111879. private _isEnabled;
  111880. private _parent;
  111881. private _arrow;
  111882. private _coloredMaterial;
  111883. private _hoverMaterial;
  111884. /**
  111885. * Creates an AxisScaleGizmo
  111886. * @param gizmoLayer The utility layer the gizmo will be added to
  111887. * @param dragAxis The axis which the gizmo will be able to scale on
  111888. * @param color The color of the gizmo
  111889. */
  111890. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111891. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111892. /**
  111893. * If the gizmo is enabled
  111894. */
  111895. isEnabled: boolean;
  111896. /**
  111897. * Disposes of the gizmo
  111898. */
  111899. dispose(): void;
  111900. /**
  111901. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111902. * @param mesh The mesh to replace the default mesh of the gizmo
  111903. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111904. */
  111905. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111906. }
  111907. }
  111908. declare module BABYLON {
  111909. /**
  111910. * Bounding box gizmo
  111911. */
  111912. export class BoundingBoxGizmo extends Gizmo {
  111913. private _lineBoundingBox;
  111914. private _rotateSpheresParent;
  111915. private _scaleBoxesParent;
  111916. private _boundingDimensions;
  111917. private _renderObserver;
  111918. private _pointerObserver;
  111919. private _scaleDragSpeed;
  111920. private _tmpQuaternion;
  111921. private _tmpVector;
  111922. private _tmpRotationMatrix;
  111923. /**
  111924. * 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)
  111925. */
  111926. ignoreChildren: boolean;
  111927. /**
  111928. * 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)
  111929. */
  111930. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111931. /**
  111932. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111933. */
  111934. rotationSphereSize: number;
  111935. /**
  111936. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111937. */
  111938. scaleBoxSize: number;
  111939. /**
  111940. * 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)
  111941. */
  111942. fixedDragMeshScreenSize: boolean;
  111943. /**
  111944. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111945. */
  111946. fixedDragMeshScreenSizeDistanceFactor: number;
  111947. /**
  111948. * Fired when a rotation sphere or scale box is dragged
  111949. */
  111950. onDragStartObservable: Observable<{}>;
  111951. /**
  111952. * Fired when a scale box is dragged
  111953. */
  111954. onScaleBoxDragObservable: Observable<{}>;
  111955. /**
  111956. * Fired when a scale box drag is ended
  111957. */
  111958. onScaleBoxDragEndObservable: Observable<{}>;
  111959. /**
  111960. * Fired when a rotation sphere is dragged
  111961. */
  111962. onRotationSphereDragObservable: Observable<{}>;
  111963. /**
  111964. * Fired when a rotation sphere drag is ended
  111965. */
  111966. onRotationSphereDragEndObservable: Observable<{}>;
  111967. /**
  111968. * 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)
  111969. */
  111970. scalePivot: Nullable<Vector3>;
  111971. /**
  111972. * Mesh used as a pivot to rotate the attached mesh
  111973. */
  111974. private _anchorMesh;
  111975. private _existingMeshScale;
  111976. private _dragMesh;
  111977. private pointerDragBehavior;
  111978. private coloredMaterial;
  111979. private hoverColoredMaterial;
  111980. /**
  111981. * Sets the color of the bounding box gizmo
  111982. * @param color the color to set
  111983. */
  111984. setColor(color: Color3): void;
  111985. /**
  111986. * Creates an BoundingBoxGizmo
  111987. * @param gizmoLayer The utility layer the gizmo will be added to
  111988. * @param color The color of the gizmo
  111989. */
  111990. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111992. private _selectNode;
  111993. /**
  111994. * Updates the bounding box information for the Gizmo
  111995. */
  111996. updateBoundingBox(): void;
  111997. private _updateRotationSpheres;
  111998. private _updateScaleBoxes;
  111999. /**
  112000. * Enables rotation on the specified axis and disables rotation on the others
  112001. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112002. */
  112003. setEnabledRotationAxis(axis: string): void;
  112004. /**
  112005. * Enables/disables scaling
  112006. * @param enable if scaling should be enabled
  112007. */
  112008. setEnabledScaling(enable: boolean): void;
  112009. private _updateDummy;
  112010. /**
  112011. * Enables a pointer drag behavior on the bounding box of the gizmo
  112012. */
  112013. enableDragBehavior(): void;
  112014. /**
  112015. * Disposes of the gizmo
  112016. */
  112017. dispose(): void;
  112018. /**
  112019. * 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)
  112020. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112021. * @returns the bounding box mesh with the passed in mesh as a child
  112022. */
  112023. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112024. /**
  112025. * CustomMeshes are not supported by this gizmo
  112026. * @param mesh The mesh to replace the default mesh of the gizmo
  112027. */
  112028. setCustomMesh(mesh: Mesh): void;
  112029. }
  112030. }
  112031. declare module BABYLON {
  112032. /**
  112033. * Single plane rotation gizmo
  112034. */
  112035. export class PlaneRotationGizmo extends Gizmo {
  112036. /**
  112037. * Drag behavior responsible for the gizmos dragging interactions
  112038. */
  112039. dragBehavior: PointerDragBehavior;
  112040. private _pointerObserver;
  112041. /**
  112042. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112043. */
  112044. snapDistance: number;
  112045. /**
  112046. * Event that fires each time the gizmo snaps to a new location.
  112047. * * snapDistance is the the change in distance
  112048. */
  112049. onSnapObservable: Observable<{
  112050. snapDistance: number;
  112051. }>;
  112052. private _isEnabled;
  112053. private _parent;
  112054. /**
  112055. * Creates a PlaneRotationGizmo
  112056. * @param gizmoLayer The utility layer the gizmo will be added to
  112057. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112058. * @param color The color of the gizmo
  112059. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112060. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112061. */
  112062. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112063. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112064. /**
  112065. * If the gizmo is enabled
  112066. */
  112067. isEnabled: boolean;
  112068. /**
  112069. * Disposes of the gizmo
  112070. */
  112071. dispose(): void;
  112072. }
  112073. }
  112074. declare module BABYLON {
  112075. /**
  112076. * Gizmo that enables rotating a mesh along 3 axis
  112077. */
  112078. export class RotationGizmo extends Gizmo {
  112079. /**
  112080. * Internal gizmo used for interactions on the x axis
  112081. */
  112082. xGizmo: PlaneRotationGizmo;
  112083. /**
  112084. * Internal gizmo used for interactions on the y axis
  112085. */
  112086. yGizmo: PlaneRotationGizmo;
  112087. /**
  112088. * Internal gizmo used for interactions on the z axis
  112089. */
  112090. zGizmo: PlaneRotationGizmo;
  112091. /** Fires an event when any of it's sub gizmos are dragged */
  112092. onDragStartObservable: Observable<unknown>;
  112093. /** Fires an event when any of it's sub gizmos are released from dragging */
  112094. onDragEndObservable: Observable<unknown>;
  112095. private _meshAttached;
  112096. attachedMesh: Nullable<AbstractMesh>;
  112097. /**
  112098. * Creates a RotationGizmo
  112099. * @param gizmoLayer The utility layer the gizmo will be added to
  112100. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112101. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112102. */
  112103. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112104. updateGizmoRotationToMatchAttachedMesh: boolean;
  112105. /**
  112106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112107. */
  112108. snapDistance: number;
  112109. /**
  112110. * Ratio for the scale of the gizmo (Default: 1)
  112111. */
  112112. scaleRatio: number;
  112113. /**
  112114. * Disposes of the gizmo
  112115. */
  112116. dispose(): void;
  112117. /**
  112118. * CustomMeshes are not supported by this gizmo
  112119. * @param mesh The mesh to replace the default mesh of the gizmo
  112120. */
  112121. setCustomMesh(mesh: Mesh): void;
  112122. }
  112123. }
  112124. declare module BABYLON {
  112125. /**
  112126. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112127. */
  112128. export class GizmoManager implements IDisposable {
  112129. private scene;
  112130. /**
  112131. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112132. */
  112133. gizmos: {
  112134. positionGizmo: Nullable<PositionGizmo>;
  112135. rotationGizmo: Nullable<RotationGizmo>;
  112136. scaleGizmo: Nullable<ScaleGizmo>;
  112137. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112138. };
  112139. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112140. clearGizmoOnEmptyPointerEvent: boolean;
  112141. /** Fires an event when the manager is attached to a mesh */
  112142. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112143. private _gizmosEnabled;
  112144. private _pointerObserver;
  112145. private _attachedMesh;
  112146. private _boundingBoxColor;
  112147. private _defaultUtilityLayer;
  112148. private _defaultKeepDepthUtilityLayer;
  112149. /**
  112150. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112151. */
  112152. boundingBoxDragBehavior: SixDofDragBehavior;
  112153. /**
  112154. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112155. */
  112156. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112157. /**
  112158. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112159. */
  112160. usePointerToAttachGizmos: boolean;
  112161. /**
  112162. * Utility layer that the bounding box gizmo belongs to
  112163. */
  112164. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112165. /**
  112166. * Utility layer that all gizmos besides bounding box belong to
  112167. */
  112168. readonly utilityLayer: UtilityLayerRenderer;
  112169. /**
  112170. * Instatiates a gizmo manager
  112171. * @param scene the scene to overlay the gizmos on top of
  112172. */
  112173. constructor(scene: Scene);
  112174. /**
  112175. * Attaches a set of gizmos to the specified mesh
  112176. * @param mesh The mesh the gizmo's should be attached to
  112177. */
  112178. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112179. /**
  112180. * If the position gizmo is enabled
  112181. */
  112182. positionGizmoEnabled: boolean;
  112183. /**
  112184. * If the rotation gizmo is enabled
  112185. */
  112186. rotationGizmoEnabled: boolean;
  112187. /**
  112188. * If the scale gizmo is enabled
  112189. */
  112190. scaleGizmoEnabled: boolean;
  112191. /**
  112192. * If the boundingBox gizmo is enabled
  112193. */
  112194. boundingBoxGizmoEnabled: boolean;
  112195. /**
  112196. * Disposes of the gizmo manager
  112197. */
  112198. dispose(): void;
  112199. }
  112200. }
  112201. declare module BABYLON {
  112202. /**
  112203. * A directional light is defined by a direction (what a surprise!).
  112204. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112205. * 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.
  112206. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112207. */
  112208. export class DirectionalLight extends ShadowLight {
  112209. private _shadowFrustumSize;
  112210. /**
  112211. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112212. */
  112213. /**
  112214. * Specifies a fix frustum size for the shadow generation.
  112215. */
  112216. shadowFrustumSize: number;
  112217. private _shadowOrthoScale;
  112218. /**
  112219. * Gets the shadow projection scale against the optimal computed one.
  112220. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112221. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112222. */
  112223. /**
  112224. * Sets the shadow projection scale against the optimal computed one.
  112225. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112226. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112227. */
  112228. shadowOrthoScale: number;
  112229. /**
  112230. * Automatically compute the projection matrix to best fit (including all the casters)
  112231. * on each frame.
  112232. */
  112233. autoUpdateExtends: boolean;
  112234. private _orthoLeft;
  112235. private _orthoRight;
  112236. private _orthoTop;
  112237. private _orthoBottom;
  112238. /**
  112239. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112240. * The directional light is emitted from everywhere in the given direction.
  112241. * It can cast shadows.
  112242. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112243. * @param name The friendly name of the light
  112244. * @param direction The direction of the light
  112245. * @param scene The scene the light belongs to
  112246. */
  112247. constructor(name: string, direction: Vector3, scene: Scene);
  112248. /**
  112249. * Returns the string "DirectionalLight".
  112250. * @return The class name
  112251. */
  112252. getClassName(): string;
  112253. /**
  112254. * Returns the integer 1.
  112255. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112256. */
  112257. getTypeID(): number;
  112258. /**
  112259. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112260. * Returns the DirectionalLight Shadow projection matrix.
  112261. */
  112262. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112263. /**
  112264. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112265. * Returns the DirectionalLight Shadow projection matrix.
  112266. */
  112267. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112268. /**
  112269. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112270. * Returns the DirectionalLight Shadow projection matrix.
  112271. */
  112272. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112273. protected _buildUniformLayout(): void;
  112274. /**
  112275. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112276. * @param effect The effect to update
  112277. * @param lightIndex The index of the light in the effect to update
  112278. * @returns The directional light
  112279. */
  112280. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112281. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112282. /**
  112283. * Gets the minZ used for shadow according to both the scene and the light.
  112284. *
  112285. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112286. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112287. * @param activeCamera The camera we are returning the min for
  112288. * @returns the depth min z
  112289. */
  112290. getDepthMinZ(activeCamera: Camera): number;
  112291. /**
  112292. * Gets the maxZ used for shadow according to both the scene and the light.
  112293. *
  112294. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112295. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112296. * @param activeCamera The camera we are returning the max for
  112297. * @returns the depth max z
  112298. */
  112299. getDepthMaxZ(activeCamera: Camera): number;
  112300. /**
  112301. * Prepares the list of defines specific to the light type.
  112302. * @param defines the list of defines
  112303. * @param lightIndex defines the index of the light for the effect
  112304. */
  112305. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112306. }
  112307. }
  112308. declare module BABYLON {
  112309. /**
  112310. * Class containing static functions to help procedurally build meshes
  112311. */
  112312. export class HemisphereBuilder {
  112313. /**
  112314. * Creates a hemisphere mesh
  112315. * @param name defines the name of the mesh
  112316. * @param options defines the options used to create the mesh
  112317. * @param scene defines the hosting scene
  112318. * @returns the hemisphere mesh
  112319. */
  112320. static CreateHemisphere(name: string, options: {
  112321. segments?: number;
  112322. diameter?: number;
  112323. sideOrientation?: number;
  112324. }, scene: any): Mesh;
  112325. }
  112326. }
  112327. declare module BABYLON {
  112328. /**
  112329. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112330. * These values define a cone of light starting from the position, emitting toward the direction.
  112331. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112332. * and the exponent defines the speed of the decay of the light with distance (reach).
  112333. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112334. */
  112335. export class SpotLight extends ShadowLight {
  112336. private _angle;
  112337. private _innerAngle;
  112338. private _cosHalfAngle;
  112339. private _lightAngleScale;
  112340. private _lightAngleOffset;
  112341. /**
  112342. * Gets the cone angle of the spot light in Radians.
  112343. */
  112344. /**
  112345. * Sets the cone angle of the spot light in Radians.
  112346. */
  112347. angle: number;
  112348. /**
  112349. * Only used in gltf falloff mode, this defines the angle where
  112350. * the directional falloff will start before cutting at angle which could be seen
  112351. * as outer angle.
  112352. */
  112353. /**
  112354. * Only used in gltf falloff mode, this defines the angle where
  112355. * the directional falloff will start before cutting at angle which could be seen
  112356. * as outer angle.
  112357. */
  112358. innerAngle: number;
  112359. private _shadowAngleScale;
  112360. /**
  112361. * Allows scaling the angle of the light for shadow generation only.
  112362. */
  112363. /**
  112364. * Allows scaling the angle of the light for shadow generation only.
  112365. */
  112366. shadowAngleScale: number;
  112367. /**
  112368. * The light decay speed with the distance from the emission spot.
  112369. */
  112370. exponent: number;
  112371. private _projectionTextureMatrix;
  112372. /**
  112373. * Allows reading the projecton texture
  112374. */
  112375. readonly projectionTextureMatrix: Matrix;
  112376. protected _projectionTextureLightNear: number;
  112377. /**
  112378. * Gets the near clip of the Spotlight for texture projection.
  112379. */
  112380. /**
  112381. * Sets the near clip of the Spotlight for texture projection.
  112382. */
  112383. projectionTextureLightNear: number;
  112384. protected _projectionTextureLightFar: number;
  112385. /**
  112386. * Gets the far clip of the Spotlight for texture projection.
  112387. */
  112388. /**
  112389. * Sets the far clip of the Spotlight for texture projection.
  112390. */
  112391. projectionTextureLightFar: number;
  112392. protected _projectionTextureUpDirection: Vector3;
  112393. /**
  112394. * Gets the Up vector of the Spotlight for texture projection.
  112395. */
  112396. /**
  112397. * Sets the Up vector of the Spotlight for texture projection.
  112398. */
  112399. projectionTextureUpDirection: Vector3;
  112400. private _projectionTexture;
  112401. /**
  112402. * Gets the projection texture of the light.
  112403. */
  112404. /**
  112405. * Sets the projection texture of the light.
  112406. */
  112407. projectionTexture: Nullable<BaseTexture>;
  112408. private _projectionTextureViewLightDirty;
  112409. private _projectionTextureProjectionLightDirty;
  112410. private _projectionTextureDirty;
  112411. private _projectionTextureViewTargetVector;
  112412. private _projectionTextureViewLightMatrix;
  112413. private _projectionTextureProjectionLightMatrix;
  112414. private _projectionTextureScalingMatrix;
  112415. /**
  112416. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112417. * It can cast shadows.
  112418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112419. * @param name The light friendly name
  112420. * @param position The position of the spot light in the scene
  112421. * @param direction The direction of the light in the scene
  112422. * @param angle The cone angle of the light in Radians
  112423. * @param exponent The light decay speed with the distance from the emission spot
  112424. * @param scene The scene the lights belongs to
  112425. */
  112426. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112427. /**
  112428. * Returns the string "SpotLight".
  112429. * @returns the class name
  112430. */
  112431. getClassName(): string;
  112432. /**
  112433. * Returns the integer 2.
  112434. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112435. */
  112436. getTypeID(): number;
  112437. /**
  112438. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112439. */
  112440. protected _setDirection(value: Vector3): void;
  112441. /**
  112442. * Overrides the position setter to recompute the projection texture view light Matrix.
  112443. */
  112444. protected _setPosition(value: Vector3): void;
  112445. /**
  112446. * 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.
  112447. * Returns the SpotLight.
  112448. */
  112449. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112450. protected _computeProjectionTextureViewLightMatrix(): void;
  112451. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112452. /**
  112453. * Main function for light texture projection matrix computing.
  112454. */
  112455. protected _computeProjectionTextureMatrix(): void;
  112456. protected _buildUniformLayout(): void;
  112457. private _computeAngleValues;
  112458. /**
  112459. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112460. * @param effect The effect to update
  112461. * @param lightIndex The index of the light in the effect to update
  112462. * @returns The spot light
  112463. */
  112464. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112465. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112466. /**
  112467. * Disposes the light and the associated resources.
  112468. */
  112469. dispose(): void;
  112470. /**
  112471. * Prepares the list of defines specific to the light type.
  112472. * @param defines the list of defines
  112473. * @param lightIndex defines the index of the light for the effect
  112474. */
  112475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112476. }
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * Gizmo that enables viewing a light
  112481. */
  112482. export class LightGizmo extends Gizmo {
  112483. private _lightMesh;
  112484. private _material;
  112485. private cachedPosition;
  112486. private cachedForward;
  112487. /**
  112488. * Creates a LightGizmo
  112489. * @param gizmoLayer The utility layer the gizmo will be added to
  112490. */
  112491. constructor(gizmoLayer?: UtilityLayerRenderer);
  112492. private _light;
  112493. /**
  112494. * The light that the gizmo is attached to
  112495. */
  112496. light: Nullable<Light>;
  112497. /**
  112498. * Gets the material used to render the light gizmo
  112499. */
  112500. readonly material: StandardMaterial;
  112501. /**
  112502. * @hidden
  112503. * Updates the gizmo to match the attached mesh's position/rotation
  112504. */
  112505. protected _update(): void;
  112506. private static _Scale;
  112507. /**
  112508. * Creates the lines for a light mesh
  112509. */
  112510. private static _createLightLines;
  112511. /**
  112512. * Disposes of the light gizmo
  112513. */
  112514. dispose(): void;
  112515. private static _CreateHemisphericLightMesh;
  112516. private static _CreatePointLightMesh;
  112517. private static _CreateSpotLightMesh;
  112518. private static _CreateDirectionalLightMesh;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. /** @hidden */
  112523. export var backgroundFragmentDeclaration: {
  112524. name: string;
  112525. shader: string;
  112526. };
  112527. }
  112528. declare module BABYLON {
  112529. /** @hidden */
  112530. export var backgroundUboDeclaration: {
  112531. name: string;
  112532. shader: string;
  112533. };
  112534. }
  112535. declare module BABYLON {
  112536. /** @hidden */
  112537. export var backgroundPixelShader: {
  112538. name: string;
  112539. shader: string;
  112540. };
  112541. }
  112542. declare module BABYLON {
  112543. /** @hidden */
  112544. export var backgroundVertexDeclaration: {
  112545. name: string;
  112546. shader: string;
  112547. };
  112548. }
  112549. declare module BABYLON {
  112550. /** @hidden */
  112551. export var backgroundVertexShader: {
  112552. name: string;
  112553. shader: string;
  112554. };
  112555. }
  112556. declare module BABYLON {
  112557. /**
  112558. * Background material used to create an efficient environement around your scene.
  112559. */
  112560. export class BackgroundMaterial extends PushMaterial {
  112561. /**
  112562. * Standard reflectance value at parallel view angle.
  112563. */
  112564. static StandardReflectance0: number;
  112565. /**
  112566. * Standard reflectance value at grazing angle.
  112567. */
  112568. static StandardReflectance90: number;
  112569. protected _primaryColor: Color3;
  112570. /**
  112571. * Key light Color (multiply against the environement texture)
  112572. */
  112573. primaryColor: Color3;
  112574. protected __perceptualColor: Nullable<Color3>;
  112575. /**
  112576. * Experimental Internal Use Only.
  112577. *
  112578. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112579. * This acts as a helper to set the primary color to a more "human friendly" value.
  112580. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112581. * output color as close as possible from the chosen value.
  112582. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112583. * part of lighting setup.)
  112584. */
  112585. _perceptualColor: Nullable<Color3>;
  112586. protected _primaryColorShadowLevel: float;
  112587. /**
  112588. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112589. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112590. */
  112591. primaryColorShadowLevel: float;
  112592. protected _primaryColorHighlightLevel: float;
  112593. /**
  112594. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112595. * The primary color is used at the level chosen to define what the white area would look.
  112596. */
  112597. primaryColorHighlightLevel: float;
  112598. protected _reflectionTexture: Nullable<BaseTexture>;
  112599. /**
  112600. * Reflection Texture used in the material.
  112601. * Should be author in a specific way for the best result (refer to the documentation).
  112602. */
  112603. reflectionTexture: Nullable<BaseTexture>;
  112604. protected _reflectionBlur: float;
  112605. /**
  112606. * Reflection Texture level of blur.
  112607. *
  112608. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112609. * texture twice.
  112610. */
  112611. reflectionBlur: float;
  112612. protected _diffuseTexture: Nullable<BaseTexture>;
  112613. /**
  112614. * Diffuse Texture used in the material.
  112615. * Should be author in a specific way for the best result (refer to the documentation).
  112616. */
  112617. diffuseTexture: Nullable<BaseTexture>;
  112618. protected _shadowLights: Nullable<IShadowLight[]>;
  112619. /**
  112620. * Specify the list of lights casting shadow on the material.
  112621. * All scene shadow lights will be included if null.
  112622. */
  112623. shadowLights: Nullable<IShadowLight[]>;
  112624. protected _shadowLevel: float;
  112625. /**
  112626. * Helps adjusting the shadow to a softer level if required.
  112627. * 0 means black shadows and 1 means no shadows.
  112628. */
  112629. shadowLevel: float;
  112630. protected _sceneCenter: Vector3;
  112631. /**
  112632. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112633. * It is usually zero but might be interesting to modify according to your setup.
  112634. */
  112635. sceneCenter: Vector3;
  112636. protected _opacityFresnel: boolean;
  112637. /**
  112638. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112639. * This helps ensuring a nice transition when the camera goes under the ground.
  112640. */
  112641. opacityFresnel: boolean;
  112642. protected _reflectionFresnel: boolean;
  112643. /**
  112644. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112645. * This helps adding a mirror texture on the ground.
  112646. */
  112647. reflectionFresnel: boolean;
  112648. protected _reflectionFalloffDistance: number;
  112649. /**
  112650. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112651. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112652. */
  112653. reflectionFalloffDistance: number;
  112654. protected _reflectionAmount: number;
  112655. /**
  112656. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112657. */
  112658. reflectionAmount: number;
  112659. protected _reflectionReflectance0: number;
  112660. /**
  112661. * This specifies the weight of the reflection at grazing angle.
  112662. */
  112663. reflectionReflectance0: number;
  112664. protected _reflectionReflectance90: number;
  112665. /**
  112666. * This specifies the weight of the reflection at a perpendicular point of view.
  112667. */
  112668. reflectionReflectance90: number;
  112669. /**
  112670. * Sets the reflection reflectance fresnel values according to the default standard
  112671. * empirically know to work well :-)
  112672. */
  112673. reflectionStandardFresnelWeight: number;
  112674. protected _useRGBColor: boolean;
  112675. /**
  112676. * Helps to directly use the maps channels instead of their level.
  112677. */
  112678. useRGBColor: boolean;
  112679. protected _enableNoise: boolean;
  112680. /**
  112681. * This helps reducing the banding effect that could occur on the background.
  112682. */
  112683. enableNoise: boolean;
  112684. /**
  112685. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112686. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112687. * Recommended to be keep at 1.0 except for special cases.
  112688. */
  112689. fovMultiplier: number;
  112690. private _fovMultiplier;
  112691. /**
  112692. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112693. */
  112694. useEquirectangularFOV: boolean;
  112695. private _maxSimultaneousLights;
  112696. /**
  112697. * Number of Simultaneous lights allowed on the material.
  112698. */
  112699. maxSimultaneousLights: int;
  112700. /**
  112701. * Default configuration related to image processing available in the Background Material.
  112702. */
  112703. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112704. /**
  112705. * Keep track of the image processing observer to allow dispose and replace.
  112706. */
  112707. private _imageProcessingObserver;
  112708. /**
  112709. * Attaches a new image processing configuration to the PBR Material.
  112710. * @param configuration (if null the scene configuration will be use)
  112711. */
  112712. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112713. /**
  112714. * Gets the image processing configuration used either in this material.
  112715. */
  112716. /**
  112717. * Sets the Default image processing configuration used either in the this material.
  112718. *
  112719. * If sets to null, the scene one is in use.
  112720. */
  112721. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112722. /**
  112723. * Gets wether the color curves effect is enabled.
  112724. */
  112725. /**
  112726. * Sets wether the color curves effect is enabled.
  112727. */
  112728. cameraColorCurvesEnabled: boolean;
  112729. /**
  112730. * Gets wether the color grading effect is enabled.
  112731. */
  112732. /**
  112733. * Gets wether the color grading effect is enabled.
  112734. */
  112735. cameraColorGradingEnabled: boolean;
  112736. /**
  112737. * Gets wether tonemapping is enabled or not.
  112738. */
  112739. /**
  112740. * Sets wether tonemapping is enabled or not
  112741. */
  112742. cameraToneMappingEnabled: boolean;
  112743. /**
  112744. * The camera exposure used on this material.
  112745. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112746. * This corresponds to a photographic exposure.
  112747. */
  112748. /**
  112749. * The camera exposure used on this material.
  112750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112751. * This corresponds to a photographic exposure.
  112752. */
  112753. cameraExposure: float;
  112754. /**
  112755. * Gets The camera contrast used on this material.
  112756. */
  112757. /**
  112758. * Sets The camera contrast used on this material.
  112759. */
  112760. cameraContrast: float;
  112761. /**
  112762. * Gets the Color Grading 2D Lookup Texture.
  112763. */
  112764. /**
  112765. * Sets the Color Grading 2D Lookup Texture.
  112766. */
  112767. cameraColorGradingTexture: Nullable<BaseTexture>;
  112768. /**
  112769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112771. * 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;
  112772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112773. */
  112774. /**
  112775. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112776. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112777. * 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;
  112778. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112779. */
  112780. cameraColorCurves: Nullable<ColorCurves>;
  112781. /**
  112782. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112783. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112784. */
  112785. switchToBGR: boolean;
  112786. private _renderTargets;
  112787. private _reflectionControls;
  112788. private _white;
  112789. private _primaryShadowColor;
  112790. private _primaryHighlightColor;
  112791. /**
  112792. * Instantiates a Background Material in the given scene
  112793. * @param name The friendly name of the material
  112794. * @param scene The scene to add the material to
  112795. */
  112796. constructor(name: string, scene: Scene);
  112797. /**
  112798. * Gets a boolean indicating that current material needs to register RTT
  112799. */
  112800. readonly hasRenderTargetTextures: boolean;
  112801. /**
  112802. * The entire material has been created in order to prevent overdraw.
  112803. * @returns false
  112804. */
  112805. needAlphaTesting(): boolean;
  112806. /**
  112807. * The entire material has been created in order to prevent overdraw.
  112808. * @returns true if blending is enable
  112809. */
  112810. needAlphaBlending(): boolean;
  112811. /**
  112812. * Checks wether the material is ready to be rendered for a given mesh.
  112813. * @param mesh The mesh to render
  112814. * @param subMesh The submesh to check against
  112815. * @param useInstances Specify wether or not the material is used with instances
  112816. * @returns true if all the dependencies are ready (Textures, Effects...)
  112817. */
  112818. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112819. /**
  112820. * Compute the primary color according to the chosen perceptual color.
  112821. */
  112822. private _computePrimaryColorFromPerceptualColor;
  112823. /**
  112824. * Compute the highlights and shadow colors according to their chosen levels.
  112825. */
  112826. private _computePrimaryColors;
  112827. /**
  112828. * Build the uniform buffer used in the material.
  112829. */
  112830. buildUniformLayout(): void;
  112831. /**
  112832. * Unbind the material.
  112833. */
  112834. unbind(): void;
  112835. /**
  112836. * Bind only the world matrix to the material.
  112837. * @param world The world matrix to bind.
  112838. */
  112839. bindOnlyWorldMatrix(world: Matrix): void;
  112840. /**
  112841. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112842. * @param world The world matrix to bind.
  112843. * @param subMesh The submesh to bind for.
  112844. */
  112845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112846. /**
  112847. * Checks to see if a texture is used in the material.
  112848. * @param texture - Base texture to use.
  112849. * @returns - Boolean specifying if a texture is used in the material.
  112850. */
  112851. hasTexture(texture: BaseTexture): boolean;
  112852. /**
  112853. * Dispose the material.
  112854. * @param forceDisposeEffect Force disposal of the associated effect.
  112855. * @param forceDisposeTextures Force disposal of the associated textures.
  112856. */
  112857. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112858. /**
  112859. * Clones the material.
  112860. * @param name The cloned name.
  112861. * @returns The cloned material.
  112862. */
  112863. clone(name: string): BackgroundMaterial;
  112864. /**
  112865. * Serializes the current material to its JSON representation.
  112866. * @returns The JSON representation.
  112867. */
  112868. serialize(): any;
  112869. /**
  112870. * Gets the class name of the material
  112871. * @returns "BackgroundMaterial"
  112872. */
  112873. getClassName(): string;
  112874. /**
  112875. * Parse a JSON input to create back a background material.
  112876. * @param source The JSON data to parse
  112877. * @param scene The scene to create the parsed material in
  112878. * @param rootUrl The root url of the assets the material depends upon
  112879. * @returns the instantiated BackgroundMaterial.
  112880. */
  112881. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112882. }
  112883. }
  112884. declare module BABYLON {
  112885. /**
  112886. * Represents the different options available during the creation of
  112887. * a Environment helper.
  112888. *
  112889. * This can control the default ground, skybox and image processing setup of your scene.
  112890. */
  112891. export interface IEnvironmentHelperOptions {
  112892. /**
  112893. * Specifies wether or not to create a ground.
  112894. * True by default.
  112895. */
  112896. createGround: boolean;
  112897. /**
  112898. * Specifies the ground size.
  112899. * 15 by default.
  112900. */
  112901. groundSize: number;
  112902. /**
  112903. * The texture used on the ground for the main color.
  112904. * Comes from the BabylonJS CDN by default.
  112905. *
  112906. * Remarks: Can be either a texture or a url.
  112907. */
  112908. groundTexture: string | BaseTexture;
  112909. /**
  112910. * The color mixed in the ground texture by default.
  112911. * BabylonJS clearColor by default.
  112912. */
  112913. groundColor: Color3;
  112914. /**
  112915. * Specifies the ground opacity.
  112916. * 1 by default.
  112917. */
  112918. groundOpacity: number;
  112919. /**
  112920. * Enables the ground to receive shadows.
  112921. * True by default.
  112922. */
  112923. enableGroundShadow: boolean;
  112924. /**
  112925. * Helps preventing the shadow to be fully black on the ground.
  112926. * 0.5 by default.
  112927. */
  112928. groundShadowLevel: number;
  112929. /**
  112930. * Creates a mirror texture attach to the ground.
  112931. * false by default.
  112932. */
  112933. enableGroundMirror: boolean;
  112934. /**
  112935. * Specifies the ground mirror size ratio.
  112936. * 0.3 by default as the default kernel is 64.
  112937. */
  112938. groundMirrorSizeRatio: number;
  112939. /**
  112940. * Specifies the ground mirror blur kernel size.
  112941. * 64 by default.
  112942. */
  112943. groundMirrorBlurKernel: number;
  112944. /**
  112945. * Specifies the ground mirror visibility amount.
  112946. * 1 by default
  112947. */
  112948. groundMirrorAmount: number;
  112949. /**
  112950. * Specifies the ground mirror reflectance weight.
  112951. * This uses the standard weight of the background material to setup the fresnel effect
  112952. * of the mirror.
  112953. * 1 by default.
  112954. */
  112955. groundMirrorFresnelWeight: number;
  112956. /**
  112957. * Specifies the ground mirror Falloff distance.
  112958. * This can helps reducing the size of the reflection.
  112959. * 0 by Default.
  112960. */
  112961. groundMirrorFallOffDistance: number;
  112962. /**
  112963. * Specifies the ground mirror texture type.
  112964. * Unsigned Int by Default.
  112965. */
  112966. groundMirrorTextureType: number;
  112967. /**
  112968. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112969. * the shown objects.
  112970. */
  112971. groundYBias: number;
  112972. /**
  112973. * Specifies wether or not to create a skybox.
  112974. * True by default.
  112975. */
  112976. createSkybox: boolean;
  112977. /**
  112978. * Specifies the skybox size.
  112979. * 20 by default.
  112980. */
  112981. skyboxSize: number;
  112982. /**
  112983. * The texture used on the skybox for the main color.
  112984. * Comes from the BabylonJS CDN by default.
  112985. *
  112986. * Remarks: Can be either a texture or a url.
  112987. */
  112988. skyboxTexture: string | BaseTexture;
  112989. /**
  112990. * The color mixed in the skybox texture by default.
  112991. * BabylonJS clearColor by default.
  112992. */
  112993. skyboxColor: Color3;
  112994. /**
  112995. * The background rotation around the Y axis of the scene.
  112996. * This helps aligning the key lights of your scene with the background.
  112997. * 0 by default.
  112998. */
  112999. backgroundYRotation: number;
  113000. /**
  113001. * Compute automatically the size of the elements to best fit with the scene.
  113002. */
  113003. sizeAuto: boolean;
  113004. /**
  113005. * Default position of the rootMesh if autoSize is not true.
  113006. */
  113007. rootPosition: Vector3;
  113008. /**
  113009. * Sets up the image processing in the scene.
  113010. * true by default.
  113011. */
  113012. setupImageProcessing: boolean;
  113013. /**
  113014. * The texture used as your environment texture in the scene.
  113015. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113016. *
  113017. * Remarks: Can be either a texture or a url.
  113018. */
  113019. environmentTexture: string | BaseTexture;
  113020. /**
  113021. * The value of the exposure to apply to the scene.
  113022. * 0.6 by default if setupImageProcessing is true.
  113023. */
  113024. cameraExposure: number;
  113025. /**
  113026. * The value of the contrast to apply to the scene.
  113027. * 1.6 by default if setupImageProcessing is true.
  113028. */
  113029. cameraContrast: number;
  113030. /**
  113031. * Specifies wether or not tonemapping should be enabled in the scene.
  113032. * true by default if setupImageProcessing is true.
  113033. */
  113034. toneMappingEnabled: boolean;
  113035. }
  113036. /**
  113037. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113038. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113039. * It also helps with the default setup of your imageProcessing configuration.
  113040. */
  113041. export class EnvironmentHelper {
  113042. /**
  113043. * Default ground texture URL.
  113044. */
  113045. private static _groundTextureCDNUrl;
  113046. /**
  113047. * Default skybox texture URL.
  113048. */
  113049. private static _skyboxTextureCDNUrl;
  113050. /**
  113051. * Default environment texture URL.
  113052. */
  113053. private static _environmentTextureCDNUrl;
  113054. /**
  113055. * Creates the default options for the helper.
  113056. */
  113057. private static _getDefaultOptions;
  113058. private _rootMesh;
  113059. /**
  113060. * Gets the root mesh created by the helper.
  113061. */
  113062. readonly rootMesh: Mesh;
  113063. private _skybox;
  113064. /**
  113065. * Gets the skybox created by the helper.
  113066. */
  113067. readonly skybox: Nullable<Mesh>;
  113068. private _skyboxTexture;
  113069. /**
  113070. * Gets the skybox texture created by the helper.
  113071. */
  113072. readonly skyboxTexture: Nullable<BaseTexture>;
  113073. private _skyboxMaterial;
  113074. /**
  113075. * Gets the skybox material created by the helper.
  113076. */
  113077. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113078. private _ground;
  113079. /**
  113080. * Gets the ground mesh created by the helper.
  113081. */
  113082. readonly ground: Nullable<Mesh>;
  113083. private _groundTexture;
  113084. /**
  113085. * Gets the ground texture created by the helper.
  113086. */
  113087. readonly groundTexture: Nullable<BaseTexture>;
  113088. private _groundMirror;
  113089. /**
  113090. * Gets the ground mirror created by the helper.
  113091. */
  113092. readonly groundMirror: Nullable<MirrorTexture>;
  113093. /**
  113094. * Gets the ground mirror render list to helps pushing the meshes
  113095. * you wish in the ground reflection.
  113096. */
  113097. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113098. private _groundMaterial;
  113099. /**
  113100. * Gets the ground material created by the helper.
  113101. */
  113102. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113103. /**
  113104. * Stores the creation options.
  113105. */
  113106. private readonly _scene;
  113107. private _options;
  113108. /**
  113109. * This observable will be notified with any error during the creation of the environment,
  113110. * mainly texture creation errors.
  113111. */
  113112. onErrorObservable: Observable<{
  113113. message?: string;
  113114. exception?: any;
  113115. }>;
  113116. /**
  113117. * constructor
  113118. * @param options Defines the options we want to customize the helper
  113119. * @param scene The scene to add the material to
  113120. */
  113121. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113122. /**
  113123. * Updates the background according to the new options
  113124. * @param options
  113125. */
  113126. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113127. /**
  113128. * Sets the primary color of all the available elements.
  113129. * @param color the main color to affect to the ground and the background
  113130. */
  113131. setMainColor(color: Color3): void;
  113132. /**
  113133. * Setup the image processing according to the specified options.
  113134. */
  113135. private _setupImageProcessing;
  113136. /**
  113137. * Setup the environment texture according to the specified options.
  113138. */
  113139. private _setupEnvironmentTexture;
  113140. /**
  113141. * Setup the background according to the specified options.
  113142. */
  113143. private _setupBackground;
  113144. /**
  113145. * Get the scene sizes according to the setup.
  113146. */
  113147. private _getSceneSize;
  113148. /**
  113149. * Setup the ground according to the specified options.
  113150. */
  113151. private _setupGround;
  113152. /**
  113153. * Setup the ground material according to the specified options.
  113154. */
  113155. private _setupGroundMaterial;
  113156. /**
  113157. * Setup the ground diffuse texture according to the specified options.
  113158. */
  113159. private _setupGroundDiffuseTexture;
  113160. /**
  113161. * Setup the ground mirror texture according to the specified options.
  113162. */
  113163. private _setupGroundMirrorTexture;
  113164. /**
  113165. * Setup the ground to receive the mirror texture.
  113166. */
  113167. private _setupMirrorInGroundMaterial;
  113168. /**
  113169. * Setup the skybox according to the specified options.
  113170. */
  113171. private _setupSkybox;
  113172. /**
  113173. * Setup the skybox material according to the specified options.
  113174. */
  113175. private _setupSkyboxMaterial;
  113176. /**
  113177. * Setup the skybox reflection texture according to the specified options.
  113178. */
  113179. private _setupSkyboxReflectionTexture;
  113180. private _errorHandler;
  113181. /**
  113182. * Dispose all the elements created by the Helper.
  113183. */
  113184. dispose(): void;
  113185. }
  113186. }
  113187. declare module BABYLON {
  113188. /**
  113189. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113190. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113191. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113192. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113193. */
  113194. export class PhotoDome extends TransformNode {
  113195. /**
  113196. * Define the image as a Monoscopic panoramic 360 image.
  113197. */
  113198. static readonly MODE_MONOSCOPIC: number;
  113199. /**
  113200. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113201. */
  113202. static readonly MODE_TOPBOTTOM: number;
  113203. /**
  113204. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113205. */
  113206. static readonly MODE_SIDEBYSIDE: number;
  113207. private _useDirectMapping;
  113208. /**
  113209. * The texture being displayed on the sphere
  113210. */
  113211. protected _photoTexture: Texture;
  113212. /**
  113213. * Gets or sets the texture being displayed on the sphere
  113214. */
  113215. photoTexture: Texture;
  113216. /**
  113217. * Observable raised when an error occured while loading the 360 image
  113218. */
  113219. onLoadErrorObservable: Observable<string>;
  113220. /**
  113221. * The skybox material
  113222. */
  113223. protected _material: BackgroundMaterial;
  113224. /**
  113225. * The surface used for the skybox
  113226. */
  113227. protected _mesh: Mesh;
  113228. /**
  113229. * Gets the mesh used for the skybox.
  113230. */
  113231. readonly mesh: Mesh;
  113232. /**
  113233. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113234. * Also see the options.resolution property.
  113235. */
  113236. fovMultiplier: number;
  113237. private _imageMode;
  113238. /**
  113239. * Gets or set the current video mode for the video. It can be:
  113240. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113241. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113242. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113243. */
  113244. imageMode: number;
  113245. /**
  113246. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113247. * @param name Element's name, child elements will append suffixes for their own names.
  113248. * @param urlsOfPhoto defines the url of the photo to display
  113249. * @param options defines an object containing optional or exposed sub element properties
  113250. * @param onError defines a callback called when an error occured while loading the texture
  113251. */
  113252. constructor(name: string, urlOfPhoto: string, options: {
  113253. resolution?: number;
  113254. size?: number;
  113255. useDirectMapping?: boolean;
  113256. faceForward?: boolean;
  113257. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113258. private _onBeforeCameraRenderObserver;
  113259. private _changeImageMode;
  113260. /**
  113261. * Releases resources associated with this node.
  113262. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113263. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113264. */
  113265. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113266. }
  113267. }
  113268. declare module BABYLON {
  113269. /**
  113270. * Class used to host RGBD texture specific utilities
  113271. */
  113272. export class RGBDTextureTools {
  113273. /**
  113274. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113275. * @param texture the texture to expand.
  113276. */
  113277. static ExpandRGBDTexture(texture: Texture): void;
  113278. }
  113279. }
  113280. declare module BABYLON {
  113281. /**
  113282. * Class used to host texture specific utilities
  113283. */
  113284. export class BRDFTextureTools {
  113285. /**
  113286. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113287. * @param scene defines the hosting scene
  113288. * @returns the environment BRDF texture
  113289. */
  113290. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113291. private static _environmentBRDFBase64Texture;
  113292. }
  113293. }
  113294. declare module BABYLON {
  113295. /**
  113296. * @hidden
  113297. */
  113298. export interface IMaterialClearCoatDefines {
  113299. CLEARCOAT: boolean;
  113300. CLEARCOAT_DEFAULTIOR: boolean;
  113301. CLEARCOAT_TEXTURE: boolean;
  113302. CLEARCOAT_TEXTUREDIRECTUV: number;
  113303. CLEARCOAT_BUMP: boolean;
  113304. CLEARCOAT_BUMPDIRECTUV: number;
  113305. CLEARCOAT_TINT: boolean;
  113306. CLEARCOAT_TINT_TEXTURE: boolean;
  113307. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113308. /** @hidden */
  113309. _areTexturesDirty: boolean;
  113310. }
  113311. /**
  113312. * Define the code related to the clear coat parameters of the pbr material.
  113313. */
  113314. export class PBRClearCoatConfiguration {
  113315. /**
  113316. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113317. * The default fits with a polyurethane material.
  113318. */
  113319. private static readonly _DefaultIndexOfRefraction;
  113320. private _isEnabled;
  113321. /**
  113322. * Defines if the clear coat is enabled in the material.
  113323. */
  113324. isEnabled: boolean;
  113325. /**
  113326. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113327. */
  113328. intensity: number;
  113329. /**
  113330. * Defines the clear coat layer roughness.
  113331. */
  113332. roughness: number;
  113333. private _indexOfRefraction;
  113334. /**
  113335. * Defines the index of refraction of the clear coat.
  113336. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113337. * The default fits with a polyurethane material.
  113338. * Changing the default value is more performance intensive.
  113339. */
  113340. indexOfRefraction: number;
  113341. private _texture;
  113342. /**
  113343. * Stores the clear coat values in a texture.
  113344. */
  113345. texture: Nullable<BaseTexture>;
  113346. private _bumpTexture;
  113347. /**
  113348. * Define the clear coat specific bump texture.
  113349. */
  113350. bumpTexture: Nullable<BaseTexture>;
  113351. private _isTintEnabled;
  113352. /**
  113353. * Defines if the clear coat tint is enabled in the material.
  113354. */
  113355. isTintEnabled: boolean;
  113356. /**
  113357. * Defines the clear coat tint of the material.
  113358. * This is only use if tint is enabled
  113359. */
  113360. tintColor: Color3;
  113361. /**
  113362. * Defines the distance at which the tint color should be found in the
  113363. * clear coat media.
  113364. * This is only use if tint is enabled
  113365. */
  113366. tintColorAtDistance: number;
  113367. /**
  113368. * Defines the clear coat layer thickness.
  113369. * This is only use if tint is enabled
  113370. */
  113371. tintThickness: number;
  113372. private _tintTexture;
  113373. /**
  113374. * Stores the clear tint values in a texture.
  113375. * rgb is tint
  113376. * a is a thickness factor
  113377. */
  113378. tintTexture: Nullable<BaseTexture>;
  113379. /** @hidden */
  113380. private _internalMarkAllSubMeshesAsTexturesDirty;
  113381. /** @hidden */
  113382. _markAllSubMeshesAsTexturesDirty(): void;
  113383. /**
  113384. * Instantiate a new istance of clear coat configuration.
  113385. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113386. */
  113387. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113388. /**
  113389. * Gets wehter the submesh is ready to be used or not.
  113390. * @param defines the list of "defines" to update.
  113391. * @param scene defines the scene the material belongs to.
  113392. * @param engine defines the engine the material belongs to.
  113393. * @param disableBumpMap defines wether the material disables bump or not.
  113394. * @returns - boolean indicating that the submesh is ready or not.
  113395. */
  113396. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113397. /**
  113398. * Checks to see if a texture is used in the material.
  113399. * @param defines the list of "defines" to update.
  113400. * @param scene defines the scene to the material belongs to.
  113401. */
  113402. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113403. /**
  113404. * Binds the material data.
  113405. * @param uniformBuffer defines the Uniform buffer to fill in.
  113406. * @param scene defines the scene the material belongs to.
  113407. * @param engine defines the engine the material belongs to.
  113408. * @param disableBumpMap defines wether the material disables bump or not.
  113409. * @param isFrozen defines wether the material is frozen or not.
  113410. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113411. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113412. */
  113413. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113414. /**
  113415. * Checks to see if a texture is used in the material.
  113416. * @param texture - Base texture to use.
  113417. * @returns - Boolean specifying if a texture is used in the material.
  113418. */
  113419. hasTexture(texture: BaseTexture): boolean;
  113420. /**
  113421. * Returns an array of the actively used textures.
  113422. * @param activeTextures Array of BaseTextures
  113423. */
  113424. getActiveTextures(activeTextures: BaseTexture[]): void;
  113425. /**
  113426. * Returns the animatable textures.
  113427. * @param animatables Array of animatable textures.
  113428. */
  113429. getAnimatables(animatables: IAnimatable[]): void;
  113430. /**
  113431. * Disposes the resources of the material.
  113432. * @param forceDisposeTextures - Forces the disposal of all textures.
  113433. */
  113434. dispose(forceDisposeTextures?: boolean): void;
  113435. /**
  113436. * Get the current class name of the texture useful for serialization or dynamic coding.
  113437. * @returns "PBRClearCoatConfiguration"
  113438. */
  113439. getClassName(): string;
  113440. /**
  113441. * Add fallbacks to the effect fallbacks list.
  113442. * @param defines defines the Base texture to use.
  113443. * @param fallbacks defines the current fallback list.
  113444. * @param currentRank defines the current fallback rank.
  113445. * @returns the new fallback rank.
  113446. */
  113447. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113448. /**
  113449. * Add the required uniforms to the current list.
  113450. * @param uniforms defines the current uniform list.
  113451. */
  113452. static AddUniforms(uniforms: string[]): void;
  113453. /**
  113454. * Add the required samplers to the current list.
  113455. * @param samplers defines the current sampler list.
  113456. */
  113457. static AddSamplers(samplers: string[]): void;
  113458. /**
  113459. * Add the required uniforms to the current buffer.
  113460. * @param uniformBuffer defines the current uniform buffer.
  113461. */
  113462. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113463. /**
  113464. * Makes a duplicate of the current configuration into another one.
  113465. * @param clearCoatConfiguration define the config where to copy the info
  113466. */
  113467. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113468. /**
  113469. * Serializes this clear coat configuration.
  113470. * @returns - An object with the serialized config.
  113471. */
  113472. serialize(): any;
  113473. /**
  113474. * Parses a anisotropy Configuration from a serialized object.
  113475. * @param source - Serialized object.
  113476. * @param scene Defines the scene we are parsing for
  113477. * @param rootUrl Defines the rootUrl to load from
  113478. */
  113479. parse(source: any, scene: Scene, rootUrl: string): void;
  113480. }
  113481. }
  113482. declare module BABYLON {
  113483. /**
  113484. * @hidden
  113485. */
  113486. export interface IMaterialAnisotropicDefines {
  113487. ANISOTROPIC: boolean;
  113488. ANISOTROPIC_TEXTURE: boolean;
  113489. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113490. MAINUV1: boolean;
  113491. _areTexturesDirty: boolean;
  113492. _needUVs: boolean;
  113493. }
  113494. /**
  113495. * Define the code related to the anisotropic parameters of the pbr material.
  113496. */
  113497. export class PBRAnisotropicConfiguration {
  113498. private _isEnabled;
  113499. /**
  113500. * Defines if the anisotropy is enabled in the material.
  113501. */
  113502. isEnabled: boolean;
  113503. /**
  113504. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113505. */
  113506. intensity: number;
  113507. /**
  113508. * Defines if the effect is along the tangents, bitangents or in between.
  113509. * By default, the effect is "strectching" the highlights along the tangents.
  113510. */
  113511. direction: Vector2;
  113512. private _texture;
  113513. /**
  113514. * Stores the anisotropy values in a texture.
  113515. * rg is direction (like normal from -1 to 1)
  113516. * b is a intensity
  113517. */
  113518. texture: Nullable<BaseTexture>;
  113519. /** @hidden */
  113520. private _internalMarkAllSubMeshesAsTexturesDirty;
  113521. /** @hidden */
  113522. _markAllSubMeshesAsTexturesDirty(): void;
  113523. /**
  113524. * Instantiate a new istance of anisotropy configuration.
  113525. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113526. */
  113527. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113528. /**
  113529. * Specifies that the submesh is ready to be used.
  113530. * @param defines the list of "defines" to update.
  113531. * @param scene defines the scene the material belongs to.
  113532. * @returns - boolean indicating that the submesh is ready or not.
  113533. */
  113534. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113535. /**
  113536. * Checks to see if a texture is used in the material.
  113537. * @param defines the list of "defines" to update.
  113538. * @param mesh the mesh we are preparing the defines for.
  113539. * @param scene defines the scene the material belongs to.
  113540. */
  113541. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113542. /**
  113543. * Binds the material data.
  113544. * @param uniformBuffer defines the Uniform buffer to fill in.
  113545. * @param scene defines the scene the material belongs to.
  113546. * @param isFrozen defines wether the material is frozen or not.
  113547. */
  113548. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113549. /**
  113550. * Checks to see if a texture is used in the material.
  113551. * @param texture - Base texture to use.
  113552. * @returns - Boolean specifying if a texture is used in the material.
  113553. */
  113554. hasTexture(texture: BaseTexture): boolean;
  113555. /**
  113556. * Returns an array of the actively used textures.
  113557. * @param activeTextures Array of BaseTextures
  113558. */
  113559. getActiveTextures(activeTextures: BaseTexture[]): void;
  113560. /**
  113561. * Returns the animatable textures.
  113562. * @param animatables Array of animatable textures.
  113563. */
  113564. getAnimatables(animatables: IAnimatable[]): void;
  113565. /**
  113566. * Disposes the resources of the material.
  113567. * @param forceDisposeTextures - Forces the disposal of all textures.
  113568. */
  113569. dispose(forceDisposeTextures?: boolean): void;
  113570. /**
  113571. * Get the current class name of the texture useful for serialization or dynamic coding.
  113572. * @returns "PBRAnisotropicConfiguration"
  113573. */
  113574. getClassName(): string;
  113575. /**
  113576. * Add fallbacks to the effect fallbacks list.
  113577. * @param defines defines the Base texture to use.
  113578. * @param fallbacks defines the current fallback list.
  113579. * @param currentRank defines the current fallback rank.
  113580. * @returns the new fallback rank.
  113581. */
  113582. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113583. /**
  113584. * Add the required uniforms to the current list.
  113585. * @param uniforms defines the current uniform list.
  113586. */
  113587. static AddUniforms(uniforms: string[]): void;
  113588. /**
  113589. * Add the required uniforms to the current buffer.
  113590. * @param uniformBuffer defines the current uniform buffer.
  113591. */
  113592. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113593. /**
  113594. * Add the required samplers to the current list.
  113595. * @param samplers defines the current sampler list.
  113596. */
  113597. static AddSamplers(samplers: string[]): void;
  113598. /**
  113599. * Makes a duplicate of the current configuration into another one.
  113600. * @param anisotropicConfiguration define the config where to copy the info
  113601. */
  113602. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113603. /**
  113604. * Serializes this anisotropy configuration.
  113605. * @returns - An object with the serialized config.
  113606. */
  113607. serialize(): any;
  113608. /**
  113609. * Parses a anisotropy Configuration from a serialized object.
  113610. * @param source - Serialized object.
  113611. * @param scene Defines the scene we are parsing for
  113612. * @param rootUrl Defines the rootUrl to load from
  113613. */
  113614. parse(source: any, scene: Scene, rootUrl: string): void;
  113615. }
  113616. }
  113617. declare module BABYLON {
  113618. /**
  113619. * @hidden
  113620. */
  113621. export interface IMaterialBRDFDefines {
  113622. BRDF_V_HEIGHT_CORRELATED: boolean;
  113623. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113624. SPHERICAL_HARMONICS: boolean;
  113625. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113626. /** @hidden */
  113627. _areMiscDirty: boolean;
  113628. }
  113629. /**
  113630. * Define the code related to the BRDF parameters of the pbr material.
  113631. */
  113632. export class PBRBRDFConfiguration {
  113633. /**
  113634. * Default value used for the energy conservation.
  113635. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113636. */
  113637. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113638. /**
  113639. * Default value used for the Smith Visibility Height Correlated mode.
  113640. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113641. */
  113642. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113643. /**
  113644. * Default value used for the IBL diffuse part.
  113645. * This can help switching back to the polynomials mode globally which is a tiny bit
  113646. * less GPU intensive at the drawback of a lower quality.
  113647. */
  113648. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113649. /**
  113650. * Default value used for activating energy conservation for the specular workflow.
  113651. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113652. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113653. */
  113654. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113655. private _useEnergyConservation;
  113656. /**
  113657. * Defines if the material uses energy conservation.
  113658. */
  113659. useEnergyConservation: boolean;
  113660. private _useSmithVisibilityHeightCorrelated;
  113661. /**
  113662. * LEGACY Mode set to false
  113663. * Defines if the material uses height smith correlated visibility term.
  113664. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113665. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113666. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113667. * Not relying on height correlated will also disable energy conservation.
  113668. */
  113669. useSmithVisibilityHeightCorrelated: boolean;
  113670. private _useSphericalHarmonics;
  113671. /**
  113672. * LEGACY Mode set to false
  113673. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113674. * diffuse part of the IBL.
  113675. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113676. * to the ground truth.
  113677. */
  113678. useSphericalHarmonics: boolean;
  113679. private _useSpecularGlossinessInputEnergyConservation;
  113680. /**
  113681. * Defines if the material uses energy conservation, when the specular workflow is active.
  113682. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113683. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113684. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113685. */
  113686. useSpecularGlossinessInputEnergyConservation: boolean;
  113687. /** @hidden */
  113688. private _internalMarkAllSubMeshesAsMiscDirty;
  113689. /** @hidden */
  113690. _markAllSubMeshesAsMiscDirty(): void;
  113691. /**
  113692. * Instantiate a new istance of clear coat configuration.
  113693. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113694. */
  113695. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113696. /**
  113697. * Checks to see if a texture is used in the material.
  113698. * @param defines the list of "defines" to update.
  113699. */
  113700. prepareDefines(defines: IMaterialBRDFDefines): void;
  113701. /**
  113702. * Get the current class name of the texture useful for serialization or dynamic coding.
  113703. * @returns "PBRClearCoatConfiguration"
  113704. */
  113705. getClassName(): string;
  113706. /**
  113707. * Makes a duplicate of the current configuration into another one.
  113708. * @param brdfConfiguration define the config where to copy the info
  113709. */
  113710. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113711. /**
  113712. * Serializes this BRDF configuration.
  113713. * @returns - An object with the serialized config.
  113714. */
  113715. serialize(): any;
  113716. /**
  113717. * Parses a anisotropy Configuration from a serialized object.
  113718. * @param source - Serialized object.
  113719. * @param scene Defines the scene we are parsing for
  113720. * @param rootUrl Defines the rootUrl to load from
  113721. */
  113722. parse(source: any, scene: Scene, rootUrl: string): void;
  113723. }
  113724. }
  113725. declare module BABYLON {
  113726. /**
  113727. * @hidden
  113728. */
  113729. export interface IMaterialSheenDefines {
  113730. SHEEN: boolean;
  113731. SHEEN_TEXTURE: boolean;
  113732. SHEEN_TEXTUREDIRECTUV: number;
  113733. SHEEN_LINKWITHALBEDO: boolean;
  113734. /** @hidden */
  113735. _areTexturesDirty: boolean;
  113736. }
  113737. /**
  113738. * Define the code related to the Sheen parameters of the pbr material.
  113739. */
  113740. export class PBRSheenConfiguration {
  113741. private _isEnabled;
  113742. /**
  113743. * Defines if the material uses sheen.
  113744. */
  113745. isEnabled: boolean;
  113746. private _linkSheenWithAlbedo;
  113747. /**
  113748. * Defines if the sheen is linked to the sheen color.
  113749. */
  113750. linkSheenWithAlbedo: boolean;
  113751. /**
  113752. * Defines the sheen intensity.
  113753. */
  113754. intensity: number;
  113755. /**
  113756. * Defines the sheen color.
  113757. */
  113758. color: Color3;
  113759. private _texture;
  113760. /**
  113761. * Stores the sheen tint values in a texture.
  113762. * rgb is tint
  113763. * a is a intensity
  113764. */
  113765. texture: Nullable<BaseTexture>;
  113766. /** @hidden */
  113767. private _internalMarkAllSubMeshesAsTexturesDirty;
  113768. /** @hidden */
  113769. _markAllSubMeshesAsTexturesDirty(): void;
  113770. /**
  113771. * Instantiate a new istance of clear coat configuration.
  113772. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113773. */
  113774. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113775. /**
  113776. * Specifies that the submesh is ready to be used.
  113777. * @param defines the list of "defines" to update.
  113778. * @param scene defines the scene the material belongs to.
  113779. * @returns - boolean indicating that the submesh is ready or not.
  113780. */
  113781. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113782. /**
  113783. * Checks to see if a texture is used in the material.
  113784. * @param defines the list of "defines" to update.
  113785. * @param scene defines the scene the material belongs to.
  113786. */
  113787. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113788. /**
  113789. * Binds the material data.
  113790. * @param uniformBuffer defines the Uniform buffer to fill in.
  113791. * @param scene defines the scene the material belongs to.
  113792. * @param isFrozen defines wether the material is frozen or not.
  113793. */
  113794. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113795. /**
  113796. * Checks to see if a texture is used in the material.
  113797. * @param texture - Base texture to use.
  113798. * @returns - Boolean specifying if a texture is used in the material.
  113799. */
  113800. hasTexture(texture: BaseTexture): boolean;
  113801. /**
  113802. * Returns an array of the actively used textures.
  113803. * @param activeTextures Array of BaseTextures
  113804. */
  113805. getActiveTextures(activeTextures: BaseTexture[]): void;
  113806. /**
  113807. * Returns the animatable textures.
  113808. * @param animatables Array of animatable textures.
  113809. */
  113810. getAnimatables(animatables: IAnimatable[]): void;
  113811. /**
  113812. * Disposes the resources of the material.
  113813. * @param forceDisposeTextures - Forces the disposal of all textures.
  113814. */
  113815. dispose(forceDisposeTextures?: boolean): void;
  113816. /**
  113817. * Get the current class name of the texture useful for serialization or dynamic coding.
  113818. * @returns "PBRSheenConfiguration"
  113819. */
  113820. getClassName(): string;
  113821. /**
  113822. * Add fallbacks to the effect fallbacks list.
  113823. * @param defines defines the Base texture to use.
  113824. * @param fallbacks defines the current fallback list.
  113825. * @param currentRank defines the current fallback rank.
  113826. * @returns the new fallback rank.
  113827. */
  113828. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113829. /**
  113830. * Add the required uniforms to the current list.
  113831. * @param uniforms defines the current uniform list.
  113832. */
  113833. static AddUniforms(uniforms: string[]): void;
  113834. /**
  113835. * Add the required uniforms to the current buffer.
  113836. * @param uniformBuffer defines the current uniform buffer.
  113837. */
  113838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113839. /**
  113840. * Add the required samplers to the current list.
  113841. * @param samplers defines the current sampler list.
  113842. */
  113843. static AddSamplers(samplers: string[]): void;
  113844. /**
  113845. * Makes a duplicate of the current configuration into another one.
  113846. * @param sheenConfiguration define the config where to copy the info
  113847. */
  113848. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113849. /**
  113850. * Serializes this BRDF configuration.
  113851. * @returns - An object with the serialized config.
  113852. */
  113853. serialize(): any;
  113854. /**
  113855. * Parses a anisotropy Configuration from a serialized object.
  113856. * @param source - Serialized object.
  113857. * @param scene Defines the scene we are parsing for
  113858. * @param rootUrl Defines the rootUrl to load from
  113859. */
  113860. parse(source: any, scene: Scene, rootUrl: string): void;
  113861. }
  113862. }
  113863. declare module BABYLON {
  113864. /**
  113865. * @hidden
  113866. */
  113867. export interface IMaterialSubSurfaceDefines {
  113868. SUBSURFACE: boolean;
  113869. SS_REFRACTION: boolean;
  113870. SS_TRANSLUCENCY: boolean;
  113871. SS_SCATERRING: boolean;
  113872. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113873. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113874. SS_REFRACTIONMAP_3D: boolean;
  113875. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113876. SS_LODINREFRACTIONALPHA: boolean;
  113877. SS_GAMMAREFRACTION: boolean;
  113878. SS_RGBDREFRACTION: boolean;
  113879. SS_LINEARSPECULARREFRACTION: boolean;
  113880. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113881. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113882. /** @hidden */
  113883. _areTexturesDirty: boolean;
  113884. }
  113885. /**
  113886. * Define the code related to the sub surface parameters of the pbr material.
  113887. */
  113888. export class PBRSubSurfaceConfiguration {
  113889. private _isRefractionEnabled;
  113890. /**
  113891. * Defines if the refraction is enabled in the material.
  113892. */
  113893. isRefractionEnabled: boolean;
  113894. private _isTranslucencyEnabled;
  113895. /**
  113896. * Defines if the translucency is enabled in the material.
  113897. */
  113898. isTranslucencyEnabled: boolean;
  113899. private _isScatteringEnabled;
  113900. /**
  113901. * Defines the refraction intensity of the material.
  113902. * The refraction when enabled replaces the Diffuse part of the material.
  113903. * The intensity helps transitionning between diffuse and refraction.
  113904. */
  113905. refractionIntensity: number;
  113906. /**
  113907. * Defines the translucency intensity of the material.
  113908. * When translucency has been enabled, this defines how much of the "translucency"
  113909. * is addded to the diffuse part of the material.
  113910. */
  113911. translucencyIntensity: number;
  113912. /**
  113913. * Defines the scattering intensity of the material.
  113914. * When scattering has been enabled, this defines how much of the "scattered light"
  113915. * is addded to the diffuse part of the material.
  113916. */
  113917. scatteringIntensity: number;
  113918. private _thicknessTexture;
  113919. /**
  113920. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113921. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113922. * 0 would mean minimumThickness
  113923. * 1 would mean maximumThickness
  113924. * The other channels might be use as a mask to vary the different effects intensity.
  113925. */
  113926. thicknessTexture: Nullable<BaseTexture>;
  113927. private _refractionTexture;
  113928. /**
  113929. * Defines the texture to use for refraction.
  113930. */
  113931. refractionTexture: Nullable<BaseTexture>;
  113932. private _indexOfRefraction;
  113933. /**
  113934. * Defines the index of refraction used in the material.
  113935. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113936. */
  113937. indexOfRefraction: number;
  113938. private _invertRefractionY;
  113939. /**
  113940. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113941. */
  113942. invertRefractionY: boolean;
  113943. private _linkRefractionWithTransparency;
  113944. /**
  113945. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113946. * Materials half opaque for instance using refraction could benefit from this control.
  113947. */
  113948. linkRefractionWithTransparency: boolean;
  113949. /**
  113950. * Defines the minimum thickness stored in the thickness map.
  113951. * If no thickness map is defined, this value will be used to simulate thickness.
  113952. */
  113953. minimumThickness: number;
  113954. /**
  113955. * Defines the maximum thickness stored in the thickness map.
  113956. */
  113957. maximumThickness: number;
  113958. /**
  113959. * Defines the volume tint of the material.
  113960. * This is used for both translucency and scattering.
  113961. */
  113962. tintColor: Color3;
  113963. /**
  113964. * Defines the distance at which the tint color should be found in the media.
  113965. * This is used for refraction only.
  113966. */
  113967. tintColorAtDistance: number;
  113968. /**
  113969. * Defines how far each channel transmit through the media.
  113970. * It is defined as a color to simplify it selection.
  113971. */
  113972. diffusionDistance: Color3;
  113973. private _useMaskFromThicknessTexture;
  113974. /**
  113975. * Stores the intensity of the different subsurface effects in the thickness texture.
  113976. * * the green channel is the translucency intensity.
  113977. * * the blue channel is the scattering intensity.
  113978. * * the alpha channel is the refraction intensity.
  113979. */
  113980. useMaskFromThicknessTexture: boolean;
  113981. /** @hidden */
  113982. private _internalMarkAllSubMeshesAsTexturesDirty;
  113983. /** @hidden */
  113984. _markAllSubMeshesAsTexturesDirty(): void;
  113985. /**
  113986. * Instantiate a new istance of sub surface configuration.
  113987. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113988. */
  113989. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113990. /**
  113991. * Gets wehter the submesh is ready to be used or not.
  113992. * @param defines the list of "defines" to update.
  113993. * @param scene defines the scene the material belongs to.
  113994. * @returns - boolean indicating that the submesh is ready or not.
  113995. */
  113996. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113997. /**
  113998. * Checks to see if a texture is used in the material.
  113999. * @param defines the list of "defines" to update.
  114000. * @param scene defines the scene to the material belongs to.
  114001. */
  114002. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114003. /**
  114004. * Binds the material data.
  114005. * @param uniformBuffer defines the Uniform buffer to fill in.
  114006. * @param scene defines the scene the material belongs to.
  114007. * @param engine defines the engine the material belongs to.
  114008. * @param isFrozen defines wether the material is frozen or not.
  114009. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114010. */
  114011. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114012. /**
  114013. * Unbinds the material from the mesh.
  114014. * @param activeEffect defines the effect that should be unbound from.
  114015. * @returns true if unbound, otherwise false
  114016. */
  114017. unbind(activeEffect: Effect): boolean;
  114018. /**
  114019. * Returns the texture used for refraction or null if none is used.
  114020. * @param scene defines the scene the material belongs to.
  114021. * @returns - Refraction texture if present. If no refraction texture and refraction
  114022. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114023. */
  114024. private _getRefractionTexture;
  114025. /**
  114026. * Returns true if alpha blending should be disabled.
  114027. */
  114028. readonly disableAlphaBlending: boolean;
  114029. /**
  114030. * Fills the list of render target textures.
  114031. * @param renderTargets the list of render targets to update
  114032. */
  114033. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114034. /**
  114035. * Checks to see if a texture is used in the material.
  114036. * @param texture - Base texture to use.
  114037. * @returns - Boolean specifying if a texture is used in the material.
  114038. */
  114039. hasTexture(texture: BaseTexture): boolean;
  114040. /**
  114041. * Gets a boolean indicating that current material needs to register RTT
  114042. * @returns true if this uses a render target otherwise false.
  114043. */
  114044. hasRenderTargetTextures(): boolean;
  114045. /**
  114046. * Returns an array of the actively used textures.
  114047. * @param activeTextures Array of BaseTextures
  114048. */
  114049. getActiveTextures(activeTextures: BaseTexture[]): void;
  114050. /**
  114051. * Returns the animatable textures.
  114052. * @param animatables Array of animatable textures.
  114053. */
  114054. getAnimatables(animatables: IAnimatable[]): void;
  114055. /**
  114056. * Disposes the resources of the material.
  114057. * @param forceDisposeTextures - Forces the disposal of all textures.
  114058. */
  114059. dispose(forceDisposeTextures?: boolean): void;
  114060. /**
  114061. * Get the current class name of the texture useful for serialization or dynamic coding.
  114062. * @returns "PBRSubSurfaceConfiguration"
  114063. */
  114064. getClassName(): string;
  114065. /**
  114066. * Add fallbacks to the effect fallbacks list.
  114067. * @param defines defines the Base texture to use.
  114068. * @param fallbacks defines the current fallback list.
  114069. * @param currentRank defines the current fallback rank.
  114070. * @returns the new fallback rank.
  114071. */
  114072. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114073. /**
  114074. * Add the required uniforms to the current list.
  114075. * @param uniforms defines the current uniform list.
  114076. */
  114077. static AddUniforms(uniforms: string[]): void;
  114078. /**
  114079. * Add the required samplers to the current list.
  114080. * @param samplers defines the current sampler list.
  114081. */
  114082. static AddSamplers(samplers: string[]): void;
  114083. /**
  114084. * Add the required uniforms to the current buffer.
  114085. * @param uniformBuffer defines the current uniform buffer.
  114086. */
  114087. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114088. /**
  114089. * Makes a duplicate of the current configuration into another one.
  114090. * @param configuration define the config where to copy the info
  114091. */
  114092. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114093. /**
  114094. * Serializes this Sub Surface configuration.
  114095. * @returns - An object with the serialized config.
  114096. */
  114097. serialize(): any;
  114098. /**
  114099. * Parses a anisotropy Configuration from a serialized object.
  114100. * @param source - Serialized object.
  114101. * @param scene Defines the scene we are parsing for
  114102. * @param rootUrl Defines the rootUrl to load from
  114103. */
  114104. parse(source: any, scene: Scene, rootUrl: string): void;
  114105. }
  114106. }
  114107. declare module BABYLON {
  114108. /** @hidden */
  114109. export var pbrFragmentDeclaration: {
  114110. name: string;
  114111. shader: string;
  114112. };
  114113. }
  114114. declare module BABYLON {
  114115. /** @hidden */
  114116. export var pbrUboDeclaration: {
  114117. name: string;
  114118. shader: string;
  114119. };
  114120. }
  114121. declare module BABYLON {
  114122. /** @hidden */
  114123. export var pbrFragmentExtraDeclaration: {
  114124. name: string;
  114125. shader: string;
  114126. };
  114127. }
  114128. declare module BABYLON {
  114129. /** @hidden */
  114130. export var pbrFragmentSamplersDeclaration: {
  114131. name: string;
  114132. shader: string;
  114133. };
  114134. }
  114135. declare module BABYLON {
  114136. /** @hidden */
  114137. export var pbrHelperFunctions: {
  114138. name: string;
  114139. shader: string;
  114140. };
  114141. }
  114142. declare module BABYLON {
  114143. /** @hidden */
  114144. export var harmonicsFunctions: {
  114145. name: string;
  114146. shader: string;
  114147. };
  114148. }
  114149. declare module BABYLON {
  114150. /** @hidden */
  114151. export var pbrDirectLightingSetupFunctions: {
  114152. name: string;
  114153. shader: string;
  114154. };
  114155. }
  114156. declare module BABYLON {
  114157. /** @hidden */
  114158. export var pbrDirectLightingFalloffFunctions: {
  114159. name: string;
  114160. shader: string;
  114161. };
  114162. }
  114163. declare module BABYLON {
  114164. /** @hidden */
  114165. export var pbrBRDFFunctions: {
  114166. name: string;
  114167. shader: string;
  114168. };
  114169. }
  114170. declare module BABYLON {
  114171. /** @hidden */
  114172. export var pbrDirectLightingFunctions: {
  114173. name: string;
  114174. shader: string;
  114175. };
  114176. }
  114177. declare module BABYLON {
  114178. /** @hidden */
  114179. export var pbrIBLFunctions: {
  114180. name: string;
  114181. shader: string;
  114182. };
  114183. }
  114184. declare module BABYLON {
  114185. /** @hidden */
  114186. export var pbrDebug: {
  114187. name: string;
  114188. shader: string;
  114189. };
  114190. }
  114191. declare module BABYLON {
  114192. /** @hidden */
  114193. export var pbrPixelShader: {
  114194. name: string;
  114195. shader: string;
  114196. };
  114197. }
  114198. declare module BABYLON {
  114199. /** @hidden */
  114200. export var pbrVertexDeclaration: {
  114201. name: string;
  114202. shader: string;
  114203. };
  114204. }
  114205. declare module BABYLON {
  114206. /** @hidden */
  114207. export var pbrVertexShader: {
  114208. name: string;
  114209. shader: string;
  114210. };
  114211. }
  114212. declare module BABYLON {
  114213. /**
  114214. * Manages the defines for the PBR Material.
  114215. * @hidden
  114216. */
  114217. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114218. PBR: boolean;
  114219. MAINUV1: boolean;
  114220. MAINUV2: boolean;
  114221. UV1: boolean;
  114222. UV2: boolean;
  114223. ALBEDO: boolean;
  114224. ALBEDODIRECTUV: number;
  114225. VERTEXCOLOR: boolean;
  114226. AMBIENT: boolean;
  114227. AMBIENTDIRECTUV: number;
  114228. AMBIENTINGRAYSCALE: boolean;
  114229. OPACITY: boolean;
  114230. VERTEXALPHA: boolean;
  114231. OPACITYDIRECTUV: number;
  114232. OPACITYRGB: boolean;
  114233. ALPHATEST: boolean;
  114234. DEPTHPREPASS: boolean;
  114235. ALPHABLEND: boolean;
  114236. ALPHAFROMALBEDO: boolean;
  114237. ALPHATESTVALUE: string;
  114238. SPECULAROVERALPHA: boolean;
  114239. RADIANCEOVERALPHA: boolean;
  114240. ALPHAFRESNEL: boolean;
  114241. LINEARALPHAFRESNEL: boolean;
  114242. PREMULTIPLYALPHA: boolean;
  114243. EMISSIVE: boolean;
  114244. EMISSIVEDIRECTUV: number;
  114245. REFLECTIVITY: boolean;
  114246. REFLECTIVITYDIRECTUV: number;
  114247. SPECULARTERM: boolean;
  114248. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114249. MICROSURFACEAUTOMATIC: boolean;
  114250. LODBASEDMICROSFURACE: boolean;
  114251. MICROSURFACEMAP: boolean;
  114252. MICROSURFACEMAPDIRECTUV: number;
  114253. METALLICWORKFLOW: boolean;
  114254. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114255. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114256. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114257. AOSTOREINMETALMAPRED: boolean;
  114258. ENVIRONMENTBRDF: boolean;
  114259. ENVIRONMENTBRDF_RGBD: boolean;
  114260. NORMAL: boolean;
  114261. TANGENT: boolean;
  114262. BUMP: boolean;
  114263. BUMPDIRECTUV: number;
  114264. OBJECTSPACE_NORMALMAP: boolean;
  114265. PARALLAX: boolean;
  114266. PARALLAXOCCLUSION: boolean;
  114267. NORMALXYSCALE: boolean;
  114268. LIGHTMAP: boolean;
  114269. LIGHTMAPDIRECTUV: number;
  114270. USELIGHTMAPASSHADOWMAP: boolean;
  114271. GAMMALIGHTMAP: boolean;
  114272. RGBDLIGHTMAP: boolean;
  114273. REFLECTION: boolean;
  114274. REFLECTIONMAP_3D: boolean;
  114275. REFLECTIONMAP_SPHERICAL: boolean;
  114276. REFLECTIONMAP_PLANAR: boolean;
  114277. REFLECTIONMAP_CUBIC: boolean;
  114278. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114279. REFLECTIONMAP_PROJECTION: boolean;
  114280. REFLECTIONMAP_SKYBOX: boolean;
  114281. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114282. REFLECTIONMAP_EXPLICIT: boolean;
  114283. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114284. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114285. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114286. INVERTCUBICMAP: boolean;
  114287. USESPHERICALFROMREFLECTIONMAP: boolean;
  114288. USEIRRADIANCEMAP: boolean;
  114289. SPHERICAL_HARMONICS: boolean;
  114290. USESPHERICALINVERTEX: boolean;
  114291. REFLECTIONMAP_OPPOSITEZ: boolean;
  114292. LODINREFLECTIONALPHA: boolean;
  114293. GAMMAREFLECTION: boolean;
  114294. RGBDREFLECTION: boolean;
  114295. LINEARSPECULARREFLECTION: boolean;
  114296. RADIANCEOCCLUSION: boolean;
  114297. HORIZONOCCLUSION: boolean;
  114298. INSTANCES: boolean;
  114299. NUM_BONE_INFLUENCERS: number;
  114300. BonesPerMesh: number;
  114301. BONETEXTURE: boolean;
  114302. NONUNIFORMSCALING: boolean;
  114303. MORPHTARGETS: boolean;
  114304. MORPHTARGETS_NORMAL: boolean;
  114305. MORPHTARGETS_TANGENT: boolean;
  114306. MORPHTARGETS_UV: boolean;
  114307. NUM_MORPH_INFLUENCERS: number;
  114308. IMAGEPROCESSING: boolean;
  114309. VIGNETTE: boolean;
  114310. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114311. VIGNETTEBLENDMODEOPAQUE: boolean;
  114312. TONEMAPPING: boolean;
  114313. TONEMAPPING_ACES: boolean;
  114314. CONTRAST: boolean;
  114315. COLORCURVES: boolean;
  114316. COLORGRADING: boolean;
  114317. COLORGRADING3D: boolean;
  114318. SAMPLER3DGREENDEPTH: boolean;
  114319. SAMPLER3DBGRMAP: boolean;
  114320. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114321. EXPOSURE: boolean;
  114322. MULTIVIEW: boolean;
  114323. USEPHYSICALLIGHTFALLOFF: boolean;
  114324. USEGLTFLIGHTFALLOFF: boolean;
  114325. TWOSIDEDLIGHTING: boolean;
  114326. SHADOWFLOAT: boolean;
  114327. CLIPPLANE: boolean;
  114328. CLIPPLANE2: boolean;
  114329. CLIPPLANE3: boolean;
  114330. CLIPPLANE4: boolean;
  114331. POINTSIZE: boolean;
  114332. FOG: boolean;
  114333. LOGARITHMICDEPTH: boolean;
  114334. FORCENORMALFORWARD: boolean;
  114335. SPECULARAA: boolean;
  114336. CLEARCOAT: boolean;
  114337. CLEARCOAT_DEFAULTIOR: boolean;
  114338. CLEARCOAT_TEXTURE: boolean;
  114339. CLEARCOAT_TEXTUREDIRECTUV: number;
  114340. CLEARCOAT_BUMP: boolean;
  114341. CLEARCOAT_BUMPDIRECTUV: number;
  114342. CLEARCOAT_TINT: boolean;
  114343. CLEARCOAT_TINT_TEXTURE: boolean;
  114344. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114345. ANISOTROPIC: boolean;
  114346. ANISOTROPIC_TEXTURE: boolean;
  114347. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114348. BRDF_V_HEIGHT_CORRELATED: boolean;
  114349. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114350. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114351. SHEEN: boolean;
  114352. SHEEN_TEXTURE: boolean;
  114353. SHEEN_TEXTUREDIRECTUV: number;
  114354. SHEEN_LINKWITHALBEDO: boolean;
  114355. SUBSURFACE: boolean;
  114356. SS_REFRACTION: boolean;
  114357. SS_TRANSLUCENCY: boolean;
  114358. SS_SCATERRING: boolean;
  114359. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114360. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114361. SS_REFRACTIONMAP_3D: boolean;
  114362. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114363. SS_LODINREFRACTIONALPHA: boolean;
  114364. SS_GAMMAREFRACTION: boolean;
  114365. SS_RGBDREFRACTION: boolean;
  114366. SS_LINEARSPECULARREFRACTION: boolean;
  114367. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114368. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114369. UNLIT: boolean;
  114370. DEBUGMODE: number;
  114371. /**
  114372. * Initializes the PBR Material defines.
  114373. */
  114374. constructor();
  114375. /**
  114376. * Resets the PBR Material defines.
  114377. */
  114378. reset(): void;
  114379. }
  114380. /**
  114381. * The Physically based material base class of BJS.
  114382. *
  114383. * This offers the main features of a standard PBR material.
  114384. * For more information, please refer to the documentation :
  114385. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114386. */
  114387. export abstract class PBRBaseMaterial extends PushMaterial {
  114388. /**
  114389. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114390. */
  114391. static readonly PBRMATERIAL_OPAQUE: number;
  114392. /**
  114393. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114394. */
  114395. static readonly PBRMATERIAL_ALPHATEST: number;
  114396. /**
  114397. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114398. */
  114399. static readonly PBRMATERIAL_ALPHABLEND: number;
  114400. /**
  114401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114402. * They are also discarded below the alpha cutoff threshold to improve performances.
  114403. */
  114404. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114405. /**
  114406. * Defines the default value of how much AO map is occluding the analytical lights
  114407. * (point spot...).
  114408. */
  114409. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114410. /**
  114411. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114412. */
  114413. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114414. /**
  114415. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114416. * to enhance interoperability with other engines.
  114417. */
  114418. static readonly LIGHTFALLOFF_GLTF: number;
  114419. /**
  114420. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114421. * to enhance interoperability with other materials.
  114422. */
  114423. static readonly LIGHTFALLOFF_STANDARD: number;
  114424. /**
  114425. * Intensity of the direct lights e.g. the four lights available in your scene.
  114426. * This impacts both the direct diffuse and specular highlights.
  114427. */
  114428. protected _directIntensity: number;
  114429. /**
  114430. * Intensity of the emissive part of the material.
  114431. * This helps controlling the emissive effect without modifying the emissive color.
  114432. */
  114433. protected _emissiveIntensity: number;
  114434. /**
  114435. * Intensity of the environment e.g. how much the environment will light the object
  114436. * either through harmonics for rough material or through the refelction for shiny ones.
  114437. */
  114438. protected _environmentIntensity: number;
  114439. /**
  114440. * This is a special control allowing the reduction of the specular highlights coming from the
  114441. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114442. */
  114443. protected _specularIntensity: number;
  114444. /**
  114445. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114446. */
  114447. private _lightingInfos;
  114448. /**
  114449. * Debug Control allowing disabling the bump map on this material.
  114450. */
  114451. protected _disableBumpMap: boolean;
  114452. /**
  114453. * AKA Diffuse Texture in standard nomenclature.
  114454. */
  114455. protected _albedoTexture: Nullable<BaseTexture>;
  114456. /**
  114457. * AKA Occlusion Texture in other nomenclature.
  114458. */
  114459. protected _ambientTexture: Nullable<BaseTexture>;
  114460. /**
  114461. * AKA Occlusion Texture Intensity in other nomenclature.
  114462. */
  114463. protected _ambientTextureStrength: number;
  114464. /**
  114465. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114466. * 1 means it completely occludes it
  114467. * 0 mean it has no impact
  114468. */
  114469. protected _ambientTextureImpactOnAnalyticalLights: number;
  114470. /**
  114471. * Stores the alpha values in a texture.
  114472. */
  114473. protected _opacityTexture: Nullable<BaseTexture>;
  114474. /**
  114475. * Stores the reflection values in a texture.
  114476. */
  114477. protected _reflectionTexture: Nullable<BaseTexture>;
  114478. /**
  114479. * Stores the emissive values in a texture.
  114480. */
  114481. protected _emissiveTexture: Nullable<BaseTexture>;
  114482. /**
  114483. * AKA Specular texture in other nomenclature.
  114484. */
  114485. protected _reflectivityTexture: Nullable<BaseTexture>;
  114486. /**
  114487. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114488. */
  114489. protected _metallicTexture: Nullable<BaseTexture>;
  114490. /**
  114491. * Specifies the metallic scalar of the metallic/roughness workflow.
  114492. * Can also be used to scale the metalness values of the metallic texture.
  114493. */
  114494. protected _metallic: Nullable<number>;
  114495. /**
  114496. * Specifies the roughness scalar of the metallic/roughness workflow.
  114497. * Can also be used to scale the roughness values of the metallic texture.
  114498. */
  114499. protected _roughness: Nullable<number>;
  114500. /**
  114501. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114502. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114503. */
  114504. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114505. /**
  114506. * Stores surface normal data used to displace a mesh in a texture.
  114507. */
  114508. protected _bumpTexture: Nullable<BaseTexture>;
  114509. /**
  114510. * Stores the pre-calculated light information of a mesh in a texture.
  114511. */
  114512. protected _lightmapTexture: Nullable<BaseTexture>;
  114513. /**
  114514. * The color of a material in ambient lighting.
  114515. */
  114516. protected _ambientColor: Color3;
  114517. /**
  114518. * AKA Diffuse Color in other nomenclature.
  114519. */
  114520. protected _albedoColor: Color3;
  114521. /**
  114522. * AKA Specular Color in other nomenclature.
  114523. */
  114524. protected _reflectivityColor: Color3;
  114525. /**
  114526. * The color applied when light is reflected from a material.
  114527. */
  114528. protected _reflectionColor: Color3;
  114529. /**
  114530. * The color applied when light is emitted from a material.
  114531. */
  114532. protected _emissiveColor: Color3;
  114533. /**
  114534. * AKA Glossiness in other nomenclature.
  114535. */
  114536. protected _microSurface: number;
  114537. /**
  114538. * Specifies that the material will use the light map as a show map.
  114539. */
  114540. protected _useLightmapAsShadowmap: boolean;
  114541. /**
  114542. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114543. * makes the reflect vector face the model (under horizon).
  114544. */
  114545. protected _useHorizonOcclusion: boolean;
  114546. /**
  114547. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114548. * too much the area relying on ambient texture to define their ambient occlusion.
  114549. */
  114550. protected _useRadianceOcclusion: boolean;
  114551. /**
  114552. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114553. */
  114554. protected _useAlphaFromAlbedoTexture: boolean;
  114555. /**
  114556. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114557. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114558. */
  114559. protected _useSpecularOverAlpha: boolean;
  114560. /**
  114561. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114562. */
  114563. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114564. /**
  114565. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114566. */
  114567. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114568. /**
  114569. * Specifies if the metallic texture contains the roughness information in its green channel.
  114570. */
  114571. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114572. /**
  114573. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114574. */
  114575. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114576. /**
  114577. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114578. */
  114579. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114580. /**
  114581. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114582. */
  114583. protected _useAmbientInGrayScale: boolean;
  114584. /**
  114585. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114586. * The material will try to infer what glossiness each pixel should be.
  114587. */
  114588. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114589. /**
  114590. * Defines the falloff type used in this material.
  114591. * It by default is Physical.
  114592. */
  114593. protected _lightFalloff: number;
  114594. /**
  114595. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114596. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114597. */
  114598. protected _useRadianceOverAlpha: boolean;
  114599. /**
  114600. * Allows using an object space normal map (instead of tangent space).
  114601. */
  114602. protected _useObjectSpaceNormalMap: boolean;
  114603. /**
  114604. * Allows using the bump map in parallax mode.
  114605. */
  114606. protected _useParallax: boolean;
  114607. /**
  114608. * Allows using the bump map in parallax occlusion mode.
  114609. */
  114610. protected _useParallaxOcclusion: boolean;
  114611. /**
  114612. * Controls the scale bias of the parallax mode.
  114613. */
  114614. protected _parallaxScaleBias: number;
  114615. /**
  114616. * If sets to true, disables all the lights affecting the material.
  114617. */
  114618. protected _disableLighting: boolean;
  114619. /**
  114620. * Number of Simultaneous lights allowed on the material.
  114621. */
  114622. protected _maxSimultaneousLights: number;
  114623. /**
  114624. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114625. */
  114626. protected _invertNormalMapX: boolean;
  114627. /**
  114628. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114629. */
  114630. protected _invertNormalMapY: boolean;
  114631. /**
  114632. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114633. */
  114634. protected _twoSidedLighting: boolean;
  114635. /**
  114636. * Defines the alpha limits in alpha test mode.
  114637. */
  114638. protected _alphaCutOff: number;
  114639. /**
  114640. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114641. */
  114642. protected _forceAlphaTest: boolean;
  114643. /**
  114644. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114645. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114646. */
  114647. protected _useAlphaFresnel: boolean;
  114648. /**
  114649. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114650. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114651. */
  114652. protected _useLinearAlphaFresnel: boolean;
  114653. /**
  114654. * The transparency mode of the material.
  114655. */
  114656. protected _transparencyMode: Nullable<number>;
  114657. /**
  114658. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114659. * from cos thetav and roughness:
  114660. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114661. */
  114662. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114663. /**
  114664. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114665. */
  114666. protected _forceIrradianceInFragment: boolean;
  114667. /**
  114668. * Force normal to face away from face.
  114669. */
  114670. protected _forceNormalForward: boolean;
  114671. /**
  114672. * Enables specular anti aliasing in the PBR shader.
  114673. * It will both interacts on the Geometry for analytical and IBL lighting.
  114674. * It also prefilter the roughness map based on the bump values.
  114675. */
  114676. protected _enableSpecularAntiAliasing: boolean;
  114677. /**
  114678. * Default configuration related to image processing available in the PBR Material.
  114679. */
  114680. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114681. /**
  114682. * Keep track of the image processing observer to allow dispose and replace.
  114683. */
  114684. private _imageProcessingObserver;
  114685. /**
  114686. * Attaches a new image processing configuration to the PBR Material.
  114687. * @param configuration
  114688. */
  114689. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114690. /**
  114691. * Stores the available render targets.
  114692. */
  114693. private _renderTargets;
  114694. /**
  114695. * Sets the global ambient color for the material used in lighting calculations.
  114696. */
  114697. private _globalAmbientColor;
  114698. /**
  114699. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114700. */
  114701. private _useLogarithmicDepth;
  114702. /**
  114703. * If set to true, no lighting calculations will be applied.
  114704. */
  114705. private _unlit;
  114706. private _debugMode;
  114707. /**
  114708. * @hidden
  114709. * This is reserved for the inspector.
  114710. * Defines the material debug mode.
  114711. * It helps seeing only some components of the material while troubleshooting.
  114712. */
  114713. debugMode: number;
  114714. /**
  114715. * @hidden
  114716. * This is reserved for the inspector.
  114717. * Specify from where on screen the debug mode should start.
  114718. * The value goes from -1 (full screen) to 1 (not visible)
  114719. * It helps with side by side comparison against the final render
  114720. * This defaults to -1
  114721. */
  114722. private debugLimit;
  114723. /**
  114724. * @hidden
  114725. * This is reserved for the inspector.
  114726. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114727. * You can use the factor to better multiply the final value.
  114728. */
  114729. private debugFactor;
  114730. /**
  114731. * Defines the clear coat layer parameters for the material.
  114732. */
  114733. readonly clearCoat: PBRClearCoatConfiguration;
  114734. /**
  114735. * Defines the anisotropic parameters for the material.
  114736. */
  114737. readonly anisotropy: PBRAnisotropicConfiguration;
  114738. /**
  114739. * Defines the BRDF parameters for the material.
  114740. */
  114741. readonly brdf: PBRBRDFConfiguration;
  114742. /**
  114743. * Defines the Sheen parameters for the material.
  114744. */
  114745. readonly sheen: PBRSheenConfiguration;
  114746. /**
  114747. * Defines the SubSurface parameters for the material.
  114748. */
  114749. readonly subSurface: PBRSubSurfaceConfiguration;
  114750. /**
  114751. * Custom callback helping to override the default shader used in the material.
  114752. */
  114753. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114754. protected _rebuildInParallel: boolean;
  114755. /**
  114756. * Instantiates a new PBRMaterial instance.
  114757. *
  114758. * @param name The material name
  114759. * @param scene The scene the material will be use in.
  114760. */
  114761. constructor(name: string, scene: Scene);
  114762. /**
  114763. * Gets a boolean indicating that current material needs to register RTT
  114764. */
  114765. readonly hasRenderTargetTextures: boolean;
  114766. /**
  114767. * Gets the name of the material class.
  114768. */
  114769. getClassName(): string;
  114770. /**
  114771. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114772. */
  114773. /**
  114774. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114775. */
  114776. useLogarithmicDepth: boolean;
  114777. /**
  114778. * Gets the current transparency mode.
  114779. */
  114780. /**
  114781. * Sets the transparency mode of the material.
  114782. *
  114783. * | Value | Type | Description |
  114784. * | ----- | ----------------------------------- | ----------- |
  114785. * | 0 | OPAQUE | |
  114786. * | 1 | ALPHATEST | |
  114787. * | 2 | ALPHABLEND | |
  114788. * | 3 | ALPHATESTANDBLEND | |
  114789. *
  114790. */
  114791. transparencyMode: Nullable<number>;
  114792. /**
  114793. * Returns true if alpha blending should be disabled.
  114794. */
  114795. private readonly _disableAlphaBlending;
  114796. /**
  114797. * Specifies whether or not this material should be rendered in alpha blend mode.
  114798. */
  114799. needAlphaBlending(): boolean;
  114800. /**
  114801. * Specifies if the mesh will require alpha blending.
  114802. * @param mesh - BJS mesh.
  114803. */
  114804. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114805. /**
  114806. * Specifies whether or not this material should be rendered in alpha test mode.
  114807. */
  114808. needAlphaTesting(): boolean;
  114809. /**
  114810. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114811. */
  114812. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114813. /**
  114814. * Gets the texture used for the alpha test.
  114815. */
  114816. getAlphaTestTexture(): Nullable<BaseTexture>;
  114817. /**
  114818. * Specifies that the submesh is ready to be used.
  114819. * @param mesh - BJS mesh.
  114820. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114821. * @param useInstances - Specifies that instances should be used.
  114822. * @returns - boolean indicating that the submesh is ready or not.
  114823. */
  114824. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114825. /**
  114826. * Specifies if the material uses metallic roughness workflow.
  114827. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114828. */
  114829. isMetallicWorkflow(): boolean;
  114830. private _prepareEffect;
  114831. private _prepareDefines;
  114832. /**
  114833. * Force shader compilation
  114834. */
  114835. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114836. clipPlane: boolean;
  114837. }>): void;
  114838. /**
  114839. * Initializes the uniform buffer layout for the shader.
  114840. */
  114841. buildUniformLayout(): void;
  114842. /**
  114843. * Unbinds the material from the mesh
  114844. */
  114845. unbind(): void;
  114846. /**
  114847. * Binds the submesh data.
  114848. * @param world - The world matrix.
  114849. * @param mesh - The BJS mesh.
  114850. * @param subMesh - A submesh of the BJS mesh.
  114851. */
  114852. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114853. /**
  114854. * Returns the animatable textures.
  114855. * @returns - Array of animatable textures.
  114856. */
  114857. getAnimatables(): IAnimatable[];
  114858. /**
  114859. * Returns the texture used for reflections.
  114860. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114861. */
  114862. private _getReflectionTexture;
  114863. /**
  114864. * Returns an array of the actively used textures.
  114865. * @returns - Array of BaseTextures
  114866. */
  114867. getActiveTextures(): BaseTexture[];
  114868. /**
  114869. * Checks to see if a texture is used in the material.
  114870. * @param texture - Base texture to use.
  114871. * @returns - Boolean specifying if a texture is used in the material.
  114872. */
  114873. hasTexture(texture: BaseTexture): boolean;
  114874. /**
  114875. * Disposes the resources of the material.
  114876. * @param forceDisposeEffect - Forces the disposal of effects.
  114877. * @param forceDisposeTextures - Forces the disposal of all textures.
  114878. */
  114879. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114880. }
  114881. }
  114882. declare module BABYLON {
  114883. /**
  114884. * The Physically based material of BJS.
  114885. *
  114886. * This offers the main features of a standard PBR material.
  114887. * For more information, please refer to the documentation :
  114888. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114889. */
  114890. export class PBRMaterial extends PBRBaseMaterial {
  114891. /**
  114892. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114893. */
  114894. static readonly PBRMATERIAL_OPAQUE: number;
  114895. /**
  114896. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114897. */
  114898. static readonly PBRMATERIAL_ALPHATEST: number;
  114899. /**
  114900. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114901. */
  114902. static readonly PBRMATERIAL_ALPHABLEND: number;
  114903. /**
  114904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114905. * They are also discarded below the alpha cutoff threshold to improve performances.
  114906. */
  114907. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114908. /**
  114909. * Defines the default value of how much AO map is occluding the analytical lights
  114910. * (point spot...).
  114911. */
  114912. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114913. /**
  114914. * Intensity of the direct lights e.g. the four lights available in your scene.
  114915. * This impacts both the direct diffuse and specular highlights.
  114916. */
  114917. directIntensity: number;
  114918. /**
  114919. * Intensity of the emissive part of the material.
  114920. * This helps controlling the emissive effect without modifying the emissive color.
  114921. */
  114922. emissiveIntensity: number;
  114923. /**
  114924. * Intensity of the environment e.g. how much the environment will light the object
  114925. * either through harmonics for rough material or through the refelction for shiny ones.
  114926. */
  114927. environmentIntensity: number;
  114928. /**
  114929. * This is a special control allowing the reduction of the specular highlights coming from the
  114930. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114931. */
  114932. specularIntensity: number;
  114933. /**
  114934. * Debug Control allowing disabling the bump map on this material.
  114935. */
  114936. disableBumpMap: boolean;
  114937. /**
  114938. * AKA Diffuse Texture in standard nomenclature.
  114939. */
  114940. albedoTexture: BaseTexture;
  114941. /**
  114942. * AKA Occlusion Texture in other nomenclature.
  114943. */
  114944. ambientTexture: BaseTexture;
  114945. /**
  114946. * AKA Occlusion Texture Intensity in other nomenclature.
  114947. */
  114948. ambientTextureStrength: number;
  114949. /**
  114950. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114951. * 1 means it completely occludes it
  114952. * 0 mean it has no impact
  114953. */
  114954. ambientTextureImpactOnAnalyticalLights: number;
  114955. /**
  114956. * Stores the alpha values in a texture.
  114957. */
  114958. opacityTexture: BaseTexture;
  114959. /**
  114960. * Stores the reflection values in a texture.
  114961. */
  114962. reflectionTexture: Nullable<BaseTexture>;
  114963. /**
  114964. * Stores the emissive values in a texture.
  114965. */
  114966. emissiveTexture: BaseTexture;
  114967. /**
  114968. * AKA Specular texture in other nomenclature.
  114969. */
  114970. reflectivityTexture: BaseTexture;
  114971. /**
  114972. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114973. */
  114974. metallicTexture: BaseTexture;
  114975. /**
  114976. * Specifies the metallic scalar of the metallic/roughness workflow.
  114977. * Can also be used to scale the metalness values of the metallic texture.
  114978. */
  114979. metallic: Nullable<number>;
  114980. /**
  114981. * Specifies the roughness scalar of the metallic/roughness workflow.
  114982. * Can also be used to scale the roughness values of the metallic texture.
  114983. */
  114984. roughness: Nullable<number>;
  114985. /**
  114986. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114987. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114988. */
  114989. microSurfaceTexture: BaseTexture;
  114990. /**
  114991. * Stores surface normal data used to displace a mesh in a texture.
  114992. */
  114993. bumpTexture: BaseTexture;
  114994. /**
  114995. * Stores the pre-calculated light information of a mesh in a texture.
  114996. */
  114997. lightmapTexture: BaseTexture;
  114998. /**
  114999. * Stores the refracted light information in a texture.
  115000. */
  115001. refractionTexture: Nullable<BaseTexture>;
  115002. /**
  115003. * The color of a material in ambient lighting.
  115004. */
  115005. ambientColor: Color3;
  115006. /**
  115007. * AKA Diffuse Color in other nomenclature.
  115008. */
  115009. albedoColor: Color3;
  115010. /**
  115011. * AKA Specular Color in other nomenclature.
  115012. */
  115013. reflectivityColor: Color3;
  115014. /**
  115015. * The color reflected from the material.
  115016. */
  115017. reflectionColor: Color3;
  115018. /**
  115019. * The color emitted from the material.
  115020. */
  115021. emissiveColor: Color3;
  115022. /**
  115023. * AKA Glossiness in other nomenclature.
  115024. */
  115025. microSurface: number;
  115026. /**
  115027. * source material index of refraction (IOR)' / 'destination material IOR.
  115028. */
  115029. indexOfRefraction: number;
  115030. /**
  115031. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115032. */
  115033. invertRefractionY: boolean;
  115034. /**
  115035. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115036. * Materials half opaque for instance using refraction could benefit from this control.
  115037. */
  115038. linkRefractionWithTransparency: boolean;
  115039. /**
  115040. * If true, the light map contains occlusion information instead of lighting info.
  115041. */
  115042. useLightmapAsShadowmap: boolean;
  115043. /**
  115044. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115045. */
  115046. useAlphaFromAlbedoTexture: boolean;
  115047. /**
  115048. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115049. */
  115050. forceAlphaTest: boolean;
  115051. /**
  115052. * Defines the alpha limits in alpha test mode.
  115053. */
  115054. alphaCutOff: number;
  115055. /**
  115056. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115057. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115058. */
  115059. useSpecularOverAlpha: boolean;
  115060. /**
  115061. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115062. */
  115063. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115064. /**
  115065. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115066. */
  115067. useRoughnessFromMetallicTextureAlpha: boolean;
  115068. /**
  115069. * Specifies if the metallic texture contains the roughness information in its green channel.
  115070. */
  115071. useRoughnessFromMetallicTextureGreen: boolean;
  115072. /**
  115073. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115074. */
  115075. useMetallnessFromMetallicTextureBlue: boolean;
  115076. /**
  115077. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115078. */
  115079. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115080. /**
  115081. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115082. */
  115083. useAmbientInGrayScale: boolean;
  115084. /**
  115085. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115086. * The material will try to infer what glossiness each pixel should be.
  115087. */
  115088. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115089. /**
  115090. * BJS is using an harcoded light falloff based on a manually sets up range.
  115091. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115092. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115093. */
  115094. /**
  115095. * BJS is using an harcoded light falloff based on a manually sets up range.
  115096. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115097. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115098. */
  115099. usePhysicalLightFalloff: boolean;
  115100. /**
  115101. * In order to support the falloff compatibility with gltf, a special mode has been added
  115102. * to reproduce the gltf light falloff.
  115103. */
  115104. /**
  115105. * In order to support the falloff compatibility with gltf, a special mode has been added
  115106. * to reproduce the gltf light falloff.
  115107. */
  115108. useGLTFLightFalloff: boolean;
  115109. /**
  115110. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115111. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115112. */
  115113. useRadianceOverAlpha: boolean;
  115114. /**
  115115. * Allows using an object space normal map (instead of tangent space).
  115116. */
  115117. useObjectSpaceNormalMap: boolean;
  115118. /**
  115119. * Allows using the bump map in parallax mode.
  115120. */
  115121. useParallax: boolean;
  115122. /**
  115123. * Allows using the bump map in parallax occlusion mode.
  115124. */
  115125. useParallaxOcclusion: boolean;
  115126. /**
  115127. * Controls the scale bias of the parallax mode.
  115128. */
  115129. parallaxScaleBias: number;
  115130. /**
  115131. * If sets to true, disables all the lights affecting the material.
  115132. */
  115133. disableLighting: boolean;
  115134. /**
  115135. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115136. */
  115137. forceIrradianceInFragment: boolean;
  115138. /**
  115139. * Number of Simultaneous lights allowed on the material.
  115140. */
  115141. maxSimultaneousLights: number;
  115142. /**
  115143. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115144. */
  115145. invertNormalMapX: boolean;
  115146. /**
  115147. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115148. */
  115149. invertNormalMapY: boolean;
  115150. /**
  115151. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115152. */
  115153. twoSidedLighting: boolean;
  115154. /**
  115155. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115156. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115157. */
  115158. useAlphaFresnel: boolean;
  115159. /**
  115160. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115161. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115162. */
  115163. useLinearAlphaFresnel: boolean;
  115164. /**
  115165. * Let user defines the brdf lookup texture used for IBL.
  115166. * A default 8bit version is embedded but you could point at :
  115167. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115168. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115169. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115170. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115171. */
  115172. environmentBRDFTexture: Nullable<BaseTexture>;
  115173. /**
  115174. * Force normal to face away from face.
  115175. */
  115176. forceNormalForward: boolean;
  115177. /**
  115178. * Enables specular anti aliasing in the PBR shader.
  115179. * It will both interacts on the Geometry for analytical and IBL lighting.
  115180. * It also prefilter the roughness map based on the bump values.
  115181. */
  115182. enableSpecularAntiAliasing: boolean;
  115183. /**
  115184. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115185. * makes the reflect vector face the model (under horizon).
  115186. */
  115187. useHorizonOcclusion: boolean;
  115188. /**
  115189. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115190. * too much the area relying on ambient texture to define their ambient occlusion.
  115191. */
  115192. useRadianceOcclusion: boolean;
  115193. /**
  115194. * If set to true, no lighting calculations will be applied.
  115195. */
  115196. unlit: boolean;
  115197. /**
  115198. * Gets the image processing configuration used either in this material.
  115199. */
  115200. /**
  115201. * Sets the Default image processing configuration used either in the this material.
  115202. *
  115203. * If sets to null, the scene one is in use.
  115204. */
  115205. imageProcessingConfiguration: ImageProcessingConfiguration;
  115206. /**
  115207. * Gets wether the color curves effect is enabled.
  115208. */
  115209. /**
  115210. * Sets wether the color curves effect is enabled.
  115211. */
  115212. cameraColorCurvesEnabled: boolean;
  115213. /**
  115214. * Gets wether the color grading effect is enabled.
  115215. */
  115216. /**
  115217. * Gets wether the color grading effect is enabled.
  115218. */
  115219. cameraColorGradingEnabled: boolean;
  115220. /**
  115221. * Gets wether tonemapping is enabled or not.
  115222. */
  115223. /**
  115224. * Sets wether tonemapping is enabled or not
  115225. */
  115226. cameraToneMappingEnabled: boolean;
  115227. /**
  115228. * The camera exposure used on this material.
  115229. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115230. * This corresponds to a photographic exposure.
  115231. */
  115232. /**
  115233. * The camera exposure used on this material.
  115234. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115235. * This corresponds to a photographic exposure.
  115236. */
  115237. cameraExposure: number;
  115238. /**
  115239. * Gets The camera contrast used on this material.
  115240. */
  115241. /**
  115242. * Sets The camera contrast used on this material.
  115243. */
  115244. cameraContrast: number;
  115245. /**
  115246. * Gets the Color Grading 2D Lookup Texture.
  115247. */
  115248. /**
  115249. * Sets the Color Grading 2D Lookup Texture.
  115250. */
  115251. cameraColorGradingTexture: Nullable<BaseTexture>;
  115252. /**
  115253. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115254. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115255. * 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;
  115256. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115257. */
  115258. /**
  115259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115261. * 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;
  115262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115263. */
  115264. cameraColorCurves: Nullable<ColorCurves>;
  115265. /**
  115266. * Instantiates a new PBRMaterial instance.
  115267. *
  115268. * @param name The material name
  115269. * @param scene The scene the material will be use in.
  115270. */
  115271. constructor(name: string, scene: Scene);
  115272. /**
  115273. * Returns the name of this material class.
  115274. */
  115275. getClassName(): string;
  115276. /**
  115277. * Makes a duplicate of the current material.
  115278. * @param name - name to use for the new material.
  115279. */
  115280. clone(name: string): PBRMaterial;
  115281. /**
  115282. * Serializes this PBR Material.
  115283. * @returns - An object with the serialized material.
  115284. */
  115285. serialize(): any;
  115286. /**
  115287. * Parses a PBR Material from a serialized object.
  115288. * @param source - Serialized object.
  115289. * @param scene - BJS scene instance.
  115290. * @param rootUrl - url for the scene object
  115291. * @returns - PBRMaterial
  115292. */
  115293. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115294. }
  115295. }
  115296. declare module BABYLON {
  115297. /**
  115298. * Direct draw surface info
  115299. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115300. */
  115301. export interface DDSInfo {
  115302. /**
  115303. * Width of the texture
  115304. */
  115305. width: number;
  115306. /**
  115307. * Width of the texture
  115308. */
  115309. height: number;
  115310. /**
  115311. * Number of Mipmaps for the texture
  115312. * @see https://en.wikipedia.org/wiki/Mipmap
  115313. */
  115314. mipmapCount: number;
  115315. /**
  115316. * If the textures format is a known fourCC format
  115317. * @see https://www.fourcc.org/
  115318. */
  115319. isFourCC: boolean;
  115320. /**
  115321. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115322. */
  115323. isRGB: boolean;
  115324. /**
  115325. * If the texture is a lumincance format
  115326. */
  115327. isLuminance: boolean;
  115328. /**
  115329. * If this is a cube texture
  115330. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115331. */
  115332. isCube: boolean;
  115333. /**
  115334. * If the texture is a compressed format eg. FOURCC_DXT1
  115335. */
  115336. isCompressed: boolean;
  115337. /**
  115338. * The dxgiFormat of the texture
  115339. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115340. */
  115341. dxgiFormat: number;
  115342. /**
  115343. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115344. */
  115345. textureType: number;
  115346. /**
  115347. * Sphericle polynomial created for the dds texture
  115348. */
  115349. sphericalPolynomial?: SphericalPolynomial;
  115350. }
  115351. /**
  115352. * Class used to provide DDS decompression tools
  115353. */
  115354. export class DDSTools {
  115355. /**
  115356. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115357. */
  115358. static StoreLODInAlphaChannel: boolean;
  115359. /**
  115360. * Gets DDS information from an array buffer
  115361. * @param arrayBuffer defines the array buffer to read data from
  115362. * @returns the DDS information
  115363. */
  115364. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115365. private static _FloatView;
  115366. private static _Int32View;
  115367. private static _ToHalfFloat;
  115368. private static _FromHalfFloat;
  115369. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115370. private static _GetHalfFloatRGBAArrayBuffer;
  115371. private static _GetFloatRGBAArrayBuffer;
  115372. private static _GetFloatAsUIntRGBAArrayBuffer;
  115373. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115374. private static _GetRGBAArrayBuffer;
  115375. private static _ExtractLongWordOrder;
  115376. private static _GetRGBArrayBuffer;
  115377. private static _GetLuminanceArrayBuffer;
  115378. /**
  115379. * Uploads DDS Levels to a Babylon Texture
  115380. * @hidden
  115381. */
  115382. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115383. }
  115384. interface ThinEngine {
  115385. /**
  115386. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115387. * @param rootUrl defines the url where the file to load is located
  115388. * @param scene defines the current scene
  115389. * @param lodScale defines scale to apply to the mip map selection
  115390. * @param lodOffset defines offset to apply to the mip map selection
  115391. * @param onLoad defines an optional callback raised when the texture is loaded
  115392. * @param onError defines an optional callback raised if there is an issue to load the texture
  115393. * @param format defines the format of the data
  115394. * @param forcedExtension defines the extension to use to pick the right loader
  115395. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115396. * @returns the cube texture as an InternalTexture
  115397. */
  115398. 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;
  115399. }
  115400. }
  115401. declare module BABYLON {
  115402. /**
  115403. * Implementation of the DDS Texture Loader.
  115404. * @hidden
  115405. */
  115406. export class _DDSTextureLoader implements IInternalTextureLoader {
  115407. /**
  115408. * Defines wether the loader supports cascade loading the different faces.
  115409. */
  115410. readonly supportCascades: boolean;
  115411. /**
  115412. * This returns if the loader support the current file information.
  115413. * @param extension defines the file extension of the file being loaded
  115414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115415. * @param fallback defines the fallback internal texture if any
  115416. * @param isBase64 defines whether the texture is encoded as a base64
  115417. * @param isBuffer defines whether the texture data are stored as a buffer
  115418. * @returns true if the loader can load the specified file
  115419. */
  115420. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115421. /**
  115422. * Transform the url before loading if required.
  115423. * @param rootUrl the url of the texture
  115424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115425. * @returns the transformed texture
  115426. */
  115427. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115428. /**
  115429. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115430. * @param rootUrl the url of the texture
  115431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115432. * @returns the fallback texture
  115433. */
  115434. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115435. /**
  115436. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115437. * @param data contains the texture data
  115438. * @param texture defines the BabylonJS internal texture
  115439. * @param createPolynomials will be true if polynomials have been requested
  115440. * @param onLoad defines the callback to trigger once the texture is ready
  115441. * @param onError defines the callback to trigger in case of error
  115442. */
  115443. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115444. /**
  115445. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115446. * @param data contains the texture data
  115447. * @param texture defines the BabylonJS internal texture
  115448. * @param callback defines the method to call once ready to upload
  115449. */
  115450. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115451. }
  115452. }
  115453. declare module BABYLON {
  115454. /**
  115455. * Implementation of the ENV Texture Loader.
  115456. * @hidden
  115457. */
  115458. export class _ENVTextureLoader implements IInternalTextureLoader {
  115459. /**
  115460. * Defines wether the loader supports cascade loading the different faces.
  115461. */
  115462. readonly supportCascades: boolean;
  115463. /**
  115464. * This returns if the loader support the current file information.
  115465. * @param extension defines the file extension of the file being loaded
  115466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115467. * @param fallback defines the fallback internal texture if any
  115468. * @param isBase64 defines whether the texture is encoded as a base64
  115469. * @param isBuffer defines whether the texture data are stored as a buffer
  115470. * @returns true if the loader can load the specified file
  115471. */
  115472. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115473. /**
  115474. * Transform the url before loading if required.
  115475. * @param rootUrl the url of the texture
  115476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115477. * @returns the transformed texture
  115478. */
  115479. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115480. /**
  115481. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115482. * @param rootUrl the url of the texture
  115483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115484. * @returns the fallback texture
  115485. */
  115486. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115487. /**
  115488. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115489. * @param data contains the texture data
  115490. * @param texture defines the BabylonJS internal texture
  115491. * @param createPolynomials will be true if polynomials have been requested
  115492. * @param onLoad defines the callback to trigger once the texture is ready
  115493. * @param onError defines the callback to trigger in case of error
  115494. */
  115495. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115496. /**
  115497. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115498. * @param data contains the texture data
  115499. * @param texture defines the BabylonJS internal texture
  115500. * @param callback defines the method to call once ready to upload
  115501. */
  115502. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115503. }
  115504. }
  115505. declare module BABYLON {
  115506. /**
  115507. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115508. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115509. */
  115510. export class KhronosTextureContainer {
  115511. /** contents of the KTX container file */
  115512. arrayBuffer: any;
  115513. private static HEADER_LEN;
  115514. private static COMPRESSED_2D;
  115515. private static COMPRESSED_3D;
  115516. private static TEX_2D;
  115517. private static TEX_3D;
  115518. /**
  115519. * Gets the openGL type
  115520. */
  115521. glType: number;
  115522. /**
  115523. * Gets the openGL type size
  115524. */
  115525. glTypeSize: number;
  115526. /**
  115527. * Gets the openGL format
  115528. */
  115529. glFormat: number;
  115530. /**
  115531. * Gets the openGL internal format
  115532. */
  115533. glInternalFormat: number;
  115534. /**
  115535. * Gets the base internal format
  115536. */
  115537. glBaseInternalFormat: number;
  115538. /**
  115539. * Gets image width in pixel
  115540. */
  115541. pixelWidth: number;
  115542. /**
  115543. * Gets image height in pixel
  115544. */
  115545. pixelHeight: number;
  115546. /**
  115547. * Gets image depth in pixels
  115548. */
  115549. pixelDepth: number;
  115550. /**
  115551. * Gets the number of array elements
  115552. */
  115553. numberOfArrayElements: number;
  115554. /**
  115555. * Gets the number of faces
  115556. */
  115557. numberOfFaces: number;
  115558. /**
  115559. * Gets the number of mipmap levels
  115560. */
  115561. numberOfMipmapLevels: number;
  115562. /**
  115563. * Gets the bytes of key value data
  115564. */
  115565. bytesOfKeyValueData: number;
  115566. /**
  115567. * Gets the load type
  115568. */
  115569. loadType: number;
  115570. /**
  115571. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115572. */
  115573. isInvalid: boolean;
  115574. /**
  115575. * Creates a new KhronosTextureContainer
  115576. * @param arrayBuffer contents of the KTX container file
  115577. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115578. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115579. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115580. */
  115581. constructor(
  115582. /** contents of the KTX container file */
  115583. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115584. /**
  115585. * Uploads KTX content to a Babylon Texture.
  115586. * It is assumed that the texture has already been created & is currently bound
  115587. * @hidden
  115588. */
  115589. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115590. private _upload2DCompressedLevels;
  115591. }
  115592. }
  115593. declare module BABYLON {
  115594. /**
  115595. * Implementation of the KTX Texture Loader.
  115596. * @hidden
  115597. */
  115598. export class _KTXTextureLoader implements IInternalTextureLoader {
  115599. /**
  115600. * Defines wether the loader supports cascade loading the different faces.
  115601. */
  115602. readonly supportCascades: boolean;
  115603. /**
  115604. * This returns if the loader support the current file information.
  115605. * @param extension defines the file extension of the file being loaded
  115606. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115607. * @param fallback defines the fallback internal texture if any
  115608. * @param isBase64 defines whether the texture is encoded as a base64
  115609. * @param isBuffer defines whether the texture data are stored as a buffer
  115610. * @returns true if the loader can load the specified file
  115611. */
  115612. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115613. /**
  115614. * Transform the url before loading if required.
  115615. * @param rootUrl the url of the texture
  115616. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115617. * @returns the transformed texture
  115618. */
  115619. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115620. /**
  115621. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115622. * @param rootUrl the url of the texture
  115623. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115624. * @returns the fallback texture
  115625. */
  115626. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115627. /**
  115628. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115629. * @param data contains the texture data
  115630. * @param texture defines the BabylonJS internal texture
  115631. * @param createPolynomials will be true if polynomials have been requested
  115632. * @param onLoad defines the callback to trigger once the texture is ready
  115633. * @param onError defines the callback to trigger in case of error
  115634. */
  115635. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115636. /**
  115637. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115638. * @param data contains the texture data
  115639. * @param texture defines the BabylonJS internal texture
  115640. * @param callback defines the method to call once ready to upload
  115641. */
  115642. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115643. }
  115644. }
  115645. declare module BABYLON {
  115646. /**
  115647. * Options for the default xr helper
  115648. */
  115649. export class WebXRDefaultExperienceOptions {
  115650. /**
  115651. * Floor meshes that should be used for teleporting
  115652. */
  115653. floorMeshes: Array<AbstractMesh>;
  115654. }
  115655. /**
  115656. * Default experience which provides a similar setup to the previous webVRExperience
  115657. */
  115658. export class WebXRDefaultExperience {
  115659. /**
  115660. * Base experience
  115661. */
  115662. baseExperience: WebXRExperienceHelper;
  115663. /**
  115664. * Input experience extension
  115665. */
  115666. input: WebXRInput;
  115667. /**
  115668. * Loads the controller models
  115669. */
  115670. controllerModelLoader: WebXRControllerModelLoader;
  115671. /**
  115672. * Enables laser pointer and selection
  115673. */
  115674. pointerSelection: WebXRControllerPointerSelection;
  115675. /**
  115676. * Enables teleportation
  115677. */
  115678. teleportation: WebXRControllerTeleportation;
  115679. /**
  115680. * Enables ui for enetering/exiting xr
  115681. */
  115682. enterExitUI: WebXREnterExitUI;
  115683. /**
  115684. * Default output canvas xr should render to
  115685. */
  115686. outputCanvas: WebXRManagedOutputCanvas;
  115687. /**
  115688. * Creates the default xr experience
  115689. * @param scene scene
  115690. * @param options options for basic configuration
  115691. * @returns resulting WebXRDefaultExperience
  115692. */
  115693. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115694. private constructor();
  115695. /**
  115696. * DIsposes of the experience helper
  115697. */
  115698. dispose(): void;
  115699. }
  115700. }
  115701. declare module BABYLON {
  115702. /** @hidden */
  115703. export var _forceSceneHelpersToBundle: boolean;
  115704. interface Scene {
  115705. /**
  115706. * Creates a default light for the scene.
  115707. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115708. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115709. */
  115710. createDefaultLight(replace?: boolean): void;
  115711. /**
  115712. * Creates a default camera for the scene.
  115713. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115714. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115715. * @param replace has default false, when true replaces the active camera in the scene
  115716. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115717. */
  115718. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115719. /**
  115720. * Creates a default camera and a default light.
  115721. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115722. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115723. * @param replace has the default false, when true replaces the active camera/light in the scene
  115724. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115725. */
  115726. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115727. /**
  115728. * Creates a new sky box
  115729. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115730. * @param environmentTexture defines the texture to use as environment texture
  115731. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115732. * @param scale defines the overall scale of the skybox
  115733. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115734. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115735. * @returns a new mesh holding the sky box
  115736. */
  115737. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115738. /**
  115739. * Creates a new environment
  115740. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115741. * @param options defines the options you can use to configure the environment
  115742. * @returns the new EnvironmentHelper
  115743. */
  115744. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115745. /**
  115746. * Creates a new VREXperienceHelper
  115747. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115748. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115749. * @returns a new VREXperienceHelper
  115750. */
  115751. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115752. /**
  115753. * Creates a new WebXRDefaultExperience
  115754. * @see http://doc.babylonjs.com/how_to/webxr
  115755. * @param options experience options
  115756. * @returns a promise for a new WebXRDefaultExperience
  115757. */
  115758. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115759. }
  115760. }
  115761. declare module BABYLON {
  115762. /**
  115763. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115764. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115765. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115766. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115767. */
  115768. export class VideoDome extends TransformNode {
  115769. /**
  115770. * Define the video source as a Monoscopic panoramic 360 video.
  115771. */
  115772. static readonly MODE_MONOSCOPIC: number;
  115773. /**
  115774. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115775. */
  115776. static readonly MODE_TOPBOTTOM: number;
  115777. /**
  115778. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115779. */
  115780. static readonly MODE_SIDEBYSIDE: number;
  115781. private _halfDome;
  115782. private _useDirectMapping;
  115783. /**
  115784. * The video texture being displayed on the sphere
  115785. */
  115786. protected _videoTexture: VideoTexture;
  115787. /**
  115788. * Gets the video texture being displayed on the sphere
  115789. */
  115790. readonly videoTexture: VideoTexture;
  115791. /**
  115792. * The skybox material
  115793. */
  115794. protected _material: BackgroundMaterial;
  115795. /**
  115796. * The surface used for the skybox
  115797. */
  115798. protected _mesh: Mesh;
  115799. /**
  115800. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115801. */
  115802. private _halfDomeMask;
  115803. /**
  115804. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115805. * Also see the options.resolution property.
  115806. */
  115807. fovMultiplier: number;
  115808. private _videoMode;
  115809. /**
  115810. * Gets or set the current video mode for the video. It can be:
  115811. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115812. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115813. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115814. */
  115815. videoMode: number;
  115816. /**
  115817. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115818. *
  115819. */
  115820. /**
  115821. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115822. */
  115823. halfDome: boolean;
  115824. /**
  115825. * Oberserver used in Stereoscopic VR Mode.
  115826. */
  115827. private _onBeforeCameraRenderObserver;
  115828. /**
  115829. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115830. * @param name Element's name, child elements will append suffixes for their own names.
  115831. * @param urlsOrVideo defines the url(s) or the video element to use
  115832. * @param options An object containing optional or exposed sub element properties
  115833. */
  115834. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115835. resolution?: number;
  115836. clickToPlay?: boolean;
  115837. autoPlay?: boolean;
  115838. loop?: boolean;
  115839. size?: number;
  115840. poster?: string;
  115841. faceForward?: boolean;
  115842. useDirectMapping?: boolean;
  115843. halfDomeMode?: boolean;
  115844. }, scene: Scene);
  115845. private _changeVideoMode;
  115846. /**
  115847. * Releases resources associated with this node.
  115848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115850. */
  115851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115852. }
  115853. }
  115854. declare module BABYLON {
  115855. /**
  115856. * This class can be used to get instrumentation data from a Babylon engine
  115857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115858. */
  115859. export class EngineInstrumentation implements IDisposable {
  115860. /**
  115861. * Define the instrumented engine.
  115862. */
  115863. engine: Engine;
  115864. private _captureGPUFrameTime;
  115865. private _gpuFrameTimeToken;
  115866. private _gpuFrameTime;
  115867. private _captureShaderCompilationTime;
  115868. private _shaderCompilationTime;
  115869. private _onBeginFrameObserver;
  115870. private _onEndFrameObserver;
  115871. private _onBeforeShaderCompilationObserver;
  115872. private _onAfterShaderCompilationObserver;
  115873. /**
  115874. * Gets the perf counter used for GPU frame time
  115875. */
  115876. readonly gpuFrameTimeCounter: PerfCounter;
  115877. /**
  115878. * Gets the GPU frame time capture status
  115879. */
  115880. /**
  115881. * Enable or disable the GPU frame time capture
  115882. */
  115883. captureGPUFrameTime: boolean;
  115884. /**
  115885. * Gets the perf counter used for shader compilation time
  115886. */
  115887. readonly shaderCompilationTimeCounter: PerfCounter;
  115888. /**
  115889. * Gets the shader compilation time capture status
  115890. */
  115891. /**
  115892. * Enable or disable the shader compilation time capture
  115893. */
  115894. captureShaderCompilationTime: boolean;
  115895. /**
  115896. * Instantiates a new engine instrumentation.
  115897. * This class can be used to get instrumentation data from a Babylon engine
  115898. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115899. * @param engine Defines the engine to instrument
  115900. */
  115901. constructor(
  115902. /**
  115903. * Define the instrumented engine.
  115904. */
  115905. engine: Engine);
  115906. /**
  115907. * Dispose and release associated resources.
  115908. */
  115909. dispose(): void;
  115910. }
  115911. }
  115912. declare module BABYLON {
  115913. /**
  115914. * This class can be used to get instrumentation data from a Babylon engine
  115915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115916. */
  115917. export class SceneInstrumentation implements IDisposable {
  115918. /**
  115919. * Defines the scene to instrument
  115920. */
  115921. scene: Scene;
  115922. private _captureActiveMeshesEvaluationTime;
  115923. private _activeMeshesEvaluationTime;
  115924. private _captureRenderTargetsRenderTime;
  115925. private _renderTargetsRenderTime;
  115926. private _captureFrameTime;
  115927. private _frameTime;
  115928. private _captureRenderTime;
  115929. private _renderTime;
  115930. private _captureInterFrameTime;
  115931. private _interFrameTime;
  115932. private _captureParticlesRenderTime;
  115933. private _particlesRenderTime;
  115934. private _captureSpritesRenderTime;
  115935. private _spritesRenderTime;
  115936. private _capturePhysicsTime;
  115937. private _physicsTime;
  115938. private _captureAnimationsTime;
  115939. private _animationsTime;
  115940. private _captureCameraRenderTime;
  115941. private _cameraRenderTime;
  115942. private _onBeforeActiveMeshesEvaluationObserver;
  115943. private _onAfterActiveMeshesEvaluationObserver;
  115944. private _onBeforeRenderTargetsRenderObserver;
  115945. private _onAfterRenderTargetsRenderObserver;
  115946. private _onAfterRenderObserver;
  115947. private _onBeforeDrawPhaseObserver;
  115948. private _onAfterDrawPhaseObserver;
  115949. private _onBeforeAnimationsObserver;
  115950. private _onBeforeParticlesRenderingObserver;
  115951. private _onAfterParticlesRenderingObserver;
  115952. private _onBeforeSpritesRenderingObserver;
  115953. private _onAfterSpritesRenderingObserver;
  115954. private _onBeforePhysicsObserver;
  115955. private _onAfterPhysicsObserver;
  115956. private _onAfterAnimationsObserver;
  115957. private _onBeforeCameraRenderObserver;
  115958. private _onAfterCameraRenderObserver;
  115959. /**
  115960. * Gets the perf counter used for active meshes evaluation time
  115961. */
  115962. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115963. /**
  115964. * Gets the active meshes evaluation time capture status
  115965. */
  115966. /**
  115967. * Enable or disable the active meshes evaluation time capture
  115968. */
  115969. captureActiveMeshesEvaluationTime: boolean;
  115970. /**
  115971. * Gets the perf counter used for render targets render time
  115972. */
  115973. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115974. /**
  115975. * Gets the render targets render time capture status
  115976. */
  115977. /**
  115978. * Enable or disable the render targets render time capture
  115979. */
  115980. captureRenderTargetsRenderTime: boolean;
  115981. /**
  115982. * Gets the perf counter used for particles render time
  115983. */
  115984. readonly particlesRenderTimeCounter: PerfCounter;
  115985. /**
  115986. * Gets the particles render time capture status
  115987. */
  115988. /**
  115989. * Enable or disable the particles render time capture
  115990. */
  115991. captureParticlesRenderTime: boolean;
  115992. /**
  115993. * Gets the perf counter used for sprites render time
  115994. */
  115995. readonly spritesRenderTimeCounter: PerfCounter;
  115996. /**
  115997. * Gets the sprites render time capture status
  115998. */
  115999. /**
  116000. * Enable or disable the sprites render time capture
  116001. */
  116002. captureSpritesRenderTime: boolean;
  116003. /**
  116004. * Gets the perf counter used for physics time
  116005. */
  116006. readonly physicsTimeCounter: PerfCounter;
  116007. /**
  116008. * Gets the physics time capture status
  116009. */
  116010. /**
  116011. * Enable or disable the physics time capture
  116012. */
  116013. capturePhysicsTime: boolean;
  116014. /**
  116015. * Gets the perf counter used for animations time
  116016. */
  116017. readonly animationsTimeCounter: PerfCounter;
  116018. /**
  116019. * Gets the animations time capture status
  116020. */
  116021. /**
  116022. * Enable or disable the animations time capture
  116023. */
  116024. captureAnimationsTime: boolean;
  116025. /**
  116026. * Gets the perf counter used for frame time capture
  116027. */
  116028. readonly frameTimeCounter: PerfCounter;
  116029. /**
  116030. * Gets the frame time capture status
  116031. */
  116032. /**
  116033. * Enable or disable the frame time capture
  116034. */
  116035. captureFrameTime: boolean;
  116036. /**
  116037. * Gets the perf counter used for inter-frames time capture
  116038. */
  116039. readonly interFrameTimeCounter: PerfCounter;
  116040. /**
  116041. * Gets the inter-frames time capture status
  116042. */
  116043. /**
  116044. * Enable or disable the inter-frames time capture
  116045. */
  116046. captureInterFrameTime: boolean;
  116047. /**
  116048. * Gets the perf counter used for render time capture
  116049. */
  116050. readonly renderTimeCounter: PerfCounter;
  116051. /**
  116052. * Gets the render time capture status
  116053. */
  116054. /**
  116055. * Enable or disable the render time capture
  116056. */
  116057. captureRenderTime: boolean;
  116058. /**
  116059. * Gets the perf counter used for camera render time capture
  116060. */
  116061. readonly cameraRenderTimeCounter: PerfCounter;
  116062. /**
  116063. * Gets the camera render time capture status
  116064. */
  116065. /**
  116066. * Enable or disable the camera render time capture
  116067. */
  116068. captureCameraRenderTime: boolean;
  116069. /**
  116070. * Gets the perf counter used for draw calls
  116071. */
  116072. readonly drawCallsCounter: PerfCounter;
  116073. /**
  116074. * Instantiates a new scene instrumentation.
  116075. * This class can be used to get instrumentation data from a Babylon engine
  116076. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116077. * @param scene Defines the scene to instrument
  116078. */
  116079. constructor(
  116080. /**
  116081. * Defines the scene to instrument
  116082. */
  116083. scene: Scene);
  116084. /**
  116085. * Dispose and release associated resources.
  116086. */
  116087. dispose(): void;
  116088. }
  116089. }
  116090. declare module BABYLON {
  116091. /** @hidden */
  116092. export var glowMapGenerationPixelShader: {
  116093. name: string;
  116094. shader: string;
  116095. };
  116096. }
  116097. declare module BABYLON {
  116098. /** @hidden */
  116099. export var glowMapGenerationVertexShader: {
  116100. name: string;
  116101. shader: string;
  116102. };
  116103. }
  116104. declare module BABYLON {
  116105. /**
  116106. * Effect layer options. This helps customizing the behaviour
  116107. * of the effect layer.
  116108. */
  116109. export interface IEffectLayerOptions {
  116110. /**
  116111. * Multiplication factor apply to the canvas size to compute the render target size
  116112. * used to generated the objects (the smaller the faster).
  116113. */
  116114. mainTextureRatio: number;
  116115. /**
  116116. * Enforces a fixed size texture to ensure effect stability across devices.
  116117. */
  116118. mainTextureFixedSize?: number;
  116119. /**
  116120. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116121. */
  116122. alphaBlendingMode: number;
  116123. /**
  116124. * The camera attached to the layer.
  116125. */
  116126. camera: Nullable<Camera>;
  116127. /**
  116128. * The rendering group to draw the layer in.
  116129. */
  116130. renderingGroupId: number;
  116131. }
  116132. /**
  116133. * The effect layer Helps adding post process effect blended with the main pass.
  116134. *
  116135. * This can be for instance use to generate glow or higlight effects on the scene.
  116136. *
  116137. * The effect layer class can not be used directly and is intented to inherited from to be
  116138. * customized per effects.
  116139. */
  116140. export abstract class EffectLayer {
  116141. private _vertexBuffers;
  116142. private _indexBuffer;
  116143. private _cachedDefines;
  116144. private _effectLayerMapGenerationEffect;
  116145. private _effectLayerOptions;
  116146. private _mergeEffect;
  116147. protected _scene: Scene;
  116148. protected _engine: Engine;
  116149. protected _maxSize: number;
  116150. protected _mainTextureDesiredSize: ISize;
  116151. protected _mainTexture: RenderTargetTexture;
  116152. protected _shouldRender: boolean;
  116153. protected _postProcesses: PostProcess[];
  116154. protected _textures: BaseTexture[];
  116155. protected _emissiveTextureAndColor: {
  116156. texture: Nullable<BaseTexture>;
  116157. color: Color4;
  116158. };
  116159. /**
  116160. * The name of the layer
  116161. */
  116162. name: string;
  116163. /**
  116164. * The clear color of the texture used to generate the glow map.
  116165. */
  116166. neutralColor: Color4;
  116167. /**
  116168. * Specifies wether the highlight layer is enabled or not.
  116169. */
  116170. isEnabled: boolean;
  116171. /**
  116172. * Gets the camera attached to the layer.
  116173. */
  116174. readonly camera: Nullable<Camera>;
  116175. /**
  116176. * Gets the rendering group id the layer should render in.
  116177. */
  116178. renderingGroupId: number;
  116179. /**
  116180. * An event triggered when the effect layer has been disposed.
  116181. */
  116182. onDisposeObservable: Observable<EffectLayer>;
  116183. /**
  116184. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116185. */
  116186. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116187. /**
  116188. * An event triggered when the generated texture is being merged in the scene.
  116189. */
  116190. onBeforeComposeObservable: Observable<EffectLayer>;
  116191. /**
  116192. * An event triggered when the generated texture has been merged in the scene.
  116193. */
  116194. onAfterComposeObservable: Observable<EffectLayer>;
  116195. /**
  116196. * An event triggered when the efffect layer changes its size.
  116197. */
  116198. onSizeChangedObservable: Observable<EffectLayer>;
  116199. /** @hidden */
  116200. static _SceneComponentInitialization: (scene: Scene) => void;
  116201. /**
  116202. * Instantiates a new effect Layer and references it in the scene.
  116203. * @param name The name of the layer
  116204. * @param scene The scene to use the layer in
  116205. */
  116206. constructor(
  116207. /** The Friendly of the effect in the scene */
  116208. name: string, scene: Scene);
  116209. /**
  116210. * Get the effect name of the layer.
  116211. * @return The effect name
  116212. */
  116213. abstract getEffectName(): string;
  116214. /**
  116215. * Checks for the readiness of the element composing the layer.
  116216. * @param subMesh the mesh to check for
  116217. * @param useInstances specify wether or not to use instances to render the mesh
  116218. * @return true if ready otherwise, false
  116219. */
  116220. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116221. /**
  116222. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116223. * @returns true if the effect requires stencil during the main canvas render pass.
  116224. */
  116225. abstract needStencil(): boolean;
  116226. /**
  116227. * Create the merge effect. This is the shader use to blit the information back
  116228. * to the main canvas at the end of the scene rendering.
  116229. * @returns The effect containing the shader used to merge the effect on the main canvas
  116230. */
  116231. protected abstract _createMergeEffect(): Effect;
  116232. /**
  116233. * Creates the render target textures and post processes used in the effect layer.
  116234. */
  116235. protected abstract _createTextureAndPostProcesses(): void;
  116236. /**
  116237. * Implementation specific of rendering the generating effect on the main canvas.
  116238. * @param effect The effect used to render through
  116239. */
  116240. protected abstract _internalRender(effect: Effect): void;
  116241. /**
  116242. * Sets the required values for both the emissive texture and and the main color.
  116243. */
  116244. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116245. /**
  116246. * Free any resources and references associated to a mesh.
  116247. * Internal use
  116248. * @param mesh The mesh to free.
  116249. */
  116250. abstract _disposeMesh(mesh: Mesh): void;
  116251. /**
  116252. * Serializes this layer (Glow or Highlight for example)
  116253. * @returns a serialized layer object
  116254. */
  116255. abstract serialize?(): any;
  116256. /**
  116257. * Initializes the effect layer with the required options.
  116258. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116259. */
  116260. protected _init(options: Partial<IEffectLayerOptions>): void;
  116261. /**
  116262. * Generates the index buffer of the full screen quad blending to the main canvas.
  116263. */
  116264. private _generateIndexBuffer;
  116265. /**
  116266. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116267. */
  116268. private _generateVertexBuffer;
  116269. /**
  116270. * Sets the main texture desired size which is the closest power of two
  116271. * of the engine canvas size.
  116272. */
  116273. private _setMainTextureSize;
  116274. /**
  116275. * Creates the main texture for the effect layer.
  116276. */
  116277. protected _createMainTexture(): void;
  116278. /**
  116279. * Adds specific effects defines.
  116280. * @param defines The defines to add specifics to.
  116281. */
  116282. protected _addCustomEffectDefines(defines: string[]): void;
  116283. /**
  116284. * Checks for the readiness of the element composing the layer.
  116285. * @param subMesh the mesh to check for
  116286. * @param useInstances specify wether or not to use instances to render the mesh
  116287. * @param emissiveTexture the associated emissive texture used to generate the glow
  116288. * @return true if ready otherwise, false
  116289. */
  116290. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116291. /**
  116292. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116293. */
  116294. render(): void;
  116295. /**
  116296. * Determine if a given mesh will be used in the current effect.
  116297. * @param mesh mesh to test
  116298. * @returns true if the mesh will be used
  116299. */
  116300. hasMesh(mesh: AbstractMesh): boolean;
  116301. /**
  116302. * Returns true if the layer contains information to display, otherwise false.
  116303. * @returns true if the glow layer should be rendered
  116304. */
  116305. shouldRender(): boolean;
  116306. /**
  116307. * Returns true if the mesh should render, otherwise false.
  116308. * @param mesh The mesh to render
  116309. * @returns true if it should render otherwise false
  116310. */
  116311. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116312. /**
  116313. * Returns true if the mesh can be rendered, otherwise false.
  116314. * @param mesh The mesh to render
  116315. * @param material The material used on the mesh
  116316. * @returns true if it can be rendered otherwise false
  116317. */
  116318. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116319. /**
  116320. * Returns true if the mesh should render, otherwise false.
  116321. * @param mesh The mesh to render
  116322. * @returns true if it should render otherwise false
  116323. */
  116324. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116325. /**
  116326. * Renders the submesh passed in parameter to the generation map.
  116327. */
  116328. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116329. /**
  116330. * Rebuild the required buffers.
  116331. * @hidden Internal use only.
  116332. */
  116333. _rebuild(): void;
  116334. /**
  116335. * Dispose only the render target textures and post process.
  116336. */
  116337. private _disposeTextureAndPostProcesses;
  116338. /**
  116339. * Dispose the highlight layer and free resources.
  116340. */
  116341. dispose(): void;
  116342. /**
  116343. * Gets the class name of the effect layer
  116344. * @returns the string with the class name of the effect layer
  116345. */
  116346. getClassName(): string;
  116347. /**
  116348. * Creates an effect layer from parsed effect layer data
  116349. * @param parsedEffectLayer defines effect layer data
  116350. * @param scene defines the current scene
  116351. * @param rootUrl defines the root URL containing the effect layer information
  116352. * @returns a parsed effect Layer
  116353. */
  116354. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116355. }
  116356. }
  116357. declare module BABYLON {
  116358. interface AbstractScene {
  116359. /**
  116360. * The list of effect layers (highlights/glow) added to the scene
  116361. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116362. * @see http://doc.babylonjs.com/how_to/glow_layer
  116363. */
  116364. effectLayers: Array<EffectLayer>;
  116365. /**
  116366. * Removes the given effect layer from this scene.
  116367. * @param toRemove defines the effect layer to remove
  116368. * @returns the index of the removed effect layer
  116369. */
  116370. removeEffectLayer(toRemove: EffectLayer): number;
  116371. /**
  116372. * Adds the given effect layer to this scene
  116373. * @param newEffectLayer defines the effect layer to add
  116374. */
  116375. addEffectLayer(newEffectLayer: EffectLayer): void;
  116376. }
  116377. /**
  116378. * Defines the layer scene component responsible to manage any effect layers
  116379. * in a given scene.
  116380. */
  116381. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116382. /**
  116383. * The component name helpfull to identify the component in the list of scene components.
  116384. */
  116385. readonly name: string;
  116386. /**
  116387. * The scene the component belongs to.
  116388. */
  116389. scene: Scene;
  116390. private _engine;
  116391. private _renderEffects;
  116392. private _needStencil;
  116393. private _previousStencilState;
  116394. /**
  116395. * Creates a new instance of the component for the given scene
  116396. * @param scene Defines the scene to register the component in
  116397. */
  116398. constructor(scene: Scene);
  116399. /**
  116400. * Registers the component in a given scene
  116401. */
  116402. register(): void;
  116403. /**
  116404. * Rebuilds the elements related to this component in case of
  116405. * context lost for instance.
  116406. */
  116407. rebuild(): void;
  116408. /**
  116409. * Serializes the component data to the specified json object
  116410. * @param serializationObject The object to serialize to
  116411. */
  116412. serialize(serializationObject: any): void;
  116413. /**
  116414. * Adds all the elements from the container to the scene
  116415. * @param container the container holding the elements
  116416. */
  116417. addFromContainer(container: AbstractScene): void;
  116418. /**
  116419. * Removes all the elements in the container from the scene
  116420. * @param container contains the elements to remove
  116421. * @param dispose if the removed element should be disposed (default: false)
  116422. */
  116423. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116424. /**
  116425. * Disposes the component and the associated ressources.
  116426. */
  116427. dispose(): void;
  116428. private _isReadyForMesh;
  116429. private _renderMainTexture;
  116430. private _setStencil;
  116431. private _setStencilBack;
  116432. private _draw;
  116433. private _drawCamera;
  116434. private _drawRenderingGroup;
  116435. }
  116436. }
  116437. declare module BABYLON {
  116438. /** @hidden */
  116439. export var glowMapMergePixelShader: {
  116440. name: string;
  116441. shader: string;
  116442. };
  116443. }
  116444. declare module BABYLON {
  116445. /** @hidden */
  116446. export var glowMapMergeVertexShader: {
  116447. name: string;
  116448. shader: string;
  116449. };
  116450. }
  116451. declare module BABYLON {
  116452. interface AbstractScene {
  116453. /**
  116454. * Return a the first highlight layer of the scene with a given name.
  116455. * @param name The name of the highlight layer to look for.
  116456. * @return The highlight layer if found otherwise null.
  116457. */
  116458. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116459. }
  116460. /**
  116461. * Glow layer options. This helps customizing the behaviour
  116462. * of the glow layer.
  116463. */
  116464. export interface IGlowLayerOptions {
  116465. /**
  116466. * Multiplication factor apply to the canvas size to compute the render target size
  116467. * used to generated the glowing objects (the smaller the faster).
  116468. */
  116469. mainTextureRatio: number;
  116470. /**
  116471. * Enforces a fixed size texture to ensure resize independant blur.
  116472. */
  116473. mainTextureFixedSize?: number;
  116474. /**
  116475. * How big is the kernel of the blur texture.
  116476. */
  116477. blurKernelSize: number;
  116478. /**
  116479. * The camera attached to the layer.
  116480. */
  116481. camera: Nullable<Camera>;
  116482. /**
  116483. * Enable MSAA by chosing the number of samples.
  116484. */
  116485. mainTextureSamples?: number;
  116486. /**
  116487. * The rendering group to draw the layer in.
  116488. */
  116489. renderingGroupId: number;
  116490. }
  116491. /**
  116492. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116493. *
  116494. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116495. * glowy meshes to your scene.
  116496. *
  116497. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116498. */
  116499. export class GlowLayer extends EffectLayer {
  116500. /**
  116501. * Effect Name of the layer.
  116502. */
  116503. static readonly EffectName: string;
  116504. /**
  116505. * The default blur kernel size used for the glow.
  116506. */
  116507. static DefaultBlurKernelSize: number;
  116508. /**
  116509. * The default texture size ratio used for the glow.
  116510. */
  116511. static DefaultTextureRatio: number;
  116512. /**
  116513. * Sets the kernel size of the blur.
  116514. */
  116515. /**
  116516. * Gets the kernel size of the blur.
  116517. */
  116518. blurKernelSize: number;
  116519. /**
  116520. * Sets the glow intensity.
  116521. */
  116522. /**
  116523. * Gets the glow intensity.
  116524. */
  116525. intensity: number;
  116526. private _options;
  116527. private _intensity;
  116528. private _horizontalBlurPostprocess1;
  116529. private _verticalBlurPostprocess1;
  116530. private _horizontalBlurPostprocess2;
  116531. private _verticalBlurPostprocess2;
  116532. private _blurTexture1;
  116533. private _blurTexture2;
  116534. private _postProcesses1;
  116535. private _postProcesses2;
  116536. private _includedOnlyMeshes;
  116537. private _excludedMeshes;
  116538. /**
  116539. * Callback used to let the user override the color selection on a per mesh basis
  116540. */
  116541. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116542. /**
  116543. * Callback used to let the user override the texture selection on a per mesh basis
  116544. */
  116545. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116546. /**
  116547. * Instantiates a new glow Layer and references it to the scene.
  116548. * @param name The name of the layer
  116549. * @param scene The scene to use the layer in
  116550. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116551. */
  116552. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116553. /**
  116554. * Get the effect name of the layer.
  116555. * @return The effect name
  116556. */
  116557. getEffectName(): string;
  116558. /**
  116559. * Create the merge effect. This is the shader use to blit the information back
  116560. * to the main canvas at the end of the scene rendering.
  116561. */
  116562. protected _createMergeEffect(): Effect;
  116563. /**
  116564. * Creates the render target textures and post processes used in the glow layer.
  116565. */
  116566. protected _createTextureAndPostProcesses(): void;
  116567. /**
  116568. * Checks for the readiness of the element composing the layer.
  116569. * @param subMesh the mesh to check for
  116570. * @param useInstances specify wether or not to use instances to render the mesh
  116571. * @param emissiveTexture the associated emissive texture used to generate the glow
  116572. * @return true if ready otherwise, false
  116573. */
  116574. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116575. /**
  116576. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116577. */
  116578. needStencil(): boolean;
  116579. /**
  116580. * Returns true if the mesh can be rendered, otherwise false.
  116581. * @param mesh The mesh to render
  116582. * @param material The material used on the mesh
  116583. * @returns true if it can be rendered otherwise false
  116584. */
  116585. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116586. /**
  116587. * Implementation specific of rendering the generating effect on the main canvas.
  116588. * @param effect The effect used to render through
  116589. */
  116590. protected _internalRender(effect: Effect): void;
  116591. /**
  116592. * Sets the required values for both the emissive texture and and the main color.
  116593. */
  116594. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116595. /**
  116596. * Returns true if the mesh should render, otherwise false.
  116597. * @param mesh The mesh to render
  116598. * @returns true if it should render otherwise false
  116599. */
  116600. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116601. /**
  116602. * Adds specific effects defines.
  116603. * @param defines The defines to add specifics to.
  116604. */
  116605. protected _addCustomEffectDefines(defines: string[]): void;
  116606. /**
  116607. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116608. * @param mesh The mesh to exclude from the glow layer
  116609. */
  116610. addExcludedMesh(mesh: Mesh): void;
  116611. /**
  116612. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116613. * @param mesh The mesh to remove
  116614. */
  116615. removeExcludedMesh(mesh: Mesh): void;
  116616. /**
  116617. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116618. * @param mesh The mesh to include in the glow layer
  116619. */
  116620. addIncludedOnlyMesh(mesh: Mesh): void;
  116621. /**
  116622. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116623. * @param mesh The mesh to remove
  116624. */
  116625. removeIncludedOnlyMesh(mesh: Mesh): void;
  116626. /**
  116627. * Determine if a given mesh will be used in the glow layer
  116628. * @param mesh The mesh to test
  116629. * @returns true if the mesh will be highlighted by the current glow layer
  116630. */
  116631. hasMesh(mesh: AbstractMesh): boolean;
  116632. /**
  116633. * Free any resources and references associated to a mesh.
  116634. * Internal use
  116635. * @param mesh The mesh to free.
  116636. * @hidden
  116637. */
  116638. _disposeMesh(mesh: Mesh): void;
  116639. /**
  116640. * Gets the class name of the effect layer
  116641. * @returns the string with the class name of the effect layer
  116642. */
  116643. getClassName(): string;
  116644. /**
  116645. * Serializes this glow layer
  116646. * @returns a serialized glow layer object
  116647. */
  116648. serialize(): any;
  116649. /**
  116650. * Creates a Glow Layer from parsed glow layer data
  116651. * @param parsedGlowLayer defines glow layer data
  116652. * @param scene defines the current scene
  116653. * @param rootUrl defines the root URL containing the glow layer information
  116654. * @returns a parsed Glow Layer
  116655. */
  116656. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116657. }
  116658. }
  116659. declare module BABYLON {
  116660. /** @hidden */
  116661. export var glowBlurPostProcessPixelShader: {
  116662. name: string;
  116663. shader: string;
  116664. };
  116665. }
  116666. declare module BABYLON {
  116667. interface AbstractScene {
  116668. /**
  116669. * Return a the first highlight layer of the scene with a given name.
  116670. * @param name The name of the highlight layer to look for.
  116671. * @return The highlight layer if found otherwise null.
  116672. */
  116673. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116674. }
  116675. /**
  116676. * Highlight layer options. This helps customizing the behaviour
  116677. * of the highlight layer.
  116678. */
  116679. export interface IHighlightLayerOptions {
  116680. /**
  116681. * Multiplication factor apply to the canvas size to compute the render target size
  116682. * used to generated the glowing objects (the smaller the faster).
  116683. */
  116684. mainTextureRatio: number;
  116685. /**
  116686. * Enforces a fixed size texture to ensure resize independant blur.
  116687. */
  116688. mainTextureFixedSize?: number;
  116689. /**
  116690. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116691. * of the picture to blur (the smaller the faster).
  116692. */
  116693. blurTextureSizeRatio: number;
  116694. /**
  116695. * How big in texel of the blur texture is the vertical blur.
  116696. */
  116697. blurVerticalSize: number;
  116698. /**
  116699. * How big in texel of the blur texture is the horizontal blur.
  116700. */
  116701. blurHorizontalSize: number;
  116702. /**
  116703. * Alpha blending mode used to apply the blur. Default is combine.
  116704. */
  116705. alphaBlendingMode: number;
  116706. /**
  116707. * The camera attached to the layer.
  116708. */
  116709. camera: Nullable<Camera>;
  116710. /**
  116711. * Should we display highlight as a solid stroke?
  116712. */
  116713. isStroke?: boolean;
  116714. /**
  116715. * The rendering group to draw the layer in.
  116716. */
  116717. renderingGroupId: number;
  116718. }
  116719. /**
  116720. * The highlight layer Helps adding a glow effect around a mesh.
  116721. *
  116722. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116723. * glowy meshes to your scene.
  116724. *
  116725. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116726. */
  116727. export class HighlightLayer extends EffectLayer {
  116728. name: string;
  116729. /**
  116730. * Effect Name of the highlight layer.
  116731. */
  116732. static readonly EffectName: string;
  116733. /**
  116734. * The neutral color used during the preparation of the glow effect.
  116735. * This is black by default as the blend operation is a blend operation.
  116736. */
  116737. static NeutralColor: Color4;
  116738. /**
  116739. * Stencil value used for glowing meshes.
  116740. */
  116741. static GlowingMeshStencilReference: number;
  116742. /**
  116743. * Stencil value used for the other meshes in the scene.
  116744. */
  116745. static NormalMeshStencilReference: number;
  116746. /**
  116747. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116748. */
  116749. innerGlow: boolean;
  116750. /**
  116751. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116752. */
  116753. outerGlow: boolean;
  116754. /**
  116755. * Specifies the horizontal size of the blur.
  116756. */
  116757. /**
  116758. * Gets the horizontal size of the blur.
  116759. */
  116760. blurHorizontalSize: number;
  116761. /**
  116762. * Specifies the vertical size of the blur.
  116763. */
  116764. /**
  116765. * Gets the vertical size of the blur.
  116766. */
  116767. blurVerticalSize: number;
  116768. /**
  116769. * An event triggered when the highlight layer is being blurred.
  116770. */
  116771. onBeforeBlurObservable: Observable<HighlightLayer>;
  116772. /**
  116773. * An event triggered when the highlight layer has been blurred.
  116774. */
  116775. onAfterBlurObservable: Observable<HighlightLayer>;
  116776. private _instanceGlowingMeshStencilReference;
  116777. private _options;
  116778. private _downSamplePostprocess;
  116779. private _horizontalBlurPostprocess;
  116780. private _verticalBlurPostprocess;
  116781. private _blurTexture;
  116782. private _meshes;
  116783. private _excludedMeshes;
  116784. /**
  116785. * Instantiates a new highlight Layer and references it to the scene..
  116786. * @param name The name of the layer
  116787. * @param scene The scene to use the layer in
  116788. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116789. */
  116790. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116791. /**
  116792. * Get the effect name of the layer.
  116793. * @return The effect name
  116794. */
  116795. getEffectName(): string;
  116796. /**
  116797. * Create the merge effect. This is the shader use to blit the information back
  116798. * to the main canvas at the end of the scene rendering.
  116799. */
  116800. protected _createMergeEffect(): Effect;
  116801. /**
  116802. * Creates the render target textures and post processes used in the highlight layer.
  116803. */
  116804. protected _createTextureAndPostProcesses(): void;
  116805. /**
  116806. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116807. */
  116808. needStencil(): boolean;
  116809. /**
  116810. * Checks for the readiness of the element composing the layer.
  116811. * @param subMesh the mesh to check for
  116812. * @param useInstances specify wether or not to use instances to render the mesh
  116813. * @param emissiveTexture the associated emissive texture used to generate the glow
  116814. * @return true if ready otherwise, false
  116815. */
  116816. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116817. /**
  116818. * Implementation specific of rendering the generating effect on the main canvas.
  116819. * @param effect The effect used to render through
  116820. */
  116821. protected _internalRender(effect: Effect): void;
  116822. /**
  116823. * Returns true if the layer contains information to display, otherwise false.
  116824. */
  116825. shouldRender(): boolean;
  116826. /**
  116827. * Returns true if the mesh should render, otherwise false.
  116828. * @param mesh The mesh to render
  116829. * @returns true if it should render otherwise false
  116830. */
  116831. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116832. /**
  116833. * Sets the required values for both the emissive texture and and the main color.
  116834. */
  116835. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116836. /**
  116837. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116838. * @param mesh The mesh to exclude from the highlight layer
  116839. */
  116840. addExcludedMesh(mesh: Mesh): void;
  116841. /**
  116842. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116843. * @param mesh The mesh to highlight
  116844. */
  116845. removeExcludedMesh(mesh: Mesh): void;
  116846. /**
  116847. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116848. * @param mesh mesh to test
  116849. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116850. */
  116851. hasMesh(mesh: AbstractMesh): boolean;
  116852. /**
  116853. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116854. * @param mesh The mesh to highlight
  116855. * @param color The color of the highlight
  116856. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116857. */
  116858. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116859. /**
  116860. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116861. * @param mesh The mesh to highlight
  116862. */
  116863. removeMesh(mesh: Mesh): void;
  116864. /**
  116865. * Force the stencil to the normal expected value for none glowing parts
  116866. */
  116867. private _defaultStencilReference;
  116868. /**
  116869. * Free any resources and references associated to a mesh.
  116870. * Internal use
  116871. * @param mesh The mesh to free.
  116872. * @hidden
  116873. */
  116874. _disposeMesh(mesh: Mesh): void;
  116875. /**
  116876. * Dispose the highlight layer and free resources.
  116877. */
  116878. dispose(): void;
  116879. /**
  116880. * Gets the class name of the effect layer
  116881. * @returns the string with the class name of the effect layer
  116882. */
  116883. getClassName(): string;
  116884. /**
  116885. * Serializes this Highlight layer
  116886. * @returns a serialized Highlight layer object
  116887. */
  116888. serialize(): any;
  116889. /**
  116890. * Creates a Highlight layer from parsed Highlight layer data
  116891. * @param parsedHightlightLayer defines the Highlight layer data
  116892. * @param scene defines the current scene
  116893. * @param rootUrl defines the root URL containing the Highlight layer information
  116894. * @returns a parsed Highlight layer
  116895. */
  116896. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116897. }
  116898. }
  116899. declare module BABYLON {
  116900. interface AbstractScene {
  116901. /**
  116902. * The list of layers (background and foreground) of the scene
  116903. */
  116904. layers: Array<Layer>;
  116905. }
  116906. /**
  116907. * Defines the layer scene component responsible to manage any layers
  116908. * in a given scene.
  116909. */
  116910. export class LayerSceneComponent implements ISceneComponent {
  116911. /**
  116912. * The component name helpfull to identify the component in the list of scene components.
  116913. */
  116914. readonly name: string;
  116915. /**
  116916. * The scene the component belongs to.
  116917. */
  116918. scene: Scene;
  116919. private _engine;
  116920. /**
  116921. * Creates a new instance of the component for the given scene
  116922. * @param scene Defines the scene to register the component in
  116923. */
  116924. constructor(scene: Scene);
  116925. /**
  116926. * Registers the component in a given scene
  116927. */
  116928. register(): void;
  116929. /**
  116930. * Rebuilds the elements related to this component in case of
  116931. * context lost for instance.
  116932. */
  116933. rebuild(): void;
  116934. /**
  116935. * Disposes the component and the associated ressources.
  116936. */
  116937. dispose(): void;
  116938. private _draw;
  116939. private _drawCameraPredicate;
  116940. private _drawCameraBackground;
  116941. private _drawCameraForeground;
  116942. private _drawRenderTargetPredicate;
  116943. private _drawRenderTargetBackground;
  116944. private _drawRenderTargetForeground;
  116945. /**
  116946. * Adds all the elements from the container to the scene
  116947. * @param container the container holding the elements
  116948. */
  116949. addFromContainer(container: AbstractScene): void;
  116950. /**
  116951. * Removes all the elements in the container from the scene
  116952. * @param container contains the elements to remove
  116953. * @param dispose if the removed element should be disposed (default: false)
  116954. */
  116955. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116956. }
  116957. }
  116958. declare module BABYLON {
  116959. /** @hidden */
  116960. export var layerPixelShader: {
  116961. name: string;
  116962. shader: string;
  116963. };
  116964. }
  116965. declare module BABYLON {
  116966. /** @hidden */
  116967. export var layerVertexShader: {
  116968. name: string;
  116969. shader: string;
  116970. };
  116971. }
  116972. declare module BABYLON {
  116973. /**
  116974. * This represents a full screen 2d layer.
  116975. * This can be useful to display a picture in the background of your scene for instance.
  116976. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116977. */
  116978. export class Layer {
  116979. /**
  116980. * Define the name of the layer.
  116981. */
  116982. name: string;
  116983. /**
  116984. * Define the texture the layer should display.
  116985. */
  116986. texture: Nullable<Texture>;
  116987. /**
  116988. * Is the layer in background or foreground.
  116989. */
  116990. isBackground: boolean;
  116991. /**
  116992. * Define the color of the layer (instead of texture).
  116993. */
  116994. color: Color4;
  116995. /**
  116996. * Define the scale of the layer in order to zoom in out of the texture.
  116997. */
  116998. scale: Vector2;
  116999. /**
  117000. * Define an offset for the layer in order to shift the texture.
  117001. */
  117002. offset: Vector2;
  117003. /**
  117004. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117005. */
  117006. alphaBlendingMode: number;
  117007. /**
  117008. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117009. * Alpha test will not mix with the background color in case of transparency.
  117010. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117011. */
  117012. alphaTest: boolean;
  117013. /**
  117014. * Define a mask to restrict the layer to only some of the scene cameras.
  117015. */
  117016. layerMask: number;
  117017. /**
  117018. * Define the list of render target the layer is visible into.
  117019. */
  117020. renderTargetTextures: RenderTargetTexture[];
  117021. /**
  117022. * Define if the layer is only used in renderTarget or if it also
  117023. * renders in the main frame buffer of the canvas.
  117024. */
  117025. renderOnlyInRenderTargetTextures: boolean;
  117026. private _scene;
  117027. private _vertexBuffers;
  117028. private _indexBuffer;
  117029. private _effect;
  117030. private _alphaTestEffect;
  117031. /**
  117032. * An event triggered when the layer is disposed.
  117033. */
  117034. onDisposeObservable: Observable<Layer>;
  117035. private _onDisposeObserver;
  117036. /**
  117037. * Back compatibility with callback before the onDisposeObservable existed.
  117038. * The set callback will be triggered when the layer has been disposed.
  117039. */
  117040. onDispose: () => void;
  117041. /**
  117042. * An event triggered before rendering the scene
  117043. */
  117044. onBeforeRenderObservable: Observable<Layer>;
  117045. private _onBeforeRenderObserver;
  117046. /**
  117047. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117048. * The set callback will be triggered just before rendering the layer.
  117049. */
  117050. onBeforeRender: () => void;
  117051. /**
  117052. * An event triggered after rendering the scene
  117053. */
  117054. onAfterRenderObservable: Observable<Layer>;
  117055. private _onAfterRenderObserver;
  117056. /**
  117057. * Back compatibility with callback before the onAfterRenderObservable existed.
  117058. * The set callback will be triggered just after rendering the layer.
  117059. */
  117060. onAfterRender: () => void;
  117061. /**
  117062. * Instantiates a new layer.
  117063. * This represents a full screen 2d layer.
  117064. * This can be useful to display a picture in the background of your scene for instance.
  117065. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117066. * @param name Define the name of the layer in the scene
  117067. * @param imgUrl Define the url of the texture to display in the layer
  117068. * @param scene Define the scene the layer belongs to
  117069. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117070. * @param color Defines a color for the layer
  117071. */
  117072. constructor(
  117073. /**
  117074. * Define the name of the layer.
  117075. */
  117076. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117077. private _createIndexBuffer;
  117078. /** @hidden */
  117079. _rebuild(): void;
  117080. /**
  117081. * Renders the layer in the scene.
  117082. */
  117083. render(): void;
  117084. /**
  117085. * Disposes and releases the associated ressources.
  117086. */
  117087. dispose(): void;
  117088. }
  117089. }
  117090. declare module BABYLON {
  117091. /** @hidden */
  117092. export var lensFlarePixelShader: {
  117093. name: string;
  117094. shader: string;
  117095. };
  117096. }
  117097. declare module BABYLON {
  117098. /** @hidden */
  117099. export var lensFlareVertexShader: {
  117100. name: string;
  117101. shader: string;
  117102. };
  117103. }
  117104. declare module BABYLON {
  117105. /**
  117106. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117107. * It is usually composed of several `lensFlare`.
  117108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117109. */
  117110. export class LensFlareSystem {
  117111. /**
  117112. * Define the name of the lens flare system
  117113. */
  117114. name: string;
  117115. /**
  117116. * List of lens flares used in this system.
  117117. */
  117118. lensFlares: LensFlare[];
  117119. /**
  117120. * Define a limit from the border the lens flare can be visible.
  117121. */
  117122. borderLimit: number;
  117123. /**
  117124. * Define a viewport border we do not want to see the lens flare in.
  117125. */
  117126. viewportBorder: number;
  117127. /**
  117128. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117129. */
  117130. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117131. /**
  117132. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117133. */
  117134. layerMask: number;
  117135. /**
  117136. * Define the id of the lens flare system in the scene.
  117137. * (equal to name by default)
  117138. */
  117139. id: string;
  117140. private _scene;
  117141. private _emitter;
  117142. private _vertexBuffers;
  117143. private _indexBuffer;
  117144. private _effect;
  117145. private _positionX;
  117146. private _positionY;
  117147. private _isEnabled;
  117148. /** @hidden */
  117149. static _SceneComponentInitialization: (scene: Scene) => void;
  117150. /**
  117151. * Instantiates a lens flare system.
  117152. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117153. * It is usually composed of several `lensFlare`.
  117154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117155. * @param name Define the name of the lens flare system in the scene
  117156. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117157. * @param scene Define the scene the lens flare system belongs to
  117158. */
  117159. constructor(
  117160. /**
  117161. * Define the name of the lens flare system
  117162. */
  117163. name: string, emitter: any, scene: Scene);
  117164. /**
  117165. * Define if the lens flare system is enabled.
  117166. */
  117167. isEnabled: boolean;
  117168. /**
  117169. * Get the scene the effects belongs to.
  117170. * @returns the scene holding the lens flare system
  117171. */
  117172. getScene(): Scene;
  117173. /**
  117174. * Get the emitter of the lens flare system.
  117175. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117176. * @returns the emitter of the lens flare system
  117177. */
  117178. getEmitter(): any;
  117179. /**
  117180. * Set the emitter of the lens flare system.
  117181. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117182. * @param newEmitter Define the new emitter of the system
  117183. */
  117184. setEmitter(newEmitter: any): void;
  117185. /**
  117186. * Get the lens flare system emitter position.
  117187. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117188. * @returns the position
  117189. */
  117190. getEmitterPosition(): Vector3;
  117191. /**
  117192. * @hidden
  117193. */
  117194. computeEffectivePosition(globalViewport: Viewport): boolean;
  117195. /** @hidden */
  117196. _isVisible(): boolean;
  117197. /**
  117198. * @hidden
  117199. */
  117200. render(): boolean;
  117201. /**
  117202. * Dispose and release the lens flare with its associated resources.
  117203. */
  117204. dispose(): void;
  117205. /**
  117206. * Parse a lens flare system from a JSON repressentation
  117207. * @param parsedLensFlareSystem Define the JSON to parse
  117208. * @param scene Define the scene the parsed system should be instantiated in
  117209. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117210. * @returns the parsed system
  117211. */
  117212. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117213. /**
  117214. * Serialize the current Lens Flare System into a JSON representation.
  117215. * @returns the serialized JSON
  117216. */
  117217. serialize(): any;
  117218. }
  117219. }
  117220. declare module BABYLON {
  117221. /**
  117222. * This represents one of the lens effect in a `lensFlareSystem`.
  117223. * It controls one of the indiviual texture used in the effect.
  117224. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117225. */
  117226. export class LensFlare {
  117227. /**
  117228. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117229. */
  117230. size: number;
  117231. /**
  117232. * 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.
  117233. */
  117234. position: number;
  117235. /**
  117236. * Define the lens color.
  117237. */
  117238. color: Color3;
  117239. /**
  117240. * Define the lens texture.
  117241. */
  117242. texture: Nullable<Texture>;
  117243. /**
  117244. * Define the alpha mode to render this particular lens.
  117245. */
  117246. alphaMode: number;
  117247. private _system;
  117248. /**
  117249. * Creates a new Lens Flare.
  117250. * This represents one of the lens effect in a `lensFlareSystem`.
  117251. * It controls one of the indiviual texture used in the effect.
  117252. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117253. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117254. * @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.
  117255. * @param color Define the lens color
  117256. * @param imgUrl Define the lens texture url
  117257. * @param system Define the `lensFlareSystem` this flare is part of
  117258. * @returns The newly created Lens Flare
  117259. */
  117260. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117261. /**
  117262. * Instantiates a new Lens Flare.
  117263. * This represents one of the lens effect in a `lensFlareSystem`.
  117264. * It controls one of the indiviual texture used in the effect.
  117265. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117266. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117267. * @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.
  117268. * @param color Define the lens color
  117269. * @param imgUrl Define the lens texture url
  117270. * @param system Define the `lensFlareSystem` this flare is part of
  117271. */
  117272. constructor(
  117273. /**
  117274. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117275. */
  117276. size: number,
  117277. /**
  117278. * 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.
  117279. */
  117280. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117281. /**
  117282. * Dispose and release the lens flare with its associated resources.
  117283. */
  117284. dispose(): void;
  117285. }
  117286. }
  117287. declare module BABYLON {
  117288. interface AbstractScene {
  117289. /**
  117290. * The list of lens flare system added to the scene
  117291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117292. */
  117293. lensFlareSystems: Array<LensFlareSystem>;
  117294. /**
  117295. * Removes the given lens flare system from this scene.
  117296. * @param toRemove The lens flare system to remove
  117297. * @returns The index of the removed lens flare system
  117298. */
  117299. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117300. /**
  117301. * Adds the given lens flare system to this scene
  117302. * @param newLensFlareSystem The lens flare system to add
  117303. */
  117304. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117305. /**
  117306. * Gets a lens flare system using its name
  117307. * @param name defines the name to look for
  117308. * @returns the lens flare system or null if not found
  117309. */
  117310. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117311. /**
  117312. * Gets a lens flare system using its id
  117313. * @param id defines the id to look for
  117314. * @returns the lens flare system or null if not found
  117315. */
  117316. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117317. }
  117318. /**
  117319. * Defines the lens flare scene component responsible to manage any lens flares
  117320. * in a given scene.
  117321. */
  117322. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117323. /**
  117324. * The component name helpfull to identify the component in the list of scene components.
  117325. */
  117326. readonly name: string;
  117327. /**
  117328. * The scene the component belongs to.
  117329. */
  117330. scene: Scene;
  117331. /**
  117332. * Creates a new instance of the component for the given scene
  117333. * @param scene Defines the scene to register the component in
  117334. */
  117335. constructor(scene: Scene);
  117336. /**
  117337. * Registers the component in a given scene
  117338. */
  117339. register(): void;
  117340. /**
  117341. * Rebuilds the elements related to this component in case of
  117342. * context lost for instance.
  117343. */
  117344. rebuild(): void;
  117345. /**
  117346. * Adds all the elements from the container to the scene
  117347. * @param container the container holding the elements
  117348. */
  117349. addFromContainer(container: AbstractScene): void;
  117350. /**
  117351. * Removes all the elements in the container from the scene
  117352. * @param container contains the elements to remove
  117353. * @param dispose if the removed element should be disposed (default: false)
  117354. */
  117355. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117356. /**
  117357. * Serializes the component data to the specified json object
  117358. * @param serializationObject The object to serialize to
  117359. */
  117360. serialize(serializationObject: any): void;
  117361. /**
  117362. * Disposes the component and the associated ressources.
  117363. */
  117364. dispose(): void;
  117365. private _draw;
  117366. }
  117367. }
  117368. declare module BABYLON {
  117369. /**
  117370. * Defines the shadow generator component responsible to manage any shadow generators
  117371. * in a given scene.
  117372. */
  117373. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117374. /**
  117375. * The component name helpfull to identify the component in the list of scene components.
  117376. */
  117377. readonly name: string;
  117378. /**
  117379. * The scene the component belongs to.
  117380. */
  117381. scene: Scene;
  117382. /**
  117383. * Creates a new instance of the component for the given scene
  117384. * @param scene Defines the scene to register the component in
  117385. */
  117386. constructor(scene: Scene);
  117387. /**
  117388. * Registers the component in a given scene
  117389. */
  117390. register(): void;
  117391. /**
  117392. * Rebuilds the elements related to this component in case of
  117393. * context lost for instance.
  117394. */
  117395. rebuild(): void;
  117396. /**
  117397. * Serializes the component data to the specified json object
  117398. * @param serializationObject The object to serialize to
  117399. */
  117400. serialize(serializationObject: any): void;
  117401. /**
  117402. * Adds all the elements from the container to the scene
  117403. * @param container the container holding the elements
  117404. */
  117405. addFromContainer(container: AbstractScene): void;
  117406. /**
  117407. * Removes all the elements in the container from the scene
  117408. * @param container contains the elements to remove
  117409. * @param dispose if the removed element should be disposed (default: false)
  117410. */
  117411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117412. /**
  117413. * Rebuilds the elements related to this component in case of
  117414. * context lost for instance.
  117415. */
  117416. dispose(): void;
  117417. private _gatherRenderTargets;
  117418. }
  117419. }
  117420. declare module BABYLON {
  117421. /**
  117422. * A point light is a light defined by an unique point in world space.
  117423. * The light is emitted in every direction from this point.
  117424. * A good example of a point light is a standard light bulb.
  117425. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117426. */
  117427. export class PointLight extends ShadowLight {
  117428. private _shadowAngle;
  117429. /**
  117430. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117431. * This specifies what angle the shadow will use to be created.
  117432. *
  117433. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117434. */
  117435. /**
  117436. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117437. * This specifies what angle the shadow will use to be created.
  117438. *
  117439. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117440. */
  117441. shadowAngle: number;
  117442. /**
  117443. * Gets the direction if it has been set.
  117444. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117445. */
  117446. /**
  117447. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117448. */
  117449. direction: Vector3;
  117450. /**
  117451. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117452. * A PointLight emits the light in every direction.
  117453. * It can cast shadows.
  117454. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117455. * ```javascript
  117456. * var pointLight = new PointLight("pl", camera.position, scene);
  117457. * ```
  117458. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117459. * @param name The light friendly name
  117460. * @param position The position of the point light in the scene
  117461. * @param scene The scene the lights belongs to
  117462. */
  117463. constructor(name: string, position: Vector3, scene: Scene);
  117464. /**
  117465. * Returns the string "PointLight"
  117466. * @returns the class name
  117467. */
  117468. getClassName(): string;
  117469. /**
  117470. * Returns the integer 0.
  117471. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117472. */
  117473. getTypeID(): number;
  117474. /**
  117475. * Specifies wether or not the shadowmap should be a cube texture.
  117476. * @returns true if the shadowmap needs to be a cube texture.
  117477. */
  117478. needCube(): boolean;
  117479. /**
  117480. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117481. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117482. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117483. */
  117484. getShadowDirection(faceIndex?: number): Vector3;
  117485. /**
  117486. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117487. * - fov = PI / 2
  117488. * - aspect ratio : 1.0
  117489. * - z-near and far equal to the active camera minZ and maxZ.
  117490. * Returns the PointLight.
  117491. */
  117492. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117493. protected _buildUniformLayout(): void;
  117494. /**
  117495. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117496. * @param effect The effect to update
  117497. * @param lightIndex The index of the light in the effect to update
  117498. * @returns The point light
  117499. */
  117500. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117501. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117502. /**
  117503. * Prepares the list of defines specific to the light type.
  117504. * @param defines the list of defines
  117505. * @param lightIndex defines the index of the light for the effect
  117506. */
  117507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117508. }
  117509. }
  117510. declare module BABYLON {
  117511. /**
  117512. * Header information of HDR texture files.
  117513. */
  117514. export interface HDRInfo {
  117515. /**
  117516. * The height of the texture in pixels.
  117517. */
  117518. height: number;
  117519. /**
  117520. * The width of the texture in pixels.
  117521. */
  117522. width: number;
  117523. /**
  117524. * The index of the beginning of the data in the binary file.
  117525. */
  117526. dataPosition: number;
  117527. }
  117528. /**
  117529. * This groups tools to convert HDR texture to native colors array.
  117530. */
  117531. export class HDRTools {
  117532. private static Ldexp;
  117533. private static Rgbe2float;
  117534. private static readStringLine;
  117535. /**
  117536. * Reads header information from an RGBE texture stored in a native array.
  117537. * More information on this format are available here:
  117538. * https://en.wikipedia.org/wiki/RGBE_image_format
  117539. *
  117540. * @param uint8array The binary file stored in native array.
  117541. * @return The header information.
  117542. */
  117543. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117544. /**
  117545. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117546. * This RGBE texture needs to store the information as a panorama.
  117547. *
  117548. * More information on this format are available here:
  117549. * https://en.wikipedia.org/wiki/RGBE_image_format
  117550. *
  117551. * @param buffer The binary file stored in an array buffer.
  117552. * @param size The expected size of the extracted cubemap.
  117553. * @return The Cube Map information.
  117554. */
  117555. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117556. /**
  117557. * Returns the pixels data extracted from an RGBE texture.
  117558. * This pixels will be stored left to right up to down in the R G B order in one array.
  117559. *
  117560. * More information on this format are available here:
  117561. * https://en.wikipedia.org/wiki/RGBE_image_format
  117562. *
  117563. * @param uint8array The binary file stored in an array buffer.
  117564. * @param hdrInfo The header information of the file.
  117565. * @return The pixels data in RGB right to left up to down order.
  117566. */
  117567. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117568. private static RGBE_ReadPixels_RLE;
  117569. }
  117570. }
  117571. declare module BABYLON {
  117572. /**
  117573. * This represents a texture coming from an HDR input.
  117574. *
  117575. * The only supported format is currently panorama picture stored in RGBE format.
  117576. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117577. */
  117578. export class HDRCubeTexture extends BaseTexture {
  117579. private static _facesMapping;
  117580. private _generateHarmonics;
  117581. private _noMipmap;
  117582. private _textureMatrix;
  117583. private _size;
  117584. private _onLoad;
  117585. private _onError;
  117586. /**
  117587. * The texture URL.
  117588. */
  117589. url: string;
  117590. /**
  117591. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117592. */
  117593. coordinatesMode: number;
  117594. protected _isBlocking: boolean;
  117595. /**
  117596. * Sets wether or not the texture is blocking during loading.
  117597. */
  117598. /**
  117599. * Gets wether or not the texture is blocking during loading.
  117600. */
  117601. isBlocking: boolean;
  117602. protected _rotationY: number;
  117603. /**
  117604. * Sets texture matrix rotation angle around Y axis in radians.
  117605. */
  117606. /**
  117607. * Gets texture matrix rotation angle around Y axis radians.
  117608. */
  117609. rotationY: number;
  117610. /**
  117611. * Gets or sets the center of the bounding box associated with the cube texture
  117612. * It must define where the camera used to render the texture was set
  117613. */
  117614. boundingBoxPosition: Vector3;
  117615. private _boundingBoxSize;
  117616. /**
  117617. * Gets or sets the size of the bounding box associated with the cube texture
  117618. * When defined, the cubemap will switch to local mode
  117619. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117620. * @example https://www.babylonjs-playground.com/#RNASML
  117621. */
  117622. boundingBoxSize: Vector3;
  117623. /**
  117624. * Instantiates an HDRTexture from the following parameters.
  117625. *
  117626. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117627. * @param scene The scene the texture will be used in
  117628. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117629. * @param noMipmap Forces to not generate the mipmap if true
  117630. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117631. * @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)
  117632. * @param reserved Reserved flag for internal use.
  117633. */
  117634. 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>);
  117635. /**
  117636. * Get the current class name of the texture useful for serialization or dynamic coding.
  117637. * @returns "HDRCubeTexture"
  117638. */
  117639. getClassName(): string;
  117640. /**
  117641. * Occurs when the file is raw .hdr file.
  117642. */
  117643. private loadTexture;
  117644. clone(): HDRCubeTexture;
  117645. delayLoad(): void;
  117646. /**
  117647. * Get the texture reflection matrix used to rotate/transform the reflection.
  117648. * @returns the reflection matrix
  117649. */
  117650. getReflectionTextureMatrix(): Matrix;
  117651. /**
  117652. * Set the texture reflection matrix used to rotate/transform the reflection.
  117653. * @param value Define the reflection matrix to set
  117654. */
  117655. setReflectionTextureMatrix(value: Matrix): void;
  117656. /**
  117657. * Parses a JSON representation of an HDR Texture in order to create the texture
  117658. * @param parsedTexture Define the JSON representation
  117659. * @param scene Define the scene the texture should be created in
  117660. * @param rootUrl Define the root url in case we need to load relative dependencies
  117661. * @returns the newly created texture after parsing
  117662. */
  117663. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117664. serialize(): any;
  117665. }
  117666. }
  117667. declare module BABYLON {
  117668. /**
  117669. * Class used to control physics engine
  117670. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117671. */
  117672. export class PhysicsEngine implements IPhysicsEngine {
  117673. private _physicsPlugin;
  117674. /**
  117675. * Global value used to control the smallest number supported by the simulation
  117676. */
  117677. static Epsilon: number;
  117678. private _impostors;
  117679. private _joints;
  117680. /**
  117681. * Gets the gravity vector used by the simulation
  117682. */
  117683. gravity: Vector3;
  117684. /**
  117685. * Factory used to create the default physics plugin.
  117686. * @returns The default physics plugin
  117687. */
  117688. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117689. /**
  117690. * Creates a new Physics Engine
  117691. * @param gravity defines the gravity vector used by the simulation
  117692. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117693. */
  117694. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117695. /**
  117696. * Sets the gravity vector used by the simulation
  117697. * @param gravity defines the gravity vector to use
  117698. */
  117699. setGravity(gravity: Vector3): void;
  117700. /**
  117701. * Set the time step of the physics engine.
  117702. * Default is 1/60.
  117703. * To slow it down, enter 1/600 for example.
  117704. * To speed it up, 1/30
  117705. * @param newTimeStep defines the new timestep to apply to this world.
  117706. */
  117707. setTimeStep(newTimeStep?: number): void;
  117708. /**
  117709. * Get the time step of the physics engine.
  117710. * @returns the current time step
  117711. */
  117712. getTimeStep(): number;
  117713. /**
  117714. * Release all resources
  117715. */
  117716. dispose(): void;
  117717. /**
  117718. * Gets the name of the current physics plugin
  117719. * @returns the name of the plugin
  117720. */
  117721. getPhysicsPluginName(): string;
  117722. /**
  117723. * Adding a new impostor for the impostor tracking.
  117724. * This will be done by the impostor itself.
  117725. * @param impostor the impostor to add
  117726. */
  117727. addImpostor(impostor: PhysicsImpostor): void;
  117728. /**
  117729. * Remove an impostor from the engine.
  117730. * This impostor and its mesh will not longer be updated by the physics engine.
  117731. * @param impostor the impostor to remove
  117732. */
  117733. removeImpostor(impostor: PhysicsImpostor): void;
  117734. /**
  117735. * Add a joint to the physics engine
  117736. * @param mainImpostor defines the main impostor to which the joint is added.
  117737. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117738. * @param joint defines the joint that will connect both impostors.
  117739. */
  117740. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117741. /**
  117742. * Removes a joint from the simulation
  117743. * @param mainImpostor defines the impostor used with the joint
  117744. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117745. * @param joint defines the joint to remove
  117746. */
  117747. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117748. /**
  117749. * Called by the scene. No need to call it.
  117750. * @param delta defines the timespam between frames
  117751. */
  117752. _step(delta: number): void;
  117753. /**
  117754. * Gets the current plugin used to run the simulation
  117755. * @returns current plugin
  117756. */
  117757. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117758. /**
  117759. * Gets the list of physic impostors
  117760. * @returns an array of PhysicsImpostor
  117761. */
  117762. getImpostors(): Array<PhysicsImpostor>;
  117763. /**
  117764. * Gets the impostor for a physics enabled object
  117765. * @param object defines the object impersonated by the impostor
  117766. * @returns the PhysicsImpostor or null if not found
  117767. */
  117768. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117769. /**
  117770. * Gets the impostor for a physics body object
  117771. * @param body defines physics body used by the impostor
  117772. * @returns the PhysicsImpostor or null if not found
  117773. */
  117774. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117775. /**
  117776. * Does a raycast in the physics world
  117777. * @param from when should the ray start?
  117778. * @param to when should the ray end?
  117779. * @returns PhysicsRaycastResult
  117780. */
  117781. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117782. }
  117783. }
  117784. declare module BABYLON {
  117785. /** @hidden */
  117786. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117787. private _useDeltaForWorldStep;
  117788. world: any;
  117789. name: string;
  117790. private _physicsMaterials;
  117791. private _fixedTimeStep;
  117792. private _cannonRaycastResult;
  117793. private _raycastResult;
  117794. private _physicsBodysToRemoveAfterStep;
  117795. BJSCANNON: any;
  117796. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117797. setGravity(gravity: Vector3): void;
  117798. setTimeStep(timeStep: number): void;
  117799. getTimeStep(): number;
  117800. executeStep(delta: number): void;
  117801. private _removeMarkedPhysicsBodiesFromWorld;
  117802. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117803. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117804. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117805. private _processChildMeshes;
  117806. removePhysicsBody(impostor: PhysicsImpostor): void;
  117807. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117808. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117809. private _addMaterial;
  117810. private _checkWithEpsilon;
  117811. private _createShape;
  117812. private _createHeightmap;
  117813. private _minus90X;
  117814. private _plus90X;
  117815. private _tmpPosition;
  117816. private _tmpDeltaPosition;
  117817. private _tmpUnityRotation;
  117818. private _updatePhysicsBodyTransformation;
  117819. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117820. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117821. isSupported(): boolean;
  117822. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117823. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117824. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117825. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117826. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117827. getBodyMass(impostor: PhysicsImpostor): number;
  117828. getBodyFriction(impostor: PhysicsImpostor): number;
  117829. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117830. getBodyRestitution(impostor: PhysicsImpostor): number;
  117831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117832. sleepBody(impostor: PhysicsImpostor): void;
  117833. wakeUpBody(impostor: PhysicsImpostor): void;
  117834. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117835. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117836. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117837. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117838. getRadius(impostor: PhysicsImpostor): number;
  117839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117840. dispose(): void;
  117841. private _extendNamespace;
  117842. /**
  117843. * Does a raycast in the physics world
  117844. * @param from when should the ray start?
  117845. * @param to when should the ray end?
  117846. * @returns PhysicsRaycastResult
  117847. */
  117848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117849. }
  117850. }
  117851. declare module BABYLON {
  117852. /** @hidden */
  117853. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117854. world: any;
  117855. name: string;
  117856. BJSOIMO: any;
  117857. private _raycastResult;
  117858. constructor(iterations?: number, oimoInjection?: any);
  117859. setGravity(gravity: Vector3): void;
  117860. setTimeStep(timeStep: number): void;
  117861. getTimeStep(): number;
  117862. private _tmpImpostorsArray;
  117863. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117864. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117865. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117866. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117867. private _tmpPositionVector;
  117868. removePhysicsBody(impostor: PhysicsImpostor): void;
  117869. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117870. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117871. isSupported(): boolean;
  117872. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117873. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117874. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117875. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117876. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117878. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117879. getBodyMass(impostor: PhysicsImpostor): number;
  117880. getBodyFriction(impostor: PhysicsImpostor): number;
  117881. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117882. getBodyRestitution(impostor: PhysicsImpostor): number;
  117883. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117884. sleepBody(impostor: PhysicsImpostor): void;
  117885. wakeUpBody(impostor: PhysicsImpostor): void;
  117886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117887. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117888. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117890. getRadius(impostor: PhysicsImpostor): number;
  117891. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117892. dispose(): void;
  117893. /**
  117894. * Does a raycast in the physics world
  117895. * @param from when should the ray start?
  117896. * @param to when should the ray end?
  117897. * @returns PhysicsRaycastResult
  117898. */
  117899. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117900. }
  117901. }
  117902. declare module BABYLON {
  117903. /**
  117904. * Class containing static functions to help procedurally build meshes
  117905. */
  117906. export class RibbonBuilder {
  117907. /**
  117908. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117909. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117910. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117911. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117912. * * 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
  117913. * * 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
  117914. * * 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
  117915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117918. * * 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
  117919. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117920. * * 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
  117921. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117923. * @param name defines the name of the mesh
  117924. * @param options defines the options used to create the mesh
  117925. * @param scene defines the hosting scene
  117926. * @returns the ribbon mesh
  117927. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117929. */
  117930. static CreateRibbon(name: string, options: {
  117931. pathArray: Vector3[][];
  117932. closeArray?: boolean;
  117933. closePath?: boolean;
  117934. offset?: number;
  117935. updatable?: boolean;
  117936. sideOrientation?: number;
  117937. frontUVs?: Vector4;
  117938. backUVs?: Vector4;
  117939. instance?: Mesh;
  117940. invertUV?: boolean;
  117941. uvs?: Vector2[];
  117942. colors?: Color4[];
  117943. }, scene?: Nullable<Scene>): Mesh;
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. /**
  117948. * Class containing static functions to help procedurally build meshes
  117949. */
  117950. export class ShapeBuilder {
  117951. /**
  117952. * 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.
  117953. * * 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.
  117954. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117955. * * 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.
  117956. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117957. * * 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
  117958. * * 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
  117959. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117962. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117964. * @param name defines the name of the mesh
  117965. * @param options defines the options used to create the mesh
  117966. * @param scene defines the hosting scene
  117967. * @returns the extruded shape mesh
  117968. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117970. */
  117971. static ExtrudeShape(name: string, options: {
  117972. shape: Vector3[];
  117973. path: Vector3[];
  117974. scale?: number;
  117975. rotation?: number;
  117976. cap?: number;
  117977. updatable?: boolean;
  117978. sideOrientation?: number;
  117979. frontUVs?: Vector4;
  117980. backUVs?: Vector4;
  117981. instance?: Mesh;
  117982. invertUV?: boolean;
  117983. }, scene?: Nullable<Scene>): Mesh;
  117984. /**
  117985. * Creates an custom extruded shape mesh.
  117986. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117987. * * 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.
  117988. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117989. * * 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
  117990. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117991. * * 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
  117992. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117993. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117994. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117995. * * 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
  117996. * * 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
  117997. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118002. * @param name defines the name of the mesh
  118003. * @param options defines the options used to create the mesh
  118004. * @param scene defines the hosting scene
  118005. * @returns the custom extruded shape mesh
  118006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118007. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118008. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118009. */
  118010. static ExtrudeShapeCustom(name: string, options: {
  118011. shape: Vector3[];
  118012. path: Vector3[];
  118013. scaleFunction?: any;
  118014. rotationFunction?: any;
  118015. ribbonCloseArray?: boolean;
  118016. ribbonClosePath?: boolean;
  118017. cap?: number;
  118018. updatable?: boolean;
  118019. sideOrientation?: number;
  118020. frontUVs?: Vector4;
  118021. backUVs?: Vector4;
  118022. instance?: Mesh;
  118023. invertUV?: boolean;
  118024. }, scene?: Nullable<Scene>): Mesh;
  118025. private static _ExtrudeShapeGeneric;
  118026. }
  118027. }
  118028. declare module BABYLON {
  118029. /**
  118030. * AmmoJS Physics plugin
  118031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118032. * @see https://github.com/kripken/ammo.js/
  118033. */
  118034. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118035. private _useDeltaForWorldStep;
  118036. /**
  118037. * Reference to the Ammo library
  118038. */
  118039. bjsAMMO: any;
  118040. /**
  118041. * Created ammoJS world which physics bodies are added to
  118042. */
  118043. world: any;
  118044. /**
  118045. * Name of the plugin
  118046. */
  118047. name: string;
  118048. private _timeStep;
  118049. private _fixedTimeStep;
  118050. private _maxSteps;
  118051. private _tmpQuaternion;
  118052. private _tmpAmmoTransform;
  118053. private _tmpAmmoQuaternion;
  118054. private _tmpAmmoConcreteContactResultCallback;
  118055. private _collisionConfiguration;
  118056. private _dispatcher;
  118057. private _overlappingPairCache;
  118058. private _solver;
  118059. private _softBodySolver;
  118060. private _tmpAmmoVectorA;
  118061. private _tmpAmmoVectorB;
  118062. private _tmpAmmoVectorC;
  118063. private _tmpAmmoVectorD;
  118064. private _tmpContactCallbackResult;
  118065. private _tmpAmmoVectorRCA;
  118066. private _tmpAmmoVectorRCB;
  118067. private _raycastResult;
  118068. private static readonly DISABLE_COLLISION_FLAG;
  118069. private static readonly KINEMATIC_FLAG;
  118070. private static readonly DISABLE_DEACTIVATION_FLAG;
  118071. /**
  118072. * Initializes the ammoJS plugin
  118073. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118074. * @param ammoInjection can be used to inject your own ammo reference
  118075. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118076. */
  118077. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118078. /**
  118079. * Sets the gravity of the physics world (m/(s^2))
  118080. * @param gravity Gravity to set
  118081. */
  118082. setGravity(gravity: Vector3): void;
  118083. /**
  118084. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118085. * @param timeStep timestep to use in seconds
  118086. */
  118087. setTimeStep(timeStep: number): void;
  118088. /**
  118089. * 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)
  118090. * @param fixedTimeStep fixedTimeStep to use in seconds
  118091. */
  118092. setFixedTimeStep(fixedTimeStep: number): void;
  118093. /**
  118094. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118095. * @param maxSteps the maximum number of steps by the physics engine per frame
  118096. */
  118097. setMaxSteps(maxSteps: number): void;
  118098. /**
  118099. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118100. * @returns the current timestep in seconds
  118101. */
  118102. getTimeStep(): number;
  118103. private _isImpostorInContact;
  118104. private _isImpostorPairInContact;
  118105. private _stepSimulation;
  118106. /**
  118107. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118108. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118109. * After the step the babylon meshes are set to the position of the physics imposters
  118110. * @param delta amount of time to step forward
  118111. * @param impostors array of imposters to update before/after the step
  118112. */
  118113. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118114. /**
  118115. * Update babylon mesh to match physics world object
  118116. * @param impostor imposter to match
  118117. */
  118118. private _afterSoftStep;
  118119. /**
  118120. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118121. * @param impostor imposter to match
  118122. */
  118123. private _ropeStep;
  118124. /**
  118125. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118126. * @param impostor imposter to match
  118127. */
  118128. private _softbodyOrClothStep;
  118129. private _tmpVector;
  118130. private _tmpMatrix;
  118131. /**
  118132. * Applies an impulse on the imposter
  118133. * @param impostor imposter to apply impulse to
  118134. * @param force amount of force to be applied to the imposter
  118135. * @param contactPoint the location to apply the impulse on the imposter
  118136. */
  118137. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118138. /**
  118139. * Applies a force on the imposter
  118140. * @param impostor imposter to apply force
  118141. * @param force amount of force to be applied to the imposter
  118142. * @param contactPoint the location to apply the force on the imposter
  118143. */
  118144. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118145. /**
  118146. * Creates a physics body using the plugin
  118147. * @param impostor the imposter to create the physics body on
  118148. */
  118149. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118150. /**
  118151. * Removes the physics body from the imposter and disposes of the body's memory
  118152. * @param impostor imposter to remove the physics body from
  118153. */
  118154. removePhysicsBody(impostor: PhysicsImpostor): void;
  118155. /**
  118156. * Generates a joint
  118157. * @param impostorJoint the imposter joint to create the joint with
  118158. */
  118159. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118160. /**
  118161. * Removes a joint
  118162. * @param impostorJoint the imposter joint to remove the joint from
  118163. */
  118164. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118165. private _addMeshVerts;
  118166. /**
  118167. * Initialise the soft body vertices to match its object's (mesh) vertices
  118168. * Softbody vertices (nodes) are in world space and to match this
  118169. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118170. * @param impostor to create the softbody for
  118171. */
  118172. private _softVertexData;
  118173. /**
  118174. * Create an impostor's soft body
  118175. * @param impostor to create the softbody for
  118176. */
  118177. private _createSoftbody;
  118178. /**
  118179. * Create cloth for an impostor
  118180. * @param impostor to create the softbody for
  118181. */
  118182. private _createCloth;
  118183. /**
  118184. * Create rope for an impostor
  118185. * @param impostor to create the softbody for
  118186. */
  118187. private _createRope;
  118188. private _addHullVerts;
  118189. private _createShape;
  118190. /**
  118191. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118192. * @param impostor imposter containing the physics body and babylon object
  118193. */
  118194. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118195. /**
  118196. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118197. * @param impostor imposter containing the physics body and babylon object
  118198. * @param newPosition new position
  118199. * @param newRotation new rotation
  118200. */
  118201. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118202. /**
  118203. * If this plugin is supported
  118204. * @returns true if its supported
  118205. */
  118206. isSupported(): boolean;
  118207. /**
  118208. * Sets the linear velocity of the physics body
  118209. * @param impostor imposter to set the velocity on
  118210. * @param velocity velocity to set
  118211. */
  118212. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118213. /**
  118214. * Sets the angular velocity of the physics body
  118215. * @param impostor imposter to set the velocity on
  118216. * @param velocity velocity to set
  118217. */
  118218. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118219. /**
  118220. * gets the linear velocity
  118221. * @param impostor imposter to get linear velocity from
  118222. * @returns linear velocity
  118223. */
  118224. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118225. /**
  118226. * gets the angular velocity
  118227. * @param impostor imposter to get angular velocity from
  118228. * @returns angular velocity
  118229. */
  118230. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118231. /**
  118232. * Sets the mass of physics body
  118233. * @param impostor imposter to set the mass on
  118234. * @param mass mass to set
  118235. */
  118236. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118237. /**
  118238. * Gets the mass of the physics body
  118239. * @param impostor imposter to get the mass from
  118240. * @returns mass
  118241. */
  118242. getBodyMass(impostor: PhysicsImpostor): number;
  118243. /**
  118244. * Gets friction of the impostor
  118245. * @param impostor impostor to get friction from
  118246. * @returns friction value
  118247. */
  118248. getBodyFriction(impostor: PhysicsImpostor): number;
  118249. /**
  118250. * Sets friction of the impostor
  118251. * @param impostor impostor to set friction on
  118252. * @param friction friction value
  118253. */
  118254. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118255. /**
  118256. * Gets restitution of the impostor
  118257. * @param impostor impostor to get restitution from
  118258. * @returns restitution value
  118259. */
  118260. getBodyRestitution(impostor: PhysicsImpostor): number;
  118261. /**
  118262. * Sets resitution of the impostor
  118263. * @param impostor impostor to set resitution on
  118264. * @param restitution resitution value
  118265. */
  118266. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118267. /**
  118268. * Gets pressure inside the impostor
  118269. * @param impostor impostor to get pressure from
  118270. * @returns pressure value
  118271. */
  118272. getBodyPressure(impostor: PhysicsImpostor): number;
  118273. /**
  118274. * Sets pressure inside a soft body impostor
  118275. * Cloth and rope must remain 0 pressure
  118276. * @param impostor impostor to set pressure on
  118277. * @param pressure pressure value
  118278. */
  118279. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118280. /**
  118281. * Gets stiffness of the impostor
  118282. * @param impostor impostor to get stiffness from
  118283. * @returns pressure value
  118284. */
  118285. getBodyStiffness(impostor: PhysicsImpostor): number;
  118286. /**
  118287. * Sets stiffness of the impostor
  118288. * @param impostor impostor to set stiffness on
  118289. * @param stiffness stiffness value from 0 to 1
  118290. */
  118291. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118292. /**
  118293. * Gets velocityIterations of the impostor
  118294. * @param impostor impostor to get velocity iterations from
  118295. * @returns velocityIterations value
  118296. */
  118297. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118298. /**
  118299. * Sets velocityIterations of the impostor
  118300. * @param impostor impostor to set velocity iterations on
  118301. * @param velocityIterations velocityIterations value
  118302. */
  118303. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118304. /**
  118305. * Gets positionIterations of the impostor
  118306. * @param impostor impostor to get position iterations from
  118307. * @returns positionIterations value
  118308. */
  118309. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118310. /**
  118311. * Sets positionIterations of the impostor
  118312. * @param impostor impostor to set position on
  118313. * @param positionIterations positionIterations value
  118314. */
  118315. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118316. /**
  118317. * Append an anchor to a cloth object
  118318. * @param impostor is the cloth impostor to add anchor to
  118319. * @param otherImpostor is the rigid impostor to anchor to
  118320. * @param width ratio across width from 0 to 1
  118321. * @param height ratio up height from 0 to 1
  118322. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118323. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118324. */
  118325. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118326. /**
  118327. * Append an hook to a rope object
  118328. * @param impostor is the rope impostor to add hook to
  118329. * @param otherImpostor is the rigid impostor to hook to
  118330. * @param length ratio along the rope from 0 to 1
  118331. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118332. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118333. */
  118334. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118335. /**
  118336. * Sleeps the physics body and stops it from being active
  118337. * @param impostor impostor to sleep
  118338. */
  118339. sleepBody(impostor: PhysicsImpostor): void;
  118340. /**
  118341. * Activates the physics body
  118342. * @param impostor impostor to activate
  118343. */
  118344. wakeUpBody(impostor: PhysicsImpostor): void;
  118345. /**
  118346. * Updates the distance parameters of the joint
  118347. * @param joint joint to update
  118348. * @param maxDistance maximum distance of the joint
  118349. * @param minDistance minimum distance of the joint
  118350. */
  118351. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118352. /**
  118353. * Sets a motor on the joint
  118354. * @param joint joint to set motor on
  118355. * @param speed speed of the motor
  118356. * @param maxForce maximum force of the motor
  118357. * @param motorIndex index of the motor
  118358. */
  118359. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118360. /**
  118361. * Sets the motors limit
  118362. * @param joint joint to set limit on
  118363. * @param upperLimit upper limit
  118364. * @param lowerLimit lower limit
  118365. */
  118366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118367. /**
  118368. * Syncs the position and rotation of a mesh with the impostor
  118369. * @param mesh mesh to sync
  118370. * @param impostor impostor to update the mesh with
  118371. */
  118372. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118373. /**
  118374. * Gets the radius of the impostor
  118375. * @param impostor impostor to get radius from
  118376. * @returns the radius
  118377. */
  118378. getRadius(impostor: PhysicsImpostor): number;
  118379. /**
  118380. * Gets the box size of the impostor
  118381. * @param impostor impostor to get box size from
  118382. * @param result the resulting box size
  118383. */
  118384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118385. /**
  118386. * Disposes of the impostor
  118387. */
  118388. dispose(): void;
  118389. /**
  118390. * Does a raycast in the physics world
  118391. * @param from when should the ray start?
  118392. * @param to when should the ray end?
  118393. * @returns PhysicsRaycastResult
  118394. */
  118395. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118396. }
  118397. }
  118398. declare module BABYLON {
  118399. interface AbstractScene {
  118400. /**
  118401. * The list of reflection probes added to the scene
  118402. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118403. */
  118404. reflectionProbes: Array<ReflectionProbe>;
  118405. /**
  118406. * Removes the given reflection probe from this scene.
  118407. * @param toRemove The reflection probe to remove
  118408. * @returns The index of the removed reflection probe
  118409. */
  118410. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118411. /**
  118412. * Adds the given reflection probe to this scene.
  118413. * @param newReflectionProbe The reflection probe to add
  118414. */
  118415. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118416. }
  118417. /**
  118418. * Class used to generate realtime reflection / refraction cube textures
  118419. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118420. */
  118421. export class ReflectionProbe {
  118422. /** defines the name of the probe */
  118423. name: string;
  118424. private _scene;
  118425. private _renderTargetTexture;
  118426. private _projectionMatrix;
  118427. private _viewMatrix;
  118428. private _target;
  118429. private _add;
  118430. private _attachedMesh;
  118431. private _invertYAxis;
  118432. /** Gets or sets probe position (center of the cube map) */
  118433. position: Vector3;
  118434. /**
  118435. * Creates a new reflection probe
  118436. * @param name defines the name of the probe
  118437. * @param size defines the texture resolution (for each face)
  118438. * @param scene defines the hosting scene
  118439. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118440. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118441. */
  118442. constructor(
  118443. /** defines the name of the probe */
  118444. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118445. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118446. samples: number;
  118447. /** Gets or sets the refresh rate to use (on every frame by default) */
  118448. refreshRate: number;
  118449. /**
  118450. * Gets the hosting scene
  118451. * @returns a Scene
  118452. */
  118453. getScene(): Scene;
  118454. /** Gets the internal CubeTexture used to render to */
  118455. readonly cubeTexture: RenderTargetTexture;
  118456. /** Gets the list of meshes to render */
  118457. readonly renderList: Nullable<AbstractMesh[]>;
  118458. /**
  118459. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118460. * @param mesh defines the mesh to attach to
  118461. */
  118462. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118463. /**
  118464. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118465. * @param renderingGroupId The rendering group id corresponding to its index
  118466. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118467. */
  118468. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118469. /**
  118470. * Clean all associated resources
  118471. */
  118472. dispose(): void;
  118473. /**
  118474. * Converts the reflection probe information to a readable string for debug purpose.
  118475. * @param fullDetails Supports for multiple levels of logging within scene loading
  118476. * @returns the human readable reflection probe info
  118477. */
  118478. toString(fullDetails?: boolean): string;
  118479. /**
  118480. * Get the class name of the relfection probe.
  118481. * @returns "ReflectionProbe"
  118482. */
  118483. getClassName(): string;
  118484. /**
  118485. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118486. * @returns The JSON representation of the texture
  118487. */
  118488. serialize(): any;
  118489. /**
  118490. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118491. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118492. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118493. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118494. * @returns The parsed reflection probe if successful
  118495. */
  118496. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118497. }
  118498. }
  118499. declare module BABYLON {
  118500. /** @hidden */
  118501. export var _BabylonLoaderRegistered: boolean;
  118502. }
  118503. declare module BABYLON {
  118504. /**
  118505. * The Physically based simple base material of BJS.
  118506. *
  118507. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118508. * It is used as the base class for both the specGloss and metalRough conventions.
  118509. */
  118510. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118511. /**
  118512. * Number of Simultaneous lights allowed on the material.
  118513. */
  118514. maxSimultaneousLights: number;
  118515. /**
  118516. * If sets to true, disables all the lights affecting the material.
  118517. */
  118518. disableLighting: boolean;
  118519. /**
  118520. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118521. */
  118522. environmentTexture: BaseTexture;
  118523. /**
  118524. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118525. */
  118526. invertNormalMapX: boolean;
  118527. /**
  118528. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118529. */
  118530. invertNormalMapY: boolean;
  118531. /**
  118532. * Normal map used in the model.
  118533. */
  118534. normalTexture: BaseTexture;
  118535. /**
  118536. * Emissivie color used to self-illuminate the model.
  118537. */
  118538. emissiveColor: Color3;
  118539. /**
  118540. * Emissivie texture used to self-illuminate the model.
  118541. */
  118542. emissiveTexture: BaseTexture;
  118543. /**
  118544. * Occlusion Channel Strenght.
  118545. */
  118546. occlusionStrength: number;
  118547. /**
  118548. * Occlusion Texture of the material (adding extra occlusion effects).
  118549. */
  118550. occlusionTexture: BaseTexture;
  118551. /**
  118552. * Defines the alpha limits in alpha test mode.
  118553. */
  118554. alphaCutOff: number;
  118555. /**
  118556. * Gets the current double sided mode.
  118557. */
  118558. /**
  118559. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118560. */
  118561. doubleSided: boolean;
  118562. /**
  118563. * Stores the pre-calculated light information of a mesh in a texture.
  118564. */
  118565. lightmapTexture: BaseTexture;
  118566. /**
  118567. * If true, the light map contains occlusion information instead of lighting info.
  118568. */
  118569. useLightmapAsShadowmap: boolean;
  118570. /**
  118571. * Instantiates a new PBRMaterial instance.
  118572. *
  118573. * @param name The material name
  118574. * @param scene The scene the material will be use in.
  118575. */
  118576. constructor(name: string, scene: Scene);
  118577. getClassName(): string;
  118578. }
  118579. }
  118580. declare module BABYLON {
  118581. /**
  118582. * The PBR material of BJS following the metal roughness convention.
  118583. *
  118584. * This fits to the PBR convention in the GLTF definition:
  118585. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118586. */
  118587. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118588. /**
  118589. * The base color has two different interpretations depending on the value of metalness.
  118590. * When the material is a metal, the base color is the specific measured reflectance value
  118591. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118592. * of the material.
  118593. */
  118594. baseColor: Color3;
  118595. /**
  118596. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118597. * well as opacity information in the alpha channel.
  118598. */
  118599. baseTexture: BaseTexture;
  118600. /**
  118601. * Specifies the metallic scalar value of the material.
  118602. * Can also be used to scale the metalness values of the metallic texture.
  118603. */
  118604. metallic: number;
  118605. /**
  118606. * Specifies the roughness scalar value of the material.
  118607. * Can also be used to scale the roughness values of the metallic texture.
  118608. */
  118609. roughness: number;
  118610. /**
  118611. * Texture containing both the metallic value in the B channel and the
  118612. * roughness value in the G channel to keep better precision.
  118613. */
  118614. metallicRoughnessTexture: BaseTexture;
  118615. /**
  118616. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118617. *
  118618. * @param name The material name
  118619. * @param scene The scene the material will be use in.
  118620. */
  118621. constructor(name: string, scene: Scene);
  118622. /**
  118623. * Return the currrent class name of the material.
  118624. */
  118625. getClassName(): string;
  118626. /**
  118627. * Makes a duplicate of the current material.
  118628. * @param name - name to use for the new material.
  118629. */
  118630. clone(name: string): PBRMetallicRoughnessMaterial;
  118631. /**
  118632. * Serialize the material to a parsable JSON object.
  118633. */
  118634. serialize(): any;
  118635. /**
  118636. * Parses a JSON object correponding to the serialize function.
  118637. */
  118638. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * The PBR material of BJS following the specular glossiness convention.
  118644. *
  118645. * This fits to the PBR convention in the GLTF definition:
  118646. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118647. */
  118648. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118649. /**
  118650. * Specifies the diffuse color of the material.
  118651. */
  118652. diffuseColor: Color3;
  118653. /**
  118654. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118655. * channel.
  118656. */
  118657. diffuseTexture: BaseTexture;
  118658. /**
  118659. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118660. */
  118661. specularColor: Color3;
  118662. /**
  118663. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118664. */
  118665. glossiness: number;
  118666. /**
  118667. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118668. */
  118669. specularGlossinessTexture: BaseTexture;
  118670. /**
  118671. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118672. *
  118673. * @param name The material name
  118674. * @param scene The scene the material will be use in.
  118675. */
  118676. constructor(name: string, scene: Scene);
  118677. /**
  118678. * Return the currrent class name of the material.
  118679. */
  118680. getClassName(): string;
  118681. /**
  118682. * Makes a duplicate of the current material.
  118683. * @param name - name to use for the new material.
  118684. */
  118685. clone(name: string): PBRSpecularGlossinessMaterial;
  118686. /**
  118687. * Serialize the material to a parsable JSON object.
  118688. */
  118689. serialize(): any;
  118690. /**
  118691. * Parses a JSON object correponding to the serialize function.
  118692. */
  118693. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118694. }
  118695. }
  118696. declare module BABYLON {
  118697. /**
  118698. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118699. * It can help converting any input color in a desired output one. This can then be used to create effects
  118700. * from sepia, black and white to sixties or futuristic rendering...
  118701. *
  118702. * The only supported format is currently 3dl.
  118703. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118704. */
  118705. export class ColorGradingTexture extends BaseTexture {
  118706. /**
  118707. * The current texture matrix. (will always be identity in color grading texture)
  118708. */
  118709. private _textureMatrix;
  118710. /**
  118711. * The texture URL.
  118712. */
  118713. url: string;
  118714. /**
  118715. * Empty line regex stored for GC.
  118716. */
  118717. private static _noneEmptyLineRegex;
  118718. private _engine;
  118719. /**
  118720. * Instantiates a ColorGradingTexture from the following parameters.
  118721. *
  118722. * @param url The location of the color gradind data (currently only supporting 3dl)
  118723. * @param scene The scene the texture will be used in
  118724. */
  118725. constructor(url: string, scene: Scene);
  118726. /**
  118727. * Returns the texture matrix used in most of the material.
  118728. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118729. */
  118730. getTextureMatrix(): Matrix;
  118731. /**
  118732. * Occurs when the file being loaded is a .3dl LUT file.
  118733. */
  118734. private load3dlTexture;
  118735. /**
  118736. * Starts the loading process of the texture.
  118737. */
  118738. private loadTexture;
  118739. /**
  118740. * Clones the color gradind texture.
  118741. */
  118742. clone(): ColorGradingTexture;
  118743. /**
  118744. * Called during delayed load for textures.
  118745. */
  118746. delayLoad(): void;
  118747. /**
  118748. * Parses a color grading texture serialized by Babylon.
  118749. * @param parsedTexture The texture information being parsedTexture
  118750. * @param scene The scene to load the texture in
  118751. * @param rootUrl The root url of the data assets to load
  118752. * @return A color gradind texture
  118753. */
  118754. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118755. /**
  118756. * Serializes the LUT texture to json format.
  118757. */
  118758. serialize(): any;
  118759. }
  118760. }
  118761. declare module BABYLON {
  118762. /**
  118763. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118764. */
  118765. export class EquiRectangularCubeTexture extends BaseTexture {
  118766. /** The six faces of the cube. */
  118767. private static _FacesMapping;
  118768. private _noMipmap;
  118769. private _onLoad;
  118770. private _onError;
  118771. /** The size of the cubemap. */
  118772. private _size;
  118773. /** The buffer of the image. */
  118774. private _buffer;
  118775. /** The width of the input image. */
  118776. private _width;
  118777. /** The height of the input image. */
  118778. private _height;
  118779. /** The URL to the image. */
  118780. url: string;
  118781. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118782. coordinatesMode: number;
  118783. /**
  118784. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118785. * @param url The location of the image
  118786. * @param scene The scene the texture will be used in
  118787. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118788. * @param noMipmap Forces to not generate the mipmap if true
  118789. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118790. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118791. * @param onLoad — defines a callback called when texture is loaded
  118792. * @param onError — defines a callback called if there is an error
  118793. */
  118794. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118795. /**
  118796. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118797. */
  118798. private loadImage;
  118799. /**
  118800. * Convert the image buffer into a cubemap and create a CubeTexture.
  118801. */
  118802. private loadTexture;
  118803. /**
  118804. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118805. * @param buffer The ArrayBuffer that should be converted.
  118806. * @returns The buffer as Float32Array.
  118807. */
  118808. private getFloat32ArrayFromArrayBuffer;
  118809. /**
  118810. * Get the current class name of the texture useful for serialization or dynamic coding.
  118811. * @returns "EquiRectangularCubeTexture"
  118812. */
  118813. getClassName(): string;
  118814. /**
  118815. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118816. * @returns A clone of the current EquiRectangularCubeTexture.
  118817. */
  118818. clone(): EquiRectangularCubeTexture;
  118819. }
  118820. }
  118821. declare module BABYLON {
  118822. /**
  118823. * Based on jsTGALoader - Javascript loader for TGA file
  118824. * By Vincent Thibault
  118825. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118826. */
  118827. export class TGATools {
  118828. private static _TYPE_INDEXED;
  118829. private static _TYPE_RGB;
  118830. private static _TYPE_GREY;
  118831. private static _TYPE_RLE_INDEXED;
  118832. private static _TYPE_RLE_RGB;
  118833. private static _TYPE_RLE_GREY;
  118834. private static _ORIGIN_MASK;
  118835. private static _ORIGIN_SHIFT;
  118836. private static _ORIGIN_BL;
  118837. private static _ORIGIN_BR;
  118838. private static _ORIGIN_UL;
  118839. private static _ORIGIN_UR;
  118840. /**
  118841. * Gets the header of a TGA file
  118842. * @param data defines the TGA data
  118843. * @returns the header
  118844. */
  118845. static GetTGAHeader(data: Uint8Array): any;
  118846. /**
  118847. * Uploads TGA content to a Babylon Texture
  118848. * @hidden
  118849. */
  118850. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118851. /** @hidden */
  118852. 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;
  118853. /** @hidden */
  118854. 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;
  118855. /** @hidden */
  118856. 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;
  118857. /** @hidden */
  118858. 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;
  118859. /** @hidden */
  118860. 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;
  118861. /** @hidden */
  118862. 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;
  118863. }
  118864. }
  118865. declare module BABYLON {
  118866. /**
  118867. * Implementation of the TGA Texture Loader.
  118868. * @hidden
  118869. */
  118870. export class _TGATextureLoader implements IInternalTextureLoader {
  118871. /**
  118872. * Defines wether the loader supports cascade loading the different faces.
  118873. */
  118874. readonly supportCascades: boolean;
  118875. /**
  118876. * This returns if the loader support the current file information.
  118877. * @param extension defines the file extension of the file being loaded
  118878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118879. * @param fallback defines the fallback internal texture if any
  118880. * @param isBase64 defines whether the texture is encoded as a base64
  118881. * @param isBuffer defines whether the texture data are stored as a buffer
  118882. * @returns true if the loader can load the specified file
  118883. */
  118884. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118885. /**
  118886. * Transform the url before loading if required.
  118887. * @param rootUrl the url of the texture
  118888. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118889. * @returns the transformed texture
  118890. */
  118891. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118892. /**
  118893. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118894. * @param rootUrl the url of the texture
  118895. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118896. * @returns the fallback texture
  118897. */
  118898. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118899. /**
  118900. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118901. * @param data contains the texture data
  118902. * @param texture defines the BabylonJS internal texture
  118903. * @param createPolynomials will be true if polynomials have been requested
  118904. * @param onLoad defines the callback to trigger once the texture is ready
  118905. * @param onError defines the callback to trigger in case of error
  118906. */
  118907. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118908. /**
  118909. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118910. * @param data contains the texture data
  118911. * @param texture defines the BabylonJS internal texture
  118912. * @param callback defines the method to call once ready to upload
  118913. */
  118914. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118915. }
  118916. }
  118917. declare module BABYLON {
  118918. /**
  118919. * Info about the .basis files
  118920. */
  118921. class BasisFileInfo {
  118922. /**
  118923. * If the file has alpha
  118924. */
  118925. hasAlpha: boolean;
  118926. /**
  118927. * Info about each image of the basis file
  118928. */
  118929. images: Array<{
  118930. levels: Array<{
  118931. width: number;
  118932. height: number;
  118933. transcodedPixels: ArrayBufferView;
  118934. }>;
  118935. }>;
  118936. }
  118937. /**
  118938. * Result of transcoding a basis file
  118939. */
  118940. class TranscodeResult {
  118941. /**
  118942. * Info about the .basis file
  118943. */
  118944. fileInfo: BasisFileInfo;
  118945. /**
  118946. * Format to use when loading the file
  118947. */
  118948. format: number;
  118949. }
  118950. /**
  118951. * Configuration options for the Basis transcoder
  118952. */
  118953. export class BasisTranscodeConfiguration {
  118954. /**
  118955. * Supported compression formats used to determine the supported output format of the transcoder
  118956. */
  118957. supportedCompressionFormats?: {
  118958. /**
  118959. * etc1 compression format
  118960. */
  118961. etc1?: boolean;
  118962. /**
  118963. * s3tc compression format
  118964. */
  118965. s3tc?: boolean;
  118966. /**
  118967. * pvrtc compression format
  118968. */
  118969. pvrtc?: boolean;
  118970. /**
  118971. * etc2 compression format
  118972. */
  118973. etc2?: boolean;
  118974. };
  118975. /**
  118976. * If mipmap levels should be loaded for transcoded images (Default: true)
  118977. */
  118978. loadMipmapLevels?: boolean;
  118979. /**
  118980. * Index of a single image to load (Default: all images)
  118981. */
  118982. loadSingleImage?: number;
  118983. }
  118984. /**
  118985. * Used to load .Basis files
  118986. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118987. */
  118988. export class BasisTools {
  118989. private static _IgnoreSupportedFormats;
  118990. /**
  118991. * URL to use when loading the basis transcoder
  118992. */
  118993. static JSModuleURL: string;
  118994. /**
  118995. * URL to use when loading the wasm module for the transcoder
  118996. */
  118997. static WasmModuleURL: string;
  118998. /**
  118999. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119000. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119001. * @returns internal format corresponding to the Basis format
  119002. */
  119003. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119004. private static _WorkerPromise;
  119005. private static _Worker;
  119006. private static _actionId;
  119007. private static _CreateWorkerAsync;
  119008. /**
  119009. * Transcodes a loaded image file to compressed pixel data
  119010. * @param imageData image data to transcode
  119011. * @param config configuration options for the transcoding
  119012. * @returns a promise resulting in the transcoded image
  119013. */
  119014. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119015. /**
  119016. * Loads a texture from the transcode result
  119017. * @param texture texture load to
  119018. * @param transcodeResult the result of transcoding the basis file to load from
  119019. */
  119020. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119021. }
  119022. }
  119023. declare module BABYLON {
  119024. /**
  119025. * Loader for .basis file format
  119026. */
  119027. export class _BasisTextureLoader implements IInternalTextureLoader {
  119028. /**
  119029. * Defines whether the loader supports cascade loading the different faces.
  119030. */
  119031. readonly supportCascades: boolean;
  119032. /**
  119033. * This returns if the loader support the current file information.
  119034. * @param extension defines the file extension of the file being loaded
  119035. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119036. * @param fallback defines the fallback internal texture if any
  119037. * @param isBase64 defines whether the texture is encoded as a base64
  119038. * @param isBuffer defines whether the texture data are stored as a buffer
  119039. * @returns true if the loader can load the specified file
  119040. */
  119041. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119042. /**
  119043. * Transform the url before loading if required.
  119044. * @param rootUrl the url of the texture
  119045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119046. * @returns the transformed texture
  119047. */
  119048. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119049. /**
  119050. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119051. * @param rootUrl the url of the texture
  119052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119053. * @returns the fallback texture
  119054. */
  119055. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119056. /**
  119057. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119058. * @param data contains the texture data
  119059. * @param texture defines the BabylonJS internal texture
  119060. * @param createPolynomials will be true if polynomials have been requested
  119061. * @param onLoad defines the callback to trigger once the texture is ready
  119062. * @param onError defines the callback to trigger in case of error
  119063. */
  119064. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119065. /**
  119066. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119067. * @param data contains the texture data
  119068. * @param texture defines the BabylonJS internal texture
  119069. * @param callback defines the method to call once ready to upload
  119070. */
  119071. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. /**
  119076. * 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.
  119077. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119078. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119079. */
  119080. export class CustomProceduralTexture extends ProceduralTexture {
  119081. private _animate;
  119082. private _time;
  119083. private _config;
  119084. private _texturePath;
  119085. /**
  119086. * Instantiates a new Custom Procedural Texture.
  119087. * 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.
  119088. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119089. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119090. * @param name Define the name of the texture
  119091. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119092. * @param size Define the size of the texture to create
  119093. * @param scene Define the scene the texture belongs to
  119094. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119095. * @param generateMipMaps Define if the texture should creates mip maps or not
  119096. */
  119097. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119098. private _loadJson;
  119099. /**
  119100. * Is the texture ready to be used ? (rendered at least once)
  119101. * @returns true if ready, otherwise, false.
  119102. */
  119103. isReady(): boolean;
  119104. /**
  119105. * Render the texture to its associated render target.
  119106. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119107. */
  119108. render(useCameraPostProcess?: boolean): void;
  119109. /**
  119110. * Update the list of dependant textures samplers in the shader.
  119111. */
  119112. updateTextures(): void;
  119113. /**
  119114. * Update the uniform values of the procedural texture in the shader.
  119115. */
  119116. updateShaderUniforms(): void;
  119117. /**
  119118. * Define if the texture animates or not.
  119119. */
  119120. animate: boolean;
  119121. }
  119122. }
  119123. declare module BABYLON {
  119124. /** @hidden */
  119125. export var noisePixelShader: {
  119126. name: string;
  119127. shader: string;
  119128. };
  119129. }
  119130. declare module BABYLON {
  119131. /**
  119132. * Class used to generate noise procedural textures
  119133. */
  119134. export class NoiseProceduralTexture extends ProceduralTexture {
  119135. private _time;
  119136. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119137. brightness: number;
  119138. /** Defines the number of octaves to process */
  119139. octaves: number;
  119140. /** Defines the level of persistence (0.8 by default) */
  119141. persistence: number;
  119142. /** Gets or sets animation speed factor (default is 1) */
  119143. animationSpeedFactor: number;
  119144. /**
  119145. * Creates a new NoiseProceduralTexture
  119146. * @param name defines the name fo the texture
  119147. * @param size defines the size of the texture (default is 256)
  119148. * @param scene defines the hosting scene
  119149. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119150. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119151. */
  119152. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119153. private _updateShaderUniforms;
  119154. protected _getDefines(): string;
  119155. /** Generate the current state of the procedural texture */
  119156. render(useCameraPostProcess?: boolean): void;
  119157. /**
  119158. * Serializes this noise procedural texture
  119159. * @returns a serialized noise procedural texture object
  119160. */
  119161. serialize(): any;
  119162. /**
  119163. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119164. * @param parsedTexture defines parsed texture data
  119165. * @param scene defines the current scene
  119166. * @param rootUrl defines the root URL containing noise procedural texture information
  119167. * @returns a parsed NoiseProceduralTexture
  119168. */
  119169. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119170. }
  119171. }
  119172. declare module BABYLON {
  119173. /**
  119174. * Raw cube texture where the raw buffers are passed in
  119175. */
  119176. export class RawCubeTexture extends CubeTexture {
  119177. /**
  119178. * Creates a cube texture where the raw buffers are passed in.
  119179. * @param scene defines the scene the texture is attached to
  119180. * @param data defines the array of data to use to create each face
  119181. * @param size defines the size of the textures
  119182. * @param format defines the format of the data
  119183. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119184. * @param generateMipMaps defines if the engine should generate the mip levels
  119185. * @param invertY defines if data must be stored with Y axis inverted
  119186. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119187. * @param compression defines the compression used (null by default)
  119188. */
  119189. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119190. /**
  119191. * Updates the raw cube texture.
  119192. * @param data defines the data to store
  119193. * @param format defines the data format
  119194. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119195. * @param invertY defines if data must be stored with Y axis inverted
  119196. * @param compression defines the compression used (null by default)
  119197. * @param level defines which level of the texture to update
  119198. */
  119199. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119200. /**
  119201. * Updates a raw cube texture with RGBD encoded data.
  119202. * @param data defines the array of data [mipmap][face] to use to create each face
  119203. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119204. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119205. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119206. * @returns a promsie that resolves when the operation is complete
  119207. */
  119208. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119209. /**
  119210. * Clones the raw cube texture.
  119211. * @return a new cube texture
  119212. */
  119213. clone(): CubeTexture;
  119214. /** @hidden */
  119215. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119216. }
  119217. }
  119218. declare module BABYLON {
  119219. /**
  119220. * Class used to store 3D textures containing user data
  119221. */
  119222. export class RawTexture3D extends Texture {
  119223. /** Gets or sets the texture format to use */
  119224. format: number;
  119225. private _engine;
  119226. /**
  119227. * Create a new RawTexture3D
  119228. * @param data defines the data of the texture
  119229. * @param width defines the width of the texture
  119230. * @param height defines the height of the texture
  119231. * @param depth defines the depth of the texture
  119232. * @param format defines the texture format to use
  119233. * @param scene defines the hosting scene
  119234. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119235. * @param invertY defines if texture must be stored with Y axis inverted
  119236. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119237. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119238. */
  119239. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119240. /** Gets or sets the texture format to use */
  119241. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119242. /**
  119243. * Update the texture with new data
  119244. * @param data defines the data to store in the texture
  119245. */
  119246. update(data: ArrayBufferView): void;
  119247. }
  119248. }
  119249. declare module BABYLON {
  119250. /**
  119251. * Creates a refraction texture used by refraction channel of the standard material.
  119252. * It is like a mirror but to see through a material.
  119253. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119254. */
  119255. export class RefractionTexture extends RenderTargetTexture {
  119256. /**
  119257. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119258. * 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.
  119259. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119260. */
  119261. refractionPlane: Plane;
  119262. /**
  119263. * Define how deep under the surface we should see.
  119264. */
  119265. depth: number;
  119266. /**
  119267. * Creates a refraction texture used by refraction channel of the standard material.
  119268. * It is like a mirror but to see through a material.
  119269. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119270. * @param name Define the texture name
  119271. * @param size Define the size of the underlying texture
  119272. * @param scene Define the scene the refraction belongs to
  119273. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119274. */
  119275. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119276. /**
  119277. * Clone the refraction texture.
  119278. * @returns the cloned texture
  119279. */
  119280. clone(): RefractionTexture;
  119281. /**
  119282. * Serialize the texture to a JSON representation you could use in Parse later on
  119283. * @returns the serialized JSON representation
  119284. */
  119285. serialize(): any;
  119286. }
  119287. }
  119288. declare module BABYLON {
  119289. /**
  119290. * Defines the options related to the creation of an HtmlElementTexture
  119291. */
  119292. export interface IHtmlElementTextureOptions {
  119293. /**
  119294. * Defines wether mip maps should be created or not.
  119295. */
  119296. generateMipMaps?: boolean;
  119297. /**
  119298. * Defines the sampling mode of the texture.
  119299. */
  119300. samplingMode?: number;
  119301. /**
  119302. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119303. */
  119304. engine: Nullable<ThinEngine>;
  119305. /**
  119306. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119307. */
  119308. scene: Nullable<Scene>;
  119309. }
  119310. /**
  119311. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119312. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119313. * is automatically managed.
  119314. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119315. * in your application.
  119316. *
  119317. * As the update is not automatic, you need to call them manually.
  119318. */
  119319. export class HtmlElementTexture extends BaseTexture {
  119320. /**
  119321. * The texture URL.
  119322. */
  119323. element: HTMLVideoElement | HTMLCanvasElement;
  119324. private static readonly DefaultOptions;
  119325. private _textureMatrix;
  119326. private _engine;
  119327. private _isVideo;
  119328. private _generateMipMaps;
  119329. private _samplingMode;
  119330. /**
  119331. * Instantiates a HtmlElementTexture from the following parameters.
  119332. *
  119333. * @param name Defines the name of the texture
  119334. * @param element Defines the video or canvas the texture is filled with
  119335. * @param options Defines the other none mandatory texture creation options
  119336. */
  119337. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119338. private _createInternalTexture;
  119339. /**
  119340. * Returns the texture matrix used in most of the material.
  119341. */
  119342. getTextureMatrix(): Matrix;
  119343. /**
  119344. * Updates the content of the texture.
  119345. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119346. */
  119347. update(invertY?: Nullable<boolean>): void;
  119348. }
  119349. }
  119350. declare module BABYLON {
  119351. /**
  119352. * Enum used to define the target of a block
  119353. */
  119354. export enum NodeMaterialBlockTargets {
  119355. /** Vertex shader */
  119356. Vertex = 1,
  119357. /** Fragment shader */
  119358. Fragment = 2,
  119359. /** Neutral */
  119360. Neutral = 4,
  119361. /** Vertex and Fragment */
  119362. VertexAndFragment = 3
  119363. }
  119364. }
  119365. declare module BABYLON {
  119366. /**
  119367. * Defines the kind of connection point for node based material
  119368. */
  119369. export enum NodeMaterialBlockConnectionPointTypes {
  119370. /** Float */
  119371. Float = 1,
  119372. /** Int */
  119373. Int = 2,
  119374. /** Vector2 */
  119375. Vector2 = 4,
  119376. /** Vector3 */
  119377. Vector3 = 8,
  119378. /** Vector4 */
  119379. Vector4 = 16,
  119380. /** Color3 */
  119381. Color3 = 32,
  119382. /** Color4 */
  119383. Color4 = 64,
  119384. /** Matrix */
  119385. Matrix = 128,
  119386. /** Detect type based on connection */
  119387. AutoDetect = 1024,
  119388. /** Output type that will be defined by input type */
  119389. BasedOnInput = 2048
  119390. }
  119391. }
  119392. declare module BABYLON {
  119393. /**
  119394. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119395. */
  119396. export enum NodeMaterialBlockConnectionPointMode {
  119397. /** Value is an uniform */
  119398. Uniform = 0,
  119399. /** Value is a mesh attribute */
  119400. Attribute = 1,
  119401. /** Value is a varying between vertex and fragment shaders */
  119402. Varying = 2,
  119403. /** Mode is undefined */
  119404. Undefined = 3
  119405. }
  119406. }
  119407. declare module BABYLON {
  119408. /**
  119409. * Enum used to define system values e.g. values automatically provided by the system
  119410. */
  119411. export enum NodeMaterialSystemValues {
  119412. /** World */
  119413. World = 1,
  119414. /** View */
  119415. View = 2,
  119416. /** Projection */
  119417. Projection = 3,
  119418. /** ViewProjection */
  119419. ViewProjection = 4,
  119420. /** WorldView */
  119421. WorldView = 5,
  119422. /** WorldViewProjection */
  119423. WorldViewProjection = 6,
  119424. /** CameraPosition */
  119425. CameraPosition = 7,
  119426. /** Fog Color */
  119427. FogColor = 8,
  119428. /** Delta time */
  119429. DeltaTime = 9
  119430. }
  119431. }
  119432. declare module BABYLON {
  119433. /**
  119434. * Root class for all node material optimizers
  119435. */
  119436. export class NodeMaterialOptimizer {
  119437. /**
  119438. * Function used to optimize a NodeMaterial graph
  119439. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119440. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119441. */
  119442. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119443. }
  119444. }
  119445. declare module BABYLON {
  119446. /**
  119447. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119448. */
  119449. export class TransformBlock extends NodeMaterialBlock {
  119450. /**
  119451. * Defines the value to use to complement W value to transform it to a Vector4
  119452. */
  119453. complementW: number;
  119454. /**
  119455. * Defines the value to use to complement z value to transform it to a Vector4
  119456. */
  119457. complementZ: number;
  119458. /**
  119459. * Creates a new TransformBlock
  119460. * @param name defines the block name
  119461. */
  119462. constructor(name: string);
  119463. /**
  119464. * Gets the current class name
  119465. * @returns the class name
  119466. */
  119467. getClassName(): string;
  119468. /**
  119469. * Gets the vector input
  119470. */
  119471. readonly vector: NodeMaterialConnectionPoint;
  119472. /**
  119473. * Gets the output component
  119474. */
  119475. readonly output: NodeMaterialConnectionPoint;
  119476. /**
  119477. * Gets the matrix transform input
  119478. */
  119479. readonly transform: NodeMaterialConnectionPoint;
  119480. protected _buildBlock(state: NodeMaterialBuildState): this;
  119481. serialize(): any;
  119482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119483. protected _dumpPropertiesCode(): string;
  119484. }
  119485. }
  119486. declare module BABYLON {
  119487. /**
  119488. * Block used to output the vertex position
  119489. */
  119490. export class VertexOutputBlock extends NodeMaterialBlock {
  119491. /**
  119492. * Creates a new VertexOutputBlock
  119493. * @param name defines the block name
  119494. */
  119495. constructor(name: string);
  119496. /**
  119497. * Gets the current class name
  119498. * @returns the class name
  119499. */
  119500. getClassName(): string;
  119501. /**
  119502. * Gets the vector input component
  119503. */
  119504. readonly vector: NodeMaterialConnectionPoint;
  119505. protected _buildBlock(state: NodeMaterialBuildState): this;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * Block used to output the final color
  119511. */
  119512. export class FragmentOutputBlock extends NodeMaterialBlock {
  119513. /**
  119514. * Create a new FragmentOutputBlock
  119515. * @param name defines the block name
  119516. */
  119517. constructor(name: string);
  119518. /**
  119519. * Gets the current class name
  119520. * @returns the class name
  119521. */
  119522. getClassName(): string;
  119523. /**
  119524. * Gets the rgba input component
  119525. */
  119526. readonly rgba: NodeMaterialConnectionPoint;
  119527. /**
  119528. * Gets the rgb input component
  119529. */
  119530. readonly rgb: NodeMaterialConnectionPoint;
  119531. /**
  119532. * Gets the a input component
  119533. */
  119534. readonly a: NodeMaterialConnectionPoint;
  119535. protected _buildBlock(state: NodeMaterialBuildState): this;
  119536. }
  119537. }
  119538. declare module BABYLON {
  119539. /**
  119540. * Block used to read a reflection texture from a sampler
  119541. */
  119542. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119543. private _define3DName;
  119544. private _defineCubicName;
  119545. private _defineExplicitName;
  119546. private _defineProjectionName;
  119547. private _defineLocalCubicName;
  119548. private _defineSphericalName;
  119549. private _definePlanarName;
  119550. private _defineEquirectangularName;
  119551. private _defineMirroredEquirectangularFixedName;
  119552. private _defineEquirectangularFixedName;
  119553. private _defineSkyboxName;
  119554. private _cubeSamplerName;
  119555. private _2DSamplerName;
  119556. private _positionUVWName;
  119557. private _directionWName;
  119558. private _reflectionCoordsName;
  119559. private _reflection2DCoordsName;
  119560. private _reflectionColorName;
  119561. private _reflectionMatrixName;
  119562. /**
  119563. * Gets or sets the texture associated with the node
  119564. */
  119565. texture: Nullable<BaseTexture>;
  119566. /**
  119567. * Create a new TextureBlock
  119568. * @param name defines the block name
  119569. */
  119570. constructor(name: string);
  119571. /**
  119572. * Gets the current class name
  119573. * @returns the class name
  119574. */
  119575. getClassName(): string;
  119576. /**
  119577. * Gets the world position input component
  119578. */
  119579. readonly position: NodeMaterialConnectionPoint;
  119580. /**
  119581. * Gets the world position input component
  119582. */
  119583. readonly worldPosition: NodeMaterialConnectionPoint;
  119584. /**
  119585. * Gets the world normal input component
  119586. */
  119587. readonly worldNormal: NodeMaterialConnectionPoint;
  119588. /**
  119589. * Gets the world input component
  119590. */
  119591. readonly world: NodeMaterialConnectionPoint;
  119592. /**
  119593. * Gets the camera (or eye) position component
  119594. */
  119595. readonly cameraPosition: NodeMaterialConnectionPoint;
  119596. /**
  119597. * Gets the view input component
  119598. */
  119599. readonly view: NodeMaterialConnectionPoint;
  119600. /**
  119601. * Gets the rgb output component
  119602. */
  119603. readonly rgb: NodeMaterialConnectionPoint;
  119604. /**
  119605. * Gets the r output component
  119606. */
  119607. readonly r: NodeMaterialConnectionPoint;
  119608. /**
  119609. * Gets the g output component
  119610. */
  119611. readonly g: NodeMaterialConnectionPoint;
  119612. /**
  119613. * Gets the b output component
  119614. */
  119615. readonly b: NodeMaterialConnectionPoint;
  119616. autoConfigure(material: NodeMaterial): void;
  119617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119618. isReady(): boolean;
  119619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119620. private _injectVertexCode;
  119621. private _writeOutput;
  119622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119623. serialize(): any;
  119624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119625. }
  119626. }
  119627. declare module BABYLON {
  119628. /**
  119629. * Interface used to configure the node material editor
  119630. */
  119631. export interface INodeMaterialEditorOptions {
  119632. /** Define the URl to load node editor script */
  119633. editorURL?: string;
  119634. }
  119635. /** @hidden */
  119636. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119637. /** BONES */
  119638. NUM_BONE_INFLUENCERS: number;
  119639. BonesPerMesh: number;
  119640. BONETEXTURE: boolean;
  119641. /** MORPH TARGETS */
  119642. MORPHTARGETS: boolean;
  119643. MORPHTARGETS_NORMAL: boolean;
  119644. MORPHTARGETS_TANGENT: boolean;
  119645. MORPHTARGETS_UV: boolean;
  119646. NUM_MORPH_INFLUENCERS: number;
  119647. /** IMAGE PROCESSING */
  119648. IMAGEPROCESSING: boolean;
  119649. VIGNETTE: boolean;
  119650. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119651. VIGNETTEBLENDMODEOPAQUE: boolean;
  119652. TONEMAPPING: boolean;
  119653. TONEMAPPING_ACES: boolean;
  119654. CONTRAST: boolean;
  119655. EXPOSURE: boolean;
  119656. COLORCURVES: boolean;
  119657. COLORGRADING: boolean;
  119658. COLORGRADING3D: boolean;
  119659. SAMPLER3DGREENDEPTH: boolean;
  119660. SAMPLER3DBGRMAP: boolean;
  119661. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119662. /** MISC. */
  119663. BUMPDIRECTUV: number;
  119664. constructor();
  119665. setValue(name: string, value: boolean): void;
  119666. }
  119667. /**
  119668. * Class used to configure NodeMaterial
  119669. */
  119670. export interface INodeMaterialOptions {
  119671. /**
  119672. * Defines if blocks should emit comments
  119673. */
  119674. emitComments: boolean;
  119675. }
  119676. /**
  119677. * Class used to create a node based material built by assembling shader blocks
  119678. */
  119679. export class NodeMaterial extends PushMaterial {
  119680. private static _BuildIdGenerator;
  119681. private _options;
  119682. private _vertexCompilationState;
  119683. private _fragmentCompilationState;
  119684. private _sharedData;
  119685. private _buildId;
  119686. private _buildWasSuccessful;
  119687. private _cachedWorldViewMatrix;
  119688. private _cachedWorldViewProjectionMatrix;
  119689. private _optimizers;
  119690. private _animationFrame;
  119691. /** Define the URl to load node editor script */
  119692. static EditorURL: string;
  119693. private BJSNODEMATERIALEDITOR;
  119694. /** Get the inspector from bundle or global */
  119695. private _getGlobalNodeMaterialEditor;
  119696. /**
  119697. * 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)
  119698. */
  119699. ignoreAlpha: boolean;
  119700. /**
  119701. * Defines the maximum number of lights that can be used in the material
  119702. */
  119703. maxSimultaneousLights: number;
  119704. /**
  119705. * Observable raised when the material is built
  119706. */
  119707. onBuildObservable: Observable<NodeMaterial>;
  119708. /**
  119709. * Gets or sets the root nodes of the material vertex shader
  119710. */
  119711. _vertexOutputNodes: NodeMaterialBlock[];
  119712. /**
  119713. * Gets or sets the root nodes of the material fragment (pixel) shader
  119714. */
  119715. _fragmentOutputNodes: NodeMaterialBlock[];
  119716. /** Gets or sets options to control the node material overall behavior */
  119717. options: INodeMaterialOptions;
  119718. /**
  119719. * Default configuration related to image processing available in the standard Material.
  119720. */
  119721. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119722. /**
  119723. * Gets the image processing configuration used either in this material.
  119724. */
  119725. /**
  119726. * Sets the Default image processing configuration used either in the this material.
  119727. *
  119728. * If sets to null, the scene one is in use.
  119729. */
  119730. imageProcessingConfiguration: ImageProcessingConfiguration;
  119731. /**
  119732. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119733. */
  119734. attachedBlocks: NodeMaterialBlock[];
  119735. /**
  119736. * Create a new node based material
  119737. * @param name defines the material name
  119738. * @param scene defines the hosting scene
  119739. * @param options defines creation option
  119740. */
  119741. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119742. /**
  119743. * Gets the current class name of the material e.g. "NodeMaterial"
  119744. * @returns the class name
  119745. */
  119746. getClassName(): string;
  119747. /**
  119748. * Keep track of the image processing observer to allow dispose and replace.
  119749. */
  119750. private _imageProcessingObserver;
  119751. /**
  119752. * Attaches a new image processing configuration to the Standard Material.
  119753. * @param configuration
  119754. */
  119755. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119756. /**
  119757. * Get a block by its name
  119758. * @param name defines the name of the block to retrieve
  119759. * @returns the required block or null if not found
  119760. */
  119761. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119762. /**
  119763. * Get a block by its name
  119764. * @param predicate defines the predicate used to find the good candidate
  119765. * @returns the required block or null if not found
  119766. */
  119767. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119768. /**
  119769. * Get an input block by its name
  119770. * @param predicate defines the predicate used to find the good candidate
  119771. * @returns the required input block or null if not found
  119772. */
  119773. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119774. /**
  119775. * Gets the list of input blocks attached to this material
  119776. * @returns an array of InputBlocks
  119777. */
  119778. getInputBlocks(): InputBlock[];
  119779. /**
  119780. * Adds a new optimizer to the list of optimizers
  119781. * @param optimizer defines the optimizers to add
  119782. * @returns the current material
  119783. */
  119784. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119785. /**
  119786. * Remove an optimizer from the list of optimizers
  119787. * @param optimizer defines the optimizers to remove
  119788. * @returns the current material
  119789. */
  119790. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119791. /**
  119792. * Add a new block to the list of output nodes
  119793. * @param node defines the node to add
  119794. * @returns the current material
  119795. */
  119796. addOutputNode(node: NodeMaterialBlock): this;
  119797. /**
  119798. * Remove a block from the list of root nodes
  119799. * @param node defines the node to remove
  119800. * @returns the current material
  119801. */
  119802. removeOutputNode(node: NodeMaterialBlock): this;
  119803. private _addVertexOutputNode;
  119804. private _removeVertexOutputNode;
  119805. private _addFragmentOutputNode;
  119806. private _removeFragmentOutputNode;
  119807. /**
  119808. * Specifies if the material will require alpha blending
  119809. * @returns a boolean specifying if alpha blending is needed
  119810. */
  119811. needAlphaBlending(): boolean;
  119812. /**
  119813. * Specifies if this material should be rendered in alpha test mode
  119814. * @returns a boolean specifying if an alpha test is needed.
  119815. */
  119816. needAlphaTesting(): boolean;
  119817. private _initializeBlock;
  119818. private _resetDualBlocks;
  119819. /**
  119820. * Build the material and generates the inner effect
  119821. * @param verbose defines if the build should log activity
  119822. */
  119823. build(verbose?: boolean): void;
  119824. /**
  119825. * Runs an otpimization phase to try to improve the shader code
  119826. */
  119827. optimize(): void;
  119828. private _prepareDefinesForAttributes;
  119829. /**
  119830. * Get if the submesh is ready to be used and all its information available.
  119831. * Child classes can use it to update shaders
  119832. * @param mesh defines the mesh to check
  119833. * @param subMesh defines which submesh to check
  119834. * @param useInstances specifies that instances should be used
  119835. * @returns a boolean indicating that the submesh is ready or not
  119836. */
  119837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119838. /**
  119839. * Get a string representing the shaders built by the current node graph
  119840. */
  119841. readonly compiledShaders: string;
  119842. /**
  119843. * Binds the world matrix to the material
  119844. * @param world defines the world transformation matrix
  119845. */
  119846. bindOnlyWorldMatrix(world: Matrix): void;
  119847. /**
  119848. * Binds the submesh to this material by preparing the effect and shader to draw
  119849. * @param world defines the world transformation matrix
  119850. * @param mesh defines the mesh containing the submesh
  119851. * @param subMesh defines the submesh to bind the material to
  119852. */
  119853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119854. /**
  119855. * Gets the active textures from the material
  119856. * @returns an array of textures
  119857. */
  119858. getActiveTextures(): BaseTexture[];
  119859. /**
  119860. * Gets the list of texture blocks
  119861. * @returns an array of texture blocks
  119862. */
  119863. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119864. /**
  119865. * Specifies if the material uses a texture
  119866. * @param texture defines the texture to check against the material
  119867. * @returns a boolean specifying if the material uses the texture
  119868. */
  119869. hasTexture(texture: BaseTexture): boolean;
  119870. /**
  119871. * Disposes the material
  119872. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119873. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119874. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119875. */
  119876. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119877. /** Creates the node editor window. */
  119878. private _createNodeEditor;
  119879. /**
  119880. * Launch the node material editor
  119881. * @param config Define the configuration of the editor
  119882. * @return a promise fulfilled when the node editor is visible
  119883. */
  119884. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119885. /**
  119886. * Clear the current material
  119887. */
  119888. clear(): void;
  119889. /**
  119890. * Clear the current material and set it to a default state
  119891. */
  119892. setToDefault(): void;
  119893. /**
  119894. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119895. * @param url defines the url to load from
  119896. * @returns a promise that will fullfil when the material is fully loaded
  119897. */
  119898. loadAsync(url: string): Promise<unknown>;
  119899. private _gatherBlocks;
  119900. /**
  119901. * Generate a string containing the code declaration required to create an equivalent of this material
  119902. * @returns a string
  119903. */
  119904. generateCode(): string;
  119905. /**
  119906. * Serializes this material in a JSON representation
  119907. * @returns the serialized material object
  119908. */
  119909. serialize(): any;
  119910. private _restoreConnections;
  119911. /**
  119912. * Clear the current graph and load a new one from a serialization object
  119913. * @param source defines the JSON representation of the material
  119914. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119915. */
  119916. loadFromSerialization(source: any, rootUrl?: string): void;
  119917. /**
  119918. * Creates a node material from parsed material data
  119919. * @param source defines the JSON representation of the material
  119920. * @param scene defines the hosting scene
  119921. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119922. * @returns a new node material
  119923. */
  119924. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119925. /**
  119926. * Creates a new node material set to default basic configuration
  119927. * @param name defines the name of the material
  119928. * @param scene defines the hosting scene
  119929. * @returns a new NodeMaterial
  119930. */
  119931. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119932. }
  119933. }
  119934. declare module BABYLON {
  119935. /**
  119936. * Block used to read a texture from a sampler
  119937. */
  119938. export class TextureBlock extends NodeMaterialBlock {
  119939. private _defineName;
  119940. private _linearDefineName;
  119941. private _samplerName;
  119942. private _transformedUVName;
  119943. private _textureTransformName;
  119944. private _textureInfoName;
  119945. private _mainUVName;
  119946. private _mainUVDefineName;
  119947. /**
  119948. * Gets or sets the texture associated with the node
  119949. */
  119950. texture: Nullable<Texture>;
  119951. /**
  119952. * Create a new TextureBlock
  119953. * @param name defines the block name
  119954. */
  119955. constructor(name: string);
  119956. /**
  119957. * Gets the current class name
  119958. * @returns the class name
  119959. */
  119960. getClassName(): string;
  119961. /**
  119962. * Gets the uv input component
  119963. */
  119964. readonly uv: NodeMaterialConnectionPoint;
  119965. /**
  119966. * Gets the rgba output component
  119967. */
  119968. readonly rgba: NodeMaterialConnectionPoint;
  119969. /**
  119970. * Gets the rgb output component
  119971. */
  119972. readonly rgb: NodeMaterialConnectionPoint;
  119973. /**
  119974. * Gets the r output component
  119975. */
  119976. readonly r: NodeMaterialConnectionPoint;
  119977. /**
  119978. * Gets the g output component
  119979. */
  119980. readonly g: NodeMaterialConnectionPoint;
  119981. /**
  119982. * Gets the b output component
  119983. */
  119984. readonly b: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the a output component
  119987. */
  119988. readonly a: NodeMaterialConnectionPoint;
  119989. readonly target: NodeMaterialBlockTargets;
  119990. autoConfigure(material: NodeMaterial): void;
  119991. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119992. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119993. isReady(): boolean;
  119994. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119995. private readonly _isMixed;
  119996. private _injectVertexCode;
  119997. private _writeOutput;
  119998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119999. protected _dumpPropertiesCode(): string;
  120000. serialize(): any;
  120001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120002. }
  120003. }
  120004. declare module BABYLON {
  120005. /**
  120006. * Class used to store shared data between 2 NodeMaterialBuildState
  120007. */
  120008. export class NodeMaterialBuildStateSharedData {
  120009. /**
  120010. * Gets the list of emitted varyings
  120011. */
  120012. temps: string[];
  120013. /**
  120014. * Gets the list of emitted varyings
  120015. */
  120016. varyings: string[];
  120017. /**
  120018. * Gets the varying declaration string
  120019. */
  120020. varyingDeclaration: string;
  120021. /**
  120022. * Input blocks
  120023. */
  120024. inputBlocks: InputBlock[];
  120025. /**
  120026. * Input blocks
  120027. */
  120028. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120029. /**
  120030. * Bindable blocks (Blocks that need to set data to the effect)
  120031. */
  120032. bindableBlocks: NodeMaterialBlock[];
  120033. /**
  120034. * List of blocks that can provide a compilation fallback
  120035. */
  120036. blocksWithFallbacks: NodeMaterialBlock[];
  120037. /**
  120038. * List of blocks that can provide a define update
  120039. */
  120040. blocksWithDefines: NodeMaterialBlock[];
  120041. /**
  120042. * List of blocks that can provide a repeatable content
  120043. */
  120044. repeatableContentBlocks: NodeMaterialBlock[];
  120045. /**
  120046. * List of blocks that can provide a dynamic list of uniforms
  120047. */
  120048. dynamicUniformBlocks: NodeMaterialBlock[];
  120049. /**
  120050. * List of blocks that can block the isReady function for the material
  120051. */
  120052. blockingBlocks: NodeMaterialBlock[];
  120053. /**
  120054. * Gets the list of animated inputs
  120055. */
  120056. animatedInputs: InputBlock[];
  120057. /**
  120058. * Build Id used to avoid multiple recompilations
  120059. */
  120060. buildId: number;
  120061. /** List of emitted variables */
  120062. variableNames: {
  120063. [key: string]: number;
  120064. };
  120065. /** List of emitted defines */
  120066. defineNames: {
  120067. [key: string]: number;
  120068. };
  120069. /** Should emit comments? */
  120070. emitComments: boolean;
  120071. /** Emit build activity */
  120072. verbose: boolean;
  120073. /** Gets or sets the hosting scene */
  120074. scene: Scene;
  120075. /**
  120076. * Gets the compilation hints emitted at compilation time
  120077. */
  120078. hints: {
  120079. needWorldViewMatrix: boolean;
  120080. needWorldViewProjectionMatrix: boolean;
  120081. needAlphaBlending: boolean;
  120082. needAlphaTesting: boolean;
  120083. };
  120084. /**
  120085. * List of compilation checks
  120086. */
  120087. checks: {
  120088. emitVertex: boolean;
  120089. emitFragment: boolean;
  120090. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120091. };
  120092. /** Creates a new shared data */
  120093. constructor();
  120094. /**
  120095. * Emits console errors and exceptions if there is a failing check
  120096. */
  120097. emitErrors(): void;
  120098. }
  120099. }
  120100. declare module BABYLON {
  120101. /**
  120102. * Class used to store node based material build state
  120103. */
  120104. export class NodeMaterialBuildState {
  120105. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120106. supportUniformBuffers: boolean;
  120107. /**
  120108. * Gets the list of emitted attributes
  120109. */
  120110. attributes: string[];
  120111. /**
  120112. * Gets the list of emitted uniforms
  120113. */
  120114. uniforms: string[];
  120115. /**
  120116. * Gets the list of emitted constants
  120117. */
  120118. constants: string[];
  120119. /**
  120120. * Gets the list of emitted uniform buffers
  120121. */
  120122. uniformBuffers: string[];
  120123. /**
  120124. * Gets the list of emitted samplers
  120125. */
  120126. samplers: string[];
  120127. /**
  120128. * Gets the list of emitted functions
  120129. */
  120130. functions: {
  120131. [key: string]: string;
  120132. };
  120133. /**
  120134. * Gets the list of emitted extensions
  120135. */
  120136. extensions: {
  120137. [key: string]: string;
  120138. };
  120139. /**
  120140. * Gets the target of the compilation state
  120141. */
  120142. target: NodeMaterialBlockTargets;
  120143. /**
  120144. * Gets the list of emitted counters
  120145. */
  120146. counters: {
  120147. [key: string]: number;
  120148. };
  120149. /**
  120150. * Shared data between multiple NodeMaterialBuildState instances
  120151. */
  120152. sharedData: NodeMaterialBuildStateSharedData;
  120153. /** @hidden */
  120154. _vertexState: NodeMaterialBuildState;
  120155. /** @hidden */
  120156. _attributeDeclaration: string;
  120157. /** @hidden */
  120158. _uniformDeclaration: string;
  120159. /** @hidden */
  120160. _constantDeclaration: string;
  120161. /** @hidden */
  120162. _samplerDeclaration: string;
  120163. /** @hidden */
  120164. _varyingTransfer: string;
  120165. private _repeatableContentAnchorIndex;
  120166. /** @hidden */
  120167. _builtCompilationString: string;
  120168. /**
  120169. * Gets the emitted compilation strings
  120170. */
  120171. compilationString: string;
  120172. /**
  120173. * Finalize the compilation strings
  120174. * @param state defines the current compilation state
  120175. */
  120176. finalize(state: NodeMaterialBuildState): void;
  120177. /** @hidden */
  120178. readonly _repeatableContentAnchor: string;
  120179. /** @hidden */
  120180. _getFreeVariableName(prefix: string): string;
  120181. /** @hidden */
  120182. _getFreeDefineName(prefix: string): string;
  120183. /** @hidden */
  120184. _excludeVariableName(name: string): void;
  120185. /** @hidden */
  120186. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120187. /** @hidden */
  120188. _emitExtension(name: string, extension: string): void;
  120189. /** @hidden */
  120190. _emitFunction(name: string, code: string, comments: string): void;
  120191. /** @hidden */
  120192. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120193. replaceStrings?: {
  120194. search: RegExp;
  120195. replace: string;
  120196. }[];
  120197. repeatKey?: string;
  120198. }): string;
  120199. /** @hidden */
  120200. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120201. repeatKey?: string;
  120202. removeAttributes?: boolean;
  120203. removeUniforms?: boolean;
  120204. removeVaryings?: boolean;
  120205. removeIfDef?: boolean;
  120206. replaceStrings?: {
  120207. search: RegExp;
  120208. replace: string;
  120209. }[];
  120210. }, storeKey?: string): void;
  120211. /** @hidden */
  120212. _registerTempVariable(name: string): boolean;
  120213. /** @hidden */
  120214. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120215. /** @hidden */
  120216. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120217. /** @hidden */
  120218. _emitFloat(value: number): string;
  120219. }
  120220. }
  120221. declare module BABYLON {
  120222. /**
  120223. * Defines a block that can be used inside a node based material
  120224. */
  120225. export class NodeMaterialBlock {
  120226. private _buildId;
  120227. private _buildTarget;
  120228. private _target;
  120229. private _isFinalMerger;
  120230. private _isInput;
  120231. /** @hidden */
  120232. _codeVariableName: string;
  120233. /** @hidden */
  120234. _inputs: NodeMaterialConnectionPoint[];
  120235. /** @hidden */
  120236. _outputs: NodeMaterialConnectionPoint[];
  120237. /** @hidden */
  120238. _preparationId: number;
  120239. /**
  120240. * Gets or sets the name of the block
  120241. */
  120242. name: string;
  120243. /**
  120244. * Gets or sets the unique id of the node
  120245. */
  120246. uniqueId: number;
  120247. /**
  120248. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120249. */
  120250. readonly isFinalMerger: boolean;
  120251. /**
  120252. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120253. */
  120254. readonly isInput: boolean;
  120255. /**
  120256. * Gets or sets the build Id
  120257. */
  120258. buildId: number;
  120259. /**
  120260. * Gets or sets the target of the block
  120261. */
  120262. target: NodeMaterialBlockTargets;
  120263. /**
  120264. * Gets the list of input points
  120265. */
  120266. readonly inputs: NodeMaterialConnectionPoint[];
  120267. /** Gets the list of output points */
  120268. readonly outputs: NodeMaterialConnectionPoint[];
  120269. /**
  120270. * Find an input by its name
  120271. * @param name defines the name of the input to look for
  120272. * @returns the input or null if not found
  120273. */
  120274. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120275. /**
  120276. * Find an output by its name
  120277. * @param name defines the name of the outputto look for
  120278. * @returns the output or null if not found
  120279. */
  120280. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120281. /**
  120282. * Creates a new NodeMaterialBlock
  120283. * @param name defines the block name
  120284. * @param target defines the target of that block (Vertex by default)
  120285. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120286. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120287. */
  120288. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120289. /**
  120290. * Initialize the block and prepare the context for build
  120291. * @param state defines the state that will be used for the build
  120292. */
  120293. initialize(state: NodeMaterialBuildState): void;
  120294. /**
  120295. * Bind data to effect. Will only be called for blocks with isBindable === true
  120296. * @param effect defines the effect to bind data to
  120297. * @param nodeMaterial defines the hosting NodeMaterial
  120298. * @param mesh defines the mesh that will be rendered
  120299. */
  120300. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120301. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120302. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120303. protected _writeFloat(value: number): string;
  120304. /**
  120305. * Gets the current class name e.g. "NodeMaterialBlock"
  120306. * @returns the class name
  120307. */
  120308. getClassName(): string;
  120309. /**
  120310. * Register a new input. Must be called inside a block constructor
  120311. * @param name defines the connection point name
  120312. * @param type defines the connection point type
  120313. * @param isOptional defines a boolean indicating that this input can be omitted
  120314. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120315. * @returns the current block
  120316. */
  120317. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120318. /**
  120319. * Register a new output. Must be called inside a block constructor
  120320. * @param name defines the connection point name
  120321. * @param type defines the connection point type
  120322. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120323. * @returns the current block
  120324. */
  120325. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120326. /**
  120327. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120328. * @param forOutput defines an optional connection point to check compatibility with
  120329. * @returns the first available input or null
  120330. */
  120331. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120332. /**
  120333. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120334. * @param forBlock defines an optional block to check compatibility with
  120335. * @returns the first available input or null
  120336. */
  120337. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120338. /**
  120339. * Gets the sibling of the given output
  120340. * @param current defines the current output
  120341. * @returns the next output in the list or null
  120342. */
  120343. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120344. /**
  120345. * Connect current block with another block
  120346. * @param other defines the block to connect with
  120347. * @param options define the various options to help pick the right connections
  120348. * @returns the current block
  120349. */
  120350. connectTo(other: NodeMaterialBlock, options?: {
  120351. input?: string;
  120352. output?: string;
  120353. outputSwizzle?: string;
  120354. }): this | undefined;
  120355. protected _buildBlock(state: NodeMaterialBuildState): void;
  120356. /**
  120357. * Add uniforms, samplers and uniform buffers at compilation time
  120358. * @param state defines the state to update
  120359. * @param nodeMaterial defines the node material requesting the update
  120360. * @param defines defines the material defines to update
  120361. */
  120362. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120363. /**
  120364. * Add potential fallbacks if shader compilation fails
  120365. * @param mesh defines the mesh to be rendered
  120366. * @param fallbacks defines the current prioritized list of fallbacks
  120367. */
  120368. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120369. /**
  120370. * Initialize defines for shader compilation
  120371. * @param mesh defines the mesh to be rendered
  120372. * @param nodeMaterial defines the node material requesting the update
  120373. * @param defines defines the material defines to update
  120374. * @param useInstances specifies that instances should be used
  120375. */
  120376. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120377. /**
  120378. * Update defines for shader compilation
  120379. * @param mesh defines the mesh to be rendered
  120380. * @param nodeMaterial defines the node material requesting the update
  120381. * @param defines defines the material defines to update
  120382. * @param useInstances specifies that instances should be used
  120383. */
  120384. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120385. /**
  120386. * Lets the block try to connect some inputs automatically
  120387. * @param material defines the hosting NodeMaterial
  120388. */
  120389. autoConfigure(material: NodeMaterial): void;
  120390. /**
  120391. * Function called when a block is declared as repeatable content generator
  120392. * @param vertexShaderState defines the current compilation state for the vertex shader
  120393. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120394. * @param mesh defines the mesh to be rendered
  120395. * @param defines defines the material defines to update
  120396. */
  120397. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120398. /**
  120399. * Checks if the block is ready
  120400. * @param mesh defines the mesh to be rendered
  120401. * @param nodeMaterial defines the node material requesting the update
  120402. * @param defines defines the material defines to update
  120403. * @param useInstances specifies that instances should be used
  120404. * @returns true if the block is ready
  120405. */
  120406. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120407. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120408. private _processBuild;
  120409. /**
  120410. * Compile the current node and generate the shader code
  120411. * @param state defines the current compilation state (uniforms, samplers, current string)
  120412. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120413. * @returns true if already built
  120414. */
  120415. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120416. protected _inputRename(name: string): string;
  120417. protected _outputRename(name: string): string;
  120418. protected _dumpPropertiesCode(): string;
  120419. /** @hidden */
  120420. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120421. /**
  120422. * Clone the current block to a new identical block
  120423. * @param scene defines the hosting scene
  120424. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120425. * @returns a copy of the current block
  120426. */
  120427. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120428. /**
  120429. * Serializes this block in a JSON representation
  120430. * @returns the serialized block object
  120431. */
  120432. serialize(): any;
  120433. /** @hidden */
  120434. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120435. }
  120436. }
  120437. declare module BABYLON {
  120438. /**
  120439. * Enum defining the type of animations supported by InputBlock
  120440. */
  120441. export enum AnimatedInputBlockTypes {
  120442. /** No animation */
  120443. None = 0,
  120444. /** Time based animation. Will only work for floats */
  120445. Time = 1
  120446. }
  120447. }
  120448. declare module BABYLON {
  120449. /**
  120450. * Block used to expose an input value
  120451. */
  120452. export class InputBlock extends NodeMaterialBlock {
  120453. private _mode;
  120454. private _associatedVariableName;
  120455. private _storedValue;
  120456. private _valueCallback;
  120457. private _type;
  120458. private _animationType;
  120459. /** Gets or set a value used to limit the range of float values */
  120460. min: number;
  120461. /** Gets or set a value used to limit the range of float values */
  120462. max: number;
  120463. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120464. matrixMode: number;
  120465. /** @hidden */
  120466. _systemValue: Nullable<NodeMaterialSystemValues>;
  120467. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120468. visibleInInspector: boolean;
  120469. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120470. isConstant: boolean;
  120471. /**
  120472. * Gets or sets the connection point type (default is float)
  120473. */
  120474. readonly type: NodeMaterialBlockConnectionPointTypes;
  120475. /**
  120476. * Creates a new InputBlock
  120477. * @param name defines the block name
  120478. * @param target defines the target of that block (Vertex by default)
  120479. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120480. */
  120481. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120482. /**
  120483. * Gets the output component
  120484. */
  120485. readonly output: NodeMaterialConnectionPoint;
  120486. /**
  120487. * Set the source of this connection point to a vertex attribute
  120488. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120489. * @returns the current connection point
  120490. */
  120491. setAsAttribute(attributeName?: string): InputBlock;
  120492. /**
  120493. * Set the source of this connection point to a system value
  120494. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120495. * @returns the current connection point
  120496. */
  120497. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120498. /**
  120499. * Gets or sets the value of that point.
  120500. * Please note that this value will be ignored if valueCallback is defined
  120501. */
  120502. value: any;
  120503. /**
  120504. * Gets or sets a callback used to get the value of that point.
  120505. * Please note that setting this value will force the connection point to ignore the value property
  120506. */
  120507. valueCallback: () => any;
  120508. /**
  120509. * Gets or sets the associated variable name in the shader
  120510. */
  120511. associatedVariableName: string;
  120512. /** Gets or sets the type of animation applied to the input */
  120513. animationType: AnimatedInputBlockTypes;
  120514. /**
  120515. * Gets a boolean indicating that this connection point not defined yet
  120516. */
  120517. readonly isUndefined: boolean;
  120518. /**
  120519. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120520. * In this case the connection point name must be the name of the uniform to use.
  120521. * Can only be set on inputs
  120522. */
  120523. isUniform: boolean;
  120524. /**
  120525. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120526. * In this case the connection point name must be the name of the attribute to use
  120527. * Can only be set on inputs
  120528. */
  120529. isAttribute: boolean;
  120530. /**
  120531. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120532. * Can only be set on exit points
  120533. */
  120534. isVarying: boolean;
  120535. /**
  120536. * Gets a boolean indicating that the current connection point is a system value
  120537. */
  120538. readonly isSystemValue: boolean;
  120539. /**
  120540. * Gets or sets the current well known value or null if not defined as a system value
  120541. */
  120542. systemValue: Nullable<NodeMaterialSystemValues>;
  120543. /**
  120544. * Gets the current class name
  120545. * @returns the class name
  120546. */
  120547. getClassName(): string;
  120548. /**
  120549. * Animate the input if animationType !== None
  120550. * @param scene defines the rendering scene
  120551. */
  120552. animate(scene: Scene): void;
  120553. private _emitDefine;
  120554. initialize(state: NodeMaterialBuildState): void;
  120555. /**
  120556. * Set the input block to its default value (based on its type)
  120557. */
  120558. setDefaultValue(): void;
  120559. private _emitConstant;
  120560. private _emit;
  120561. /** @hidden */
  120562. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120563. /** @hidden */
  120564. _transmit(effect: Effect, scene: Scene): void;
  120565. protected _buildBlock(state: NodeMaterialBuildState): void;
  120566. protected _dumpPropertiesCode(): string;
  120567. serialize(): any;
  120568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120569. }
  120570. }
  120571. declare module BABYLON {
  120572. /**
  120573. * Defines a connection point for a block
  120574. */
  120575. export class NodeMaterialConnectionPoint {
  120576. /** @hidden */
  120577. _ownerBlock: NodeMaterialBlock;
  120578. /** @hidden */
  120579. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120580. private _endpoints;
  120581. private _associatedVariableName;
  120582. /** @hidden */
  120583. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120584. /** @hidden */
  120585. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120586. private _type;
  120587. /** @hidden */
  120588. _enforceAssociatedVariableName: boolean;
  120589. /**
  120590. * Gets or sets the additional types supported by this connection point
  120591. */
  120592. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120593. /**
  120594. * Gets or sets the additional types excluded by this connection point
  120595. */
  120596. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120597. /**
  120598. * Gets or sets the associated variable name in the shader
  120599. */
  120600. associatedVariableName: string;
  120601. /**
  120602. * Gets or sets the connection point type (default is float)
  120603. */
  120604. type: NodeMaterialBlockConnectionPointTypes;
  120605. /**
  120606. * Gets or sets the connection point name
  120607. */
  120608. name: string;
  120609. /**
  120610. * Gets or sets a boolean indicating that this connection point can be omitted
  120611. */
  120612. isOptional: boolean;
  120613. /**
  120614. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120615. */
  120616. define: string;
  120617. /** Gets or sets the target of that connection point */
  120618. target: NodeMaterialBlockTargets;
  120619. /**
  120620. * Gets a boolean indicating that the current point is connected
  120621. */
  120622. readonly isConnected: boolean;
  120623. /**
  120624. * Gets a boolean indicating that the current point is connected to an input block
  120625. */
  120626. readonly isConnectedToInputBlock: boolean;
  120627. /**
  120628. * Gets a the connected input block (if any)
  120629. */
  120630. readonly connectInputBlock: Nullable<InputBlock>;
  120631. /** Get the other side of the connection (if any) */
  120632. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120633. /** Get the block that owns this connection point */
  120634. readonly ownerBlock: NodeMaterialBlock;
  120635. /** Get the block connected on the other side of this connection (if any) */
  120636. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120637. /** Get the block connected on the endpoints of this connection (if any) */
  120638. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120639. /** Gets the list of connected endpoints */
  120640. readonly endpoints: NodeMaterialConnectionPoint[];
  120641. /** Gets a boolean indicating if that output point is connected to at least one input */
  120642. readonly hasEndpoints: boolean;
  120643. /**
  120644. * Creates a new connection point
  120645. * @param name defines the connection point name
  120646. * @param ownerBlock defines the block hosting this connection point
  120647. */
  120648. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120649. /**
  120650. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120651. * @returns the class name
  120652. */
  120653. getClassName(): string;
  120654. /**
  120655. * Gets an boolean indicating if the current point can be connected to another point
  120656. * @param connectionPoint defines the other connection point
  120657. * @returns true if the connection is possible
  120658. */
  120659. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120660. /**
  120661. * Connect this point to another connection point
  120662. * @param connectionPoint defines the other connection point
  120663. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120664. * @returns the current connection point
  120665. */
  120666. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120667. /**
  120668. * Disconnect this point from one of his endpoint
  120669. * @param endpoint defines the other connection point
  120670. * @returns the current connection point
  120671. */
  120672. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120673. /**
  120674. * Serializes this point in a JSON representation
  120675. * @returns the serialized point object
  120676. */
  120677. serialize(): any;
  120678. }
  120679. }
  120680. declare module BABYLON {
  120681. /**
  120682. * Block used to add support for vertex skinning (bones)
  120683. */
  120684. export class BonesBlock extends NodeMaterialBlock {
  120685. /**
  120686. * Creates a new BonesBlock
  120687. * @param name defines the block name
  120688. */
  120689. constructor(name: string);
  120690. /**
  120691. * Initialize the block and prepare the context for build
  120692. * @param state defines the state that will be used for the build
  120693. */
  120694. initialize(state: NodeMaterialBuildState): void;
  120695. /**
  120696. * Gets the current class name
  120697. * @returns the class name
  120698. */
  120699. getClassName(): string;
  120700. /**
  120701. * Gets the matrix indices input component
  120702. */
  120703. readonly matricesIndices: NodeMaterialConnectionPoint;
  120704. /**
  120705. * Gets the matrix weights input component
  120706. */
  120707. readonly matricesWeights: NodeMaterialConnectionPoint;
  120708. /**
  120709. * Gets the extra matrix indices input component
  120710. */
  120711. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120712. /**
  120713. * Gets the extra matrix weights input component
  120714. */
  120715. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120716. /**
  120717. * Gets the world input component
  120718. */
  120719. readonly world: NodeMaterialConnectionPoint;
  120720. /**
  120721. * Gets the output component
  120722. */
  120723. readonly output: NodeMaterialConnectionPoint;
  120724. autoConfigure(material: NodeMaterial): void;
  120725. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120726. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120728. protected _buildBlock(state: NodeMaterialBuildState): this;
  120729. }
  120730. }
  120731. declare module BABYLON {
  120732. /**
  120733. * Block used to add support for instances
  120734. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120735. */
  120736. export class InstancesBlock extends NodeMaterialBlock {
  120737. /**
  120738. * Creates a new InstancesBlock
  120739. * @param name defines the block name
  120740. */
  120741. constructor(name: string);
  120742. /**
  120743. * Gets the current class name
  120744. * @returns the class name
  120745. */
  120746. getClassName(): string;
  120747. /**
  120748. * Gets the first world row input component
  120749. */
  120750. readonly world0: NodeMaterialConnectionPoint;
  120751. /**
  120752. * Gets the second world row input component
  120753. */
  120754. readonly world1: NodeMaterialConnectionPoint;
  120755. /**
  120756. * Gets the third world row input component
  120757. */
  120758. readonly world2: NodeMaterialConnectionPoint;
  120759. /**
  120760. * Gets the forth world row input component
  120761. */
  120762. readonly world3: NodeMaterialConnectionPoint;
  120763. /**
  120764. * Gets the world input component
  120765. */
  120766. readonly world: NodeMaterialConnectionPoint;
  120767. /**
  120768. * Gets the output component
  120769. */
  120770. readonly output: NodeMaterialConnectionPoint;
  120771. autoConfigure(material: NodeMaterial): void;
  120772. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120773. protected _buildBlock(state: NodeMaterialBuildState): this;
  120774. }
  120775. }
  120776. declare module BABYLON {
  120777. /**
  120778. * Block used to add morph targets support to vertex shader
  120779. */
  120780. export class MorphTargetsBlock extends NodeMaterialBlock {
  120781. private _repeatableContentAnchor;
  120782. private _repeatebleContentGenerated;
  120783. /**
  120784. * Create a new MorphTargetsBlock
  120785. * @param name defines the block name
  120786. */
  120787. constructor(name: string);
  120788. /**
  120789. * Gets the current class name
  120790. * @returns the class name
  120791. */
  120792. getClassName(): string;
  120793. /**
  120794. * Gets the position input component
  120795. */
  120796. readonly position: NodeMaterialConnectionPoint;
  120797. /**
  120798. * Gets the normal input component
  120799. */
  120800. readonly normal: NodeMaterialConnectionPoint;
  120801. /**
  120802. * Gets the tangent input component
  120803. */
  120804. readonly tangent: NodeMaterialConnectionPoint;
  120805. /**
  120806. * Gets the tangent input component
  120807. */
  120808. readonly uv: NodeMaterialConnectionPoint;
  120809. /**
  120810. * Gets the position output component
  120811. */
  120812. readonly positionOutput: NodeMaterialConnectionPoint;
  120813. /**
  120814. * Gets the normal output component
  120815. */
  120816. readonly normalOutput: NodeMaterialConnectionPoint;
  120817. /**
  120818. * Gets the tangent output component
  120819. */
  120820. readonly tangentOutput: NodeMaterialConnectionPoint;
  120821. /**
  120822. * Gets the tangent output component
  120823. */
  120824. readonly uvOutput: NodeMaterialConnectionPoint;
  120825. initialize(state: NodeMaterialBuildState): void;
  120826. autoConfigure(material: NodeMaterial): void;
  120827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120829. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120830. protected _buildBlock(state: NodeMaterialBuildState): this;
  120831. }
  120832. }
  120833. declare module BABYLON {
  120834. /**
  120835. * Block used to get data information from a light
  120836. */
  120837. export class LightInformationBlock extends NodeMaterialBlock {
  120838. private _lightDataUniformName;
  120839. private _lightColorUniformName;
  120840. private _lightTypeDefineName;
  120841. /**
  120842. * Gets or sets the light associated with this block
  120843. */
  120844. light: Nullable<Light>;
  120845. /**
  120846. * Creates a new LightInformationBlock
  120847. * @param name defines the block name
  120848. */
  120849. constructor(name: string);
  120850. /**
  120851. * Gets the current class name
  120852. * @returns the class name
  120853. */
  120854. getClassName(): string;
  120855. /**
  120856. * Gets the world position input component
  120857. */
  120858. readonly worldPosition: NodeMaterialConnectionPoint;
  120859. /**
  120860. * Gets the direction output component
  120861. */
  120862. readonly direction: NodeMaterialConnectionPoint;
  120863. /**
  120864. * Gets the direction output component
  120865. */
  120866. readonly color: NodeMaterialConnectionPoint;
  120867. /**
  120868. * Gets the direction output component
  120869. */
  120870. readonly intensity: NodeMaterialConnectionPoint;
  120871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120872. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120873. protected _buildBlock(state: NodeMaterialBuildState): this;
  120874. serialize(): any;
  120875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120876. }
  120877. }
  120878. declare module BABYLON {
  120879. /**
  120880. * Block used to add image processing support to fragment shader
  120881. */
  120882. export class ImageProcessingBlock extends NodeMaterialBlock {
  120883. /**
  120884. * Create a new ImageProcessingBlock
  120885. * @param name defines the block name
  120886. */
  120887. constructor(name: string);
  120888. /**
  120889. * Gets the current class name
  120890. * @returns the class name
  120891. */
  120892. getClassName(): string;
  120893. /**
  120894. * Gets the color input component
  120895. */
  120896. readonly color: NodeMaterialConnectionPoint;
  120897. /**
  120898. * Gets the output component
  120899. */
  120900. readonly output: NodeMaterialConnectionPoint;
  120901. /**
  120902. * Initialize the block and prepare the context for build
  120903. * @param state defines the state that will be used for the build
  120904. */
  120905. initialize(state: NodeMaterialBuildState): void;
  120906. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120907. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120909. protected _buildBlock(state: NodeMaterialBuildState): this;
  120910. }
  120911. }
  120912. declare module BABYLON {
  120913. /**
  120914. * Block used to pertub normals based on a normal map
  120915. */
  120916. export class PerturbNormalBlock extends NodeMaterialBlock {
  120917. private _tangentSpaceParameterName;
  120918. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120919. invertX: boolean;
  120920. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120921. invertY: boolean;
  120922. /**
  120923. * Create a new PerturbNormalBlock
  120924. * @param name defines the block name
  120925. */
  120926. constructor(name: string);
  120927. /**
  120928. * Gets the current class name
  120929. * @returns the class name
  120930. */
  120931. getClassName(): string;
  120932. /**
  120933. * Gets the world position input component
  120934. */
  120935. readonly worldPosition: NodeMaterialConnectionPoint;
  120936. /**
  120937. * Gets the world normal input component
  120938. */
  120939. readonly worldNormal: NodeMaterialConnectionPoint;
  120940. /**
  120941. * Gets the uv input component
  120942. */
  120943. readonly uv: NodeMaterialConnectionPoint;
  120944. /**
  120945. * Gets the normal map color input component
  120946. */
  120947. readonly normalMapColor: NodeMaterialConnectionPoint;
  120948. /**
  120949. * Gets the strength input component
  120950. */
  120951. readonly strength: NodeMaterialConnectionPoint;
  120952. /**
  120953. * Gets the output component
  120954. */
  120955. readonly output: NodeMaterialConnectionPoint;
  120956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120958. autoConfigure(material: NodeMaterial): void;
  120959. protected _buildBlock(state: NodeMaterialBuildState): this;
  120960. protected _dumpPropertiesCode(): string;
  120961. serialize(): any;
  120962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120963. }
  120964. }
  120965. declare module BABYLON {
  120966. /**
  120967. * Block used to discard a pixel if a value is smaller than a cutoff
  120968. */
  120969. export class DiscardBlock extends NodeMaterialBlock {
  120970. /**
  120971. * Create a new DiscardBlock
  120972. * @param name defines the block name
  120973. */
  120974. constructor(name: string);
  120975. /**
  120976. * Gets the current class name
  120977. * @returns the class name
  120978. */
  120979. getClassName(): string;
  120980. /**
  120981. * Gets the color input component
  120982. */
  120983. readonly value: NodeMaterialConnectionPoint;
  120984. /**
  120985. * Gets the cutoff input component
  120986. */
  120987. readonly cutoff: NodeMaterialConnectionPoint;
  120988. protected _buildBlock(state: NodeMaterialBuildState): this;
  120989. }
  120990. }
  120991. declare module BABYLON {
  120992. /**
  120993. * Block used to add support for scene fog
  120994. */
  120995. export class FogBlock extends NodeMaterialBlock {
  120996. private _fogDistanceName;
  120997. private _fogParameters;
  120998. /**
  120999. * Create a new FogBlock
  121000. * @param name defines the block name
  121001. */
  121002. constructor(name: string);
  121003. /**
  121004. * Gets the current class name
  121005. * @returns the class name
  121006. */
  121007. getClassName(): string;
  121008. /**
  121009. * Gets the world position input component
  121010. */
  121011. readonly worldPosition: NodeMaterialConnectionPoint;
  121012. /**
  121013. * Gets the view input component
  121014. */
  121015. readonly view: NodeMaterialConnectionPoint;
  121016. /**
  121017. * Gets the color input component
  121018. */
  121019. readonly input: NodeMaterialConnectionPoint;
  121020. /**
  121021. * Gets the fog color input component
  121022. */
  121023. readonly fogColor: NodeMaterialConnectionPoint;
  121024. /**
  121025. * Gets the output component
  121026. */
  121027. readonly output: NodeMaterialConnectionPoint;
  121028. autoConfigure(material: NodeMaterial): void;
  121029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121030. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121031. protected _buildBlock(state: NodeMaterialBuildState): this;
  121032. }
  121033. }
  121034. declare module BABYLON {
  121035. /**
  121036. * Block used to add light in the fragment shader
  121037. */
  121038. export class LightBlock extends NodeMaterialBlock {
  121039. private _lightId;
  121040. /**
  121041. * Gets or sets the light associated with this block
  121042. */
  121043. light: Nullable<Light>;
  121044. /**
  121045. * Create a new LightBlock
  121046. * @param name defines the block name
  121047. */
  121048. constructor(name: string);
  121049. /**
  121050. * Gets the current class name
  121051. * @returns the class name
  121052. */
  121053. getClassName(): string;
  121054. /**
  121055. * Gets the world position input component
  121056. */
  121057. readonly worldPosition: NodeMaterialConnectionPoint;
  121058. /**
  121059. * Gets the world normal input component
  121060. */
  121061. readonly worldNormal: NodeMaterialConnectionPoint;
  121062. /**
  121063. * Gets the camera (or eye) position component
  121064. */
  121065. readonly cameraPosition: NodeMaterialConnectionPoint;
  121066. /**
  121067. * Gets the glossiness component
  121068. */
  121069. readonly glossiness: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the glossinness power component
  121072. */
  121073. readonly glossPower: NodeMaterialConnectionPoint;
  121074. /**
  121075. * Gets the diffuse color component
  121076. */
  121077. readonly diffuseColor: NodeMaterialConnectionPoint;
  121078. /**
  121079. * Gets the specular color component
  121080. */
  121081. readonly specularColor: NodeMaterialConnectionPoint;
  121082. /**
  121083. * Gets the diffuse output component
  121084. */
  121085. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121086. /**
  121087. * Gets the specular output component
  121088. */
  121089. readonly specularOutput: NodeMaterialConnectionPoint;
  121090. autoConfigure(material: NodeMaterial): void;
  121091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121092. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121094. private _injectVertexCode;
  121095. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121096. serialize(): any;
  121097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121098. }
  121099. }
  121100. declare module BABYLON {
  121101. /**
  121102. * Block used to multiply 2 values
  121103. */
  121104. export class MultiplyBlock extends NodeMaterialBlock {
  121105. /**
  121106. * Creates a new MultiplyBlock
  121107. * @param name defines the block name
  121108. */
  121109. constructor(name: string);
  121110. /**
  121111. * Gets the current class name
  121112. * @returns the class name
  121113. */
  121114. getClassName(): string;
  121115. /**
  121116. * Gets the left operand input component
  121117. */
  121118. readonly left: NodeMaterialConnectionPoint;
  121119. /**
  121120. * Gets the right operand input component
  121121. */
  121122. readonly right: NodeMaterialConnectionPoint;
  121123. /**
  121124. * Gets the output component
  121125. */
  121126. readonly output: NodeMaterialConnectionPoint;
  121127. protected _buildBlock(state: NodeMaterialBuildState): this;
  121128. }
  121129. }
  121130. declare module BABYLON {
  121131. /**
  121132. * Block used to add 2 vectors
  121133. */
  121134. export class AddBlock extends NodeMaterialBlock {
  121135. /**
  121136. * Creates a new AddBlock
  121137. * @param name defines the block name
  121138. */
  121139. constructor(name: string);
  121140. /**
  121141. * Gets the current class name
  121142. * @returns the class name
  121143. */
  121144. getClassName(): string;
  121145. /**
  121146. * Gets the left operand input component
  121147. */
  121148. readonly left: NodeMaterialConnectionPoint;
  121149. /**
  121150. * Gets the right operand input component
  121151. */
  121152. readonly right: NodeMaterialConnectionPoint;
  121153. /**
  121154. * Gets the output component
  121155. */
  121156. readonly output: NodeMaterialConnectionPoint;
  121157. protected _buildBlock(state: NodeMaterialBuildState): this;
  121158. }
  121159. }
  121160. declare module BABYLON {
  121161. /**
  121162. * Block used to scale a vector by a float
  121163. */
  121164. export class ScaleBlock extends NodeMaterialBlock {
  121165. /**
  121166. * Creates a new ScaleBlock
  121167. * @param name defines the block name
  121168. */
  121169. constructor(name: string);
  121170. /**
  121171. * Gets the current class name
  121172. * @returns the class name
  121173. */
  121174. getClassName(): string;
  121175. /**
  121176. * Gets the input component
  121177. */
  121178. readonly input: NodeMaterialConnectionPoint;
  121179. /**
  121180. * Gets the factor input component
  121181. */
  121182. readonly factor: NodeMaterialConnectionPoint;
  121183. /**
  121184. * Gets the output component
  121185. */
  121186. readonly output: NodeMaterialConnectionPoint;
  121187. protected _buildBlock(state: NodeMaterialBuildState): this;
  121188. }
  121189. }
  121190. declare module BABYLON {
  121191. /**
  121192. * Block used to clamp a float
  121193. */
  121194. export class ClampBlock extends NodeMaterialBlock {
  121195. /** Gets or sets the minimum range */
  121196. minimum: number;
  121197. /** Gets or sets the maximum range */
  121198. maximum: number;
  121199. /**
  121200. * Creates a new ClampBlock
  121201. * @param name defines the block name
  121202. */
  121203. constructor(name: string);
  121204. /**
  121205. * Gets the current class name
  121206. * @returns the class name
  121207. */
  121208. getClassName(): string;
  121209. /**
  121210. * Gets the value input component
  121211. */
  121212. readonly value: NodeMaterialConnectionPoint;
  121213. /**
  121214. * Gets the output component
  121215. */
  121216. readonly output: NodeMaterialConnectionPoint;
  121217. protected _buildBlock(state: NodeMaterialBuildState): this;
  121218. protected _dumpPropertiesCode(): string;
  121219. serialize(): any;
  121220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121221. }
  121222. }
  121223. declare module BABYLON {
  121224. /**
  121225. * Block used to apply a cross product between 2 vectors
  121226. */
  121227. export class CrossBlock extends NodeMaterialBlock {
  121228. /**
  121229. * Creates a new CrossBlock
  121230. * @param name defines the block name
  121231. */
  121232. constructor(name: string);
  121233. /**
  121234. * Gets the current class name
  121235. * @returns the class name
  121236. */
  121237. getClassName(): string;
  121238. /**
  121239. * Gets the left operand input component
  121240. */
  121241. readonly left: NodeMaterialConnectionPoint;
  121242. /**
  121243. * Gets the right operand input component
  121244. */
  121245. readonly right: NodeMaterialConnectionPoint;
  121246. /**
  121247. * Gets the output component
  121248. */
  121249. readonly output: NodeMaterialConnectionPoint;
  121250. protected _buildBlock(state: NodeMaterialBuildState): this;
  121251. }
  121252. }
  121253. declare module BABYLON {
  121254. /**
  121255. * Block used to apply a dot product between 2 vectors
  121256. */
  121257. export class DotBlock extends NodeMaterialBlock {
  121258. /**
  121259. * Creates a new DotBlock
  121260. * @param name defines the block name
  121261. */
  121262. constructor(name: string);
  121263. /**
  121264. * Gets the current class name
  121265. * @returns the class name
  121266. */
  121267. getClassName(): string;
  121268. /**
  121269. * Gets the left operand input component
  121270. */
  121271. readonly left: NodeMaterialConnectionPoint;
  121272. /**
  121273. * Gets the right operand input component
  121274. */
  121275. readonly right: NodeMaterialConnectionPoint;
  121276. /**
  121277. * Gets the output component
  121278. */
  121279. readonly output: NodeMaterialConnectionPoint;
  121280. protected _buildBlock(state: NodeMaterialBuildState): this;
  121281. }
  121282. }
  121283. declare module BABYLON {
  121284. /**
  121285. * Block used to remap a float from a range to a new one
  121286. */
  121287. export class RemapBlock extends NodeMaterialBlock {
  121288. /**
  121289. * Gets or sets the source range
  121290. */
  121291. sourceRange: Vector2;
  121292. /**
  121293. * Gets or sets the target range
  121294. */
  121295. targetRange: Vector2;
  121296. /**
  121297. * Creates a new RemapBlock
  121298. * @param name defines the block name
  121299. */
  121300. constructor(name: string);
  121301. /**
  121302. * Gets the current class name
  121303. * @returns the class name
  121304. */
  121305. getClassName(): string;
  121306. /**
  121307. * Gets the input component
  121308. */
  121309. readonly input: NodeMaterialConnectionPoint;
  121310. /**
  121311. * Gets the source min input component
  121312. */
  121313. readonly sourceMin: NodeMaterialConnectionPoint;
  121314. /**
  121315. * Gets the source max input component
  121316. */
  121317. readonly sourceMax: NodeMaterialConnectionPoint;
  121318. /**
  121319. * Gets the target min input component
  121320. */
  121321. readonly targetMin: NodeMaterialConnectionPoint;
  121322. /**
  121323. * Gets the target max input component
  121324. */
  121325. readonly targetMax: NodeMaterialConnectionPoint;
  121326. /**
  121327. * Gets the output component
  121328. */
  121329. readonly output: NodeMaterialConnectionPoint;
  121330. protected _buildBlock(state: NodeMaterialBuildState): this;
  121331. protected _dumpPropertiesCode(): string;
  121332. serialize(): any;
  121333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121334. }
  121335. }
  121336. declare module BABYLON {
  121337. /**
  121338. * Block used to normalize a vector
  121339. */
  121340. export class NormalizeBlock extends NodeMaterialBlock {
  121341. /**
  121342. * Creates a new NormalizeBlock
  121343. * @param name defines the block name
  121344. */
  121345. constructor(name: string);
  121346. /**
  121347. * Gets the current class name
  121348. * @returns the class name
  121349. */
  121350. getClassName(): string;
  121351. /**
  121352. * Gets the input component
  121353. */
  121354. readonly input: NodeMaterialConnectionPoint;
  121355. /**
  121356. * Gets the output component
  121357. */
  121358. readonly output: NodeMaterialConnectionPoint;
  121359. protected _buildBlock(state: NodeMaterialBuildState): this;
  121360. }
  121361. }
  121362. declare module BABYLON {
  121363. /**
  121364. * Operations supported by the Trigonometry block
  121365. */
  121366. export enum TrigonometryBlockOperations {
  121367. /** Cos */
  121368. Cos = 0,
  121369. /** Sin */
  121370. Sin = 1,
  121371. /** Abs */
  121372. Abs = 2,
  121373. /** Exp */
  121374. Exp = 3,
  121375. /** Exp2 */
  121376. Exp2 = 4,
  121377. /** Round */
  121378. Round = 5,
  121379. /** Floor */
  121380. Floor = 6,
  121381. /** Ceiling */
  121382. Ceiling = 7,
  121383. /** Square root */
  121384. Sqrt = 8,
  121385. /** Log */
  121386. Log = 9,
  121387. /** Tangent */
  121388. Tan = 10,
  121389. /** Arc tangent */
  121390. ArcTan = 11,
  121391. /** Arc cosinus */
  121392. ArcCos = 12,
  121393. /** Arc sinus */
  121394. ArcSin = 13,
  121395. /** Fraction */
  121396. Fract = 14,
  121397. /** Sign */
  121398. Sign = 15,
  121399. /** To radians (from degrees) */
  121400. Radians = 16,
  121401. /** To degrees (from radians) */
  121402. Degrees = 17
  121403. }
  121404. /**
  121405. * Block used to apply trigonometry operation to floats
  121406. */
  121407. export class TrigonometryBlock extends NodeMaterialBlock {
  121408. /**
  121409. * Gets or sets the operation applied by the block
  121410. */
  121411. operation: TrigonometryBlockOperations;
  121412. /**
  121413. * Creates a new TrigonometryBlock
  121414. * @param name defines the block name
  121415. */
  121416. constructor(name: string);
  121417. /**
  121418. * Gets the current class name
  121419. * @returns the class name
  121420. */
  121421. getClassName(): string;
  121422. /**
  121423. * Gets the input component
  121424. */
  121425. readonly input: NodeMaterialConnectionPoint;
  121426. /**
  121427. * Gets the output component
  121428. */
  121429. readonly output: NodeMaterialConnectionPoint;
  121430. protected _buildBlock(state: NodeMaterialBuildState): this;
  121431. serialize(): any;
  121432. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121433. }
  121434. }
  121435. declare module BABYLON {
  121436. /**
  121437. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121438. */
  121439. export class ColorMergerBlock extends NodeMaterialBlock {
  121440. /**
  121441. * Create a new ColorMergerBlock
  121442. * @param name defines the block name
  121443. */
  121444. constructor(name: string);
  121445. /**
  121446. * Gets the current class name
  121447. * @returns the class name
  121448. */
  121449. getClassName(): string;
  121450. /**
  121451. * Gets the r component (input)
  121452. */
  121453. readonly r: NodeMaterialConnectionPoint;
  121454. /**
  121455. * Gets the g component (input)
  121456. */
  121457. readonly g: NodeMaterialConnectionPoint;
  121458. /**
  121459. * Gets the b component (input)
  121460. */
  121461. readonly b: NodeMaterialConnectionPoint;
  121462. /**
  121463. * Gets the a component (input)
  121464. */
  121465. readonly a: NodeMaterialConnectionPoint;
  121466. /**
  121467. * Gets the rgba component (output)
  121468. */
  121469. readonly rgba: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the rgb component (output)
  121472. */
  121473. readonly rgb: NodeMaterialConnectionPoint;
  121474. protected _buildBlock(state: NodeMaterialBuildState): this;
  121475. }
  121476. }
  121477. declare module BABYLON {
  121478. /**
  121479. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121480. */
  121481. export class VectorMergerBlock extends NodeMaterialBlock {
  121482. /**
  121483. * Create a new VectorMergerBlock
  121484. * @param name defines the block name
  121485. */
  121486. constructor(name: string);
  121487. /**
  121488. * Gets the current class name
  121489. * @returns the class name
  121490. */
  121491. getClassName(): string;
  121492. /**
  121493. * Gets the x component (input)
  121494. */
  121495. readonly x: NodeMaterialConnectionPoint;
  121496. /**
  121497. * Gets the y component (input)
  121498. */
  121499. readonly y: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the z component (input)
  121502. */
  121503. readonly z: NodeMaterialConnectionPoint;
  121504. /**
  121505. * Gets the w component (input)
  121506. */
  121507. readonly w: NodeMaterialConnectionPoint;
  121508. /**
  121509. * Gets the xyzw component (output)
  121510. */
  121511. readonly xyzw: NodeMaterialConnectionPoint;
  121512. /**
  121513. * Gets the xyz component (output)
  121514. */
  121515. readonly xyz: NodeMaterialConnectionPoint;
  121516. /**
  121517. * Gets the xy component (output)
  121518. */
  121519. readonly xy: NodeMaterialConnectionPoint;
  121520. protected _buildBlock(state: NodeMaterialBuildState): this;
  121521. }
  121522. }
  121523. declare module BABYLON {
  121524. /**
  121525. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121526. */
  121527. export class ColorSplitterBlock extends NodeMaterialBlock {
  121528. /**
  121529. * Create a new ColorSplitterBlock
  121530. * @param name defines the block name
  121531. */
  121532. constructor(name: string);
  121533. /**
  121534. * Gets the current class name
  121535. * @returns the class name
  121536. */
  121537. getClassName(): string;
  121538. /**
  121539. * Gets the rgba component (input)
  121540. */
  121541. readonly rgba: NodeMaterialConnectionPoint;
  121542. /**
  121543. * Gets the rgb component (input)
  121544. */
  121545. readonly rgbIn: NodeMaterialConnectionPoint;
  121546. /**
  121547. * Gets the rgb component (output)
  121548. */
  121549. readonly rgbOut: NodeMaterialConnectionPoint;
  121550. /**
  121551. * Gets the r component (output)
  121552. */
  121553. readonly r: NodeMaterialConnectionPoint;
  121554. /**
  121555. * Gets the g component (output)
  121556. */
  121557. readonly g: NodeMaterialConnectionPoint;
  121558. /**
  121559. * Gets the b component (output)
  121560. */
  121561. readonly b: NodeMaterialConnectionPoint;
  121562. /**
  121563. * Gets the a component (output)
  121564. */
  121565. readonly a: NodeMaterialConnectionPoint;
  121566. protected _inputRename(name: string): string;
  121567. protected _outputRename(name: string): string;
  121568. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121569. }
  121570. }
  121571. declare module BABYLON {
  121572. /**
  121573. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121574. */
  121575. export class VectorSplitterBlock extends NodeMaterialBlock {
  121576. /**
  121577. * Create a new VectorSplitterBlock
  121578. * @param name defines the block name
  121579. */
  121580. constructor(name: string);
  121581. /**
  121582. * Gets the current class name
  121583. * @returns the class name
  121584. */
  121585. getClassName(): string;
  121586. /**
  121587. * Gets the xyzw component (input)
  121588. */
  121589. readonly xyzw: NodeMaterialConnectionPoint;
  121590. /**
  121591. * Gets the xyz component (input)
  121592. */
  121593. readonly xyzIn: NodeMaterialConnectionPoint;
  121594. /**
  121595. * Gets the xy component (input)
  121596. */
  121597. readonly xyIn: NodeMaterialConnectionPoint;
  121598. /**
  121599. * Gets the xyz component (output)
  121600. */
  121601. readonly xyzOut: NodeMaterialConnectionPoint;
  121602. /**
  121603. * Gets the xy component (output)
  121604. */
  121605. readonly xyOut: NodeMaterialConnectionPoint;
  121606. /**
  121607. * Gets the x component (output)
  121608. */
  121609. readonly x: NodeMaterialConnectionPoint;
  121610. /**
  121611. * Gets the y component (output)
  121612. */
  121613. readonly y: NodeMaterialConnectionPoint;
  121614. /**
  121615. * Gets the z component (output)
  121616. */
  121617. readonly z: NodeMaterialConnectionPoint;
  121618. /**
  121619. * Gets the w component (output)
  121620. */
  121621. readonly w: NodeMaterialConnectionPoint;
  121622. protected _inputRename(name: string): string;
  121623. protected _outputRename(name: string): string;
  121624. protected _buildBlock(state: NodeMaterialBuildState): this;
  121625. }
  121626. }
  121627. declare module BABYLON {
  121628. /**
  121629. * Block used to lerp between 2 values
  121630. */
  121631. export class LerpBlock extends NodeMaterialBlock {
  121632. /**
  121633. * Creates a new LerpBlock
  121634. * @param name defines the block name
  121635. */
  121636. constructor(name: string);
  121637. /**
  121638. * Gets the current class name
  121639. * @returns the class name
  121640. */
  121641. getClassName(): string;
  121642. /**
  121643. * Gets the left operand input component
  121644. */
  121645. readonly left: NodeMaterialConnectionPoint;
  121646. /**
  121647. * Gets the right operand input component
  121648. */
  121649. readonly right: NodeMaterialConnectionPoint;
  121650. /**
  121651. * Gets the gradient operand input component
  121652. */
  121653. readonly gradient: NodeMaterialConnectionPoint;
  121654. /**
  121655. * Gets the output component
  121656. */
  121657. readonly output: NodeMaterialConnectionPoint;
  121658. protected _buildBlock(state: NodeMaterialBuildState): this;
  121659. }
  121660. }
  121661. declare module BABYLON {
  121662. /**
  121663. * Block used to divide 2 vectors
  121664. */
  121665. export class DivideBlock extends NodeMaterialBlock {
  121666. /**
  121667. * Creates a new DivideBlock
  121668. * @param name defines the block name
  121669. */
  121670. constructor(name: string);
  121671. /**
  121672. * Gets the current class name
  121673. * @returns the class name
  121674. */
  121675. getClassName(): string;
  121676. /**
  121677. * Gets the left operand input component
  121678. */
  121679. readonly left: NodeMaterialConnectionPoint;
  121680. /**
  121681. * Gets the right operand input component
  121682. */
  121683. readonly right: NodeMaterialConnectionPoint;
  121684. /**
  121685. * Gets the output component
  121686. */
  121687. readonly output: NodeMaterialConnectionPoint;
  121688. protected _buildBlock(state: NodeMaterialBuildState): this;
  121689. }
  121690. }
  121691. declare module BABYLON {
  121692. /**
  121693. * Block used to subtract 2 vectors
  121694. */
  121695. export class SubtractBlock extends NodeMaterialBlock {
  121696. /**
  121697. * Creates a new SubtractBlock
  121698. * @param name defines the block name
  121699. */
  121700. constructor(name: string);
  121701. /**
  121702. * Gets the current class name
  121703. * @returns the class name
  121704. */
  121705. getClassName(): string;
  121706. /**
  121707. * Gets the left operand input component
  121708. */
  121709. readonly left: NodeMaterialConnectionPoint;
  121710. /**
  121711. * Gets the right operand input component
  121712. */
  121713. readonly right: NodeMaterialConnectionPoint;
  121714. /**
  121715. * Gets the output component
  121716. */
  121717. readonly output: NodeMaterialConnectionPoint;
  121718. protected _buildBlock(state: NodeMaterialBuildState): this;
  121719. }
  121720. }
  121721. declare module BABYLON {
  121722. /**
  121723. * Block used to step a value
  121724. */
  121725. export class StepBlock extends NodeMaterialBlock {
  121726. /**
  121727. * Creates a new StepBlock
  121728. * @param name defines the block name
  121729. */
  121730. constructor(name: string);
  121731. /**
  121732. * Gets the current class name
  121733. * @returns the class name
  121734. */
  121735. getClassName(): string;
  121736. /**
  121737. * Gets the value operand input component
  121738. */
  121739. readonly value: NodeMaterialConnectionPoint;
  121740. /**
  121741. * Gets the edge operand input component
  121742. */
  121743. readonly edge: NodeMaterialConnectionPoint;
  121744. /**
  121745. * Gets the output component
  121746. */
  121747. readonly output: NodeMaterialConnectionPoint;
  121748. protected _buildBlock(state: NodeMaterialBuildState): this;
  121749. }
  121750. }
  121751. declare module BABYLON {
  121752. /**
  121753. * Block used to get the opposite (1 - x) of a value
  121754. */
  121755. export class OneMinusBlock extends NodeMaterialBlock {
  121756. /**
  121757. * Creates a new OneMinusBlock
  121758. * @param name defines the block name
  121759. */
  121760. constructor(name: string);
  121761. /**
  121762. * Gets the current class name
  121763. * @returns the class name
  121764. */
  121765. getClassName(): string;
  121766. /**
  121767. * Gets the input component
  121768. */
  121769. readonly input: NodeMaterialConnectionPoint;
  121770. /**
  121771. * Gets the output component
  121772. */
  121773. readonly output: NodeMaterialConnectionPoint;
  121774. protected _buildBlock(state: NodeMaterialBuildState): this;
  121775. }
  121776. }
  121777. declare module BABYLON {
  121778. /**
  121779. * Block used to get the view direction
  121780. */
  121781. export class ViewDirectionBlock extends NodeMaterialBlock {
  121782. /**
  121783. * Creates a new ViewDirectionBlock
  121784. * @param name defines the block name
  121785. */
  121786. constructor(name: string);
  121787. /**
  121788. * Gets the current class name
  121789. * @returns the class name
  121790. */
  121791. getClassName(): string;
  121792. /**
  121793. * Gets the world position component
  121794. */
  121795. readonly worldPosition: NodeMaterialConnectionPoint;
  121796. /**
  121797. * Gets the camera position component
  121798. */
  121799. readonly cameraPosition: NodeMaterialConnectionPoint;
  121800. /**
  121801. * Gets the output component
  121802. */
  121803. readonly output: NodeMaterialConnectionPoint;
  121804. autoConfigure(material: NodeMaterial): void;
  121805. protected _buildBlock(state: NodeMaterialBuildState): this;
  121806. }
  121807. }
  121808. declare module BABYLON {
  121809. /**
  121810. * Block used to compute fresnel value
  121811. */
  121812. export class FresnelBlock extends NodeMaterialBlock {
  121813. /**
  121814. * Create a new FresnelBlock
  121815. * @param name defines the block name
  121816. */
  121817. constructor(name: string);
  121818. /**
  121819. * Gets the current class name
  121820. * @returns the class name
  121821. */
  121822. getClassName(): string;
  121823. /**
  121824. * Gets the world normal input component
  121825. */
  121826. readonly worldNormal: NodeMaterialConnectionPoint;
  121827. /**
  121828. * Gets the view direction input component
  121829. */
  121830. readonly viewDirection: NodeMaterialConnectionPoint;
  121831. /**
  121832. * Gets the bias input component
  121833. */
  121834. readonly bias: NodeMaterialConnectionPoint;
  121835. /**
  121836. * Gets the camera (or eye) position component
  121837. */
  121838. readonly power: NodeMaterialConnectionPoint;
  121839. /**
  121840. * Gets the fresnel output component
  121841. */
  121842. readonly fresnel: NodeMaterialConnectionPoint;
  121843. autoConfigure(material: NodeMaterial): void;
  121844. protected _buildBlock(state: NodeMaterialBuildState): this;
  121845. }
  121846. }
  121847. declare module BABYLON {
  121848. /**
  121849. * Block used to get the max of 2 values
  121850. */
  121851. export class MaxBlock extends NodeMaterialBlock {
  121852. /**
  121853. * Creates a new MaxBlock
  121854. * @param name defines the block name
  121855. */
  121856. constructor(name: string);
  121857. /**
  121858. * Gets the current class name
  121859. * @returns the class name
  121860. */
  121861. getClassName(): string;
  121862. /**
  121863. * Gets the left operand input component
  121864. */
  121865. readonly left: NodeMaterialConnectionPoint;
  121866. /**
  121867. * Gets the right operand input component
  121868. */
  121869. readonly right: NodeMaterialConnectionPoint;
  121870. /**
  121871. * Gets the output component
  121872. */
  121873. readonly output: NodeMaterialConnectionPoint;
  121874. protected _buildBlock(state: NodeMaterialBuildState): this;
  121875. }
  121876. }
  121877. declare module BABYLON {
  121878. /**
  121879. * Block used to get the min of 2 values
  121880. */
  121881. export class MinBlock extends NodeMaterialBlock {
  121882. /**
  121883. * Creates a new MinBlock
  121884. * @param name defines the block name
  121885. */
  121886. constructor(name: string);
  121887. /**
  121888. * Gets the current class name
  121889. * @returns the class name
  121890. */
  121891. getClassName(): string;
  121892. /**
  121893. * Gets the left operand input component
  121894. */
  121895. readonly left: NodeMaterialConnectionPoint;
  121896. /**
  121897. * Gets the right operand input component
  121898. */
  121899. readonly right: NodeMaterialConnectionPoint;
  121900. /**
  121901. * Gets the output component
  121902. */
  121903. readonly output: NodeMaterialConnectionPoint;
  121904. protected _buildBlock(state: NodeMaterialBuildState): this;
  121905. }
  121906. }
  121907. declare module BABYLON {
  121908. /**
  121909. * Block used to get the distance between 2 values
  121910. */
  121911. export class DistanceBlock extends NodeMaterialBlock {
  121912. /**
  121913. * Creates a new DistanceBlock
  121914. * @param name defines the block name
  121915. */
  121916. constructor(name: string);
  121917. /**
  121918. * Gets the current class name
  121919. * @returns the class name
  121920. */
  121921. getClassName(): string;
  121922. /**
  121923. * Gets the left operand input component
  121924. */
  121925. readonly left: NodeMaterialConnectionPoint;
  121926. /**
  121927. * Gets the right operand input component
  121928. */
  121929. readonly right: NodeMaterialConnectionPoint;
  121930. /**
  121931. * Gets the output component
  121932. */
  121933. readonly output: NodeMaterialConnectionPoint;
  121934. protected _buildBlock(state: NodeMaterialBuildState): this;
  121935. }
  121936. }
  121937. declare module BABYLON {
  121938. /**
  121939. * Block used to get the length of a vector
  121940. */
  121941. export class LengthBlock extends NodeMaterialBlock {
  121942. /**
  121943. * Creates a new LengthBlock
  121944. * @param name defines the block name
  121945. */
  121946. constructor(name: string);
  121947. /**
  121948. * Gets the current class name
  121949. * @returns the class name
  121950. */
  121951. getClassName(): string;
  121952. /**
  121953. * Gets the value input component
  121954. */
  121955. readonly value: NodeMaterialConnectionPoint;
  121956. /**
  121957. * Gets the output component
  121958. */
  121959. readonly output: NodeMaterialConnectionPoint;
  121960. protected _buildBlock(state: NodeMaterialBuildState): this;
  121961. }
  121962. }
  121963. declare module BABYLON {
  121964. /**
  121965. * Block used to get negative version of a value (i.e. x * -1)
  121966. */
  121967. export class NegateBlock extends NodeMaterialBlock {
  121968. /**
  121969. * Creates a new NegateBlock
  121970. * @param name defines the block name
  121971. */
  121972. constructor(name: string);
  121973. /**
  121974. * Gets the current class name
  121975. * @returns the class name
  121976. */
  121977. getClassName(): string;
  121978. /**
  121979. * Gets the value input component
  121980. */
  121981. readonly value: NodeMaterialConnectionPoint;
  121982. /**
  121983. * Gets the output component
  121984. */
  121985. readonly output: NodeMaterialConnectionPoint;
  121986. protected _buildBlock(state: NodeMaterialBuildState): this;
  121987. }
  121988. }
  121989. declare module BABYLON {
  121990. /**
  121991. * Block used to get the value of the first parameter raised to the power of the second
  121992. */
  121993. export class PowBlock extends NodeMaterialBlock {
  121994. /**
  121995. * Creates a new PowBlock
  121996. * @param name defines the block name
  121997. */
  121998. constructor(name: string);
  121999. /**
  122000. * Gets the current class name
  122001. * @returns the class name
  122002. */
  122003. getClassName(): string;
  122004. /**
  122005. * Gets the value operand input component
  122006. */
  122007. readonly value: NodeMaterialConnectionPoint;
  122008. /**
  122009. * Gets the power operand input component
  122010. */
  122011. readonly power: NodeMaterialConnectionPoint;
  122012. /**
  122013. * Gets the output component
  122014. */
  122015. readonly output: NodeMaterialConnectionPoint;
  122016. protected _buildBlock(state: NodeMaterialBuildState): this;
  122017. }
  122018. }
  122019. declare module BABYLON {
  122020. /**
  122021. * Block used to get a random number
  122022. */
  122023. export class RandomNumberBlock extends NodeMaterialBlock {
  122024. /**
  122025. * Creates a new RandomNumberBlock
  122026. * @param name defines the block name
  122027. */
  122028. constructor(name: string);
  122029. /**
  122030. * Gets the current class name
  122031. * @returns the class name
  122032. */
  122033. getClassName(): string;
  122034. /**
  122035. * Gets the seed input component
  122036. */
  122037. readonly seed: NodeMaterialConnectionPoint;
  122038. /**
  122039. * Gets the output component
  122040. */
  122041. readonly output: NodeMaterialConnectionPoint;
  122042. protected _buildBlock(state: NodeMaterialBuildState): this;
  122043. }
  122044. }
  122045. declare module BABYLON {
  122046. /**
  122047. * Block used to compute arc tangent of 2 values
  122048. */
  122049. export class ArcTan2Block extends NodeMaterialBlock {
  122050. /**
  122051. * Creates a new ArcTan2Block
  122052. * @param name defines the block name
  122053. */
  122054. constructor(name: string);
  122055. /**
  122056. * Gets the current class name
  122057. * @returns the class name
  122058. */
  122059. getClassName(): string;
  122060. /**
  122061. * Gets the x operand input component
  122062. */
  122063. readonly x: NodeMaterialConnectionPoint;
  122064. /**
  122065. * Gets the y operand input component
  122066. */
  122067. readonly y: NodeMaterialConnectionPoint;
  122068. /**
  122069. * Gets the output component
  122070. */
  122071. readonly output: NodeMaterialConnectionPoint;
  122072. protected _buildBlock(state: NodeMaterialBuildState): this;
  122073. }
  122074. }
  122075. declare module BABYLON {
  122076. /**
  122077. * Block used to smooth step a value
  122078. */
  122079. export class SmoothStepBlock extends NodeMaterialBlock {
  122080. /**
  122081. * Creates a new SmoothStepBlock
  122082. * @param name defines the block name
  122083. */
  122084. constructor(name: string);
  122085. /**
  122086. * Gets the current class name
  122087. * @returns the class name
  122088. */
  122089. getClassName(): string;
  122090. /**
  122091. * Gets the value operand input component
  122092. */
  122093. readonly value: NodeMaterialConnectionPoint;
  122094. /**
  122095. * Gets the first edge operand input component
  122096. */
  122097. readonly edge0: NodeMaterialConnectionPoint;
  122098. /**
  122099. * Gets the second edge operand input component
  122100. */
  122101. readonly edge1: NodeMaterialConnectionPoint;
  122102. /**
  122103. * Gets the output component
  122104. */
  122105. readonly output: NodeMaterialConnectionPoint;
  122106. protected _buildBlock(state: NodeMaterialBuildState): this;
  122107. }
  122108. }
  122109. declare module BABYLON {
  122110. /**
  122111. * Block used to get the reciprocal (1 / x) of a value
  122112. */
  122113. export class ReciprocalBlock extends NodeMaterialBlock {
  122114. /**
  122115. * Creates a new ReciprocalBlock
  122116. * @param name defines the block name
  122117. */
  122118. constructor(name: string);
  122119. /**
  122120. * Gets the current class name
  122121. * @returns the class name
  122122. */
  122123. getClassName(): string;
  122124. /**
  122125. * Gets the input component
  122126. */
  122127. readonly input: NodeMaterialConnectionPoint;
  122128. /**
  122129. * Gets the output component
  122130. */
  122131. readonly output: NodeMaterialConnectionPoint;
  122132. protected _buildBlock(state: NodeMaterialBuildState): this;
  122133. }
  122134. }
  122135. declare module BABYLON {
  122136. /**
  122137. * Block used to replace a color by another one
  122138. */
  122139. export class ReplaceColorBlock extends NodeMaterialBlock {
  122140. /**
  122141. * Creates a new ReplaceColorBlock
  122142. * @param name defines the block name
  122143. */
  122144. constructor(name: string);
  122145. /**
  122146. * Gets the current class name
  122147. * @returns the class name
  122148. */
  122149. getClassName(): string;
  122150. /**
  122151. * Gets the value input component
  122152. */
  122153. readonly value: NodeMaterialConnectionPoint;
  122154. /**
  122155. * Gets the reference input component
  122156. */
  122157. readonly reference: NodeMaterialConnectionPoint;
  122158. /**
  122159. * Gets the distance input component
  122160. */
  122161. readonly distance: NodeMaterialConnectionPoint;
  122162. /**
  122163. * Gets the replacement input component
  122164. */
  122165. readonly replacement: NodeMaterialConnectionPoint;
  122166. /**
  122167. * Gets the output component
  122168. */
  122169. readonly output: NodeMaterialConnectionPoint;
  122170. protected _buildBlock(state: NodeMaterialBuildState): this;
  122171. }
  122172. }
  122173. declare module BABYLON {
  122174. /**
  122175. * Block used to posterize a value
  122176. * @see https://en.wikipedia.org/wiki/Posterization
  122177. */
  122178. export class PosterizeBlock extends NodeMaterialBlock {
  122179. /**
  122180. * Creates a new PosterizeBlock
  122181. * @param name defines the block name
  122182. */
  122183. constructor(name: string);
  122184. /**
  122185. * Gets the current class name
  122186. * @returns the class name
  122187. */
  122188. getClassName(): string;
  122189. /**
  122190. * Gets the value input component
  122191. */
  122192. readonly value: NodeMaterialConnectionPoint;
  122193. /**
  122194. * Gets the steps input component
  122195. */
  122196. readonly steps: NodeMaterialConnectionPoint;
  122197. /**
  122198. * Gets the output component
  122199. */
  122200. readonly output: NodeMaterialConnectionPoint;
  122201. protected _buildBlock(state: NodeMaterialBuildState): this;
  122202. }
  122203. }
  122204. declare module BABYLON {
  122205. /**
  122206. * Operations supported by the Wave block
  122207. */
  122208. export enum WaveBlockKind {
  122209. /** SawTooth */
  122210. SawTooth = 0,
  122211. /** Square */
  122212. Square = 1,
  122213. /** Triangle */
  122214. Triangle = 2
  122215. }
  122216. /**
  122217. * Block used to apply wave operation to floats
  122218. */
  122219. export class WaveBlock extends NodeMaterialBlock {
  122220. /**
  122221. * Gets or sets the kibnd of wave to be applied by the block
  122222. */
  122223. kind: WaveBlockKind;
  122224. /**
  122225. * Creates a new WaveBlock
  122226. * @param name defines the block name
  122227. */
  122228. constructor(name: string);
  122229. /**
  122230. * Gets the current class name
  122231. * @returns the class name
  122232. */
  122233. getClassName(): string;
  122234. /**
  122235. * Gets the input component
  122236. */
  122237. readonly input: NodeMaterialConnectionPoint;
  122238. /**
  122239. * Gets the output component
  122240. */
  122241. readonly output: NodeMaterialConnectionPoint;
  122242. protected _buildBlock(state: NodeMaterialBuildState): this;
  122243. serialize(): any;
  122244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122245. }
  122246. }
  122247. declare module BABYLON {
  122248. /**
  122249. * Class used to store a color step for the GradientBlock
  122250. */
  122251. export class GradientBlockColorStep {
  122252. /**
  122253. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122254. */
  122255. step: number;
  122256. /**
  122257. * Gets or sets the color associated with this step
  122258. */
  122259. color: Color3;
  122260. /**
  122261. * Creates a new GradientBlockColorStep
  122262. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122263. * @param color defines the color associated with this step
  122264. */
  122265. constructor(
  122266. /**
  122267. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122268. */
  122269. step: number,
  122270. /**
  122271. * Gets or sets the color associated with this step
  122272. */
  122273. color: Color3);
  122274. }
  122275. /**
  122276. * Block used to return a color from a gradient based on an input value between 0 and 1
  122277. */
  122278. export class GradientBlock extends NodeMaterialBlock {
  122279. /**
  122280. * Gets or sets the list of color steps
  122281. */
  122282. colorSteps: GradientBlockColorStep[];
  122283. /**
  122284. * Creates a new GradientBlock
  122285. * @param name defines the block name
  122286. */
  122287. constructor(name: string);
  122288. /**
  122289. * Gets the current class name
  122290. * @returns the class name
  122291. */
  122292. getClassName(): string;
  122293. /**
  122294. * Gets the gradient input component
  122295. */
  122296. readonly gradient: NodeMaterialConnectionPoint;
  122297. /**
  122298. * Gets the output component
  122299. */
  122300. readonly output: NodeMaterialConnectionPoint;
  122301. private _writeColorConstant;
  122302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122303. serialize(): any;
  122304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122305. protected _dumpPropertiesCode(): string;
  122306. }
  122307. }
  122308. declare module BABYLON {
  122309. /**
  122310. * Block used to normalize lerp between 2 values
  122311. */
  122312. export class NLerpBlock extends NodeMaterialBlock {
  122313. /**
  122314. * Creates a new NLerpBlock
  122315. * @param name defines the block name
  122316. */
  122317. constructor(name: string);
  122318. /**
  122319. * Gets the current class name
  122320. * @returns the class name
  122321. */
  122322. getClassName(): string;
  122323. /**
  122324. * Gets the left operand input component
  122325. */
  122326. readonly left: NodeMaterialConnectionPoint;
  122327. /**
  122328. * Gets the right operand input component
  122329. */
  122330. readonly right: NodeMaterialConnectionPoint;
  122331. /**
  122332. * Gets the gradient operand input component
  122333. */
  122334. readonly gradient: NodeMaterialConnectionPoint;
  122335. /**
  122336. * Gets the output component
  122337. */
  122338. readonly output: NodeMaterialConnectionPoint;
  122339. protected _buildBlock(state: NodeMaterialBuildState): this;
  122340. }
  122341. }
  122342. declare module BABYLON {
  122343. /**
  122344. * Effect Render Options
  122345. */
  122346. export interface IEffectRendererOptions {
  122347. /**
  122348. * Defines the vertices positions.
  122349. */
  122350. positions?: number[];
  122351. /**
  122352. * Defines the indices.
  122353. */
  122354. indices?: number[];
  122355. }
  122356. /**
  122357. * Helper class to render one or more effects
  122358. */
  122359. export class EffectRenderer {
  122360. private engine;
  122361. private static _DefaultOptions;
  122362. private _vertexBuffers;
  122363. private _indexBuffer;
  122364. private _ringBufferIndex;
  122365. private _ringScreenBuffer;
  122366. private _fullscreenViewport;
  122367. private _getNextFrameBuffer;
  122368. /**
  122369. * Creates an effect renderer
  122370. * @param engine the engine to use for rendering
  122371. * @param options defines the options of the effect renderer
  122372. */
  122373. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122374. /**
  122375. * Sets the current viewport in normalized coordinates 0-1
  122376. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122377. */
  122378. setViewport(viewport?: Viewport): void;
  122379. /**
  122380. * Binds the embedded attributes buffer to the effect.
  122381. * @param effect Defines the effect to bind the attributes for
  122382. */
  122383. bindBuffers(effect: Effect): void;
  122384. /**
  122385. * Sets the current effect wrapper to use during draw.
  122386. * The effect needs to be ready before calling this api.
  122387. * This also sets the default full screen position attribute.
  122388. * @param effectWrapper Defines the effect to draw with
  122389. */
  122390. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122391. /**
  122392. * Draws a full screen quad.
  122393. */
  122394. draw(): void;
  122395. /**
  122396. * renders one or more effects to a specified texture
  122397. * @param effectWrappers list of effects to renderer
  122398. * @param outputTexture texture to draw to, if null it will render to the screen
  122399. */
  122400. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122401. /**
  122402. * Disposes of the effect renderer
  122403. */
  122404. dispose(): void;
  122405. }
  122406. /**
  122407. * Options to create an EffectWrapper
  122408. */
  122409. interface EffectWrapperCreationOptions {
  122410. /**
  122411. * Engine to use to create the effect
  122412. */
  122413. engine: ThinEngine;
  122414. /**
  122415. * Fragment shader for the effect
  122416. */
  122417. fragmentShader: string;
  122418. /**
  122419. * Vertex shader for the effect
  122420. */
  122421. vertexShader?: string;
  122422. /**
  122423. * Attributes to use in the shader
  122424. */
  122425. attributeNames?: Array<string>;
  122426. /**
  122427. * Uniforms to use in the shader
  122428. */
  122429. uniformNames?: Array<string>;
  122430. /**
  122431. * Texture sampler names to use in the shader
  122432. */
  122433. samplerNames?: Array<string>;
  122434. /**
  122435. * The friendly name of the effect displayed in Spector.
  122436. */
  122437. name?: string;
  122438. }
  122439. /**
  122440. * Wraps an effect to be used for rendering
  122441. */
  122442. export class EffectWrapper {
  122443. /**
  122444. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122445. */
  122446. onApplyObservable: Observable<{}>;
  122447. /**
  122448. * The underlying effect
  122449. */
  122450. effect: Effect;
  122451. /**
  122452. * Creates an effect to be renderer
  122453. * @param creationOptions options to create the effect
  122454. */
  122455. constructor(creationOptions: EffectWrapperCreationOptions);
  122456. /**
  122457. * Disposes of the effect wrapper
  122458. */
  122459. dispose(): void;
  122460. }
  122461. }
  122462. declare module BABYLON {
  122463. /**
  122464. * Helper class to push actions to a pool of workers.
  122465. */
  122466. export class WorkerPool implements IDisposable {
  122467. private _workerInfos;
  122468. private _pendingActions;
  122469. /**
  122470. * Constructor
  122471. * @param workers Array of workers to use for actions
  122472. */
  122473. constructor(workers: Array<Worker>);
  122474. /**
  122475. * Terminates all workers and clears any pending actions.
  122476. */
  122477. dispose(): void;
  122478. /**
  122479. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122480. * pended until a worker has completed its action.
  122481. * @param action The action to perform. Call onComplete when the action is complete.
  122482. */
  122483. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122484. private _execute;
  122485. }
  122486. }
  122487. declare module BABYLON {
  122488. /**
  122489. * Configuration for Draco compression
  122490. */
  122491. export interface IDracoCompressionConfiguration {
  122492. /**
  122493. * Configuration for the decoder.
  122494. */
  122495. decoder: {
  122496. /**
  122497. * The url to the WebAssembly module.
  122498. */
  122499. wasmUrl?: string;
  122500. /**
  122501. * The url to the WebAssembly binary.
  122502. */
  122503. wasmBinaryUrl?: string;
  122504. /**
  122505. * The url to the fallback JavaScript module.
  122506. */
  122507. fallbackUrl?: string;
  122508. };
  122509. }
  122510. /**
  122511. * Draco compression (https://google.github.io/draco/)
  122512. *
  122513. * This class wraps the Draco module.
  122514. *
  122515. * **Encoder**
  122516. *
  122517. * The encoder is not currently implemented.
  122518. *
  122519. * **Decoder**
  122520. *
  122521. * 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.
  122522. *
  122523. * To update the configuration, use the following code:
  122524. * ```javascript
  122525. * DracoCompression.Configuration = {
  122526. * decoder: {
  122527. * wasmUrl: "<url to the WebAssembly library>",
  122528. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122529. * fallbackUrl: "<url to the fallback JavaScript library>",
  122530. * }
  122531. * };
  122532. * ```
  122533. *
  122534. * 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.
  122535. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122536. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122537. *
  122538. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122539. * ```javascript
  122540. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122541. * ```
  122542. *
  122543. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122544. */
  122545. export class DracoCompression implements IDisposable {
  122546. private _workerPoolPromise?;
  122547. private _decoderModulePromise?;
  122548. /**
  122549. * The configuration. Defaults to the following urls:
  122550. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122551. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122552. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122553. */
  122554. static Configuration: IDracoCompressionConfiguration;
  122555. /**
  122556. * Returns true if the decoder configuration is available.
  122557. */
  122558. static readonly DecoderAvailable: boolean;
  122559. /**
  122560. * Default number of workers to create when creating the draco compression object.
  122561. */
  122562. static DefaultNumWorkers: number;
  122563. private static GetDefaultNumWorkers;
  122564. private static _Default;
  122565. /**
  122566. * Default instance for the draco compression object.
  122567. */
  122568. static readonly Default: DracoCompression;
  122569. /**
  122570. * Constructor
  122571. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122572. */
  122573. constructor(numWorkers?: number);
  122574. /**
  122575. * Stop all async operations and release resources.
  122576. */
  122577. dispose(): void;
  122578. /**
  122579. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122580. * @returns a promise that resolves when ready
  122581. */
  122582. whenReadyAsync(): Promise<void>;
  122583. /**
  122584. * Decode Draco compressed mesh data to vertex data.
  122585. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122586. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122587. * @returns A promise that resolves with the decoded vertex data
  122588. */
  122589. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122590. [kind: string]: number;
  122591. }): Promise<VertexData>;
  122592. }
  122593. }
  122594. declare module BABYLON {
  122595. /**
  122596. * Class for building Constructive Solid Geometry
  122597. */
  122598. export class CSG {
  122599. private polygons;
  122600. /**
  122601. * The world matrix
  122602. */
  122603. matrix: Matrix;
  122604. /**
  122605. * Stores the position
  122606. */
  122607. position: Vector3;
  122608. /**
  122609. * Stores the rotation
  122610. */
  122611. rotation: Vector3;
  122612. /**
  122613. * Stores the rotation quaternion
  122614. */
  122615. rotationQuaternion: Nullable<Quaternion>;
  122616. /**
  122617. * Stores the scaling vector
  122618. */
  122619. scaling: Vector3;
  122620. /**
  122621. * Convert the Mesh to CSG
  122622. * @param mesh The Mesh to convert to CSG
  122623. * @returns A new CSG from the Mesh
  122624. */
  122625. static FromMesh(mesh: Mesh): CSG;
  122626. /**
  122627. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122628. * @param polygons Polygons used to construct a CSG solid
  122629. */
  122630. private static FromPolygons;
  122631. /**
  122632. * Clones, or makes a deep copy, of the CSG
  122633. * @returns A new CSG
  122634. */
  122635. clone(): CSG;
  122636. /**
  122637. * Unions this CSG with another CSG
  122638. * @param csg The CSG to union against this CSG
  122639. * @returns The unioned CSG
  122640. */
  122641. union(csg: CSG): CSG;
  122642. /**
  122643. * Unions this CSG with another CSG in place
  122644. * @param csg The CSG to union against this CSG
  122645. */
  122646. unionInPlace(csg: CSG): void;
  122647. /**
  122648. * Subtracts this CSG with another CSG
  122649. * @param csg The CSG to subtract against this CSG
  122650. * @returns A new CSG
  122651. */
  122652. subtract(csg: CSG): CSG;
  122653. /**
  122654. * Subtracts this CSG with another CSG in place
  122655. * @param csg The CSG to subtact against this CSG
  122656. */
  122657. subtractInPlace(csg: CSG): void;
  122658. /**
  122659. * Intersect this CSG with another CSG
  122660. * @param csg The CSG to intersect against this CSG
  122661. * @returns A new CSG
  122662. */
  122663. intersect(csg: CSG): CSG;
  122664. /**
  122665. * Intersects this CSG with another CSG in place
  122666. * @param csg The CSG to intersect against this CSG
  122667. */
  122668. intersectInPlace(csg: CSG): void;
  122669. /**
  122670. * Return a new CSG solid with solid and empty space switched. This solid is
  122671. * not modified.
  122672. * @returns A new CSG solid with solid and empty space switched
  122673. */
  122674. inverse(): CSG;
  122675. /**
  122676. * Inverses the CSG in place
  122677. */
  122678. inverseInPlace(): void;
  122679. /**
  122680. * This is used to keep meshes transformations so they can be restored
  122681. * when we build back a Babylon Mesh
  122682. * NB : All CSG operations are performed in world coordinates
  122683. * @param csg The CSG to copy the transform attributes from
  122684. * @returns This CSG
  122685. */
  122686. copyTransformAttributes(csg: CSG): CSG;
  122687. /**
  122688. * Build Raw mesh from CSG
  122689. * Coordinates here are in world space
  122690. * @param name The name of the mesh geometry
  122691. * @param scene The Scene
  122692. * @param keepSubMeshes Specifies if the submeshes should be kept
  122693. * @returns A new Mesh
  122694. */
  122695. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122696. /**
  122697. * Build Mesh from CSG taking material and transforms into account
  122698. * @param name The name of the Mesh
  122699. * @param material The material of the Mesh
  122700. * @param scene The Scene
  122701. * @param keepSubMeshes Specifies if submeshes should be kept
  122702. * @returns The new Mesh
  122703. */
  122704. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122705. }
  122706. }
  122707. declare module BABYLON {
  122708. /**
  122709. * Class used to create a trail following a mesh
  122710. */
  122711. export class TrailMesh extends Mesh {
  122712. private _generator;
  122713. private _autoStart;
  122714. private _running;
  122715. private _diameter;
  122716. private _length;
  122717. private _sectionPolygonPointsCount;
  122718. private _sectionVectors;
  122719. private _sectionNormalVectors;
  122720. private _beforeRenderObserver;
  122721. /**
  122722. * @constructor
  122723. * @param name The value used by scene.getMeshByName() to do a lookup.
  122724. * @param generator The mesh to generate a trail.
  122725. * @param scene The scene to add this mesh to.
  122726. * @param diameter Diameter of trailing mesh. Default is 1.
  122727. * @param length Length of trailing mesh. Default is 60.
  122728. * @param autoStart Automatically start trailing mesh. Default true.
  122729. */
  122730. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122731. /**
  122732. * "TrailMesh"
  122733. * @returns "TrailMesh"
  122734. */
  122735. getClassName(): string;
  122736. private _createMesh;
  122737. /**
  122738. * Start trailing mesh.
  122739. */
  122740. start(): void;
  122741. /**
  122742. * Stop trailing mesh.
  122743. */
  122744. stop(): void;
  122745. /**
  122746. * Update trailing mesh geometry.
  122747. */
  122748. update(): void;
  122749. /**
  122750. * Returns a new TrailMesh object.
  122751. * @param name is a string, the name given to the new mesh
  122752. * @param newGenerator use new generator object for cloned trail mesh
  122753. * @returns a new mesh
  122754. */
  122755. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122756. /**
  122757. * Serializes this trail mesh
  122758. * @param serializationObject object to write serialization to
  122759. */
  122760. serialize(serializationObject: any): void;
  122761. /**
  122762. * Parses a serialized trail mesh
  122763. * @param parsedMesh the serialized mesh
  122764. * @param scene the scene to create the trail mesh in
  122765. * @returns the created trail mesh
  122766. */
  122767. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122768. }
  122769. }
  122770. declare module BABYLON {
  122771. /**
  122772. * Class containing static functions to help procedurally build meshes
  122773. */
  122774. export class TiledBoxBuilder {
  122775. /**
  122776. * Creates a box mesh
  122777. * 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)
  122778. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122782. * @param name defines the name of the mesh
  122783. * @param options defines the options used to create the mesh
  122784. * @param scene defines the hosting scene
  122785. * @returns the box mesh
  122786. */
  122787. static CreateTiledBox(name: string, options: {
  122788. pattern?: number;
  122789. width?: number;
  122790. height?: number;
  122791. depth?: number;
  122792. tileSize?: number;
  122793. tileWidth?: number;
  122794. tileHeight?: number;
  122795. alignHorizontal?: number;
  122796. alignVertical?: number;
  122797. faceUV?: Vector4[];
  122798. faceColors?: Color4[];
  122799. sideOrientation?: number;
  122800. updatable?: boolean;
  122801. }, scene?: Nullable<Scene>): Mesh;
  122802. }
  122803. }
  122804. declare module BABYLON {
  122805. /**
  122806. * Class containing static functions to help procedurally build meshes
  122807. */
  122808. export class TorusKnotBuilder {
  122809. /**
  122810. * Creates a torus knot mesh
  122811. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122812. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122813. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122814. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122818. * @param name defines the name of the mesh
  122819. * @param options defines the options used to create the mesh
  122820. * @param scene defines the hosting scene
  122821. * @returns the torus knot mesh
  122822. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122823. */
  122824. static CreateTorusKnot(name: string, options: {
  122825. radius?: number;
  122826. tube?: number;
  122827. radialSegments?: number;
  122828. tubularSegments?: number;
  122829. p?: number;
  122830. q?: number;
  122831. updatable?: boolean;
  122832. sideOrientation?: number;
  122833. frontUVs?: Vector4;
  122834. backUVs?: Vector4;
  122835. }, scene: any): Mesh;
  122836. }
  122837. }
  122838. declare module BABYLON {
  122839. /**
  122840. * Polygon
  122841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122842. */
  122843. export class Polygon {
  122844. /**
  122845. * Creates a rectangle
  122846. * @param xmin bottom X coord
  122847. * @param ymin bottom Y coord
  122848. * @param xmax top X coord
  122849. * @param ymax top Y coord
  122850. * @returns points that make the resulting rectation
  122851. */
  122852. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122853. /**
  122854. * Creates a circle
  122855. * @param radius radius of circle
  122856. * @param cx scale in x
  122857. * @param cy scale in y
  122858. * @param numberOfSides number of sides that make up the circle
  122859. * @returns points that make the resulting circle
  122860. */
  122861. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122862. /**
  122863. * Creates a polygon from input string
  122864. * @param input Input polygon data
  122865. * @returns the parsed points
  122866. */
  122867. static Parse(input: string): Vector2[];
  122868. /**
  122869. * Starts building a polygon from x and y coordinates
  122870. * @param x x coordinate
  122871. * @param y y coordinate
  122872. * @returns the started path2
  122873. */
  122874. static StartingAt(x: number, y: number): Path2;
  122875. }
  122876. /**
  122877. * Builds a polygon
  122878. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122879. */
  122880. export class PolygonMeshBuilder {
  122881. private _points;
  122882. private _outlinepoints;
  122883. private _holes;
  122884. private _name;
  122885. private _scene;
  122886. private _epoints;
  122887. private _eholes;
  122888. private _addToepoint;
  122889. /**
  122890. * Babylon reference to the earcut plugin.
  122891. */
  122892. bjsEarcut: any;
  122893. /**
  122894. * Creates a PolygonMeshBuilder
  122895. * @param name name of the builder
  122896. * @param contours Path of the polygon
  122897. * @param scene scene to add to when creating the mesh
  122898. * @param earcutInjection can be used to inject your own earcut reference
  122899. */
  122900. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122901. /**
  122902. * Adds a whole within the polygon
  122903. * @param hole Array of points defining the hole
  122904. * @returns this
  122905. */
  122906. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122907. /**
  122908. * Creates the polygon
  122909. * @param updatable If the mesh should be updatable
  122910. * @param depth The depth of the mesh created
  122911. * @returns the created mesh
  122912. */
  122913. build(updatable?: boolean, depth?: number): Mesh;
  122914. /**
  122915. * Creates the polygon
  122916. * @param depth The depth of the mesh created
  122917. * @returns the created VertexData
  122918. */
  122919. buildVertexData(depth?: number): VertexData;
  122920. /**
  122921. * Adds a side to the polygon
  122922. * @param positions points that make the polygon
  122923. * @param normals normals of the polygon
  122924. * @param uvs uvs of the polygon
  122925. * @param indices indices of the polygon
  122926. * @param bounds bounds of the polygon
  122927. * @param points points of the polygon
  122928. * @param depth depth of the polygon
  122929. * @param flip flip of the polygon
  122930. */
  122931. private addSide;
  122932. }
  122933. }
  122934. declare module BABYLON {
  122935. /**
  122936. * Class containing static functions to help procedurally build meshes
  122937. */
  122938. export class PolygonBuilder {
  122939. /**
  122940. * Creates a polygon mesh
  122941. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122942. * * 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
  122943. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122946. * * Remember you can only change the shape positions, not their number when updating a polygon
  122947. * @param name defines the name of the mesh
  122948. * @param options defines the options used to create the mesh
  122949. * @param scene defines the hosting scene
  122950. * @param earcutInjection can be used to inject your own earcut reference
  122951. * @returns the polygon mesh
  122952. */
  122953. static CreatePolygon(name: string, options: {
  122954. shape: Vector3[];
  122955. holes?: Vector3[][];
  122956. depth?: number;
  122957. faceUV?: Vector4[];
  122958. faceColors?: Color4[];
  122959. updatable?: boolean;
  122960. sideOrientation?: number;
  122961. frontUVs?: Vector4;
  122962. backUVs?: Vector4;
  122963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122964. /**
  122965. * Creates an extruded polygon mesh, with depth in the Y direction.
  122966. * * 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)
  122967. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122968. * @param name defines the name of the mesh
  122969. * @param options defines the options used to create the mesh
  122970. * @param scene defines the hosting scene
  122971. * @param earcutInjection can be used to inject your own earcut reference
  122972. * @returns the polygon mesh
  122973. */
  122974. static ExtrudePolygon(name: string, options: {
  122975. shape: Vector3[];
  122976. holes?: Vector3[][];
  122977. depth?: number;
  122978. faceUV?: Vector4[];
  122979. faceColors?: Color4[];
  122980. updatable?: boolean;
  122981. sideOrientation?: number;
  122982. frontUVs?: Vector4;
  122983. backUVs?: Vector4;
  122984. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122985. }
  122986. }
  122987. declare module BABYLON {
  122988. /**
  122989. * Class containing static functions to help procedurally build meshes
  122990. */
  122991. export class LatheBuilder {
  122992. /**
  122993. * Creates lathe mesh.
  122994. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122995. * * 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
  122996. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122997. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122998. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122999. * * 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
  123000. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123001. * * 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
  123002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123004. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123006. * @param name defines the name of the mesh
  123007. * @param options defines the options used to create the mesh
  123008. * @param scene defines the hosting scene
  123009. * @returns the lathe mesh
  123010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123011. */
  123012. static CreateLathe(name: string, options: {
  123013. shape: Vector3[];
  123014. radius?: number;
  123015. tessellation?: number;
  123016. clip?: number;
  123017. arc?: number;
  123018. closed?: boolean;
  123019. updatable?: boolean;
  123020. sideOrientation?: number;
  123021. frontUVs?: Vector4;
  123022. backUVs?: Vector4;
  123023. cap?: number;
  123024. invertUV?: boolean;
  123025. }, scene?: Nullable<Scene>): Mesh;
  123026. }
  123027. }
  123028. declare module BABYLON {
  123029. /**
  123030. * Class containing static functions to help procedurally build meshes
  123031. */
  123032. export class TiledPlaneBuilder {
  123033. /**
  123034. * Creates a tiled plane mesh
  123035. * * The parameter `pattern` will, depending on value, do nothing or
  123036. * * * flip (reflect about central vertical) alternate tiles across and up
  123037. * * * flip every tile on alternate rows
  123038. * * * rotate (180 degs) alternate tiles across and up
  123039. * * * rotate every tile on alternate rows
  123040. * * * flip and rotate alternate tiles across and up
  123041. * * * flip and rotate every tile on alternate rows
  123042. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123043. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123044. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123046. * * 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)
  123047. * * 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)
  123048. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123049. * @param name defines the name of the mesh
  123050. * @param options defines the options used to create the mesh
  123051. * @param scene defines the hosting scene
  123052. * @returns the box mesh
  123053. */
  123054. static CreateTiledPlane(name: string, options: {
  123055. pattern?: number;
  123056. tileSize?: number;
  123057. tileWidth?: number;
  123058. tileHeight?: number;
  123059. size?: number;
  123060. width?: number;
  123061. height?: number;
  123062. alignHorizontal?: number;
  123063. alignVertical?: number;
  123064. sideOrientation?: number;
  123065. frontUVs?: Vector4;
  123066. backUVs?: Vector4;
  123067. updatable?: boolean;
  123068. }, scene?: Nullable<Scene>): Mesh;
  123069. }
  123070. }
  123071. declare module BABYLON {
  123072. /**
  123073. * Class containing static functions to help procedurally build meshes
  123074. */
  123075. export class TubeBuilder {
  123076. /**
  123077. * Creates a tube mesh.
  123078. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123079. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123080. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123081. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123082. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123083. * * 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)
  123084. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123085. * * 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
  123086. * * 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
  123087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123091. * @param name defines the name of the mesh
  123092. * @param options defines the options used to create the mesh
  123093. * @param scene defines the hosting scene
  123094. * @returns the tube mesh
  123095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123096. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123097. */
  123098. static CreateTube(name: string, options: {
  123099. path: Vector3[];
  123100. radius?: number;
  123101. tessellation?: number;
  123102. radiusFunction?: {
  123103. (i: number, distance: number): number;
  123104. };
  123105. cap?: number;
  123106. arc?: number;
  123107. updatable?: boolean;
  123108. sideOrientation?: number;
  123109. frontUVs?: Vector4;
  123110. backUVs?: Vector4;
  123111. instance?: Mesh;
  123112. invertUV?: boolean;
  123113. }, scene?: Nullable<Scene>): Mesh;
  123114. }
  123115. }
  123116. declare module BABYLON {
  123117. /**
  123118. * Class containing static functions to help procedurally build meshes
  123119. */
  123120. export class IcoSphereBuilder {
  123121. /**
  123122. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123123. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123124. * * 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`)
  123125. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123126. * * 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
  123127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123130. * @param name defines the name of the mesh
  123131. * @param options defines the options used to create the mesh
  123132. * @param scene defines the hosting scene
  123133. * @returns the icosahedron mesh
  123134. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123135. */
  123136. static CreateIcoSphere(name: string, options: {
  123137. radius?: number;
  123138. radiusX?: number;
  123139. radiusY?: number;
  123140. radiusZ?: number;
  123141. flat?: boolean;
  123142. subdivisions?: number;
  123143. sideOrientation?: number;
  123144. frontUVs?: Vector4;
  123145. backUVs?: Vector4;
  123146. updatable?: boolean;
  123147. }, scene?: Nullable<Scene>): Mesh;
  123148. }
  123149. }
  123150. declare module BABYLON {
  123151. /**
  123152. * Class containing static functions to help procedurally build meshes
  123153. */
  123154. export class DecalBuilder {
  123155. /**
  123156. * Creates a decal mesh.
  123157. * 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
  123158. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123159. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123160. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123161. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123162. * @param name defines the name of the mesh
  123163. * @param sourceMesh defines the mesh where the decal must be applied
  123164. * @param options defines the options used to create the mesh
  123165. * @param scene defines the hosting scene
  123166. * @returns the decal mesh
  123167. * @see https://doc.babylonjs.com/how_to/decals
  123168. */
  123169. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123170. position?: Vector3;
  123171. normal?: Vector3;
  123172. size?: Vector3;
  123173. angle?: number;
  123174. }): Mesh;
  123175. }
  123176. }
  123177. declare module BABYLON {
  123178. /**
  123179. * Class containing static functions to help procedurally build meshes
  123180. */
  123181. export class MeshBuilder {
  123182. /**
  123183. * Creates a box mesh
  123184. * * The parameter `size` sets the size (float) of each box side (default 1)
  123185. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123186. * * 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)
  123187. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123191. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123192. * @param name defines the name of the mesh
  123193. * @param options defines the options used to create the mesh
  123194. * @param scene defines the hosting scene
  123195. * @returns the box mesh
  123196. */
  123197. static CreateBox(name: string, options: {
  123198. size?: number;
  123199. width?: number;
  123200. height?: number;
  123201. depth?: number;
  123202. faceUV?: Vector4[];
  123203. faceColors?: Color4[];
  123204. sideOrientation?: number;
  123205. frontUVs?: Vector4;
  123206. backUVs?: Vector4;
  123207. updatable?: boolean;
  123208. }, scene?: Nullable<Scene>): Mesh;
  123209. /**
  123210. * Creates a tiled box mesh
  123211. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123213. * @param name defines the name of the mesh
  123214. * @param options defines the options used to create the mesh
  123215. * @param scene defines the hosting scene
  123216. * @returns the tiled box mesh
  123217. */
  123218. static CreateTiledBox(name: string, options: {
  123219. pattern?: number;
  123220. size?: number;
  123221. width?: number;
  123222. height?: number;
  123223. depth: number;
  123224. tileSize?: number;
  123225. tileWidth?: number;
  123226. tileHeight?: number;
  123227. faceUV?: Vector4[];
  123228. faceColors?: Color4[];
  123229. alignHorizontal?: number;
  123230. alignVertical?: number;
  123231. sideOrientation?: number;
  123232. updatable?: boolean;
  123233. }, scene?: Nullable<Scene>): Mesh;
  123234. /**
  123235. * Creates a sphere mesh
  123236. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123237. * * 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`)
  123238. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123239. * * 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
  123240. * * 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)
  123241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123244. * @param name defines the name of the mesh
  123245. * @param options defines the options used to create the mesh
  123246. * @param scene defines the hosting scene
  123247. * @returns the sphere mesh
  123248. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123249. */
  123250. static CreateSphere(name: string, options: {
  123251. segments?: number;
  123252. diameter?: number;
  123253. diameterX?: number;
  123254. diameterY?: number;
  123255. diameterZ?: number;
  123256. arc?: number;
  123257. slice?: number;
  123258. sideOrientation?: number;
  123259. frontUVs?: Vector4;
  123260. backUVs?: Vector4;
  123261. updatable?: boolean;
  123262. }, scene?: Nullable<Scene>): Mesh;
  123263. /**
  123264. * Creates a plane polygonal mesh. By default, this is a disc
  123265. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123266. * * 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
  123267. * * 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
  123268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123271. * @param name defines the name of the mesh
  123272. * @param options defines the options used to create the mesh
  123273. * @param scene defines the hosting scene
  123274. * @returns the plane polygonal mesh
  123275. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123276. */
  123277. static CreateDisc(name: string, options: {
  123278. radius?: number;
  123279. tessellation?: number;
  123280. arc?: number;
  123281. updatable?: boolean;
  123282. sideOrientation?: number;
  123283. frontUVs?: Vector4;
  123284. backUVs?: Vector4;
  123285. }, scene?: Nullable<Scene>): Mesh;
  123286. /**
  123287. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123288. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123289. * * 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`)
  123290. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123291. * * 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
  123292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123295. * @param name defines the name of the mesh
  123296. * @param options defines the options used to create the mesh
  123297. * @param scene defines the hosting scene
  123298. * @returns the icosahedron mesh
  123299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123300. */
  123301. static CreateIcoSphere(name: string, options: {
  123302. radius?: number;
  123303. radiusX?: number;
  123304. radiusY?: number;
  123305. radiusZ?: number;
  123306. flat?: boolean;
  123307. subdivisions?: number;
  123308. sideOrientation?: number;
  123309. frontUVs?: Vector4;
  123310. backUVs?: Vector4;
  123311. updatable?: boolean;
  123312. }, scene?: Nullable<Scene>): Mesh;
  123313. /**
  123314. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123315. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123316. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123317. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123318. * * 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
  123319. * * 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
  123320. * * 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
  123321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123324. * * 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
  123325. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123326. * * 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
  123327. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123329. * @param name defines the name of the mesh
  123330. * @param options defines the options used to create the mesh
  123331. * @param scene defines the hosting scene
  123332. * @returns the ribbon mesh
  123333. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123335. */
  123336. static CreateRibbon(name: string, options: {
  123337. pathArray: Vector3[][];
  123338. closeArray?: boolean;
  123339. closePath?: boolean;
  123340. offset?: number;
  123341. updatable?: boolean;
  123342. sideOrientation?: number;
  123343. frontUVs?: Vector4;
  123344. backUVs?: Vector4;
  123345. instance?: Mesh;
  123346. invertUV?: boolean;
  123347. uvs?: Vector2[];
  123348. colors?: Color4[];
  123349. }, scene?: Nullable<Scene>): Mesh;
  123350. /**
  123351. * Creates a cylinder or a cone mesh
  123352. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123353. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123354. * * 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.
  123355. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123356. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123357. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123358. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123359. * * 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).
  123360. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123361. * * 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).
  123362. * * 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
  123363. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123364. * * 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
  123365. * * 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.
  123366. * * If `enclose` is false, a ring surface is one element.
  123367. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123368. * * 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
  123369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123372. * @param name defines the name of the mesh
  123373. * @param options defines the options used to create the mesh
  123374. * @param scene defines the hosting scene
  123375. * @returns the cylinder mesh
  123376. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123377. */
  123378. static CreateCylinder(name: string, options: {
  123379. height?: number;
  123380. diameterTop?: number;
  123381. diameterBottom?: number;
  123382. diameter?: number;
  123383. tessellation?: number;
  123384. subdivisions?: number;
  123385. arc?: number;
  123386. faceColors?: Color4[];
  123387. faceUV?: Vector4[];
  123388. updatable?: boolean;
  123389. hasRings?: boolean;
  123390. enclose?: boolean;
  123391. cap?: number;
  123392. sideOrientation?: number;
  123393. frontUVs?: Vector4;
  123394. backUVs?: Vector4;
  123395. }, scene?: Nullable<Scene>): Mesh;
  123396. /**
  123397. * Creates a torus mesh
  123398. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123399. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123400. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123404. * @param name defines the name of the mesh
  123405. * @param options defines the options used to create the mesh
  123406. * @param scene defines the hosting scene
  123407. * @returns the torus mesh
  123408. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123409. */
  123410. static CreateTorus(name: string, options: {
  123411. diameter?: number;
  123412. thickness?: number;
  123413. tessellation?: number;
  123414. updatable?: boolean;
  123415. sideOrientation?: number;
  123416. frontUVs?: Vector4;
  123417. backUVs?: Vector4;
  123418. }, scene?: Nullable<Scene>): Mesh;
  123419. /**
  123420. * Creates a torus knot mesh
  123421. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123422. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123423. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123424. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123428. * @param name defines the name of the mesh
  123429. * @param options defines the options used to create the mesh
  123430. * @param scene defines the hosting scene
  123431. * @returns the torus knot mesh
  123432. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123433. */
  123434. static CreateTorusKnot(name: string, options: {
  123435. radius?: number;
  123436. tube?: number;
  123437. radialSegments?: number;
  123438. tubularSegments?: number;
  123439. p?: number;
  123440. q?: number;
  123441. updatable?: boolean;
  123442. sideOrientation?: number;
  123443. frontUVs?: Vector4;
  123444. backUVs?: Vector4;
  123445. }, scene?: Nullable<Scene>): Mesh;
  123446. /**
  123447. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123448. * * 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
  123449. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123450. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123451. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123452. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123453. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123454. * * 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
  123455. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123458. * @param name defines the name of the new line system
  123459. * @param options defines the options used to create the line system
  123460. * @param scene defines the hosting scene
  123461. * @returns a new line system mesh
  123462. */
  123463. static CreateLineSystem(name: string, options: {
  123464. lines: Vector3[][];
  123465. updatable?: boolean;
  123466. instance?: Nullable<LinesMesh>;
  123467. colors?: Nullable<Color4[][]>;
  123468. useVertexAlpha?: boolean;
  123469. }, scene: Nullable<Scene>): LinesMesh;
  123470. /**
  123471. * Creates a line mesh
  123472. * 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
  123473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123474. * * The parameter `points` is an array successive Vector3
  123475. * * 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
  123476. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123477. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123478. * * When updating an instance, remember that only point positions can change, not the number of points
  123479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123480. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123481. * @param name defines the name of the new line system
  123482. * @param options defines the options used to create the line system
  123483. * @param scene defines the hosting scene
  123484. * @returns a new line mesh
  123485. */
  123486. static CreateLines(name: string, options: {
  123487. points: Vector3[];
  123488. updatable?: boolean;
  123489. instance?: Nullable<LinesMesh>;
  123490. colors?: Color4[];
  123491. useVertexAlpha?: boolean;
  123492. }, scene?: Nullable<Scene>): LinesMesh;
  123493. /**
  123494. * Creates a dashed line mesh
  123495. * * 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
  123496. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123497. * * The parameter `points` is an array successive Vector3
  123498. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123499. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123500. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123501. * * 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
  123502. * * When updating an instance, remember that only point positions can change, not the number of points
  123503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123504. * @param name defines the name of the mesh
  123505. * @param options defines the options used to create the mesh
  123506. * @param scene defines the hosting scene
  123507. * @returns the dashed line mesh
  123508. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123509. */
  123510. static CreateDashedLines(name: string, options: {
  123511. points: Vector3[];
  123512. dashSize?: number;
  123513. gapSize?: number;
  123514. dashNb?: number;
  123515. updatable?: boolean;
  123516. instance?: LinesMesh;
  123517. }, scene?: Nullable<Scene>): LinesMesh;
  123518. /**
  123519. * 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.
  123520. * * 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.
  123521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123522. * * 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.
  123523. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123524. * * 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
  123525. * * 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
  123526. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123529. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123531. * @param name defines the name of the mesh
  123532. * @param options defines the options used to create the mesh
  123533. * @param scene defines the hosting scene
  123534. * @returns the extruded shape mesh
  123535. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123537. */
  123538. static ExtrudeShape(name: string, options: {
  123539. shape: Vector3[];
  123540. path: Vector3[];
  123541. scale?: number;
  123542. rotation?: number;
  123543. cap?: number;
  123544. updatable?: boolean;
  123545. sideOrientation?: number;
  123546. frontUVs?: Vector4;
  123547. backUVs?: Vector4;
  123548. instance?: Mesh;
  123549. invertUV?: boolean;
  123550. }, scene?: Nullable<Scene>): Mesh;
  123551. /**
  123552. * Creates an custom extruded shape mesh.
  123553. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123554. * * 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.
  123555. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123556. * * 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
  123557. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123558. * * 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
  123559. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123560. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123561. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123562. * * 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
  123563. * * 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
  123564. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123567. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123569. * @param name defines the name of the mesh
  123570. * @param options defines the options used to create the mesh
  123571. * @param scene defines the hosting scene
  123572. * @returns the custom extruded shape mesh
  123573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123574. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123576. */
  123577. static ExtrudeShapeCustom(name: string, options: {
  123578. shape: Vector3[];
  123579. path: Vector3[];
  123580. scaleFunction?: any;
  123581. rotationFunction?: any;
  123582. ribbonCloseArray?: boolean;
  123583. ribbonClosePath?: boolean;
  123584. cap?: number;
  123585. updatable?: boolean;
  123586. sideOrientation?: number;
  123587. frontUVs?: Vector4;
  123588. backUVs?: Vector4;
  123589. instance?: Mesh;
  123590. invertUV?: boolean;
  123591. }, scene?: Nullable<Scene>): Mesh;
  123592. /**
  123593. * Creates lathe mesh.
  123594. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123595. * * 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
  123596. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123597. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123598. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123599. * * 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
  123600. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123601. * * 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
  123602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123606. * @param name defines the name of the mesh
  123607. * @param options defines the options used to create the mesh
  123608. * @param scene defines the hosting scene
  123609. * @returns the lathe mesh
  123610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123611. */
  123612. static CreateLathe(name: string, options: {
  123613. shape: Vector3[];
  123614. radius?: number;
  123615. tessellation?: number;
  123616. clip?: number;
  123617. arc?: number;
  123618. closed?: boolean;
  123619. updatable?: boolean;
  123620. sideOrientation?: number;
  123621. frontUVs?: Vector4;
  123622. backUVs?: Vector4;
  123623. cap?: number;
  123624. invertUV?: boolean;
  123625. }, scene?: Nullable<Scene>): Mesh;
  123626. /**
  123627. * Creates a tiled plane mesh
  123628. * * You can set a limited pattern arrangement with the tiles
  123629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123632. * @param name defines the name of the mesh
  123633. * @param options defines the options used to create the mesh
  123634. * @param scene defines the hosting scene
  123635. * @returns the plane mesh
  123636. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123637. */
  123638. static CreateTiledPlane(name: string, options: {
  123639. pattern?: number;
  123640. tileSize?: number;
  123641. tileWidth?: number;
  123642. tileHeight?: number;
  123643. size?: number;
  123644. width?: number;
  123645. height?: number;
  123646. alignHorizontal?: number;
  123647. alignVertical?: number;
  123648. sideOrientation?: number;
  123649. frontUVs?: Vector4;
  123650. backUVs?: Vector4;
  123651. updatable?: boolean;
  123652. }, scene?: Nullable<Scene>): Mesh;
  123653. /**
  123654. * Creates a plane mesh
  123655. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123656. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123657. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123659. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123661. * @param name defines the name of the mesh
  123662. * @param options defines the options used to create the mesh
  123663. * @param scene defines the hosting scene
  123664. * @returns the plane mesh
  123665. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123666. */
  123667. static CreatePlane(name: string, options: {
  123668. size?: number;
  123669. width?: number;
  123670. height?: number;
  123671. sideOrientation?: number;
  123672. frontUVs?: Vector4;
  123673. backUVs?: Vector4;
  123674. updatable?: boolean;
  123675. sourcePlane?: Plane;
  123676. }, scene?: Nullable<Scene>): Mesh;
  123677. /**
  123678. * Creates a ground mesh
  123679. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123680. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123682. * @param name defines the name of the mesh
  123683. * @param options defines the options used to create the mesh
  123684. * @param scene defines the hosting scene
  123685. * @returns the ground mesh
  123686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123687. */
  123688. static CreateGround(name: string, options: {
  123689. width?: number;
  123690. height?: number;
  123691. subdivisions?: number;
  123692. subdivisionsX?: number;
  123693. subdivisionsY?: number;
  123694. updatable?: boolean;
  123695. }, scene?: Nullable<Scene>): Mesh;
  123696. /**
  123697. * Creates a tiled ground mesh
  123698. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123699. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123700. * * 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
  123701. * * 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
  123702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123703. * @param name defines the name of the mesh
  123704. * @param options defines the options used to create the mesh
  123705. * @param scene defines the hosting scene
  123706. * @returns the tiled ground mesh
  123707. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123708. */
  123709. static CreateTiledGround(name: string, options: {
  123710. xmin: number;
  123711. zmin: number;
  123712. xmax: number;
  123713. zmax: number;
  123714. subdivisions?: {
  123715. w: number;
  123716. h: number;
  123717. };
  123718. precision?: {
  123719. w: number;
  123720. h: number;
  123721. };
  123722. updatable?: boolean;
  123723. }, scene?: Nullable<Scene>): Mesh;
  123724. /**
  123725. * Creates a ground mesh from a height map
  123726. * * The parameter `url` sets the URL of the height map image resource.
  123727. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123728. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123729. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123730. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123731. * * 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.
  123732. * * 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).
  123733. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123735. * @param name defines the name of the mesh
  123736. * @param url defines the url to the height map
  123737. * @param options defines the options used to create the mesh
  123738. * @param scene defines the hosting scene
  123739. * @returns the ground mesh
  123740. * @see https://doc.babylonjs.com/babylon101/height_map
  123741. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123742. */
  123743. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123744. width?: number;
  123745. height?: number;
  123746. subdivisions?: number;
  123747. minHeight?: number;
  123748. maxHeight?: number;
  123749. colorFilter?: Color3;
  123750. alphaFilter?: number;
  123751. updatable?: boolean;
  123752. onReady?: (mesh: GroundMesh) => void;
  123753. }, scene?: Nullable<Scene>): GroundMesh;
  123754. /**
  123755. * Creates a polygon mesh
  123756. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123757. * * 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
  123758. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123761. * * Remember you can only change the shape positions, not their number when updating a polygon
  123762. * @param name defines the name of the mesh
  123763. * @param options defines the options used to create the mesh
  123764. * @param scene defines the hosting scene
  123765. * @param earcutInjection can be used to inject your own earcut reference
  123766. * @returns the polygon mesh
  123767. */
  123768. static CreatePolygon(name: string, options: {
  123769. shape: Vector3[];
  123770. holes?: Vector3[][];
  123771. depth?: number;
  123772. faceUV?: Vector4[];
  123773. faceColors?: Color4[];
  123774. updatable?: boolean;
  123775. sideOrientation?: number;
  123776. frontUVs?: Vector4;
  123777. backUVs?: Vector4;
  123778. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123779. /**
  123780. * Creates an extruded polygon mesh, with depth in the Y direction.
  123781. * * 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)
  123782. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123783. * @param name defines the name of the mesh
  123784. * @param options defines the options used to create the mesh
  123785. * @param scene defines the hosting scene
  123786. * @param earcutInjection can be used to inject your own earcut reference
  123787. * @returns the polygon mesh
  123788. */
  123789. static ExtrudePolygon(name: string, options: {
  123790. shape: Vector3[];
  123791. holes?: Vector3[][];
  123792. depth?: number;
  123793. faceUV?: Vector4[];
  123794. faceColors?: Color4[];
  123795. updatable?: boolean;
  123796. sideOrientation?: number;
  123797. frontUVs?: Vector4;
  123798. backUVs?: Vector4;
  123799. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123800. /**
  123801. * Creates a tube mesh.
  123802. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123803. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123804. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123805. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123806. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123807. * * 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)
  123808. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123809. * * 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
  123810. * * 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
  123811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123815. * @param name defines the name of the mesh
  123816. * @param options defines the options used to create the mesh
  123817. * @param scene defines the hosting scene
  123818. * @returns the tube mesh
  123819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123820. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123821. */
  123822. static CreateTube(name: string, options: {
  123823. path: Vector3[];
  123824. radius?: number;
  123825. tessellation?: number;
  123826. radiusFunction?: {
  123827. (i: number, distance: number): number;
  123828. };
  123829. cap?: number;
  123830. arc?: number;
  123831. updatable?: boolean;
  123832. sideOrientation?: number;
  123833. frontUVs?: Vector4;
  123834. backUVs?: Vector4;
  123835. instance?: Mesh;
  123836. invertUV?: boolean;
  123837. }, scene?: Nullable<Scene>): Mesh;
  123838. /**
  123839. * Creates a polyhedron mesh
  123840. * * 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
  123841. * * The parameter `size` (positive float, default 1) sets the polygon size
  123842. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123843. * * 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`
  123844. * * 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
  123845. * * 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)`)
  123846. * * 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
  123847. * * 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
  123848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123851. * @param name defines the name of the mesh
  123852. * @param options defines the options used to create the mesh
  123853. * @param scene defines the hosting scene
  123854. * @returns the polyhedron mesh
  123855. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123856. */
  123857. static CreatePolyhedron(name: string, options: {
  123858. type?: number;
  123859. size?: number;
  123860. sizeX?: number;
  123861. sizeY?: number;
  123862. sizeZ?: number;
  123863. custom?: any;
  123864. faceUV?: Vector4[];
  123865. faceColors?: Color4[];
  123866. flat?: boolean;
  123867. updatable?: boolean;
  123868. sideOrientation?: number;
  123869. frontUVs?: Vector4;
  123870. backUVs?: Vector4;
  123871. }, scene?: Nullable<Scene>): Mesh;
  123872. /**
  123873. * Creates a decal mesh.
  123874. * 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
  123875. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123876. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123877. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123878. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123879. * @param name defines the name of the mesh
  123880. * @param sourceMesh defines the mesh where the decal must be applied
  123881. * @param options defines the options used to create the mesh
  123882. * @param scene defines the hosting scene
  123883. * @returns the decal mesh
  123884. * @see https://doc.babylonjs.com/how_to/decals
  123885. */
  123886. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123887. position?: Vector3;
  123888. normal?: Vector3;
  123889. size?: Vector3;
  123890. angle?: number;
  123891. }): Mesh;
  123892. }
  123893. }
  123894. declare module BABYLON {
  123895. /**
  123896. * A simplifier interface for future simplification implementations
  123897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123898. */
  123899. export interface ISimplifier {
  123900. /**
  123901. * Simplification of a given mesh according to the given settings.
  123902. * Since this requires computation, it is assumed that the function runs async.
  123903. * @param settings The settings of the simplification, including quality and distance
  123904. * @param successCallback A callback that will be called after the mesh was simplified.
  123905. * @param errorCallback in case of an error, this callback will be called. optional.
  123906. */
  123907. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123908. }
  123909. /**
  123910. * Expected simplification settings.
  123911. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123912. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123913. */
  123914. export interface ISimplificationSettings {
  123915. /**
  123916. * Gets or sets the expected quality
  123917. */
  123918. quality: number;
  123919. /**
  123920. * Gets or sets the distance when this optimized version should be used
  123921. */
  123922. distance: number;
  123923. /**
  123924. * Gets an already optimized mesh
  123925. */
  123926. optimizeMesh?: boolean;
  123927. }
  123928. /**
  123929. * Class used to specify simplification options
  123930. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123931. */
  123932. export class SimplificationSettings implements ISimplificationSettings {
  123933. /** expected quality */
  123934. quality: number;
  123935. /** distance when this optimized version should be used */
  123936. distance: number;
  123937. /** already optimized mesh */
  123938. optimizeMesh?: boolean | undefined;
  123939. /**
  123940. * Creates a SimplificationSettings
  123941. * @param quality expected quality
  123942. * @param distance distance when this optimized version should be used
  123943. * @param optimizeMesh already optimized mesh
  123944. */
  123945. constructor(
  123946. /** expected quality */
  123947. quality: number,
  123948. /** distance when this optimized version should be used */
  123949. distance: number,
  123950. /** already optimized mesh */
  123951. optimizeMesh?: boolean | undefined);
  123952. }
  123953. /**
  123954. * Interface used to define a simplification task
  123955. */
  123956. export interface ISimplificationTask {
  123957. /**
  123958. * Array of settings
  123959. */
  123960. settings: Array<ISimplificationSettings>;
  123961. /**
  123962. * Simplification type
  123963. */
  123964. simplificationType: SimplificationType;
  123965. /**
  123966. * Mesh to simplify
  123967. */
  123968. mesh: Mesh;
  123969. /**
  123970. * Callback called on success
  123971. */
  123972. successCallback?: () => void;
  123973. /**
  123974. * Defines if parallel processing can be used
  123975. */
  123976. parallelProcessing: boolean;
  123977. }
  123978. /**
  123979. * Queue used to order the simplification tasks
  123980. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123981. */
  123982. export class SimplificationQueue {
  123983. private _simplificationArray;
  123984. /**
  123985. * Gets a boolean indicating that the process is still running
  123986. */
  123987. running: boolean;
  123988. /**
  123989. * Creates a new queue
  123990. */
  123991. constructor();
  123992. /**
  123993. * Adds a new simplification task
  123994. * @param task defines a task to add
  123995. */
  123996. addTask(task: ISimplificationTask): void;
  123997. /**
  123998. * Execute next task
  123999. */
  124000. executeNext(): void;
  124001. /**
  124002. * Execute a simplification task
  124003. * @param task defines the task to run
  124004. */
  124005. runSimplification(task: ISimplificationTask): void;
  124006. private getSimplifier;
  124007. }
  124008. /**
  124009. * The implemented types of simplification
  124010. * At the moment only Quadratic Error Decimation is implemented
  124011. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124012. */
  124013. export enum SimplificationType {
  124014. /** Quadratic error decimation */
  124015. QUADRATIC = 0
  124016. }
  124017. }
  124018. declare module BABYLON {
  124019. interface Scene {
  124020. /** @hidden (Backing field) */
  124021. _simplificationQueue: SimplificationQueue;
  124022. /**
  124023. * Gets or sets the simplification queue attached to the scene
  124024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124025. */
  124026. simplificationQueue: SimplificationQueue;
  124027. }
  124028. interface Mesh {
  124029. /**
  124030. * Simplify the mesh according to the given array of settings.
  124031. * Function will return immediately and will simplify async
  124032. * @param settings a collection of simplification settings
  124033. * @param parallelProcessing should all levels calculate parallel or one after the other
  124034. * @param simplificationType the type of simplification to run
  124035. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124036. * @returns the current mesh
  124037. */
  124038. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124039. }
  124040. /**
  124041. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124042. * created in a scene
  124043. */
  124044. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124045. /**
  124046. * The component name helpfull to identify the component in the list of scene components.
  124047. */
  124048. readonly name: string;
  124049. /**
  124050. * The scene the component belongs to.
  124051. */
  124052. scene: Scene;
  124053. /**
  124054. * Creates a new instance of the component for the given scene
  124055. * @param scene Defines the scene to register the component in
  124056. */
  124057. constructor(scene: Scene);
  124058. /**
  124059. * Registers the component in a given scene
  124060. */
  124061. register(): void;
  124062. /**
  124063. * Rebuilds the elements related to this component in case of
  124064. * context lost for instance.
  124065. */
  124066. rebuild(): void;
  124067. /**
  124068. * Disposes the component and the associated ressources
  124069. */
  124070. dispose(): void;
  124071. private _beforeCameraUpdate;
  124072. }
  124073. }
  124074. declare module BABYLON {
  124075. /**
  124076. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124077. */
  124078. export interface INavigationEnginePlugin {
  124079. /**
  124080. * plugin name
  124081. */
  124082. name: string;
  124083. /**
  124084. * Creates a navigation mesh
  124085. * @param meshes array of all the geometry used to compute the navigatio mesh
  124086. * @param parameters bunch of parameters used to filter geometry
  124087. */
  124088. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124089. /**
  124090. * Create a navigation mesh debug mesh
  124091. * @param scene is where the mesh will be added
  124092. * @returns debug display mesh
  124093. */
  124094. createDebugNavMesh(scene: Scene): Mesh;
  124095. /**
  124096. * Get a navigation mesh constrained position, closest to the parameter position
  124097. * @param position world position
  124098. * @returns the closest point to position constrained by the navigation mesh
  124099. */
  124100. getClosestPoint(position: Vector3): Vector3;
  124101. /**
  124102. * Get a navigation mesh constrained position, within a particular radius
  124103. * @param position world position
  124104. * @param maxRadius the maximum distance to the constrained world position
  124105. * @returns the closest point to position constrained by the navigation mesh
  124106. */
  124107. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124108. /**
  124109. * Compute the final position from a segment made of destination-position
  124110. * @param position world position
  124111. * @param destination world position
  124112. * @returns the resulting point along the navmesh
  124113. */
  124114. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124115. /**
  124116. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124117. * @param start world position
  124118. * @param end world position
  124119. * @returns array containing world position composing the path
  124120. */
  124121. computePath(start: Vector3, end: Vector3): Vector3[];
  124122. /**
  124123. * If this plugin is supported
  124124. * @returns true if plugin is supported
  124125. */
  124126. isSupported(): boolean;
  124127. /**
  124128. * Create a new Crowd so you can add agents
  124129. * @param maxAgents the maximum agent count in the crowd
  124130. * @param maxAgentRadius the maximum radius an agent can have
  124131. * @param scene to attach the crowd to
  124132. * @returns the crowd you can add agents to
  124133. */
  124134. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124135. /**
  124136. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124137. * The queries will try to find a solution within those bounds
  124138. * default is (1,1,1)
  124139. * @param extent x,y,z value that define the extent around the queries point of reference
  124140. */
  124141. setDefaultQueryExtent(extent: Vector3): void;
  124142. /**
  124143. * Get the Bounding box extent specified by setDefaultQueryExtent
  124144. * @returns the box extent values
  124145. */
  124146. getDefaultQueryExtent(): Vector3;
  124147. /**
  124148. * Release all resources
  124149. */
  124150. dispose(): void;
  124151. }
  124152. /**
  124153. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124154. */
  124155. export interface ICrowd {
  124156. /**
  124157. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124158. * You can attach anything to that node. The node position is updated in the scene update tick.
  124159. * @param pos world position that will be constrained by the navigation mesh
  124160. * @param parameters agent parameters
  124161. * @param transform hooked to the agent that will be update by the scene
  124162. * @returns agent index
  124163. */
  124164. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124165. /**
  124166. * Returns the agent position in world space
  124167. * @param index agent index returned by addAgent
  124168. * @returns world space position
  124169. */
  124170. getAgentPosition(index: number): Vector3;
  124171. /**
  124172. * Gets the agent velocity in world space
  124173. * @param index agent index returned by addAgent
  124174. * @returns world space velocity
  124175. */
  124176. getAgentVelocity(index: number): Vector3;
  124177. /**
  124178. * remove a particular agent previously created
  124179. * @param index agent index returned by addAgent
  124180. */
  124181. removeAgent(index: number): void;
  124182. /**
  124183. * get the list of all agents attached to this crowd
  124184. * @returns list of agent indices
  124185. */
  124186. getAgents(): number[];
  124187. /**
  124188. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124189. * @param deltaTime in seconds
  124190. */
  124191. update(deltaTime: number): void;
  124192. /**
  124193. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124194. * @param index agent index returned by addAgent
  124195. * @param destination targeted world position
  124196. */
  124197. agentGoto(index: number, destination: Vector3): void;
  124198. /**
  124199. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124200. * The queries will try to find a solution within those bounds
  124201. * default is (1,1,1)
  124202. * @param extent x,y,z value that define the extent around the queries point of reference
  124203. */
  124204. setDefaultQueryExtent(extent: Vector3): void;
  124205. /**
  124206. * Get the Bounding box extent specified by setDefaultQueryExtent
  124207. * @returns the box extent values
  124208. */
  124209. getDefaultQueryExtent(): Vector3;
  124210. /**
  124211. * Release all resources
  124212. */
  124213. dispose(): void;
  124214. }
  124215. /**
  124216. * Configures an agent
  124217. */
  124218. export interface IAgentParameters {
  124219. /**
  124220. * Agent radius. [Limit: >= 0]
  124221. */
  124222. radius: number;
  124223. /**
  124224. * Agent height. [Limit: > 0]
  124225. */
  124226. height: number;
  124227. /**
  124228. * Maximum allowed acceleration. [Limit: >= 0]
  124229. */
  124230. maxAcceleration: number;
  124231. /**
  124232. * Maximum allowed speed. [Limit: >= 0]
  124233. */
  124234. maxSpeed: number;
  124235. /**
  124236. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124237. */
  124238. collisionQueryRange: number;
  124239. /**
  124240. * The path visibility optimization range. [Limit: > 0]
  124241. */
  124242. pathOptimizationRange: number;
  124243. /**
  124244. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124245. */
  124246. separationWeight: number;
  124247. }
  124248. /**
  124249. * Configures the navigation mesh creation
  124250. */
  124251. export interface INavMeshParameters {
  124252. /**
  124253. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124254. */
  124255. cs: number;
  124256. /**
  124257. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124258. */
  124259. ch: number;
  124260. /**
  124261. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124262. */
  124263. walkableSlopeAngle: number;
  124264. /**
  124265. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124266. * be considered walkable. [Limit: >= 3] [Units: vx]
  124267. */
  124268. walkableHeight: number;
  124269. /**
  124270. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124271. */
  124272. walkableClimb: number;
  124273. /**
  124274. * The distance to erode/shrink the walkable area of the heightfield away from
  124275. * obstructions. [Limit: >=0] [Units: vx]
  124276. */
  124277. walkableRadius: number;
  124278. /**
  124279. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124280. */
  124281. maxEdgeLen: number;
  124282. /**
  124283. * The maximum distance a simplfied contour's border edges should deviate
  124284. * the original raw contour. [Limit: >=0] [Units: vx]
  124285. */
  124286. maxSimplificationError: number;
  124287. /**
  124288. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124289. */
  124290. minRegionArea: number;
  124291. /**
  124292. * Any regions with a span count smaller than this value will, if possible,
  124293. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124294. */
  124295. mergeRegionArea: number;
  124296. /**
  124297. * The maximum number of vertices allowed for polygons generated during the
  124298. * contour to polygon conversion process. [Limit: >= 3]
  124299. */
  124300. maxVertsPerPoly: number;
  124301. /**
  124302. * Sets the sampling distance to use when generating the detail mesh.
  124303. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124304. */
  124305. detailSampleDist: number;
  124306. /**
  124307. * The maximum distance the detail mesh surface should deviate from heightfield
  124308. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124309. */
  124310. detailSampleMaxError: number;
  124311. }
  124312. }
  124313. declare module BABYLON {
  124314. /**
  124315. * RecastJS navigation plugin
  124316. */
  124317. export class RecastJSPlugin implements INavigationEnginePlugin {
  124318. /**
  124319. * Reference to the Recast library
  124320. */
  124321. bjsRECAST: any;
  124322. /**
  124323. * plugin name
  124324. */
  124325. name: string;
  124326. /**
  124327. * the first navmesh created. We might extend this to support multiple navmeshes
  124328. */
  124329. navMesh: any;
  124330. /**
  124331. * Initializes the recastJS plugin
  124332. * @param recastInjection can be used to inject your own recast reference
  124333. */
  124334. constructor(recastInjection?: any);
  124335. /**
  124336. * Creates a navigation mesh
  124337. * @param meshes array of all the geometry used to compute the navigatio mesh
  124338. * @param parameters bunch of parameters used to filter geometry
  124339. */
  124340. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124341. /**
  124342. * Create a navigation mesh debug mesh
  124343. * @param scene is where the mesh will be added
  124344. * @returns debug display mesh
  124345. */
  124346. createDebugNavMesh(scene: Scene): Mesh;
  124347. /**
  124348. * Get a navigation mesh constrained position, closest to the parameter position
  124349. * @param position world position
  124350. * @returns the closest point to position constrained by the navigation mesh
  124351. */
  124352. getClosestPoint(position: Vector3): Vector3;
  124353. /**
  124354. * Get a navigation mesh constrained position, within a particular radius
  124355. * @param position world position
  124356. * @param maxRadius the maximum distance to the constrained world position
  124357. * @returns the closest point to position constrained by the navigation mesh
  124358. */
  124359. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124360. /**
  124361. * Compute the final position from a segment made of destination-position
  124362. * @param position world position
  124363. * @param destination world position
  124364. * @returns the resulting point along the navmesh
  124365. */
  124366. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124367. /**
  124368. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124369. * @param start world position
  124370. * @param end world position
  124371. * @returns array containing world position composing the path
  124372. */
  124373. computePath(start: Vector3, end: Vector3): Vector3[];
  124374. /**
  124375. * Create a new Crowd so you can add agents
  124376. * @param maxAgents the maximum agent count in the crowd
  124377. * @param maxAgentRadius the maximum radius an agent can have
  124378. * @param scene to attach the crowd to
  124379. * @returns the crowd you can add agents to
  124380. */
  124381. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124382. /**
  124383. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124384. * The queries will try to find a solution within those bounds
  124385. * default is (1,1,1)
  124386. * @param extent x,y,z value that define the extent around the queries point of reference
  124387. */
  124388. setDefaultQueryExtent(extent: Vector3): void;
  124389. /**
  124390. * Get the Bounding box extent specified by setDefaultQueryExtent
  124391. * @returns the box extent values
  124392. */
  124393. getDefaultQueryExtent(): Vector3;
  124394. /**
  124395. * Disposes
  124396. */
  124397. dispose(): void;
  124398. /**
  124399. * If this plugin is supported
  124400. * @returns true if plugin is supported
  124401. */
  124402. isSupported(): boolean;
  124403. }
  124404. /**
  124405. * Recast detour crowd implementation
  124406. */
  124407. export class RecastJSCrowd implements ICrowd {
  124408. /**
  124409. * Recast/detour plugin
  124410. */
  124411. bjsRECASTPlugin: RecastJSPlugin;
  124412. /**
  124413. * Link to the detour crowd
  124414. */
  124415. recastCrowd: any;
  124416. /**
  124417. * One transform per agent
  124418. */
  124419. transforms: TransformNode[];
  124420. /**
  124421. * All agents created
  124422. */
  124423. agents: number[];
  124424. /**
  124425. * Link to the scene is kept to unregister the crowd from the scene
  124426. */
  124427. private _scene;
  124428. /**
  124429. * Observer for crowd updates
  124430. */
  124431. private _onBeforeAnimationsObserver;
  124432. /**
  124433. * Constructor
  124434. * @param plugin recastJS plugin
  124435. * @param maxAgents the maximum agent count in the crowd
  124436. * @param maxAgentRadius the maximum radius an agent can have
  124437. * @param scene to attach the crowd to
  124438. * @returns the crowd you can add agents to
  124439. */
  124440. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124441. /**
  124442. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124443. * You can attach anything to that node. The node position is updated in the scene update tick.
  124444. * @param pos world position that will be constrained by the navigation mesh
  124445. * @param parameters agent parameters
  124446. * @param transform hooked to the agent that will be update by the scene
  124447. * @returns agent index
  124448. */
  124449. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124450. /**
  124451. * Returns the agent position in world space
  124452. * @param index agent index returned by addAgent
  124453. * @returns world space position
  124454. */
  124455. getAgentPosition(index: number): Vector3;
  124456. /**
  124457. * Returns the agent velocity in world space
  124458. * @param index agent index returned by addAgent
  124459. * @returns world space velocity
  124460. */
  124461. getAgentVelocity(index: number): Vector3;
  124462. /**
  124463. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124464. * @param index agent index returned by addAgent
  124465. * @param destination targeted world position
  124466. */
  124467. agentGoto(index: number, destination: Vector3): void;
  124468. /**
  124469. * remove a particular agent previously created
  124470. * @param index agent index returned by addAgent
  124471. */
  124472. removeAgent(index: number): void;
  124473. /**
  124474. * get the list of all agents attached to this crowd
  124475. * @returns list of agent indices
  124476. */
  124477. getAgents(): number[];
  124478. /**
  124479. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124480. * @param deltaTime in seconds
  124481. */
  124482. update(deltaTime: number): void;
  124483. /**
  124484. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124485. * The queries will try to find a solution within those bounds
  124486. * default is (1,1,1)
  124487. * @param extent x,y,z value that define the extent around the queries point of reference
  124488. */
  124489. setDefaultQueryExtent(extent: Vector3): void;
  124490. /**
  124491. * Get the Bounding box extent specified by setDefaultQueryExtent
  124492. * @returns the box extent values
  124493. */
  124494. getDefaultQueryExtent(): Vector3;
  124495. /**
  124496. * Release all resources
  124497. */
  124498. dispose(): void;
  124499. }
  124500. }
  124501. declare module BABYLON {
  124502. /**
  124503. * Class used to enable access to IndexedDB
  124504. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124505. */
  124506. export class Database implements IOfflineProvider {
  124507. private _callbackManifestChecked;
  124508. private _currentSceneUrl;
  124509. private _db;
  124510. private _enableSceneOffline;
  124511. private _enableTexturesOffline;
  124512. private _manifestVersionFound;
  124513. private _mustUpdateRessources;
  124514. private _hasReachedQuota;
  124515. private _isSupported;
  124516. private _idbFactory;
  124517. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124518. private static IsUASupportingBlobStorage;
  124519. /**
  124520. * Gets a boolean indicating if Database storate is enabled (off by default)
  124521. */
  124522. static IDBStorageEnabled: boolean;
  124523. /**
  124524. * Gets a boolean indicating if scene must be saved in the database
  124525. */
  124526. readonly enableSceneOffline: boolean;
  124527. /**
  124528. * Gets a boolean indicating if textures must be saved in the database
  124529. */
  124530. readonly enableTexturesOffline: boolean;
  124531. /**
  124532. * Creates a new Database
  124533. * @param urlToScene defines the url to load the scene
  124534. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124535. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124536. */
  124537. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124538. private static _ParseURL;
  124539. private static _ReturnFullUrlLocation;
  124540. private _checkManifestFile;
  124541. /**
  124542. * Open the database and make it available
  124543. * @param successCallback defines the callback to call on success
  124544. * @param errorCallback defines the callback to call on error
  124545. */
  124546. open(successCallback: () => void, errorCallback: () => void): void;
  124547. /**
  124548. * Loads an image from the database
  124549. * @param url defines the url to load from
  124550. * @param image defines the target DOM image
  124551. */
  124552. loadImage(url: string, image: HTMLImageElement): void;
  124553. private _loadImageFromDBAsync;
  124554. private _saveImageIntoDBAsync;
  124555. private _checkVersionFromDB;
  124556. private _loadVersionFromDBAsync;
  124557. private _saveVersionIntoDBAsync;
  124558. /**
  124559. * Loads a file from database
  124560. * @param url defines the URL to load from
  124561. * @param sceneLoaded defines a callback to call on success
  124562. * @param progressCallBack defines a callback to call when progress changed
  124563. * @param errorCallback defines a callback to call on error
  124564. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124565. */
  124566. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124567. private _loadFileAsync;
  124568. private _saveFileAsync;
  124569. /**
  124570. * Validates if xhr data is correct
  124571. * @param xhr defines the request to validate
  124572. * @param dataType defines the expected data type
  124573. * @returns true if data is correct
  124574. */
  124575. private static _ValidateXHRData;
  124576. }
  124577. }
  124578. declare module BABYLON {
  124579. /** @hidden */
  124580. export var gpuUpdateParticlesPixelShader: {
  124581. name: string;
  124582. shader: string;
  124583. };
  124584. }
  124585. declare module BABYLON {
  124586. /** @hidden */
  124587. export var gpuUpdateParticlesVertexShader: {
  124588. name: string;
  124589. shader: string;
  124590. };
  124591. }
  124592. declare module BABYLON {
  124593. /** @hidden */
  124594. export var clipPlaneFragmentDeclaration2: {
  124595. name: string;
  124596. shader: string;
  124597. };
  124598. }
  124599. declare module BABYLON {
  124600. /** @hidden */
  124601. export var gpuRenderParticlesPixelShader: {
  124602. name: string;
  124603. shader: string;
  124604. };
  124605. }
  124606. declare module BABYLON {
  124607. /** @hidden */
  124608. export var clipPlaneVertexDeclaration2: {
  124609. name: string;
  124610. shader: string;
  124611. };
  124612. }
  124613. declare module BABYLON {
  124614. /** @hidden */
  124615. export var gpuRenderParticlesVertexShader: {
  124616. name: string;
  124617. shader: string;
  124618. };
  124619. }
  124620. declare module BABYLON {
  124621. /**
  124622. * This represents a GPU particle system in Babylon
  124623. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124624. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124625. */
  124626. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124627. /**
  124628. * The layer mask we are rendering the particles through.
  124629. */
  124630. layerMask: number;
  124631. private _capacity;
  124632. private _activeCount;
  124633. private _currentActiveCount;
  124634. private _accumulatedCount;
  124635. private _renderEffect;
  124636. private _updateEffect;
  124637. private _buffer0;
  124638. private _buffer1;
  124639. private _spriteBuffer;
  124640. private _updateVAO;
  124641. private _renderVAO;
  124642. private _targetIndex;
  124643. private _sourceBuffer;
  124644. private _targetBuffer;
  124645. private _engine;
  124646. private _currentRenderId;
  124647. private _started;
  124648. private _stopped;
  124649. private _timeDelta;
  124650. private _randomTexture;
  124651. private _randomTexture2;
  124652. private _attributesStrideSize;
  124653. private _updateEffectOptions;
  124654. private _randomTextureSize;
  124655. private _actualFrame;
  124656. private readonly _rawTextureWidth;
  124657. /**
  124658. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124659. */
  124660. static readonly IsSupported: boolean;
  124661. /**
  124662. * An event triggered when the system is disposed.
  124663. */
  124664. onDisposeObservable: Observable<GPUParticleSystem>;
  124665. /**
  124666. * Gets the maximum number of particles active at the same time.
  124667. * @returns The max number of active particles.
  124668. */
  124669. getCapacity(): number;
  124670. /**
  124671. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124672. * to override the particles.
  124673. */
  124674. forceDepthWrite: boolean;
  124675. /**
  124676. * Gets or set the number of active particles
  124677. */
  124678. activeParticleCount: number;
  124679. private _preWarmDone;
  124680. /**
  124681. * Is this system ready to be used/rendered
  124682. * @return true if the system is ready
  124683. */
  124684. isReady(): boolean;
  124685. /**
  124686. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124687. * @returns True if it has been started, otherwise false.
  124688. */
  124689. isStarted(): boolean;
  124690. /**
  124691. * Starts the particle system and begins to emit
  124692. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124693. */
  124694. start(delay?: number): void;
  124695. /**
  124696. * Stops the particle system.
  124697. */
  124698. stop(): void;
  124699. /**
  124700. * Remove all active particles
  124701. */
  124702. reset(): void;
  124703. /**
  124704. * Returns the string "GPUParticleSystem"
  124705. * @returns a string containing the class name
  124706. */
  124707. getClassName(): string;
  124708. private _colorGradientsTexture;
  124709. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124710. /**
  124711. * Adds a new color gradient
  124712. * @param gradient defines the gradient to use (between 0 and 1)
  124713. * @param color1 defines the color to affect to the specified gradient
  124714. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124715. * @returns the current particle system
  124716. */
  124717. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124718. /**
  124719. * Remove a specific color gradient
  124720. * @param gradient defines the gradient to remove
  124721. * @returns the current particle system
  124722. */
  124723. removeColorGradient(gradient: number): GPUParticleSystem;
  124724. private _angularSpeedGradientsTexture;
  124725. private _sizeGradientsTexture;
  124726. private _velocityGradientsTexture;
  124727. private _limitVelocityGradientsTexture;
  124728. private _dragGradientsTexture;
  124729. private _addFactorGradient;
  124730. /**
  124731. * Adds a new size gradient
  124732. * @param gradient defines the gradient to use (between 0 and 1)
  124733. * @param factor defines the size factor to affect to the specified gradient
  124734. * @returns the current particle system
  124735. */
  124736. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124737. /**
  124738. * Remove a specific size gradient
  124739. * @param gradient defines the gradient to remove
  124740. * @returns the current particle system
  124741. */
  124742. removeSizeGradient(gradient: number): GPUParticleSystem;
  124743. /**
  124744. * Adds a new angular speed gradient
  124745. * @param gradient defines the gradient to use (between 0 and 1)
  124746. * @param factor defines the angular speed to affect to the specified gradient
  124747. * @returns the current particle system
  124748. */
  124749. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124750. /**
  124751. * Remove a specific angular speed gradient
  124752. * @param gradient defines the gradient to remove
  124753. * @returns the current particle system
  124754. */
  124755. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124756. /**
  124757. * Adds a new velocity gradient
  124758. * @param gradient defines the gradient to use (between 0 and 1)
  124759. * @param factor defines the velocity to affect to the specified gradient
  124760. * @returns the current particle system
  124761. */
  124762. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124763. /**
  124764. * Remove a specific velocity gradient
  124765. * @param gradient defines the gradient to remove
  124766. * @returns the current particle system
  124767. */
  124768. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124769. /**
  124770. * Adds a new limit velocity gradient
  124771. * @param gradient defines the gradient to use (between 0 and 1)
  124772. * @param factor defines the limit velocity value to affect to the specified gradient
  124773. * @returns the current particle system
  124774. */
  124775. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124776. /**
  124777. * Remove a specific limit velocity gradient
  124778. * @param gradient defines the gradient to remove
  124779. * @returns the current particle system
  124780. */
  124781. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124782. /**
  124783. * Adds a new drag gradient
  124784. * @param gradient defines the gradient to use (between 0 and 1)
  124785. * @param factor defines the drag value to affect to the specified gradient
  124786. * @returns the current particle system
  124787. */
  124788. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124789. /**
  124790. * Remove a specific drag gradient
  124791. * @param gradient defines the gradient to remove
  124792. * @returns the current particle system
  124793. */
  124794. removeDragGradient(gradient: number): GPUParticleSystem;
  124795. /**
  124796. * Not supported by GPUParticleSystem
  124797. * @param gradient defines the gradient to use (between 0 and 1)
  124798. * @param factor defines the emit rate value to affect to the specified gradient
  124799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124800. * @returns the current particle system
  124801. */
  124802. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124803. /**
  124804. * Not supported by GPUParticleSystem
  124805. * @param gradient defines the gradient to remove
  124806. * @returns the current particle system
  124807. */
  124808. removeEmitRateGradient(gradient: number): IParticleSystem;
  124809. /**
  124810. * Not supported by GPUParticleSystem
  124811. * @param gradient defines the gradient to use (between 0 and 1)
  124812. * @param factor defines the start size value to affect to the specified gradient
  124813. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124814. * @returns the current particle system
  124815. */
  124816. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124817. /**
  124818. * Not supported by GPUParticleSystem
  124819. * @param gradient defines the gradient to remove
  124820. * @returns the current particle system
  124821. */
  124822. removeStartSizeGradient(gradient: number): IParticleSystem;
  124823. /**
  124824. * Not supported by GPUParticleSystem
  124825. * @param gradient defines the gradient to use (between 0 and 1)
  124826. * @param min defines the color remap minimal range
  124827. * @param max defines the color remap maximal range
  124828. * @returns the current particle system
  124829. */
  124830. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124831. /**
  124832. * Not supported by GPUParticleSystem
  124833. * @param gradient defines the gradient to remove
  124834. * @returns the current particle system
  124835. */
  124836. removeColorRemapGradient(): IParticleSystem;
  124837. /**
  124838. * Not supported by GPUParticleSystem
  124839. * @param gradient defines the gradient to use (between 0 and 1)
  124840. * @param min defines the alpha remap minimal range
  124841. * @param max defines the alpha remap maximal range
  124842. * @returns the current particle system
  124843. */
  124844. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124845. /**
  124846. * Not supported by GPUParticleSystem
  124847. * @param gradient defines the gradient to remove
  124848. * @returns the current particle system
  124849. */
  124850. removeAlphaRemapGradient(): IParticleSystem;
  124851. /**
  124852. * Not supported by GPUParticleSystem
  124853. * @param gradient defines the gradient to use (between 0 and 1)
  124854. * @param color defines the color to affect to the specified gradient
  124855. * @returns the current particle system
  124856. */
  124857. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124858. /**
  124859. * Not supported by GPUParticleSystem
  124860. * @param gradient defines the gradient to remove
  124861. * @returns the current particle system
  124862. */
  124863. removeRampGradient(): IParticleSystem;
  124864. /**
  124865. * Not supported by GPUParticleSystem
  124866. * @returns the list of ramp gradients
  124867. */
  124868. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124869. /**
  124870. * Not supported by GPUParticleSystem
  124871. * Gets or sets a boolean indicating that ramp gradients must be used
  124872. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124873. */
  124874. useRampGradients: boolean;
  124875. /**
  124876. * Not supported by GPUParticleSystem
  124877. * @param gradient defines the gradient to use (between 0 and 1)
  124878. * @param factor defines the life time factor to affect to the specified gradient
  124879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124880. * @returns the current particle system
  124881. */
  124882. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124883. /**
  124884. * Not supported by GPUParticleSystem
  124885. * @param gradient defines the gradient to remove
  124886. * @returns the current particle system
  124887. */
  124888. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124889. /**
  124890. * Instantiates a GPU particle system.
  124891. * 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.
  124892. * @param name The name of the particle system
  124893. * @param options The options used to create the system
  124894. * @param scene The scene the particle system belongs to
  124895. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124896. */
  124897. constructor(name: string, options: Partial<{
  124898. capacity: number;
  124899. randomTextureSize: number;
  124900. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124901. protected _reset(): void;
  124902. private _createUpdateVAO;
  124903. private _createRenderVAO;
  124904. private _initialize;
  124905. /** @hidden */
  124906. _recreateUpdateEffect(): void;
  124907. /** @hidden */
  124908. _recreateRenderEffect(): void;
  124909. /**
  124910. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124911. * @param preWarm defines if we are in the pre-warmimg phase
  124912. */
  124913. animate(preWarm?: boolean): void;
  124914. private _createFactorGradientTexture;
  124915. private _createSizeGradientTexture;
  124916. private _createAngularSpeedGradientTexture;
  124917. private _createVelocityGradientTexture;
  124918. private _createLimitVelocityGradientTexture;
  124919. private _createDragGradientTexture;
  124920. private _createColorGradientTexture;
  124921. /**
  124922. * Renders the particle system in its current state
  124923. * @param preWarm defines if the system should only update the particles but not render them
  124924. * @returns the current number of particles
  124925. */
  124926. render(preWarm?: boolean): number;
  124927. /**
  124928. * Rebuilds the particle system
  124929. */
  124930. rebuild(): void;
  124931. private _releaseBuffers;
  124932. private _releaseVAOs;
  124933. /**
  124934. * Disposes the particle system and free the associated resources
  124935. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124936. */
  124937. dispose(disposeTexture?: boolean): void;
  124938. /**
  124939. * Clones the particle system.
  124940. * @param name The name of the cloned object
  124941. * @param newEmitter The new emitter to use
  124942. * @returns the cloned particle system
  124943. */
  124944. clone(name: string, newEmitter: any): GPUParticleSystem;
  124945. /**
  124946. * Serializes the particle system to a JSON object.
  124947. * @returns the JSON object
  124948. */
  124949. serialize(): any;
  124950. /**
  124951. * Parses a JSON object to create a GPU particle system.
  124952. * @param parsedParticleSystem The JSON object to parse
  124953. * @param scene The scene to create the particle system in
  124954. * @param rootUrl The root url to use to load external dependencies like texture
  124955. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124956. * @returns the parsed GPU particle system
  124957. */
  124958. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124959. }
  124960. }
  124961. declare module BABYLON {
  124962. /**
  124963. * Represents a set of particle systems working together to create a specific effect
  124964. */
  124965. export class ParticleSystemSet implements IDisposable {
  124966. private _emitterCreationOptions;
  124967. private _emitterNode;
  124968. /**
  124969. * Gets the particle system list
  124970. */
  124971. systems: IParticleSystem[];
  124972. /**
  124973. * Gets the emitter node used with this set
  124974. */
  124975. readonly emitterNode: Nullable<TransformNode>;
  124976. /**
  124977. * Creates a new emitter mesh as a sphere
  124978. * @param options defines the options used to create the sphere
  124979. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124980. * @param scene defines the hosting scene
  124981. */
  124982. setEmitterAsSphere(options: {
  124983. diameter: number;
  124984. segments: number;
  124985. color: Color3;
  124986. }, renderingGroupId: number, scene: Scene): void;
  124987. /**
  124988. * Starts all particle systems of the set
  124989. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124990. */
  124991. start(emitter?: AbstractMesh): void;
  124992. /**
  124993. * Release all associated resources
  124994. */
  124995. dispose(): void;
  124996. /**
  124997. * Serialize the set into a JSON compatible object
  124998. * @returns a JSON compatible representation of the set
  124999. */
  125000. serialize(): any;
  125001. /**
  125002. * Parse a new ParticleSystemSet from a serialized source
  125003. * @param data defines a JSON compatible representation of the set
  125004. * @param scene defines the hosting scene
  125005. * @param gpu defines if we want GPU particles or CPU particles
  125006. * @returns a new ParticleSystemSet
  125007. */
  125008. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125009. }
  125010. }
  125011. declare module BABYLON {
  125012. /**
  125013. * This class is made for on one-liner static method to help creating particle system set.
  125014. */
  125015. export class ParticleHelper {
  125016. /**
  125017. * Gets or sets base Assets URL
  125018. */
  125019. static BaseAssetsUrl: string;
  125020. /**
  125021. * Create a default particle system that you can tweak
  125022. * @param emitter defines the emitter to use
  125023. * @param capacity defines the system capacity (default is 500 particles)
  125024. * @param scene defines the hosting scene
  125025. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125026. * @returns the new Particle system
  125027. */
  125028. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125029. /**
  125030. * This is the main static method (one-liner) of this helper to create different particle systems
  125031. * @param type This string represents the type to the particle system to create
  125032. * @param scene The scene where the particle system should live
  125033. * @param gpu If the system will use gpu
  125034. * @returns the ParticleSystemSet created
  125035. */
  125036. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125037. /**
  125038. * Static function used to export a particle system to a ParticleSystemSet variable.
  125039. * Please note that the emitter shape is not exported
  125040. * @param systems defines the particle systems to export
  125041. * @returns the created particle system set
  125042. */
  125043. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125044. }
  125045. }
  125046. declare module BABYLON {
  125047. interface Engine {
  125048. /**
  125049. * Create an effect to use with particle systems.
  125050. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125051. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125052. * @param uniformsNames defines a list of attribute names
  125053. * @param samplers defines an array of string used to represent textures
  125054. * @param defines defines the string containing the defines to use to compile the shaders
  125055. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125056. * @param onCompiled defines a function to call when the effect creation is successful
  125057. * @param onError defines a function to call when the effect creation has failed
  125058. * @returns the new Effect
  125059. */
  125060. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125061. }
  125062. interface Mesh {
  125063. /**
  125064. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125065. * @returns an array of IParticleSystem
  125066. */
  125067. getEmittedParticleSystems(): IParticleSystem[];
  125068. /**
  125069. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125070. * @returns an array of IParticleSystem
  125071. */
  125072. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125073. }
  125074. /**
  125075. * @hidden
  125076. */
  125077. export var _IDoNeedToBeInTheBuild: number;
  125078. }
  125079. declare module BABYLON {
  125080. interface Scene {
  125081. /** @hidden (Backing field) */
  125082. _physicsEngine: Nullable<IPhysicsEngine>;
  125083. /**
  125084. * Gets the current physics engine
  125085. * @returns a IPhysicsEngine or null if none attached
  125086. */
  125087. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125088. /**
  125089. * Enables physics to the current scene
  125090. * @param gravity defines the scene's gravity for the physics engine
  125091. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125092. * @return a boolean indicating if the physics engine was initialized
  125093. */
  125094. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125095. /**
  125096. * Disables and disposes the physics engine associated with the scene
  125097. */
  125098. disablePhysicsEngine(): void;
  125099. /**
  125100. * Gets a boolean indicating if there is an active physics engine
  125101. * @returns a boolean indicating if there is an active physics engine
  125102. */
  125103. isPhysicsEnabled(): boolean;
  125104. /**
  125105. * Deletes a physics compound impostor
  125106. * @param compound defines the compound to delete
  125107. */
  125108. deleteCompoundImpostor(compound: any): void;
  125109. /**
  125110. * An event triggered when physic simulation is about to be run
  125111. */
  125112. onBeforePhysicsObservable: Observable<Scene>;
  125113. /**
  125114. * An event triggered when physic simulation has been done
  125115. */
  125116. onAfterPhysicsObservable: Observable<Scene>;
  125117. }
  125118. interface AbstractMesh {
  125119. /** @hidden */
  125120. _physicsImpostor: Nullable<PhysicsImpostor>;
  125121. /**
  125122. * Gets or sets impostor used for physic simulation
  125123. * @see http://doc.babylonjs.com/features/physics_engine
  125124. */
  125125. physicsImpostor: Nullable<PhysicsImpostor>;
  125126. /**
  125127. * Gets the current physics impostor
  125128. * @see http://doc.babylonjs.com/features/physics_engine
  125129. * @returns a physics impostor or null
  125130. */
  125131. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125132. /** Apply a physic impulse to the mesh
  125133. * @param force defines the force to apply
  125134. * @param contactPoint defines where to apply the force
  125135. * @returns the current mesh
  125136. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125137. */
  125138. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125139. /**
  125140. * Creates a physic joint between two meshes
  125141. * @param otherMesh defines the other mesh to use
  125142. * @param pivot1 defines the pivot to use on this mesh
  125143. * @param pivot2 defines the pivot to use on the other mesh
  125144. * @param options defines additional options (can be plugin dependent)
  125145. * @returns the current mesh
  125146. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125147. */
  125148. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125149. /** @hidden */
  125150. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125151. }
  125152. /**
  125153. * Defines the physics engine scene component responsible to manage a physics engine
  125154. */
  125155. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125156. /**
  125157. * The component name helpful to identify the component in the list of scene components.
  125158. */
  125159. readonly name: string;
  125160. /**
  125161. * The scene the component belongs to.
  125162. */
  125163. scene: Scene;
  125164. /**
  125165. * Creates a new instance of the component for the given scene
  125166. * @param scene Defines the scene to register the component in
  125167. */
  125168. constructor(scene: Scene);
  125169. /**
  125170. * Registers the component in a given scene
  125171. */
  125172. register(): void;
  125173. /**
  125174. * Rebuilds the elements related to this component in case of
  125175. * context lost for instance.
  125176. */
  125177. rebuild(): void;
  125178. /**
  125179. * Disposes the component and the associated ressources
  125180. */
  125181. dispose(): void;
  125182. }
  125183. }
  125184. declare module BABYLON {
  125185. /**
  125186. * A helper for physics simulations
  125187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125188. */
  125189. export class PhysicsHelper {
  125190. private _scene;
  125191. private _physicsEngine;
  125192. /**
  125193. * Initializes the Physics helper
  125194. * @param scene Babylon.js scene
  125195. */
  125196. constructor(scene: Scene);
  125197. /**
  125198. * Applies a radial explosion impulse
  125199. * @param origin the origin of the explosion
  125200. * @param radiusOrEventOptions the radius or the options of radial explosion
  125201. * @param strength the explosion strength
  125202. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125203. * @returns A physics radial explosion event, or null
  125204. */
  125205. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125206. /**
  125207. * Applies a radial explosion force
  125208. * @param origin the origin of the explosion
  125209. * @param radiusOrEventOptions the radius or the options of radial explosion
  125210. * @param strength the explosion strength
  125211. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125212. * @returns A physics radial explosion event, or null
  125213. */
  125214. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125215. /**
  125216. * Creates a gravitational field
  125217. * @param origin the origin of the explosion
  125218. * @param radiusOrEventOptions the radius or the options of radial explosion
  125219. * @param strength the explosion strength
  125220. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125221. * @returns A physics gravitational field event, or null
  125222. */
  125223. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125224. /**
  125225. * Creates a physics updraft event
  125226. * @param origin the origin of the updraft
  125227. * @param radiusOrEventOptions the radius or the options of the updraft
  125228. * @param strength the strength of the updraft
  125229. * @param height the height of the updraft
  125230. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125231. * @returns A physics updraft event, or null
  125232. */
  125233. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125234. /**
  125235. * Creates a physics vortex event
  125236. * @param origin the of the vortex
  125237. * @param radiusOrEventOptions the radius or the options of the vortex
  125238. * @param strength the strength of the vortex
  125239. * @param height the height of the vortex
  125240. * @returns a Physics vortex event, or null
  125241. * A physics vortex event or null
  125242. */
  125243. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125244. }
  125245. /**
  125246. * Represents a physics radial explosion event
  125247. */
  125248. class PhysicsRadialExplosionEvent {
  125249. private _scene;
  125250. private _options;
  125251. private _sphere;
  125252. private _dataFetched;
  125253. /**
  125254. * Initializes a radial explosioin event
  125255. * @param _scene BabylonJS scene
  125256. * @param _options The options for the vortex event
  125257. */
  125258. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125259. /**
  125260. * Returns the data related to the radial explosion event (sphere).
  125261. * @returns The radial explosion event data
  125262. */
  125263. getData(): PhysicsRadialExplosionEventData;
  125264. /**
  125265. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125266. * @param impostor A physics imposter
  125267. * @param origin the origin of the explosion
  125268. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125269. */
  125270. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125271. /**
  125272. * Triggers affecterd impostors callbacks
  125273. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125274. */
  125275. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125276. /**
  125277. * Disposes the sphere.
  125278. * @param force Specifies if the sphere should be disposed by force
  125279. */
  125280. dispose(force?: boolean): void;
  125281. /*** Helpers ***/
  125282. private _prepareSphere;
  125283. private _intersectsWithSphere;
  125284. }
  125285. /**
  125286. * Represents a gravitational field event
  125287. */
  125288. class PhysicsGravitationalFieldEvent {
  125289. private _physicsHelper;
  125290. private _scene;
  125291. private _origin;
  125292. private _options;
  125293. private _tickCallback;
  125294. private _sphere;
  125295. private _dataFetched;
  125296. /**
  125297. * Initializes the physics gravitational field event
  125298. * @param _physicsHelper A physics helper
  125299. * @param _scene BabylonJS scene
  125300. * @param _origin The origin position of the gravitational field event
  125301. * @param _options The options for the vortex event
  125302. */
  125303. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125304. /**
  125305. * Returns the data related to the gravitational field event (sphere).
  125306. * @returns A gravitational field event
  125307. */
  125308. getData(): PhysicsGravitationalFieldEventData;
  125309. /**
  125310. * Enables the gravitational field.
  125311. */
  125312. enable(): void;
  125313. /**
  125314. * Disables the gravitational field.
  125315. */
  125316. disable(): void;
  125317. /**
  125318. * Disposes the sphere.
  125319. * @param force The force to dispose from the gravitational field event
  125320. */
  125321. dispose(force?: boolean): void;
  125322. private _tick;
  125323. }
  125324. /**
  125325. * Represents a physics updraft event
  125326. */
  125327. class PhysicsUpdraftEvent {
  125328. private _scene;
  125329. private _origin;
  125330. private _options;
  125331. private _physicsEngine;
  125332. private _originTop;
  125333. private _originDirection;
  125334. private _tickCallback;
  125335. private _cylinder;
  125336. private _cylinderPosition;
  125337. private _dataFetched;
  125338. /**
  125339. * Initializes the physics updraft event
  125340. * @param _scene BabylonJS scene
  125341. * @param _origin The origin position of the updraft
  125342. * @param _options The options for the updraft event
  125343. */
  125344. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125345. /**
  125346. * Returns the data related to the updraft event (cylinder).
  125347. * @returns A physics updraft event
  125348. */
  125349. getData(): PhysicsUpdraftEventData;
  125350. /**
  125351. * Enables the updraft.
  125352. */
  125353. enable(): void;
  125354. /**
  125355. * Disables the updraft.
  125356. */
  125357. disable(): void;
  125358. /**
  125359. * Disposes the cylinder.
  125360. * @param force Specifies if the updraft should be disposed by force
  125361. */
  125362. dispose(force?: boolean): void;
  125363. private getImpostorHitData;
  125364. private _tick;
  125365. /*** Helpers ***/
  125366. private _prepareCylinder;
  125367. private _intersectsWithCylinder;
  125368. }
  125369. /**
  125370. * Represents a physics vortex event
  125371. */
  125372. class PhysicsVortexEvent {
  125373. private _scene;
  125374. private _origin;
  125375. private _options;
  125376. private _physicsEngine;
  125377. private _originTop;
  125378. private _tickCallback;
  125379. private _cylinder;
  125380. private _cylinderPosition;
  125381. private _dataFetched;
  125382. /**
  125383. * Initializes the physics vortex event
  125384. * @param _scene The BabylonJS scene
  125385. * @param _origin The origin position of the vortex
  125386. * @param _options The options for the vortex event
  125387. */
  125388. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125389. /**
  125390. * Returns the data related to the vortex event (cylinder).
  125391. * @returns The physics vortex event data
  125392. */
  125393. getData(): PhysicsVortexEventData;
  125394. /**
  125395. * Enables the vortex.
  125396. */
  125397. enable(): void;
  125398. /**
  125399. * Disables the cortex.
  125400. */
  125401. disable(): void;
  125402. /**
  125403. * Disposes the sphere.
  125404. * @param force
  125405. */
  125406. dispose(force?: boolean): void;
  125407. private getImpostorHitData;
  125408. private _tick;
  125409. /*** Helpers ***/
  125410. private _prepareCylinder;
  125411. private _intersectsWithCylinder;
  125412. }
  125413. /**
  125414. * Options fot the radial explosion event
  125415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125416. */
  125417. export class PhysicsRadialExplosionEventOptions {
  125418. /**
  125419. * The radius of the sphere for the radial explosion.
  125420. */
  125421. radius: number;
  125422. /**
  125423. * The strenth of the explosion.
  125424. */
  125425. strength: number;
  125426. /**
  125427. * The strenght of the force in correspondence to the distance of the affected object
  125428. */
  125429. falloff: PhysicsRadialImpulseFalloff;
  125430. /**
  125431. * Sphere options for the radial explosion.
  125432. */
  125433. sphere: {
  125434. segments: number;
  125435. diameter: number;
  125436. };
  125437. /**
  125438. * Sphere options for the radial explosion.
  125439. */
  125440. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125441. }
  125442. /**
  125443. * Options fot the updraft event
  125444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125445. */
  125446. export class PhysicsUpdraftEventOptions {
  125447. /**
  125448. * The radius of the cylinder for the vortex
  125449. */
  125450. radius: number;
  125451. /**
  125452. * The strenth of the updraft.
  125453. */
  125454. strength: number;
  125455. /**
  125456. * The height of the cylinder for the updraft.
  125457. */
  125458. height: number;
  125459. /**
  125460. * The mode for the the updraft.
  125461. */
  125462. updraftMode: PhysicsUpdraftMode;
  125463. }
  125464. /**
  125465. * Options fot the vortex event
  125466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125467. */
  125468. export class PhysicsVortexEventOptions {
  125469. /**
  125470. * The radius of the cylinder for the vortex
  125471. */
  125472. radius: number;
  125473. /**
  125474. * The strenth of the vortex.
  125475. */
  125476. strength: number;
  125477. /**
  125478. * The height of the cylinder for the vortex.
  125479. */
  125480. height: number;
  125481. /**
  125482. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125483. */
  125484. centripetalForceThreshold: number;
  125485. /**
  125486. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125487. */
  125488. centripetalForceMultiplier: number;
  125489. /**
  125490. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125491. */
  125492. centrifugalForceMultiplier: number;
  125493. /**
  125494. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125495. */
  125496. updraftForceMultiplier: number;
  125497. }
  125498. /**
  125499. * The strenght of the force in correspondence to the distance of the affected object
  125500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125501. */
  125502. export enum PhysicsRadialImpulseFalloff {
  125503. /** Defines that impulse is constant in strength across it's whole radius */
  125504. Constant = 0,
  125505. /** Defines that impulse gets weaker if it's further from the origin */
  125506. Linear = 1
  125507. }
  125508. /**
  125509. * The strength of the force in correspondence to the distance of the affected object
  125510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125511. */
  125512. export enum PhysicsUpdraftMode {
  125513. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125514. Center = 0,
  125515. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125516. Perpendicular = 1
  125517. }
  125518. /**
  125519. * Interface for a physics hit data
  125520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125521. */
  125522. export interface PhysicsHitData {
  125523. /**
  125524. * The force applied at the contact point
  125525. */
  125526. force: Vector3;
  125527. /**
  125528. * The contact point
  125529. */
  125530. contactPoint: Vector3;
  125531. /**
  125532. * The distance from the origin to the contact point
  125533. */
  125534. distanceFromOrigin: number;
  125535. }
  125536. /**
  125537. * Interface for radial explosion event data
  125538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125539. */
  125540. export interface PhysicsRadialExplosionEventData {
  125541. /**
  125542. * A sphere used for the radial explosion event
  125543. */
  125544. sphere: Mesh;
  125545. }
  125546. /**
  125547. * Interface for gravitational field event data
  125548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125549. */
  125550. export interface PhysicsGravitationalFieldEventData {
  125551. /**
  125552. * A sphere mesh used for the gravitational field event
  125553. */
  125554. sphere: Mesh;
  125555. }
  125556. /**
  125557. * Interface for updraft event data
  125558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125559. */
  125560. export interface PhysicsUpdraftEventData {
  125561. /**
  125562. * A cylinder used for the updraft event
  125563. */
  125564. cylinder: Mesh;
  125565. }
  125566. /**
  125567. * Interface for vortex event data
  125568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125569. */
  125570. export interface PhysicsVortexEventData {
  125571. /**
  125572. * A cylinder used for the vortex event
  125573. */
  125574. cylinder: Mesh;
  125575. }
  125576. /**
  125577. * Interface for an affected physics impostor
  125578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125579. */
  125580. export interface PhysicsAffectedImpostorWithData {
  125581. /**
  125582. * The impostor affected by the effect
  125583. */
  125584. impostor: PhysicsImpostor;
  125585. /**
  125586. * The data about the hit/horce from the explosion
  125587. */
  125588. hitData: PhysicsHitData;
  125589. }
  125590. }
  125591. declare module BABYLON {
  125592. /** @hidden */
  125593. export var blackAndWhitePixelShader: {
  125594. name: string;
  125595. shader: string;
  125596. };
  125597. }
  125598. declare module BABYLON {
  125599. /**
  125600. * Post process used to render in black and white
  125601. */
  125602. export class BlackAndWhitePostProcess extends PostProcess {
  125603. /**
  125604. * Linear about to convert he result to black and white (default: 1)
  125605. */
  125606. degree: number;
  125607. /**
  125608. * Creates a black and white post process
  125609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125610. * @param name The name of the effect.
  125611. * @param options The required width/height ratio to downsize to before computing the render pass.
  125612. * @param camera The camera to apply the render pass to.
  125613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125614. * @param engine The engine which the post process will be applied. (default: current engine)
  125615. * @param reusable If the post process can be reused on the same frame. (default: false)
  125616. */
  125617. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125618. }
  125619. }
  125620. declare module BABYLON {
  125621. /**
  125622. * This represents a set of one or more post processes in Babylon.
  125623. * A post process can be used to apply a shader to a texture after it is rendered.
  125624. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125625. */
  125626. export class PostProcessRenderEffect {
  125627. private _postProcesses;
  125628. private _getPostProcesses;
  125629. private _singleInstance;
  125630. private _cameras;
  125631. private _indicesForCamera;
  125632. /**
  125633. * Name of the effect
  125634. * @hidden
  125635. */
  125636. _name: string;
  125637. /**
  125638. * Instantiates a post process render effect.
  125639. * A post process can be used to apply a shader to a texture after it is rendered.
  125640. * @param engine The engine the effect is tied to
  125641. * @param name The name of the effect
  125642. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125643. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125644. */
  125645. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125646. /**
  125647. * Checks if all the post processes in the effect are supported.
  125648. */
  125649. readonly isSupported: boolean;
  125650. /**
  125651. * Updates the current state of the effect
  125652. * @hidden
  125653. */
  125654. _update(): void;
  125655. /**
  125656. * Attaches the effect on cameras
  125657. * @param cameras The camera to attach to.
  125658. * @hidden
  125659. */
  125660. _attachCameras(cameras: Camera): void;
  125661. /**
  125662. * Attaches the effect on cameras
  125663. * @param cameras The camera to attach to.
  125664. * @hidden
  125665. */
  125666. _attachCameras(cameras: Camera[]): void;
  125667. /**
  125668. * Detaches the effect on cameras
  125669. * @param cameras The camera to detatch from.
  125670. * @hidden
  125671. */
  125672. _detachCameras(cameras: Camera): void;
  125673. /**
  125674. * Detatches the effect on cameras
  125675. * @param cameras The camera to detatch from.
  125676. * @hidden
  125677. */
  125678. _detachCameras(cameras: Camera[]): void;
  125679. /**
  125680. * Enables the effect on given cameras
  125681. * @param cameras The camera to enable.
  125682. * @hidden
  125683. */
  125684. _enable(cameras: Camera): void;
  125685. /**
  125686. * Enables the effect on given cameras
  125687. * @param cameras The camera to enable.
  125688. * @hidden
  125689. */
  125690. _enable(cameras: Nullable<Camera[]>): void;
  125691. /**
  125692. * Disables the effect on the given cameras
  125693. * @param cameras The camera to disable.
  125694. * @hidden
  125695. */
  125696. _disable(cameras: Camera): void;
  125697. /**
  125698. * Disables the effect on the given cameras
  125699. * @param cameras The camera to disable.
  125700. * @hidden
  125701. */
  125702. _disable(cameras: Nullable<Camera[]>): void;
  125703. /**
  125704. * Gets a list of the post processes contained in the effect.
  125705. * @param camera The camera to get the post processes on.
  125706. * @returns The list of the post processes in the effect.
  125707. */
  125708. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125709. }
  125710. }
  125711. declare module BABYLON {
  125712. /** @hidden */
  125713. export var extractHighlightsPixelShader: {
  125714. name: string;
  125715. shader: string;
  125716. };
  125717. }
  125718. declare module BABYLON {
  125719. /**
  125720. * 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.
  125721. */
  125722. export class ExtractHighlightsPostProcess extends PostProcess {
  125723. /**
  125724. * The luminance threshold, pixels below this value will be set to black.
  125725. */
  125726. threshold: number;
  125727. /** @hidden */
  125728. _exposure: number;
  125729. /**
  125730. * Post process which has the input texture to be used when performing highlight extraction
  125731. * @hidden
  125732. */
  125733. _inputPostProcess: Nullable<PostProcess>;
  125734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125735. }
  125736. }
  125737. declare module BABYLON {
  125738. /** @hidden */
  125739. export var bloomMergePixelShader: {
  125740. name: string;
  125741. shader: string;
  125742. };
  125743. }
  125744. declare module BABYLON {
  125745. /**
  125746. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125747. */
  125748. export class BloomMergePostProcess extends PostProcess {
  125749. /** Weight of the bloom to be added to the original input. */
  125750. weight: number;
  125751. /**
  125752. * Creates a new instance of @see BloomMergePostProcess
  125753. * @param name The name of the effect.
  125754. * @param originalFromInput Post process which's input will be used for the merge.
  125755. * @param blurred Blurred highlights post process which's output will be used.
  125756. * @param weight Weight of the bloom to be added to the original input.
  125757. * @param options The required width/height ratio to downsize to before computing the render pass.
  125758. * @param camera The camera to apply the render pass to.
  125759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125760. * @param engine The engine which the post process will be applied. (default: current engine)
  125761. * @param reusable If the post process can be reused on the same frame. (default: false)
  125762. * @param textureType Type of textures used when performing the post process. (default: 0)
  125763. * @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)
  125764. */
  125765. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125766. /** Weight of the bloom to be added to the original input. */
  125767. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125768. }
  125769. }
  125770. declare module BABYLON {
  125771. /**
  125772. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125773. */
  125774. export class BloomEffect extends PostProcessRenderEffect {
  125775. private bloomScale;
  125776. /**
  125777. * @hidden Internal
  125778. */
  125779. _effects: Array<PostProcess>;
  125780. /**
  125781. * @hidden Internal
  125782. */
  125783. _downscale: ExtractHighlightsPostProcess;
  125784. private _blurX;
  125785. private _blurY;
  125786. private _merge;
  125787. /**
  125788. * The luminance threshold to find bright areas of the image to bloom.
  125789. */
  125790. threshold: number;
  125791. /**
  125792. * The strength of the bloom.
  125793. */
  125794. weight: number;
  125795. /**
  125796. * Specifies the size of the bloom blur kernel, relative to the final output size
  125797. */
  125798. kernel: number;
  125799. /**
  125800. * Creates a new instance of @see BloomEffect
  125801. * @param scene The scene the effect belongs to.
  125802. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125803. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125804. * @param bloomWeight The the strength of bloom.
  125805. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125806. * @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)
  125807. */
  125808. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125809. /**
  125810. * Disposes each of the internal effects for a given camera.
  125811. * @param camera The camera to dispose the effect on.
  125812. */
  125813. disposeEffects(camera: Camera): void;
  125814. /**
  125815. * @hidden Internal
  125816. */
  125817. _updateEffects(): void;
  125818. /**
  125819. * Internal
  125820. * @returns if all the contained post processes are ready.
  125821. * @hidden
  125822. */
  125823. _isReady(): boolean;
  125824. }
  125825. }
  125826. declare module BABYLON {
  125827. /** @hidden */
  125828. export var chromaticAberrationPixelShader: {
  125829. name: string;
  125830. shader: string;
  125831. };
  125832. }
  125833. declare module BABYLON {
  125834. /**
  125835. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125836. */
  125837. export class ChromaticAberrationPostProcess extends PostProcess {
  125838. /**
  125839. * The amount of seperation of rgb channels (default: 30)
  125840. */
  125841. aberrationAmount: number;
  125842. /**
  125843. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125844. */
  125845. radialIntensity: number;
  125846. /**
  125847. * 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))
  125848. */
  125849. direction: Vector2;
  125850. /**
  125851. * 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))
  125852. */
  125853. centerPosition: Vector2;
  125854. /**
  125855. * Creates a new instance ChromaticAberrationPostProcess
  125856. * @param name The name of the effect.
  125857. * @param screenWidth The width of the screen to apply the effect on.
  125858. * @param screenHeight The height of the screen to apply the effect on.
  125859. * @param options The required width/height ratio to downsize to before computing the render pass.
  125860. * @param camera The camera to apply the render pass to.
  125861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125862. * @param engine The engine which the post process will be applied. (default: current engine)
  125863. * @param reusable If the post process can be reused on the same frame. (default: false)
  125864. * @param textureType Type of textures used when performing the post process. (default: 0)
  125865. * @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)
  125866. */
  125867. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125868. }
  125869. }
  125870. declare module BABYLON {
  125871. /** @hidden */
  125872. export var circleOfConfusionPixelShader: {
  125873. name: string;
  125874. shader: string;
  125875. };
  125876. }
  125877. declare module BABYLON {
  125878. /**
  125879. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125880. */
  125881. export class CircleOfConfusionPostProcess extends PostProcess {
  125882. /**
  125883. * 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.
  125884. */
  125885. lensSize: number;
  125886. /**
  125887. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125888. */
  125889. fStop: number;
  125890. /**
  125891. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125892. */
  125893. focusDistance: number;
  125894. /**
  125895. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125896. */
  125897. focalLength: number;
  125898. private _depthTexture;
  125899. /**
  125900. * Creates a new instance CircleOfConfusionPostProcess
  125901. * @param name The name of the effect.
  125902. * @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.
  125903. * @param options The required width/height ratio to downsize to before computing the render pass.
  125904. * @param camera The camera to apply the render pass to.
  125905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125906. * @param engine The engine which the post process will be applied. (default: current engine)
  125907. * @param reusable If the post process can be reused on the same frame. (default: false)
  125908. * @param textureType Type of textures used when performing the post process. (default: 0)
  125909. * @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)
  125910. */
  125911. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125912. /**
  125913. * 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.
  125914. */
  125915. depthTexture: RenderTargetTexture;
  125916. }
  125917. }
  125918. declare module BABYLON {
  125919. /** @hidden */
  125920. export var colorCorrectionPixelShader: {
  125921. name: string;
  125922. shader: string;
  125923. };
  125924. }
  125925. declare module BABYLON {
  125926. /**
  125927. *
  125928. * This post-process allows the modification of rendered colors by using
  125929. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125930. *
  125931. * The object needs to be provided an url to a texture containing the color
  125932. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125933. * Use an image editing software to tweak the LUT to match your needs.
  125934. *
  125935. * For an example of a color LUT, see here:
  125936. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125937. * For explanations on color grading, see here:
  125938. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125939. *
  125940. */
  125941. export class ColorCorrectionPostProcess extends PostProcess {
  125942. private _colorTableTexture;
  125943. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125944. }
  125945. }
  125946. declare module BABYLON {
  125947. /** @hidden */
  125948. export var convolutionPixelShader: {
  125949. name: string;
  125950. shader: string;
  125951. };
  125952. }
  125953. declare module BABYLON {
  125954. /**
  125955. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125956. * input texture to perform effects such as edge detection or sharpening
  125957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125958. */
  125959. export class ConvolutionPostProcess extends PostProcess {
  125960. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125961. kernel: number[];
  125962. /**
  125963. * Creates a new instance ConvolutionPostProcess
  125964. * @param name The name of the effect.
  125965. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125966. * @param options The required width/height ratio to downsize to before computing the render pass.
  125967. * @param camera The camera to apply the render pass to.
  125968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125969. * @param engine The engine which the post process will be applied. (default: current engine)
  125970. * @param reusable If the post process can be reused on the same frame. (default: false)
  125971. * @param textureType Type of textures used when performing the post process. (default: 0)
  125972. */
  125973. constructor(name: string,
  125974. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125975. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125976. /**
  125977. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125978. */
  125979. static EdgeDetect0Kernel: number[];
  125980. /**
  125981. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125982. */
  125983. static EdgeDetect1Kernel: number[];
  125984. /**
  125985. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125986. */
  125987. static EdgeDetect2Kernel: number[];
  125988. /**
  125989. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125990. */
  125991. static SharpenKernel: number[];
  125992. /**
  125993. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125994. */
  125995. static EmbossKernel: number[];
  125996. /**
  125997. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125998. */
  125999. static GaussianKernel: number[];
  126000. }
  126001. }
  126002. declare module BABYLON {
  126003. /**
  126004. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126005. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126006. * based on samples that have a large difference in distance than the center pixel.
  126007. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126008. */
  126009. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126010. direction: Vector2;
  126011. /**
  126012. * Creates a new instance CircleOfConfusionPostProcess
  126013. * @param name The name of the effect.
  126014. * @param scene The scene the effect belongs to.
  126015. * @param direction The direction the blur should be applied.
  126016. * @param kernel The size of the kernel used to blur.
  126017. * @param options The required width/height ratio to downsize to before computing the render pass.
  126018. * @param camera The camera to apply the render pass to.
  126019. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126020. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126022. * @param engine The engine which the post process will be applied. (default: current engine)
  126023. * @param reusable If the post process can be reused on the same frame. (default: false)
  126024. * @param textureType Type of textures used when performing the post process. (default: 0)
  126025. * @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)
  126026. */
  126027. 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);
  126028. }
  126029. }
  126030. declare module BABYLON {
  126031. /** @hidden */
  126032. export var depthOfFieldMergePixelShader: {
  126033. name: string;
  126034. shader: string;
  126035. };
  126036. }
  126037. declare module BABYLON {
  126038. /**
  126039. * Options to be set when merging outputs from the default pipeline.
  126040. */
  126041. export class DepthOfFieldMergePostProcessOptions {
  126042. /**
  126043. * The original image to merge on top of
  126044. */
  126045. originalFromInput: PostProcess;
  126046. /**
  126047. * Parameters to perform the merge of the depth of field effect
  126048. */
  126049. depthOfField?: {
  126050. circleOfConfusion: PostProcess;
  126051. blurSteps: Array<PostProcess>;
  126052. };
  126053. /**
  126054. * Parameters to perform the merge of bloom effect
  126055. */
  126056. bloom?: {
  126057. blurred: PostProcess;
  126058. weight: number;
  126059. };
  126060. }
  126061. /**
  126062. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126063. */
  126064. export class DepthOfFieldMergePostProcess extends PostProcess {
  126065. private blurSteps;
  126066. /**
  126067. * Creates a new instance of DepthOfFieldMergePostProcess
  126068. * @param name The name of the effect.
  126069. * @param originalFromInput Post process which's input will be used for the merge.
  126070. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126071. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126072. * @param options The required width/height ratio to downsize to before computing the render pass.
  126073. * @param camera The camera to apply the render pass to.
  126074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126075. * @param engine The engine which the post process will be applied. (default: current engine)
  126076. * @param reusable If the post process can be reused on the same frame. (default: false)
  126077. * @param textureType Type of textures used when performing the post process. (default: 0)
  126078. * @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)
  126079. */
  126080. 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);
  126081. /**
  126082. * Updates the effect with the current post process compile time values and recompiles the shader.
  126083. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126084. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126085. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126086. * @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
  126087. * @param onCompiled Called when the shader has been compiled.
  126088. * @param onError Called if there is an error when compiling a shader.
  126089. */
  126090. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126091. }
  126092. }
  126093. declare module BABYLON {
  126094. /**
  126095. * Specifies the level of max blur that should be applied when using the depth of field effect
  126096. */
  126097. export enum DepthOfFieldEffectBlurLevel {
  126098. /**
  126099. * Subtle blur
  126100. */
  126101. Low = 0,
  126102. /**
  126103. * Medium blur
  126104. */
  126105. Medium = 1,
  126106. /**
  126107. * Large blur
  126108. */
  126109. High = 2
  126110. }
  126111. /**
  126112. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126113. */
  126114. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126115. private _circleOfConfusion;
  126116. /**
  126117. * @hidden Internal, blurs from high to low
  126118. */
  126119. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126120. private _depthOfFieldBlurY;
  126121. private _dofMerge;
  126122. /**
  126123. * @hidden Internal post processes in depth of field effect
  126124. */
  126125. _effects: Array<PostProcess>;
  126126. /**
  126127. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126128. */
  126129. focalLength: number;
  126130. /**
  126131. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126132. */
  126133. fStop: number;
  126134. /**
  126135. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126136. */
  126137. focusDistance: number;
  126138. /**
  126139. * 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.
  126140. */
  126141. lensSize: number;
  126142. /**
  126143. * Creates a new instance DepthOfFieldEffect
  126144. * @param scene The scene the effect belongs to.
  126145. * @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.
  126146. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126147. * @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)
  126148. */
  126149. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126150. /**
  126151. * Get the current class name of the current effet
  126152. * @returns "DepthOfFieldEffect"
  126153. */
  126154. getClassName(): string;
  126155. /**
  126156. * 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.
  126157. */
  126158. depthTexture: RenderTargetTexture;
  126159. /**
  126160. * Disposes each of the internal effects for a given camera.
  126161. * @param camera The camera to dispose the effect on.
  126162. */
  126163. disposeEffects(camera: Camera): void;
  126164. /**
  126165. * @hidden Internal
  126166. */
  126167. _updateEffects(): void;
  126168. /**
  126169. * Internal
  126170. * @returns if all the contained post processes are ready.
  126171. * @hidden
  126172. */
  126173. _isReady(): boolean;
  126174. }
  126175. }
  126176. declare module BABYLON {
  126177. /** @hidden */
  126178. export var displayPassPixelShader: {
  126179. name: string;
  126180. shader: string;
  126181. };
  126182. }
  126183. declare module BABYLON {
  126184. /**
  126185. * DisplayPassPostProcess which produces an output the same as it's input
  126186. */
  126187. export class DisplayPassPostProcess extends PostProcess {
  126188. /**
  126189. * Creates the DisplayPassPostProcess
  126190. * @param name The name of the effect.
  126191. * @param options The required width/height ratio to downsize to before computing the render pass.
  126192. * @param camera The camera to apply the render pass to.
  126193. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126194. * @param engine The engine which the post process will be applied. (default: current engine)
  126195. * @param reusable If the post process can be reused on the same frame. (default: false)
  126196. */
  126197. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126198. }
  126199. }
  126200. declare module BABYLON {
  126201. /** @hidden */
  126202. export var filterPixelShader: {
  126203. name: string;
  126204. shader: string;
  126205. };
  126206. }
  126207. declare module BABYLON {
  126208. /**
  126209. * Applies a kernel filter to the image
  126210. */
  126211. export class FilterPostProcess extends PostProcess {
  126212. /** The matrix to be applied to the image */
  126213. kernelMatrix: Matrix;
  126214. /**
  126215. *
  126216. * @param name The name of the effect.
  126217. * @param kernelMatrix The matrix to be applied to the image
  126218. * @param options The required width/height ratio to downsize to before computing the render pass.
  126219. * @param camera The camera to apply the render pass to.
  126220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126221. * @param engine The engine which the post process will be applied. (default: current engine)
  126222. * @param reusable If the post process can be reused on the same frame. (default: false)
  126223. */
  126224. constructor(name: string,
  126225. /** The matrix to be applied to the image */
  126226. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126227. }
  126228. }
  126229. declare module BABYLON {
  126230. /** @hidden */
  126231. export var fxaaPixelShader: {
  126232. name: string;
  126233. shader: string;
  126234. };
  126235. }
  126236. declare module BABYLON {
  126237. /** @hidden */
  126238. export var fxaaVertexShader: {
  126239. name: string;
  126240. shader: string;
  126241. };
  126242. }
  126243. declare module BABYLON {
  126244. /**
  126245. * Fxaa post process
  126246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126247. */
  126248. export class FxaaPostProcess extends PostProcess {
  126249. /** @hidden */
  126250. texelWidth: number;
  126251. /** @hidden */
  126252. texelHeight: number;
  126253. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126254. private _getDefines;
  126255. }
  126256. }
  126257. declare module BABYLON {
  126258. /** @hidden */
  126259. export var grainPixelShader: {
  126260. name: string;
  126261. shader: string;
  126262. };
  126263. }
  126264. declare module BABYLON {
  126265. /**
  126266. * The GrainPostProcess adds noise to the image at mid luminance levels
  126267. */
  126268. export class GrainPostProcess extends PostProcess {
  126269. /**
  126270. * The intensity of the grain added (default: 30)
  126271. */
  126272. intensity: number;
  126273. /**
  126274. * If the grain should be randomized on every frame
  126275. */
  126276. animated: boolean;
  126277. /**
  126278. * Creates a new instance of @see GrainPostProcess
  126279. * @param name The name of the effect.
  126280. * @param options The required width/height ratio to downsize to before computing the render pass.
  126281. * @param camera The camera to apply the render pass to.
  126282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126283. * @param engine The engine which the post process will be applied. (default: current engine)
  126284. * @param reusable If the post process can be reused on the same frame. (default: false)
  126285. * @param textureType Type of textures used when performing the post process. (default: 0)
  126286. * @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)
  126287. */
  126288. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126289. }
  126290. }
  126291. declare module BABYLON {
  126292. /** @hidden */
  126293. export var highlightsPixelShader: {
  126294. name: string;
  126295. shader: string;
  126296. };
  126297. }
  126298. declare module BABYLON {
  126299. /**
  126300. * Extracts highlights from the image
  126301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126302. */
  126303. export class HighlightsPostProcess extends PostProcess {
  126304. /**
  126305. * Extracts highlights from the image
  126306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126307. * @param name The name of the effect.
  126308. * @param options The required width/height ratio to downsize to before computing the render pass.
  126309. * @param camera The camera to apply the render pass to.
  126310. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126311. * @param engine The engine which the post process will be applied. (default: current engine)
  126312. * @param reusable If the post process can be reused on the same frame. (default: false)
  126313. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126314. */
  126315. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126316. }
  126317. }
  126318. declare module BABYLON {
  126319. /** @hidden */
  126320. export var mrtFragmentDeclaration: {
  126321. name: string;
  126322. shader: string;
  126323. };
  126324. }
  126325. declare module BABYLON {
  126326. /** @hidden */
  126327. export var geometryPixelShader: {
  126328. name: string;
  126329. shader: string;
  126330. };
  126331. }
  126332. declare module BABYLON {
  126333. /** @hidden */
  126334. export var geometryVertexShader: {
  126335. name: string;
  126336. shader: string;
  126337. };
  126338. }
  126339. declare module BABYLON {
  126340. /** @hidden */
  126341. interface ISavedTransformationMatrix {
  126342. world: Matrix;
  126343. viewProjection: Matrix;
  126344. }
  126345. /**
  126346. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126347. */
  126348. export class GeometryBufferRenderer {
  126349. /**
  126350. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126351. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126352. */
  126353. static readonly POSITION_TEXTURE_TYPE: number;
  126354. /**
  126355. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126356. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126357. */
  126358. static readonly VELOCITY_TEXTURE_TYPE: number;
  126359. /**
  126360. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126361. * in order to compute objects velocities when enableVelocity is set to "true"
  126362. * @hidden
  126363. */
  126364. _previousTransformationMatrices: {
  126365. [index: number]: ISavedTransformationMatrix;
  126366. };
  126367. /**
  126368. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126369. * in order to compute objects velocities when enableVelocity is set to "true"
  126370. * @hidden
  126371. */
  126372. _previousBonesTransformationMatrices: {
  126373. [index: number]: Float32Array;
  126374. };
  126375. /**
  126376. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126377. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126378. */
  126379. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126380. private _scene;
  126381. private _multiRenderTarget;
  126382. private _ratio;
  126383. private _enablePosition;
  126384. private _enableVelocity;
  126385. private _positionIndex;
  126386. private _velocityIndex;
  126387. protected _effect: Effect;
  126388. protected _cachedDefines: string;
  126389. /**
  126390. * Set the render list (meshes to be rendered) used in the G buffer.
  126391. */
  126392. renderList: Mesh[];
  126393. /**
  126394. * Gets wether or not G buffer are supported by the running hardware.
  126395. * This requires draw buffer supports
  126396. */
  126397. readonly isSupported: boolean;
  126398. /**
  126399. * Returns the index of the given texture type in the G-Buffer textures array
  126400. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126401. * @returns the index of the given texture type in the G-Buffer textures array
  126402. */
  126403. getTextureIndex(textureType: number): number;
  126404. /**
  126405. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126406. */
  126407. /**
  126408. * Sets whether or not objects positions are enabled for the G buffer.
  126409. */
  126410. enablePosition: boolean;
  126411. /**
  126412. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126413. */
  126414. /**
  126415. * Sets wether or not objects velocities are enabled for the G buffer.
  126416. */
  126417. enableVelocity: boolean;
  126418. /**
  126419. * Gets the scene associated with the buffer.
  126420. */
  126421. readonly scene: Scene;
  126422. /**
  126423. * Gets the ratio used by the buffer during its creation.
  126424. * How big is the buffer related to the main canvas.
  126425. */
  126426. readonly ratio: number;
  126427. /** @hidden */
  126428. static _SceneComponentInitialization: (scene: Scene) => void;
  126429. /**
  126430. * Creates a new G Buffer for the scene
  126431. * @param scene The scene the buffer belongs to
  126432. * @param ratio How big is the buffer related to the main canvas.
  126433. */
  126434. constructor(scene: Scene, ratio?: number);
  126435. /**
  126436. * Checks wether everything is ready to render a submesh to the G buffer.
  126437. * @param subMesh the submesh to check readiness for
  126438. * @param useInstances is the mesh drawn using instance or not
  126439. * @returns true if ready otherwise false
  126440. */
  126441. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126442. /**
  126443. * Gets the current underlying G Buffer.
  126444. * @returns the buffer
  126445. */
  126446. getGBuffer(): MultiRenderTarget;
  126447. /**
  126448. * Gets the number of samples used to render the buffer (anti aliasing).
  126449. */
  126450. /**
  126451. * Sets the number of samples used to render the buffer (anti aliasing).
  126452. */
  126453. samples: number;
  126454. /**
  126455. * Disposes the renderer and frees up associated resources.
  126456. */
  126457. dispose(): void;
  126458. protected _createRenderTargets(): void;
  126459. private _copyBonesTransformationMatrices;
  126460. }
  126461. }
  126462. declare module BABYLON {
  126463. interface Scene {
  126464. /** @hidden (Backing field) */
  126465. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126466. /**
  126467. * Gets or Sets the current geometry buffer associated to the scene.
  126468. */
  126469. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126470. /**
  126471. * Enables a GeometryBufferRender and associates it with the scene
  126472. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126473. * @returns the GeometryBufferRenderer
  126474. */
  126475. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126476. /**
  126477. * Disables the GeometryBufferRender associated with the scene
  126478. */
  126479. disableGeometryBufferRenderer(): void;
  126480. }
  126481. /**
  126482. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126483. * in several rendering techniques.
  126484. */
  126485. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126486. /**
  126487. * The component name helpful to identify the component in the list of scene components.
  126488. */
  126489. readonly name: string;
  126490. /**
  126491. * The scene the component belongs to.
  126492. */
  126493. scene: Scene;
  126494. /**
  126495. * Creates a new instance of the component for the given scene
  126496. * @param scene Defines the scene to register the component in
  126497. */
  126498. constructor(scene: Scene);
  126499. /**
  126500. * Registers the component in a given scene
  126501. */
  126502. register(): void;
  126503. /**
  126504. * Rebuilds the elements related to this component in case of
  126505. * context lost for instance.
  126506. */
  126507. rebuild(): void;
  126508. /**
  126509. * Disposes the component and the associated ressources
  126510. */
  126511. dispose(): void;
  126512. private _gatherRenderTargets;
  126513. }
  126514. }
  126515. declare module BABYLON {
  126516. /** @hidden */
  126517. export var motionBlurPixelShader: {
  126518. name: string;
  126519. shader: string;
  126520. };
  126521. }
  126522. declare module BABYLON {
  126523. /**
  126524. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126525. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126526. * As an example, all you have to do is to create the post-process:
  126527. * var mb = new BABYLON.MotionBlurPostProcess(
  126528. * 'mb', // The name of the effect.
  126529. * scene, // The scene containing the objects to blur according to their velocity.
  126530. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126531. * camera // The camera to apply the render pass to.
  126532. * );
  126533. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126534. */
  126535. export class MotionBlurPostProcess extends PostProcess {
  126536. /**
  126537. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126538. */
  126539. motionStrength: number;
  126540. /**
  126541. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126542. */
  126543. /**
  126544. * Sets the number of iterations to be used for motion blur quality
  126545. */
  126546. motionBlurSamples: number;
  126547. private _motionBlurSamples;
  126548. private _geometryBufferRenderer;
  126549. /**
  126550. * Creates a new instance MotionBlurPostProcess
  126551. * @param name The name of the effect.
  126552. * @param scene The scene containing the objects to blur according to their velocity.
  126553. * @param options The required width/height ratio to downsize to before computing the render pass.
  126554. * @param camera The camera to apply the render pass to.
  126555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126556. * @param engine The engine which the post process will be applied. (default: current engine)
  126557. * @param reusable If the post process can be reused on the same frame. (default: false)
  126558. * @param textureType Type of textures used when performing the post process. (default: 0)
  126559. * @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)
  126560. */
  126561. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126562. /**
  126563. * Excludes the given skinned mesh from computing bones velocities.
  126564. * 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.
  126565. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126566. */
  126567. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126568. /**
  126569. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126570. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126571. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126572. */
  126573. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126574. /**
  126575. * Disposes the post process.
  126576. * @param camera The camera to dispose the post process on.
  126577. */
  126578. dispose(camera?: Camera): void;
  126579. }
  126580. }
  126581. declare module BABYLON {
  126582. /** @hidden */
  126583. export var refractionPixelShader: {
  126584. name: string;
  126585. shader: string;
  126586. };
  126587. }
  126588. declare module BABYLON {
  126589. /**
  126590. * Post process which applies a refractin texture
  126591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126592. */
  126593. export class RefractionPostProcess extends PostProcess {
  126594. /** the base color of the refraction (used to taint the rendering) */
  126595. color: Color3;
  126596. /** simulated refraction depth */
  126597. depth: number;
  126598. /** the coefficient of the base color (0 to remove base color tainting) */
  126599. colorLevel: number;
  126600. private _refTexture;
  126601. private _ownRefractionTexture;
  126602. /**
  126603. * Gets or sets the refraction texture
  126604. * Please note that you are responsible for disposing the texture if you set it manually
  126605. */
  126606. refractionTexture: Texture;
  126607. /**
  126608. * Initializes the RefractionPostProcess
  126609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126610. * @param name The name of the effect.
  126611. * @param refractionTextureUrl Url of the refraction texture to use
  126612. * @param color the base color of the refraction (used to taint the rendering)
  126613. * @param depth simulated refraction depth
  126614. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126615. * @param camera The camera to apply the render pass to.
  126616. * @param options The required width/height ratio to downsize to before computing the render pass.
  126617. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126618. * @param engine The engine which the post process will be applied. (default: current engine)
  126619. * @param reusable If the post process can be reused on the same frame. (default: false)
  126620. */
  126621. constructor(name: string, refractionTextureUrl: string,
  126622. /** the base color of the refraction (used to taint the rendering) */
  126623. color: Color3,
  126624. /** simulated refraction depth */
  126625. depth: number,
  126626. /** the coefficient of the base color (0 to remove base color tainting) */
  126627. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126628. /**
  126629. * Disposes of the post process
  126630. * @param camera Camera to dispose post process on
  126631. */
  126632. dispose(camera: Camera): void;
  126633. }
  126634. }
  126635. declare module BABYLON {
  126636. /** @hidden */
  126637. export var sharpenPixelShader: {
  126638. name: string;
  126639. shader: string;
  126640. };
  126641. }
  126642. declare module BABYLON {
  126643. /**
  126644. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126645. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126646. */
  126647. export class SharpenPostProcess extends PostProcess {
  126648. /**
  126649. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126650. */
  126651. colorAmount: number;
  126652. /**
  126653. * How much sharpness should be applied (default: 0.3)
  126654. */
  126655. edgeAmount: number;
  126656. /**
  126657. * Creates a new instance ConvolutionPostProcess
  126658. * @param name The name of the effect.
  126659. * @param options The required width/height ratio to downsize to before computing the render pass.
  126660. * @param camera The camera to apply the render pass to.
  126661. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126662. * @param engine The engine which the post process will be applied. (default: current engine)
  126663. * @param reusable If the post process can be reused on the same frame. (default: false)
  126664. * @param textureType Type of textures used when performing the post process. (default: 0)
  126665. * @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)
  126666. */
  126667. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126668. }
  126669. }
  126670. declare module BABYLON {
  126671. /**
  126672. * PostProcessRenderPipeline
  126673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126674. */
  126675. export class PostProcessRenderPipeline {
  126676. private engine;
  126677. private _renderEffects;
  126678. private _renderEffectsForIsolatedPass;
  126679. /**
  126680. * List of inspectable custom properties (used by the Inspector)
  126681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126682. */
  126683. inspectableCustomProperties: IInspectable[];
  126684. /**
  126685. * @hidden
  126686. */
  126687. protected _cameras: Camera[];
  126688. /** @hidden */
  126689. _name: string;
  126690. /**
  126691. * Gets pipeline name
  126692. */
  126693. readonly name: string;
  126694. /**
  126695. * Initializes a PostProcessRenderPipeline
  126696. * @param engine engine to add the pipeline to
  126697. * @param name name of the pipeline
  126698. */
  126699. constructor(engine: Engine, name: string);
  126700. /**
  126701. * Gets the class name
  126702. * @returns "PostProcessRenderPipeline"
  126703. */
  126704. getClassName(): string;
  126705. /**
  126706. * If all the render effects in the pipeline are supported
  126707. */
  126708. readonly isSupported: boolean;
  126709. /**
  126710. * Adds an effect to the pipeline
  126711. * @param renderEffect the effect to add
  126712. */
  126713. addEffect(renderEffect: PostProcessRenderEffect): void;
  126714. /** @hidden */
  126715. _rebuild(): void;
  126716. /** @hidden */
  126717. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126718. /** @hidden */
  126719. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126720. /** @hidden */
  126721. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126722. /** @hidden */
  126723. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126724. /** @hidden */
  126725. _attachCameras(cameras: Camera, unique: boolean): void;
  126726. /** @hidden */
  126727. _attachCameras(cameras: Camera[], unique: boolean): void;
  126728. /** @hidden */
  126729. _detachCameras(cameras: Camera): void;
  126730. /** @hidden */
  126731. _detachCameras(cameras: Nullable<Camera[]>): void;
  126732. /** @hidden */
  126733. _update(): void;
  126734. /** @hidden */
  126735. _reset(): void;
  126736. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126737. /**
  126738. * Disposes of the pipeline
  126739. */
  126740. dispose(): void;
  126741. }
  126742. }
  126743. declare module BABYLON {
  126744. /**
  126745. * PostProcessRenderPipelineManager class
  126746. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126747. */
  126748. export class PostProcessRenderPipelineManager {
  126749. private _renderPipelines;
  126750. /**
  126751. * Initializes a PostProcessRenderPipelineManager
  126752. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126753. */
  126754. constructor();
  126755. /**
  126756. * Gets the list of supported render pipelines
  126757. */
  126758. readonly supportedPipelines: PostProcessRenderPipeline[];
  126759. /**
  126760. * Adds a pipeline to the manager
  126761. * @param renderPipeline The pipeline to add
  126762. */
  126763. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126764. /**
  126765. * Attaches a camera to the pipeline
  126766. * @param renderPipelineName The name of the pipeline to attach to
  126767. * @param cameras the camera to attach
  126768. * @param unique if the camera can be attached multiple times to the pipeline
  126769. */
  126770. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126771. /**
  126772. * Detaches a camera from the pipeline
  126773. * @param renderPipelineName The name of the pipeline to detach from
  126774. * @param cameras the camera to detach
  126775. */
  126776. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126777. /**
  126778. * Enables an effect by name on a pipeline
  126779. * @param renderPipelineName the name of the pipeline to enable the effect in
  126780. * @param renderEffectName the name of the effect to enable
  126781. * @param cameras the cameras that the effect should be enabled on
  126782. */
  126783. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126784. /**
  126785. * Disables an effect by name on a pipeline
  126786. * @param renderPipelineName the name of the pipeline to disable the effect in
  126787. * @param renderEffectName the name of the effect to disable
  126788. * @param cameras the cameras that the effect should be disabled on
  126789. */
  126790. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126791. /**
  126792. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126793. */
  126794. update(): void;
  126795. /** @hidden */
  126796. _rebuild(): void;
  126797. /**
  126798. * Disposes of the manager and pipelines
  126799. */
  126800. dispose(): void;
  126801. }
  126802. }
  126803. declare module BABYLON {
  126804. interface Scene {
  126805. /** @hidden (Backing field) */
  126806. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126807. /**
  126808. * Gets the postprocess render pipeline manager
  126809. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126810. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126811. */
  126812. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126813. }
  126814. /**
  126815. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126816. */
  126817. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126818. /**
  126819. * The component name helpfull to identify the component in the list of scene components.
  126820. */
  126821. readonly name: string;
  126822. /**
  126823. * The scene the component belongs to.
  126824. */
  126825. scene: Scene;
  126826. /**
  126827. * Creates a new instance of the component for the given scene
  126828. * @param scene Defines the scene to register the component in
  126829. */
  126830. constructor(scene: Scene);
  126831. /**
  126832. * Registers the component in a given scene
  126833. */
  126834. register(): void;
  126835. /**
  126836. * Rebuilds the elements related to this component in case of
  126837. * context lost for instance.
  126838. */
  126839. rebuild(): void;
  126840. /**
  126841. * Disposes the component and the associated ressources
  126842. */
  126843. dispose(): void;
  126844. private _gatherRenderTargets;
  126845. }
  126846. }
  126847. declare module BABYLON {
  126848. /**
  126849. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126850. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126851. */
  126852. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126853. private _scene;
  126854. private _camerasToBeAttached;
  126855. /**
  126856. * ID of the sharpen post process,
  126857. */
  126858. private readonly SharpenPostProcessId;
  126859. /**
  126860. * @ignore
  126861. * ID of the image processing post process;
  126862. */
  126863. readonly ImageProcessingPostProcessId: string;
  126864. /**
  126865. * @ignore
  126866. * ID of the Fast Approximate Anti-Aliasing post process;
  126867. */
  126868. readonly FxaaPostProcessId: string;
  126869. /**
  126870. * ID of the chromatic aberration post process,
  126871. */
  126872. private readonly ChromaticAberrationPostProcessId;
  126873. /**
  126874. * ID of the grain post process
  126875. */
  126876. private readonly GrainPostProcessId;
  126877. /**
  126878. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126879. */
  126880. sharpen: SharpenPostProcess;
  126881. private _sharpenEffect;
  126882. private bloom;
  126883. /**
  126884. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126885. */
  126886. depthOfField: DepthOfFieldEffect;
  126887. /**
  126888. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126889. */
  126890. fxaa: FxaaPostProcess;
  126891. /**
  126892. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126893. */
  126894. imageProcessing: ImageProcessingPostProcess;
  126895. /**
  126896. * Chromatic aberration post process which will shift rgb colors in the image
  126897. */
  126898. chromaticAberration: ChromaticAberrationPostProcess;
  126899. private _chromaticAberrationEffect;
  126900. /**
  126901. * Grain post process which add noise to the image
  126902. */
  126903. grain: GrainPostProcess;
  126904. private _grainEffect;
  126905. /**
  126906. * Glow post process which adds a glow to emissive areas of the image
  126907. */
  126908. private _glowLayer;
  126909. /**
  126910. * Animations which can be used to tweak settings over a period of time
  126911. */
  126912. animations: Animation[];
  126913. private _imageProcessingConfigurationObserver;
  126914. private _sharpenEnabled;
  126915. private _bloomEnabled;
  126916. private _depthOfFieldEnabled;
  126917. private _depthOfFieldBlurLevel;
  126918. private _fxaaEnabled;
  126919. private _imageProcessingEnabled;
  126920. private _defaultPipelineTextureType;
  126921. private _bloomScale;
  126922. private _chromaticAberrationEnabled;
  126923. private _grainEnabled;
  126924. private _buildAllowed;
  126925. /**
  126926. * Gets active scene
  126927. */
  126928. readonly scene: Scene;
  126929. /**
  126930. * Enable or disable the sharpen process from the pipeline
  126931. */
  126932. sharpenEnabled: boolean;
  126933. private _resizeObserver;
  126934. private _hardwareScaleLevel;
  126935. private _bloomKernel;
  126936. /**
  126937. * Specifies the size of the bloom blur kernel, relative to the final output size
  126938. */
  126939. bloomKernel: number;
  126940. /**
  126941. * Specifies the weight of the bloom in the final rendering
  126942. */
  126943. private _bloomWeight;
  126944. /**
  126945. * Specifies the luma threshold for the area that will be blurred by the bloom
  126946. */
  126947. private _bloomThreshold;
  126948. private _hdr;
  126949. /**
  126950. * The strength of the bloom.
  126951. */
  126952. bloomWeight: number;
  126953. /**
  126954. * The strength of the bloom.
  126955. */
  126956. bloomThreshold: number;
  126957. /**
  126958. * The scale of the bloom, lower value will provide better performance.
  126959. */
  126960. bloomScale: number;
  126961. /**
  126962. * Enable or disable the bloom from the pipeline
  126963. */
  126964. bloomEnabled: boolean;
  126965. private _rebuildBloom;
  126966. /**
  126967. * If the depth of field is enabled.
  126968. */
  126969. depthOfFieldEnabled: boolean;
  126970. /**
  126971. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126972. */
  126973. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126974. /**
  126975. * If the anti aliasing is enabled.
  126976. */
  126977. fxaaEnabled: boolean;
  126978. private _samples;
  126979. /**
  126980. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126981. */
  126982. samples: number;
  126983. /**
  126984. * If image processing is enabled.
  126985. */
  126986. imageProcessingEnabled: boolean;
  126987. /**
  126988. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126989. */
  126990. glowLayerEnabled: boolean;
  126991. /**
  126992. * Gets the glow layer (or null if not defined)
  126993. */
  126994. readonly glowLayer: Nullable<GlowLayer>;
  126995. /**
  126996. * Enable or disable the chromaticAberration process from the pipeline
  126997. */
  126998. chromaticAberrationEnabled: boolean;
  126999. /**
  127000. * Enable or disable the grain process from the pipeline
  127001. */
  127002. grainEnabled: boolean;
  127003. /**
  127004. * @constructor
  127005. * @param name - The rendering pipeline name (default: "")
  127006. * @param hdr - If high dynamic range textures should be used (default: true)
  127007. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127008. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127009. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127010. */
  127011. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127012. /**
  127013. * Get the class name
  127014. * @returns "DefaultRenderingPipeline"
  127015. */
  127016. getClassName(): string;
  127017. /**
  127018. * Force the compilation of the entire pipeline.
  127019. */
  127020. prepare(): void;
  127021. private _hasCleared;
  127022. private _prevPostProcess;
  127023. private _prevPrevPostProcess;
  127024. private _setAutoClearAndTextureSharing;
  127025. private _depthOfFieldSceneObserver;
  127026. private _buildPipeline;
  127027. private _disposePostProcesses;
  127028. /**
  127029. * Adds a camera to the pipeline
  127030. * @param camera the camera to be added
  127031. */
  127032. addCamera(camera: Camera): void;
  127033. /**
  127034. * Removes a camera from the pipeline
  127035. * @param camera the camera to remove
  127036. */
  127037. removeCamera(camera: Camera): void;
  127038. /**
  127039. * Dispose of the pipeline and stop all post processes
  127040. */
  127041. dispose(): void;
  127042. /**
  127043. * Serialize the rendering pipeline (Used when exporting)
  127044. * @returns the serialized object
  127045. */
  127046. serialize(): any;
  127047. /**
  127048. * Parse the serialized pipeline
  127049. * @param source Source pipeline.
  127050. * @param scene The scene to load the pipeline to.
  127051. * @param rootUrl The URL of the serialized pipeline.
  127052. * @returns An instantiated pipeline from the serialized object.
  127053. */
  127054. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127055. }
  127056. }
  127057. declare module BABYLON {
  127058. /** @hidden */
  127059. export var lensHighlightsPixelShader: {
  127060. name: string;
  127061. shader: string;
  127062. };
  127063. }
  127064. declare module BABYLON {
  127065. /** @hidden */
  127066. export var depthOfFieldPixelShader: {
  127067. name: string;
  127068. shader: string;
  127069. };
  127070. }
  127071. declare module BABYLON {
  127072. /**
  127073. * BABYLON.JS Chromatic Aberration GLSL Shader
  127074. * Author: Olivier Guyot
  127075. * Separates very slightly R, G and B colors on the edges of the screen
  127076. * Inspired by Francois Tarlier & Martins Upitis
  127077. */
  127078. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127079. /**
  127080. * @ignore
  127081. * The chromatic aberration PostProcess id in the pipeline
  127082. */
  127083. LensChromaticAberrationEffect: string;
  127084. /**
  127085. * @ignore
  127086. * The highlights enhancing PostProcess id in the pipeline
  127087. */
  127088. HighlightsEnhancingEffect: string;
  127089. /**
  127090. * @ignore
  127091. * The depth-of-field PostProcess id in the pipeline
  127092. */
  127093. LensDepthOfFieldEffect: string;
  127094. private _scene;
  127095. private _depthTexture;
  127096. private _grainTexture;
  127097. private _chromaticAberrationPostProcess;
  127098. private _highlightsPostProcess;
  127099. private _depthOfFieldPostProcess;
  127100. private _edgeBlur;
  127101. private _grainAmount;
  127102. private _chromaticAberration;
  127103. private _distortion;
  127104. private _highlightsGain;
  127105. private _highlightsThreshold;
  127106. private _dofDistance;
  127107. private _dofAperture;
  127108. private _dofDarken;
  127109. private _dofPentagon;
  127110. private _blurNoise;
  127111. /**
  127112. * @constructor
  127113. *
  127114. * Effect parameters are as follow:
  127115. * {
  127116. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127117. * edge_blur: number; // from 0 to x (1 for realism)
  127118. * distortion: number; // from 0 to x (1 for realism)
  127119. * grain_amount: number; // from 0 to 1
  127120. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127121. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127122. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127123. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127124. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127125. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127126. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127127. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127128. * }
  127129. * Note: if an effect parameter is unset, effect is disabled
  127130. *
  127131. * @param name The rendering pipeline name
  127132. * @param parameters - An object containing all parameters (see above)
  127133. * @param scene The scene linked to this pipeline
  127134. * @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)
  127135. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127136. */
  127137. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127138. /**
  127139. * Get the class name
  127140. * @returns "LensRenderingPipeline"
  127141. */
  127142. getClassName(): string;
  127143. /**
  127144. * Gets associated scene
  127145. */
  127146. readonly scene: Scene;
  127147. /**
  127148. * Gets or sets the edge blur
  127149. */
  127150. edgeBlur: number;
  127151. /**
  127152. * Gets or sets the grain amount
  127153. */
  127154. grainAmount: number;
  127155. /**
  127156. * Gets or sets the chromatic aberration amount
  127157. */
  127158. chromaticAberration: number;
  127159. /**
  127160. * Gets or sets the depth of field aperture
  127161. */
  127162. dofAperture: number;
  127163. /**
  127164. * Gets or sets the edge distortion
  127165. */
  127166. edgeDistortion: number;
  127167. /**
  127168. * Gets or sets the depth of field distortion
  127169. */
  127170. dofDistortion: number;
  127171. /**
  127172. * Gets or sets the darken out of focus amount
  127173. */
  127174. darkenOutOfFocus: number;
  127175. /**
  127176. * Gets or sets a boolean indicating if blur noise is enabled
  127177. */
  127178. blurNoise: boolean;
  127179. /**
  127180. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127181. */
  127182. pentagonBokeh: boolean;
  127183. /**
  127184. * Gets or sets the highlight grain amount
  127185. */
  127186. highlightsGain: number;
  127187. /**
  127188. * Gets or sets the highlight threshold
  127189. */
  127190. highlightsThreshold: number;
  127191. /**
  127192. * Sets the amount of blur at the edges
  127193. * @param amount blur amount
  127194. */
  127195. setEdgeBlur(amount: number): void;
  127196. /**
  127197. * Sets edge blur to 0
  127198. */
  127199. disableEdgeBlur(): void;
  127200. /**
  127201. * Sets the amout of grain
  127202. * @param amount Amount of grain
  127203. */
  127204. setGrainAmount(amount: number): void;
  127205. /**
  127206. * Set grain amount to 0
  127207. */
  127208. disableGrain(): void;
  127209. /**
  127210. * Sets the chromatic aberration amount
  127211. * @param amount amount of chromatic aberration
  127212. */
  127213. setChromaticAberration(amount: number): void;
  127214. /**
  127215. * Sets chromatic aberration amount to 0
  127216. */
  127217. disableChromaticAberration(): void;
  127218. /**
  127219. * Sets the EdgeDistortion amount
  127220. * @param amount amount of EdgeDistortion
  127221. */
  127222. setEdgeDistortion(amount: number): void;
  127223. /**
  127224. * Sets edge distortion to 0
  127225. */
  127226. disableEdgeDistortion(): void;
  127227. /**
  127228. * Sets the FocusDistance amount
  127229. * @param amount amount of FocusDistance
  127230. */
  127231. setFocusDistance(amount: number): void;
  127232. /**
  127233. * Disables depth of field
  127234. */
  127235. disableDepthOfField(): void;
  127236. /**
  127237. * Sets the Aperture amount
  127238. * @param amount amount of Aperture
  127239. */
  127240. setAperture(amount: number): void;
  127241. /**
  127242. * Sets the DarkenOutOfFocus amount
  127243. * @param amount amount of DarkenOutOfFocus
  127244. */
  127245. setDarkenOutOfFocus(amount: number): void;
  127246. private _pentagonBokehIsEnabled;
  127247. /**
  127248. * Creates a pentagon bokeh effect
  127249. */
  127250. enablePentagonBokeh(): void;
  127251. /**
  127252. * Disables the pentagon bokeh effect
  127253. */
  127254. disablePentagonBokeh(): void;
  127255. /**
  127256. * Enables noise blur
  127257. */
  127258. enableNoiseBlur(): void;
  127259. /**
  127260. * Disables noise blur
  127261. */
  127262. disableNoiseBlur(): void;
  127263. /**
  127264. * Sets the HighlightsGain amount
  127265. * @param amount amount of HighlightsGain
  127266. */
  127267. setHighlightsGain(amount: number): void;
  127268. /**
  127269. * Sets the HighlightsThreshold amount
  127270. * @param amount amount of HighlightsThreshold
  127271. */
  127272. setHighlightsThreshold(amount: number): void;
  127273. /**
  127274. * Disables highlights
  127275. */
  127276. disableHighlights(): void;
  127277. /**
  127278. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127279. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127280. */
  127281. dispose(disableDepthRender?: boolean): void;
  127282. private _createChromaticAberrationPostProcess;
  127283. private _createHighlightsPostProcess;
  127284. private _createDepthOfFieldPostProcess;
  127285. private _createGrainTexture;
  127286. }
  127287. }
  127288. declare module BABYLON {
  127289. /** @hidden */
  127290. export var ssao2PixelShader: {
  127291. name: string;
  127292. shader: string;
  127293. };
  127294. }
  127295. declare module BABYLON {
  127296. /** @hidden */
  127297. export var ssaoCombinePixelShader: {
  127298. name: string;
  127299. shader: string;
  127300. };
  127301. }
  127302. declare module BABYLON {
  127303. /**
  127304. * Render pipeline to produce ssao effect
  127305. */
  127306. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127307. /**
  127308. * @ignore
  127309. * The PassPostProcess id in the pipeline that contains the original scene color
  127310. */
  127311. SSAOOriginalSceneColorEffect: string;
  127312. /**
  127313. * @ignore
  127314. * The SSAO PostProcess id in the pipeline
  127315. */
  127316. SSAORenderEffect: string;
  127317. /**
  127318. * @ignore
  127319. * The horizontal blur PostProcess id in the pipeline
  127320. */
  127321. SSAOBlurHRenderEffect: string;
  127322. /**
  127323. * @ignore
  127324. * The vertical blur PostProcess id in the pipeline
  127325. */
  127326. SSAOBlurVRenderEffect: string;
  127327. /**
  127328. * @ignore
  127329. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127330. */
  127331. SSAOCombineRenderEffect: string;
  127332. /**
  127333. * The output strength of the SSAO post-process. Default value is 1.0.
  127334. */
  127335. totalStrength: number;
  127336. /**
  127337. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127338. */
  127339. maxZ: number;
  127340. /**
  127341. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127342. */
  127343. minZAspect: number;
  127344. private _samples;
  127345. /**
  127346. * Number of samples used for the SSAO calculations. Default value is 8
  127347. */
  127348. samples: number;
  127349. private _textureSamples;
  127350. /**
  127351. * Number of samples to use for antialiasing
  127352. */
  127353. textureSamples: number;
  127354. /**
  127355. * Ratio object used for SSAO ratio and blur ratio
  127356. */
  127357. private _ratio;
  127358. /**
  127359. * Dynamically generated sphere sampler.
  127360. */
  127361. private _sampleSphere;
  127362. /**
  127363. * Blur filter offsets
  127364. */
  127365. private _samplerOffsets;
  127366. private _expensiveBlur;
  127367. /**
  127368. * If bilateral blur should be used
  127369. */
  127370. expensiveBlur: boolean;
  127371. /**
  127372. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127373. */
  127374. radius: number;
  127375. /**
  127376. * The base color of the SSAO post-process
  127377. * The final result is "base + ssao" between [0, 1]
  127378. */
  127379. base: number;
  127380. /**
  127381. * Support test.
  127382. */
  127383. static readonly IsSupported: boolean;
  127384. private _scene;
  127385. private _depthTexture;
  127386. private _normalTexture;
  127387. private _randomTexture;
  127388. private _originalColorPostProcess;
  127389. private _ssaoPostProcess;
  127390. private _blurHPostProcess;
  127391. private _blurVPostProcess;
  127392. private _ssaoCombinePostProcess;
  127393. private _firstUpdate;
  127394. /**
  127395. * Gets active scene
  127396. */
  127397. readonly scene: Scene;
  127398. /**
  127399. * @constructor
  127400. * @param name The rendering pipeline name
  127401. * @param scene The scene linked to this pipeline
  127402. * @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 }
  127403. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127404. */
  127405. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127406. /**
  127407. * Get the class name
  127408. * @returns "SSAO2RenderingPipeline"
  127409. */
  127410. getClassName(): string;
  127411. /**
  127412. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127413. */
  127414. dispose(disableGeometryBufferRenderer?: boolean): void;
  127415. private _createBlurPostProcess;
  127416. /** @hidden */
  127417. _rebuild(): void;
  127418. private _bits;
  127419. private _radicalInverse_VdC;
  127420. private _hammersley;
  127421. private _hemisphereSample_uniform;
  127422. private _generateHemisphere;
  127423. private _createSSAOPostProcess;
  127424. private _createSSAOCombinePostProcess;
  127425. private _createRandomTexture;
  127426. /**
  127427. * Serialize the rendering pipeline (Used when exporting)
  127428. * @returns the serialized object
  127429. */
  127430. serialize(): any;
  127431. /**
  127432. * Parse the serialized pipeline
  127433. * @param source Source pipeline.
  127434. * @param scene The scene to load the pipeline to.
  127435. * @param rootUrl The URL of the serialized pipeline.
  127436. * @returns An instantiated pipeline from the serialized object.
  127437. */
  127438. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127439. }
  127440. }
  127441. declare module BABYLON {
  127442. /** @hidden */
  127443. export var ssaoPixelShader: {
  127444. name: string;
  127445. shader: string;
  127446. };
  127447. }
  127448. declare module BABYLON {
  127449. /**
  127450. * Render pipeline to produce ssao effect
  127451. */
  127452. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127453. /**
  127454. * @ignore
  127455. * The PassPostProcess id in the pipeline that contains the original scene color
  127456. */
  127457. SSAOOriginalSceneColorEffect: string;
  127458. /**
  127459. * @ignore
  127460. * The SSAO PostProcess id in the pipeline
  127461. */
  127462. SSAORenderEffect: string;
  127463. /**
  127464. * @ignore
  127465. * The horizontal blur PostProcess id in the pipeline
  127466. */
  127467. SSAOBlurHRenderEffect: string;
  127468. /**
  127469. * @ignore
  127470. * The vertical blur PostProcess id in the pipeline
  127471. */
  127472. SSAOBlurVRenderEffect: string;
  127473. /**
  127474. * @ignore
  127475. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127476. */
  127477. SSAOCombineRenderEffect: string;
  127478. /**
  127479. * The output strength of the SSAO post-process. Default value is 1.0.
  127480. */
  127481. totalStrength: number;
  127482. /**
  127483. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127484. */
  127485. radius: number;
  127486. /**
  127487. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127488. * Must not be equal to fallOff and superior to fallOff.
  127489. * Default value is 0.0075
  127490. */
  127491. area: number;
  127492. /**
  127493. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127494. * Must not be equal to area and inferior to area.
  127495. * Default value is 0.000001
  127496. */
  127497. fallOff: number;
  127498. /**
  127499. * The base color of the SSAO post-process
  127500. * The final result is "base + ssao" between [0, 1]
  127501. */
  127502. base: number;
  127503. private _scene;
  127504. private _depthTexture;
  127505. private _randomTexture;
  127506. private _originalColorPostProcess;
  127507. private _ssaoPostProcess;
  127508. private _blurHPostProcess;
  127509. private _blurVPostProcess;
  127510. private _ssaoCombinePostProcess;
  127511. private _firstUpdate;
  127512. /**
  127513. * Gets active scene
  127514. */
  127515. readonly scene: Scene;
  127516. /**
  127517. * @constructor
  127518. * @param name - The rendering pipeline name
  127519. * @param scene - The scene linked to this pipeline
  127520. * @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 }
  127521. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127522. */
  127523. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127524. /**
  127525. * Get the class name
  127526. * @returns "SSAORenderingPipeline"
  127527. */
  127528. getClassName(): string;
  127529. /**
  127530. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127531. */
  127532. dispose(disableDepthRender?: boolean): void;
  127533. private _createBlurPostProcess;
  127534. /** @hidden */
  127535. _rebuild(): void;
  127536. private _createSSAOPostProcess;
  127537. private _createSSAOCombinePostProcess;
  127538. private _createRandomTexture;
  127539. }
  127540. }
  127541. declare module BABYLON {
  127542. /** @hidden */
  127543. export var standardPixelShader: {
  127544. name: string;
  127545. shader: string;
  127546. };
  127547. }
  127548. declare module BABYLON {
  127549. /**
  127550. * Standard rendering pipeline
  127551. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127552. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127553. */
  127554. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127555. /**
  127556. * Public members
  127557. */
  127558. /**
  127559. * Post-process which contains the original scene color before the pipeline applies all the effects
  127560. */
  127561. originalPostProcess: Nullable<PostProcess>;
  127562. /**
  127563. * Post-process used to down scale an image x4
  127564. */
  127565. downSampleX4PostProcess: Nullable<PostProcess>;
  127566. /**
  127567. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127568. */
  127569. brightPassPostProcess: Nullable<PostProcess>;
  127570. /**
  127571. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127572. */
  127573. blurHPostProcesses: PostProcess[];
  127574. /**
  127575. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127576. */
  127577. blurVPostProcesses: PostProcess[];
  127578. /**
  127579. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127580. */
  127581. textureAdderPostProcess: Nullable<PostProcess>;
  127582. /**
  127583. * Post-process used to create volumetric lighting effect
  127584. */
  127585. volumetricLightPostProcess: Nullable<PostProcess>;
  127586. /**
  127587. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127588. */
  127589. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127590. /**
  127591. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127592. */
  127593. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127594. /**
  127595. * Post-process used to merge the volumetric light effect and the real scene color
  127596. */
  127597. volumetricLightMergePostProces: Nullable<PostProcess>;
  127598. /**
  127599. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127600. */
  127601. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127602. /**
  127603. * Base post-process used to calculate the average luminance of the final image for HDR
  127604. */
  127605. luminancePostProcess: Nullable<PostProcess>;
  127606. /**
  127607. * Post-processes used to create down sample post-processes in order to get
  127608. * the average luminance of the final image for HDR
  127609. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127610. */
  127611. luminanceDownSamplePostProcesses: PostProcess[];
  127612. /**
  127613. * Post-process used to create a HDR effect (light adaptation)
  127614. */
  127615. hdrPostProcess: Nullable<PostProcess>;
  127616. /**
  127617. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127618. */
  127619. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127620. /**
  127621. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127622. */
  127623. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127624. /**
  127625. * Post-process used to merge the final HDR post-process and the real scene color
  127626. */
  127627. hdrFinalPostProcess: Nullable<PostProcess>;
  127628. /**
  127629. * Post-process used to create a lens flare effect
  127630. */
  127631. lensFlarePostProcess: Nullable<PostProcess>;
  127632. /**
  127633. * Post-process that merges the result of the lens flare post-process and the real scene color
  127634. */
  127635. lensFlareComposePostProcess: Nullable<PostProcess>;
  127636. /**
  127637. * Post-process used to create a motion blur effect
  127638. */
  127639. motionBlurPostProcess: Nullable<PostProcess>;
  127640. /**
  127641. * Post-process used to create a depth of field effect
  127642. */
  127643. depthOfFieldPostProcess: Nullable<PostProcess>;
  127644. /**
  127645. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127646. */
  127647. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127648. /**
  127649. * Represents the brightness threshold in order to configure the illuminated surfaces
  127650. */
  127651. brightThreshold: number;
  127652. /**
  127653. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127654. */
  127655. blurWidth: number;
  127656. /**
  127657. * Sets if the blur for highlighted surfaces must be only horizontal
  127658. */
  127659. horizontalBlur: boolean;
  127660. /**
  127661. * Gets the overall exposure used by the pipeline
  127662. */
  127663. /**
  127664. * Sets the overall exposure used by the pipeline
  127665. */
  127666. exposure: number;
  127667. /**
  127668. * Texture used typically to simulate "dirty" on camera lens
  127669. */
  127670. lensTexture: Nullable<Texture>;
  127671. /**
  127672. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127673. */
  127674. volumetricLightCoefficient: number;
  127675. /**
  127676. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127677. */
  127678. volumetricLightPower: number;
  127679. /**
  127680. * Used the set the blur intensity to smooth the volumetric lights
  127681. */
  127682. volumetricLightBlurScale: number;
  127683. /**
  127684. * Light (spot or directional) used to generate the volumetric lights rays
  127685. * The source light must have a shadow generate so the pipeline can get its
  127686. * depth map
  127687. */
  127688. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127689. /**
  127690. * For eye adaptation, represents the minimum luminance the eye can see
  127691. */
  127692. hdrMinimumLuminance: number;
  127693. /**
  127694. * For eye adaptation, represents the decrease luminance speed
  127695. */
  127696. hdrDecreaseRate: number;
  127697. /**
  127698. * For eye adaptation, represents the increase luminance speed
  127699. */
  127700. hdrIncreaseRate: number;
  127701. /**
  127702. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127703. */
  127704. /**
  127705. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127706. */
  127707. hdrAutoExposure: boolean;
  127708. /**
  127709. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127710. */
  127711. lensColorTexture: Nullable<Texture>;
  127712. /**
  127713. * The overall strengh for the lens flare effect
  127714. */
  127715. lensFlareStrength: number;
  127716. /**
  127717. * Dispersion coefficient for lens flare ghosts
  127718. */
  127719. lensFlareGhostDispersal: number;
  127720. /**
  127721. * Main lens flare halo width
  127722. */
  127723. lensFlareHaloWidth: number;
  127724. /**
  127725. * Based on the lens distortion effect, defines how much the lens flare result
  127726. * is distorted
  127727. */
  127728. lensFlareDistortionStrength: number;
  127729. /**
  127730. * Configures the blur intensity used for for lens flare (halo)
  127731. */
  127732. lensFlareBlurWidth: number;
  127733. /**
  127734. * Lens star texture must be used to simulate rays on the flares and is available
  127735. * in the documentation
  127736. */
  127737. lensStarTexture: Nullable<Texture>;
  127738. /**
  127739. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127740. * flare effect by taking account of the dirt texture
  127741. */
  127742. lensFlareDirtTexture: Nullable<Texture>;
  127743. /**
  127744. * Represents the focal length for the depth of field effect
  127745. */
  127746. depthOfFieldDistance: number;
  127747. /**
  127748. * Represents the blur intensity for the blurred part of the depth of field effect
  127749. */
  127750. depthOfFieldBlurWidth: number;
  127751. /**
  127752. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127753. */
  127754. /**
  127755. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127756. */
  127757. motionStrength: number;
  127758. /**
  127759. * Gets wether or not the motion blur post-process is object based or screen based.
  127760. */
  127761. /**
  127762. * Sets wether or not the motion blur post-process should be object based or screen based
  127763. */
  127764. objectBasedMotionBlur: boolean;
  127765. /**
  127766. * List of animations for the pipeline (IAnimatable implementation)
  127767. */
  127768. animations: Animation[];
  127769. /**
  127770. * Private members
  127771. */
  127772. private _scene;
  127773. private _currentDepthOfFieldSource;
  127774. private _basePostProcess;
  127775. private _fixedExposure;
  127776. private _currentExposure;
  127777. private _hdrAutoExposure;
  127778. private _hdrCurrentLuminance;
  127779. private _motionStrength;
  127780. private _isObjectBasedMotionBlur;
  127781. private _floatTextureType;
  127782. private _camerasToBeAttached;
  127783. private _ratio;
  127784. private _bloomEnabled;
  127785. private _depthOfFieldEnabled;
  127786. private _vlsEnabled;
  127787. private _lensFlareEnabled;
  127788. private _hdrEnabled;
  127789. private _motionBlurEnabled;
  127790. private _fxaaEnabled;
  127791. private _motionBlurSamples;
  127792. private _volumetricLightStepsCount;
  127793. private _samples;
  127794. /**
  127795. * @ignore
  127796. * Specifies if the bloom pipeline is enabled
  127797. */
  127798. BloomEnabled: boolean;
  127799. /**
  127800. * @ignore
  127801. * Specifies if the depth of field pipeline is enabed
  127802. */
  127803. DepthOfFieldEnabled: boolean;
  127804. /**
  127805. * @ignore
  127806. * Specifies if the lens flare pipeline is enabed
  127807. */
  127808. LensFlareEnabled: boolean;
  127809. /**
  127810. * @ignore
  127811. * Specifies if the HDR pipeline is enabled
  127812. */
  127813. HDREnabled: boolean;
  127814. /**
  127815. * @ignore
  127816. * Specifies if the volumetric lights scattering effect is enabled
  127817. */
  127818. VLSEnabled: boolean;
  127819. /**
  127820. * @ignore
  127821. * Specifies if the motion blur effect is enabled
  127822. */
  127823. MotionBlurEnabled: boolean;
  127824. /**
  127825. * Specifies if anti-aliasing is enabled
  127826. */
  127827. fxaaEnabled: boolean;
  127828. /**
  127829. * Specifies the number of steps used to calculate the volumetric lights
  127830. * Typically in interval [50, 200]
  127831. */
  127832. volumetricLightStepsCount: number;
  127833. /**
  127834. * Specifies the number of samples used for the motion blur effect
  127835. * Typically in interval [16, 64]
  127836. */
  127837. motionBlurSamples: number;
  127838. /**
  127839. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127840. */
  127841. samples: number;
  127842. /**
  127843. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127844. * @constructor
  127845. * @param name The rendering pipeline name
  127846. * @param scene The scene linked to this pipeline
  127847. * @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)
  127848. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127849. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127850. */
  127851. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127852. private _buildPipeline;
  127853. private _createDownSampleX4PostProcess;
  127854. private _createBrightPassPostProcess;
  127855. private _createBlurPostProcesses;
  127856. private _createTextureAdderPostProcess;
  127857. private _createVolumetricLightPostProcess;
  127858. private _createLuminancePostProcesses;
  127859. private _createHdrPostProcess;
  127860. private _createLensFlarePostProcess;
  127861. private _createDepthOfFieldPostProcess;
  127862. private _createMotionBlurPostProcess;
  127863. private _getDepthTexture;
  127864. private _disposePostProcesses;
  127865. /**
  127866. * Dispose of the pipeline and stop all post processes
  127867. */
  127868. dispose(): void;
  127869. /**
  127870. * Serialize the rendering pipeline (Used when exporting)
  127871. * @returns the serialized object
  127872. */
  127873. serialize(): any;
  127874. /**
  127875. * Parse the serialized pipeline
  127876. * @param source Source pipeline.
  127877. * @param scene The scene to load the pipeline to.
  127878. * @param rootUrl The URL of the serialized pipeline.
  127879. * @returns An instantiated pipeline from the serialized object.
  127880. */
  127881. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127882. /**
  127883. * Luminance steps
  127884. */
  127885. static LuminanceSteps: number;
  127886. }
  127887. }
  127888. declare module BABYLON {
  127889. /** @hidden */
  127890. export var tonemapPixelShader: {
  127891. name: string;
  127892. shader: string;
  127893. };
  127894. }
  127895. declare module BABYLON {
  127896. /** Defines operator used for tonemapping */
  127897. export enum TonemappingOperator {
  127898. /** Hable */
  127899. Hable = 0,
  127900. /** Reinhard */
  127901. Reinhard = 1,
  127902. /** HejiDawson */
  127903. HejiDawson = 2,
  127904. /** Photographic */
  127905. Photographic = 3
  127906. }
  127907. /**
  127908. * Defines a post process to apply tone mapping
  127909. */
  127910. export class TonemapPostProcess extends PostProcess {
  127911. private _operator;
  127912. /** Defines the required exposure adjustement */
  127913. exposureAdjustment: number;
  127914. /**
  127915. * Creates a new TonemapPostProcess
  127916. * @param name defines the name of the postprocess
  127917. * @param _operator defines the operator to use
  127918. * @param exposureAdjustment defines the required exposure adjustement
  127919. * @param camera defines the camera to use (can be null)
  127920. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127921. * @param engine defines the hosting engine (can be ignore if camera is set)
  127922. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127923. */
  127924. constructor(name: string, _operator: TonemappingOperator,
  127925. /** Defines the required exposure adjustement */
  127926. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127927. }
  127928. }
  127929. declare module BABYLON {
  127930. /** @hidden */
  127931. export var depthVertexShader: {
  127932. name: string;
  127933. shader: string;
  127934. };
  127935. }
  127936. declare module BABYLON {
  127937. /** @hidden */
  127938. export var volumetricLightScatteringPixelShader: {
  127939. name: string;
  127940. shader: string;
  127941. };
  127942. }
  127943. declare module BABYLON {
  127944. /** @hidden */
  127945. export var volumetricLightScatteringPassVertexShader: {
  127946. name: string;
  127947. shader: string;
  127948. };
  127949. }
  127950. declare module BABYLON {
  127951. /** @hidden */
  127952. export var volumetricLightScatteringPassPixelShader: {
  127953. name: string;
  127954. shader: string;
  127955. };
  127956. }
  127957. declare module BABYLON {
  127958. /**
  127959. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127960. */
  127961. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127962. private _volumetricLightScatteringPass;
  127963. private _volumetricLightScatteringRTT;
  127964. private _viewPort;
  127965. private _screenCoordinates;
  127966. private _cachedDefines;
  127967. /**
  127968. * If not undefined, the mesh position is computed from the attached node position
  127969. */
  127970. attachedNode: {
  127971. position: Vector3;
  127972. };
  127973. /**
  127974. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127975. */
  127976. customMeshPosition: Vector3;
  127977. /**
  127978. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127979. */
  127980. useCustomMeshPosition: boolean;
  127981. /**
  127982. * If the post-process should inverse the light scattering direction
  127983. */
  127984. invert: boolean;
  127985. /**
  127986. * The internal mesh used by the post-process
  127987. */
  127988. mesh: Mesh;
  127989. /**
  127990. * @hidden
  127991. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127992. */
  127993. useDiffuseColor: boolean;
  127994. /**
  127995. * Array containing the excluded meshes not rendered in the internal pass
  127996. */
  127997. excludedMeshes: AbstractMesh[];
  127998. /**
  127999. * Controls the overall intensity of the post-process
  128000. */
  128001. exposure: number;
  128002. /**
  128003. * Dissipates each sample's contribution in range [0, 1]
  128004. */
  128005. decay: number;
  128006. /**
  128007. * Controls the overall intensity of each sample
  128008. */
  128009. weight: number;
  128010. /**
  128011. * Controls the density of each sample
  128012. */
  128013. density: number;
  128014. /**
  128015. * @constructor
  128016. * @param name The post-process name
  128017. * @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)
  128018. * @param camera The camera that the post-process will be attached to
  128019. * @param mesh The mesh used to create the light scattering
  128020. * @param samples The post-process quality, default 100
  128021. * @param samplingModeThe post-process filtering mode
  128022. * @param engine The babylon engine
  128023. * @param reusable If the post-process is reusable
  128024. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128025. */
  128026. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128027. /**
  128028. * Returns the string "VolumetricLightScatteringPostProcess"
  128029. * @returns "VolumetricLightScatteringPostProcess"
  128030. */
  128031. getClassName(): string;
  128032. private _isReady;
  128033. /**
  128034. * Sets the new light position for light scattering effect
  128035. * @param position The new custom light position
  128036. */
  128037. setCustomMeshPosition(position: Vector3): void;
  128038. /**
  128039. * Returns the light position for light scattering effect
  128040. * @return Vector3 The custom light position
  128041. */
  128042. getCustomMeshPosition(): Vector3;
  128043. /**
  128044. * Disposes the internal assets and detaches the post-process from the camera
  128045. */
  128046. dispose(camera: Camera): void;
  128047. /**
  128048. * Returns the render target texture used by the post-process
  128049. * @return the render target texture used by the post-process
  128050. */
  128051. getPass(): RenderTargetTexture;
  128052. private _meshExcluded;
  128053. private _createPass;
  128054. private _updateMeshScreenCoordinates;
  128055. /**
  128056. * Creates a default mesh for the Volumeric Light Scattering post-process
  128057. * @param name The mesh name
  128058. * @param scene The scene where to create the mesh
  128059. * @return the default mesh
  128060. */
  128061. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128062. }
  128063. }
  128064. declare module BABYLON {
  128065. interface Scene {
  128066. /** @hidden (Backing field) */
  128067. _boundingBoxRenderer: BoundingBoxRenderer;
  128068. /** @hidden (Backing field) */
  128069. _forceShowBoundingBoxes: boolean;
  128070. /**
  128071. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128072. */
  128073. forceShowBoundingBoxes: boolean;
  128074. /**
  128075. * Gets the bounding box renderer associated with the scene
  128076. * @returns a BoundingBoxRenderer
  128077. */
  128078. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128079. }
  128080. interface AbstractMesh {
  128081. /** @hidden (Backing field) */
  128082. _showBoundingBox: boolean;
  128083. /**
  128084. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128085. */
  128086. showBoundingBox: boolean;
  128087. }
  128088. /**
  128089. * Component responsible of rendering the bounding box of the meshes in a scene.
  128090. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128091. */
  128092. export class BoundingBoxRenderer implements ISceneComponent {
  128093. /**
  128094. * The component name helpfull to identify the component in the list of scene components.
  128095. */
  128096. readonly name: string;
  128097. /**
  128098. * The scene the component belongs to.
  128099. */
  128100. scene: Scene;
  128101. /**
  128102. * Color of the bounding box lines placed in front of an object
  128103. */
  128104. frontColor: Color3;
  128105. /**
  128106. * Color of the bounding box lines placed behind an object
  128107. */
  128108. backColor: Color3;
  128109. /**
  128110. * Defines if the renderer should show the back lines or not
  128111. */
  128112. showBackLines: boolean;
  128113. /**
  128114. * @hidden
  128115. */
  128116. renderList: SmartArray<BoundingBox>;
  128117. private _colorShader;
  128118. private _vertexBuffers;
  128119. private _indexBuffer;
  128120. private _fillIndexBuffer;
  128121. private _fillIndexData;
  128122. /**
  128123. * Instantiates a new bounding box renderer in a scene.
  128124. * @param scene the scene the renderer renders in
  128125. */
  128126. constructor(scene: Scene);
  128127. /**
  128128. * Registers the component in a given scene
  128129. */
  128130. register(): void;
  128131. private _evaluateSubMesh;
  128132. private _activeMesh;
  128133. private _prepareRessources;
  128134. private _createIndexBuffer;
  128135. /**
  128136. * Rebuilds the elements related to this component in case of
  128137. * context lost for instance.
  128138. */
  128139. rebuild(): void;
  128140. /**
  128141. * @hidden
  128142. */
  128143. reset(): void;
  128144. /**
  128145. * Render the bounding boxes of a specific rendering group
  128146. * @param renderingGroupId defines the rendering group to render
  128147. */
  128148. render(renderingGroupId: number): void;
  128149. /**
  128150. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128151. * @param mesh Define the mesh to render the occlusion bounding box for
  128152. */
  128153. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128154. /**
  128155. * Dispose and release the resources attached to this renderer.
  128156. */
  128157. dispose(): void;
  128158. }
  128159. }
  128160. declare module BABYLON {
  128161. /** @hidden */
  128162. export var depthPixelShader: {
  128163. name: string;
  128164. shader: string;
  128165. };
  128166. }
  128167. declare module BABYLON {
  128168. /**
  128169. * This represents a depth renderer in Babylon.
  128170. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128171. */
  128172. export class DepthRenderer {
  128173. private _scene;
  128174. private _depthMap;
  128175. private _effect;
  128176. private readonly _storeNonLinearDepth;
  128177. private readonly _clearColor;
  128178. /** Get if the depth renderer is using packed depth or not */
  128179. readonly isPacked: boolean;
  128180. private _cachedDefines;
  128181. private _camera;
  128182. /**
  128183. * Specifiess that the depth renderer will only be used within
  128184. * the camera it is created for.
  128185. * This can help forcing its rendering during the camera processing.
  128186. */
  128187. useOnlyInActiveCamera: boolean;
  128188. /** @hidden */
  128189. static _SceneComponentInitialization: (scene: Scene) => void;
  128190. /**
  128191. * Instantiates a depth renderer
  128192. * @param scene The scene the renderer belongs to
  128193. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128194. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128195. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128196. */
  128197. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128198. /**
  128199. * Creates the depth rendering effect and checks if the effect is ready.
  128200. * @param subMesh The submesh to be used to render the depth map of
  128201. * @param useInstances If multiple world instances should be used
  128202. * @returns if the depth renderer is ready to render the depth map
  128203. */
  128204. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128205. /**
  128206. * Gets the texture which the depth map will be written to.
  128207. * @returns The depth map texture
  128208. */
  128209. getDepthMap(): RenderTargetTexture;
  128210. /**
  128211. * Disposes of the depth renderer.
  128212. */
  128213. dispose(): void;
  128214. }
  128215. }
  128216. declare module BABYLON {
  128217. interface Scene {
  128218. /** @hidden (Backing field) */
  128219. _depthRenderer: {
  128220. [id: string]: DepthRenderer;
  128221. };
  128222. /**
  128223. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128224. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128225. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128226. * @returns the created depth renderer
  128227. */
  128228. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128229. /**
  128230. * Disables a depth renderer for a given camera
  128231. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128232. */
  128233. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128234. }
  128235. /**
  128236. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128237. * in several rendering techniques.
  128238. */
  128239. export class DepthRendererSceneComponent implements ISceneComponent {
  128240. /**
  128241. * The component name helpfull to identify the component in the list of scene components.
  128242. */
  128243. readonly name: string;
  128244. /**
  128245. * The scene the component belongs to.
  128246. */
  128247. scene: Scene;
  128248. /**
  128249. * Creates a new instance of the component for the given scene
  128250. * @param scene Defines the scene to register the component in
  128251. */
  128252. constructor(scene: Scene);
  128253. /**
  128254. * Registers the component in a given scene
  128255. */
  128256. register(): void;
  128257. /**
  128258. * Rebuilds the elements related to this component in case of
  128259. * context lost for instance.
  128260. */
  128261. rebuild(): void;
  128262. /**
  128263. * Disposes the component and the associated ressources
  128264. */
  128265. dispose(): void;
  128266. private _gatherRenderTargets;
  128267. private _gatherActiveCameraRenderTargets;
  128268. }
  128269. }
  128270. declare module BABYLON {
  128271. /** @hidden */
  128272. export var outlinePixelShader: {
  128273. name: string;
  128274. shader: string;
  128275. };
  128276. }
  128277. declare module BABYLON {
  128278. /** @hidden */
  128279. export var outlineVertexShader: {
  128280. name: string;
  128281. shader: string;
  128282. };
  128283. }
  128284. declare module BABYLON {
  128285. interface Scene {
  128286. /** @hidden */
  128287. _outlineRenderer: OutlineRenderer;
  128288. /**
  128289. * Gets the outline renderer associated with the scene
  128290. * @returns a OutlineRenderer
  128291. */
  128292. getOutlineRenderer(): OutlineRenderer;
  128293. }
  128294. interface AbstractMesh {
  128295. /** @hidden (Backing field) */
  128296. _renderOutline: boolean;
  128297. /**
  128298. * Gets or sets a boolean indicating if the outline must be rendered as well
  128299. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128300. */
  128301. renderOutline: boolean;
  128302. /** @hidden (Backing field) */
  128303. _renderOverlay: boolean;
  128304. /**
  128305. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128306. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128307. */
  128308. renderOverlay: boolean;
  128309. }
  128310. /**
  128311. * This class is responsible to draw bothe outline/overlay of meshes.
  128312. * It should not be used directly but through the available method on mesh.
  128313. */
  128314. export class OutlineRenderer implements ISceneComponent {
  128315. /**
  128316. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128317. */
  128318. private static _StencilReference;
  128319. /**
  128320. * The name of the component. Each component must have a unique name.
  128321. */
  128322. name: string;
  128323. /**
  128324. * The scene the component belongs to.
  128325. */
  128326. scene: Scene;
  128327. /**
  128328. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128329. */
  128330. zOffset: number;
  128331. private _engine;
  128332. private _effect;
  128333. private _cachedDefines;
  128334. private _savedDepthWrite;
  128335. /**
  128336. * Instantiates a new outline renderer. (There could be only one per scene).
  128337. * @param scene Defines the scene it belongs to
  128338. */
  128339. constructor(scene: Scene);
  128340. /**
  128341. * Register the component to one instance of a scene.
  128342. */
  128343. register(): void;
  128344. /**
  128345. * Rebuilds the elements related to this component in case of
  128346. * context lost for instance.
  128347. */
  128348. rebuild(): void;
  128349. /**
  128350. * Disposes the component and the associated ressources.
  128351. */
  128352. dispose(): void;
  128353. /**
  128354. * Renders the outline in the canvas.
  128355. * @param subMesh Defines the sumesh to render
  128356. * @param batch Defines the batch of meshes in case of instances
  128357. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128358. */
  128359. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128360. /**
  128361. * Returns whether or not the outline renderer is ready for a given submesh.
  128362. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128363. * @param subMesh Defines the submesh to check readyness for
  128364. * @param useInstances Defines wheter wee are trying to render instances or not
  128365. * @returns true if ready otherwise false
  128366. */
  128367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128368. private _beforeRenderingMesh;
  128369. private _afterRenderingMesh;
  128370. }
  128371. }
  128372. declare module BABYLON {
  128373. /**
  128374. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128375. * @see http://doc.babylonjs.com/babylon101/sprites
  128376. */
  128377. export class SpritePackedManager extends SpriteManager {
  128378. /** defines the packed manager's name */
  128379. name: string;
  128380. /**
  128381. * Creates a new sprite manager from a packed sprite sheet
  128382. * @param name defines the manager's name
  128383. * @param imgUrl defines the sprite sheet url
  128384. * @param capacity defines the maximum allowed number of sprites
  128385. * @param scene defines the hosting scene
  128386. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128387. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128388. * @param samplingMode defines the smapling mode to use with spritesheet
  128389. * @param fromPacked set to true; do not alter
  128390. */
  128391. constructor(
  128392. /** defines the packed manager's name */
  128393. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128394. }
  128395. }
  128396. declare module BABYLON {
  128397. /**
  128398. * Defines the list of states available for a task inside a AssetsManager
  128399. */
  128400. export enum AssetTaskState {
  128401. /**
  128402. * Initialization
  128403. */
  128404. INIT = 0,
  128405. /**
  128406. * Running
  128407. */
  128408. RUNNING = 1,
  128409. /**
  128410. * Done
  128411. */
  128412. DONE = 2,
  128413. /**
  128414. * Error
  128415. */
  128416. ERROR = 3
  128417. }
  128418. /**
  128419. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128420. */
  128421. export abstract class AbstractAssetTask {
  128422. /**
  128423. * Task name
  128424. */ name: string;
  128425. /**
  128426. * Callback called when the task is successful
  128427. */
  128428. onSuccess: (task: any) => void;
  128429. /**
  128430. * Callback called when the task is not successful
  128431. */
  128432. onError: (task: any, message?: string, exception?: any) => void;
  128433. /**
  128434. * Creates a new AssetsManager
  128435. * @param name defines the name of the task
  128436. */
  128437. constructor(
  128438. /**
  128439. * Task name
  128440. */ name: string);
  128441. private _isCompleted;
  128442. private _taskState;
  128443. private _errorObject;
  128444. /**
  128445. * Get if the task is completed
  128446. */
  128447. readonly isCompleted: boolean;
  128448. /**
  128449. * Gets the current state of the task
  128450. */
  128451. readonly taskState: AssetTaskState;
  128452. /**
  128453. * Gets the current error object (if task is in error)
  128454. */
  128455. readonly errorObject: {
  128456. message?: string;
  128457. exception?: any;
  128458. };
  128459. /**
  128460. * Internal only
  128461. * @hidden
  128462. */
  128463. _setErrorObject(message?: string, exception?: any): void;
  128464. /**
  128465. * Execute the current task
  128466. * @param scene defines the scene where you want your assets to be loaded
  128467. * @param onSuccess is a callback called when the task is successfully executed
  128468. * @param onError is a callback called if an error occurs
  128469. */
  128470. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128471. /**
  128472. * Execute the current task
  128473. * @param scene defines the scene where you want your assets to be loaded
  128474. * @param onSuccess is a callback called when the task is successfully executed
  128475. * @param onError is a callback called if an error occurs
  128476. */
  128477. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128478. /**
  128479. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128480. * This can be used with failed tasks that have the reason for failure fixed.
  128481. */
  128482. reset(): void;
  128483. private onErrorCallback;
  128484. private onDoneCallback;
  128485. }
  128486. /**
  128487. * Define the interface used by progress events raised during assets loading
  128488. */
  128489. export interface IAssetsProgressEvent {
  128490. /**
  128491. * Defines the number of remaining tasks to process
  128492. */
  128493. remainingCount: number;
  128494. /**
  128495. * Defines the total number of tasks
  128496. */
  128497. totalCount: number;
  128498. /**
  128499. * Defines the task that was just processed
  128500. */
  128501. task: AbstractAssetTask;
  128502. }
  128503. /**
  128504. * Class used to share progress information about assets loading
  128505. */
  128506. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128507. /**
  128508. * Defines the number of remaining tasks to process
  128509. */
  128510. remainingCount: number;
  128511. /**
  128512. * Defines the total number of tasks
  128513. */
  128514. totalCount: number;
  128515. /**
  128516. * Defines the task that was just processed
  128517. */
  128518. task: AbstractAssetTask;
  128519. /**
  128520. * Creates a AssetsProgressEvent
  128521. * @param remainingCount defines the number of remaining tasks to process
  128522. * @param totalCount defines the total number of tasks
  128523. * @param task defines the task that was just processed
  128524. */
  128525. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128526. }
  128527. /**
  128528. * Define a task used by AssetsManager to load meshes
  128529. */
  128530. export class MeshAssetTask extends AbstractAssetTask {
  128531. /**
  128532. * Defines the name of the task
  128533. */
  128534. name: string;
  128535. /**
  128536. * Defines the list of mesh's names you want to load
  128537. */
  128538. meshesNames: any;
  128539. /**
  128540. * Defines the root url to use as a base to load your meshes and associated resources
  128541. */
  128542. rootUrl: string;
  128543. /**
  128544. * Defines the filename of the scene to load from
  128545. */
  128546. sceneFilename: string;
  128547. /**
  128548. * Gets the list of loaded meshes
  128549. */
  128550. loadedMeshes: Array<AbstractMesh>;
  128551. /**
  128552. * Gets the list of loaded particle systems
  128553. */
  128554. loadedParticleSystems: Array<IParticleSystem>;
  128555. /**
  128556. * Gets the list of loaded skeletons
  128557. */
  128558. loadedSkeletons: Array<Skeleton>;
  128559. /**
  128560. * Gets the list of loaded animation groups
  128561. */
  128562. loadedAnimationGroups: Array<AnimationGroup>;
  128563. /**
  128564. * Callback called when the task is successful
  128565. */
  128566. onSuccess: (task: MeshAssetTask) => void;
  128567. /**
  128568. * Callback called when the task is successful
  128569. */
  128570. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128571. /**
  128572. * Creates a new MeshAssetTask
  128573. * @param name defines the name of the task
  128574. * @param meshesNames defines the list of mesh's names you want to load
  128575. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128576. * @param sceneFilename defines the filename of the scene to load from
  128577. */
  128578. constructor(
  128579. /**
  128580. * Defines the name of the task
  128581. */
  128582. name: string,
  128583. /**
  128584. * Defines the list of mesh's names you want to load
  128585. */
  128586. meshesNames: any,
  128587. /**
  128588. * Defines the root url to use as a base to load your meshes and associated resources
  128589. */
  128590. rootUrl: string,
  128591. /**
  128592. * Defines the filename of the scene to load from
  128593. */
  128594. sceneFilename: string);
  128595. /**
  128596. * Execute the current task
  128597. * @param scene defines the scene where you want your assets to be loaded
  128598. * @param onSuccess is a callback called when the task is successfully executed
  128599. * @param onError is a callback called if an error occurs
  128600. */
  128601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128602. }
  128603. /**
  128604. * Define a task used by AssetsManager to load text content
  128605. */
  128606. export class TextFileAssetTask extends AbstractAssetTask {
  128607. /**
  128608. * Defines the name of the task
  128609. */
  128610. name: string;
  128611. /**
  128612. * Defines the location of the file to load
  128613. */
  128614. url: string;
  128615. /**
  128616. * Gets the loaded text string
  128617. */
  128618. text: string;
  128619. /**
  128620. * Callback called when the task is successful
  128621. */
  128622. onSuccess: (task: TextFileAssetTask) => void;
  128623. /**
  128624. * Callback called when the task is successful
  128625. */
  128626. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128627. /**
  128628. * Creates a new TextFileAssetTask object
  128629. * @param name defines the name of the task
  128630. * @param url defines the location of the file to load
  128631. */
  128632. constructor(
  128633. /**
  128634. * Defines the name of the task
  128635. */
  128636. name: string,
  128637. /**
  128638. * Defines the location of the file to load
  128639. */
  128640. url: string);
  128641. /**
  128642. * Execute the current task
  128643. * @param scene defines the scene where you want your assets to be loaded
  128644. * @param onSuccess is a callback called when the task is successfully executed
  128645. * @param onError is a callback called if an error occurs
  128646. */
  128647. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128648. }
  128649. /**
  128650. * Define a task used by AssetsManager to load binary data
  128651. */
  128652. export class BinaryFileAssetTask extends AbstractAssetTask {
  128653. /**
  128654. * Defines the name of the task
  128655. */
  128656. name: string;
  128657. /**
  128658. * Defines the location of the file to load
  128659. */
  128660. url: string;
  128661. /**
  128662. * Gets the lodaded data (as an array buffer)
  128663. */
  128664. data: ArrayBuffer;
  128665. /**
  128666. * Callback called when the task is successful
  128667. */
  128668. onSuccess: (task: BinaryFileAssetTask) => void;
  128669. /**
  128670. * Callback called when the task is successful
  128671. */
  128672. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128673. /**
  128674. * Creates a new BinaryFileAssetTask object
  128675. * @param name defines the name of the new task
  128676. * @param url defines the location of the file to load
  128677. */
  128678. constructor(
  128679. /**
  128680. * Defines the name of the task
  128681. */
  128682. name: string,
  128683. /**
  128684. * Defines the location of the file to load
  128685. */
  128686. url: string);
  128687. /**
  128688. * Execute the current task
  128689. * @param scene defines the scene where you want your assets to be loaded
  128690. * @param onSuccess is a callback called when the task is successfully executed
  128691. * @param onError is a callback called if an error occurs
  128692. */
  128693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128694. }
  128695. /**
  128696. * Define a task used by AssetsManager to load images
  128697. */
  128698. export class ImageAssetTask extends AbstractAssetTask {
  128699. /**
  128700. * Defines the name of the task
  128701. */
  128702. name: string;
  128703. /**
  128704. * Defines the location of the image to load
  128705. */
  128706. url: string;
  128707. /**
  128708. * Gets the loaded images
  128709. */
  128710. image: HTMLImageElement;
  128711. /**
  128712. * Callback called when the task is successful
  128713. */
  128714. onSuccess: (task: ImageAssetTask) => void;
  128715. /**
  128716. * Callback called when the task is successful
  128717. */
  128718. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128719. /**
  128720. * Creates a new ImageAssetTask
  128721. * @param name defines the name of the task
  128722. * @param url defines the location of the image to load
  128723. */
  128724. constructor(
  128725. /**
  128726. * Defines the name of the task
  128727. */
  128728. name: string,
  128729. /**
  128730. * Defines the location of the image to load
  128731. */
  128732. url: string);
  128733. /**
  128734. * Execute the current task
  128735. * @param scene defines the scene where you want your assets to be loaded
  128736. * @param onSuccess is a callback called when the task is successfully executed
  128737. * @param onError is a callback called if an error occurs
  128738. */
  128739. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128740. }
  128741. /**
  128742. * Defines the interface used by texture loading tasks
  128743. */
  128744. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128745. /**
  128746. * Gets the loaded texture
  128747. */
  128748. texture: TEX;
  128749. }
  128750. /**
  128751. * Define a task used by AssetsManager to load 2D textures
  128752. */
  128753. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128754. /**
  128755. * Defines the name of the task
  128756. */
  128757. name: string;
  128758. /**
  128759. * Defines the location of the file to load
  128760. */
  128761. url: string;
  128762. /**
  128763. * Defines if mipmap should not be generated (default is false)
  128764. */
  128765. noMipmap?: boolean | undefined;
  128766. /**
  128767. * Defines if texture must be inverted on Y axis (default is false)
  128768. */
  128769. invertY?: boolean | undefined;
  128770. /**
  128771. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128772. */
  128773. samplingMode: number;
  128774. /**
  128775. * Gets the loaded texture
  128776. */
  128777. texture: Texture;
  128778. /**
  128779. * Callback called when the task is successful
  128780. */
  128781. onSuccess: (task: TextureAssetTask) => void;
  128782. /**
  128783. * Callback called when the task is successful
  128784. */
  128785. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128786. /**
  128787. * Creates a new TextureAssetTask object
  128788. * @param name defines the name of the task
  128789. * @param url defines the location of the file to load
  128790. * @param noMipmap defines if mipmap should not be generated (default is false)
  128791. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128792. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128793. */
  128794. constructor(
  128795. /**
  128796. * Defines the name of the task
  128797. */
  128798. name: string,
  128799. /**
  128800. * Defines the location of the file to load
  128801. */
  128802. url: string,
  128803. /**
  128804. * Defines if mipmap should not be generated (default is false)
  128805. */
  128806. noMipmap?: boolean | undefined,
  128807. /**
  128808. * Defines if texture must be inverted on Y axis (default is false)
  128809. */
  128810. invertY?: boolean | undefined,
  128811. /**
  128812. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128813. */
  128814. samplingMode?: number);
  128815. /**
  128816. * Execute the current task
  128817. * @param scene defines the scene where you want your assets to be loaded
  128818. * @param onSuccess is a callback called when the task is successfully executed
  128819. * @param onError is a callback called if an error occurs
  128820. */
  128821. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128822. }
  128823. /**
  128824. * Define a task used by AssetsManager to load cube textures
  128825. */
  128826. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128827. /**
  128828. * Defines the name of the task
  128829. */
  128830. name: string;
  128831. /**
  128832. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128833. */
  128834. url: string;
  128835. /**
  128836. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128837. */
  128838. extensions?: string[] | undefined;
  128839. /**
  128840. * Defines if mipmaps should not be generated (default is false)
  128841. */
  128842. noMipmap?: boolean | undefined;
  128843. /**
  128844. * Defines the explicit list of files (undefined by default)
  128845. */
  128846. files?: string[] | undefined;
  128847. /**
  128848. * Gets the loaded texture
  128849. */
  128850. texture: CubeTexture;
  128851. /**
  128852. * Callback called when the task is successful
  128853. */
  128854. onSuccess: (task: CubeTextureAssetTask) => void;
  128855. /**
  128856. * Callback called when the task is successful
  128857. */
  128858. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128859. /**
  128860. * Creates a new CubeTextureAssetTask
  128861. * @param name defines the name of the task
  128862. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128863. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128864. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128865. * @param files defines the explicit list of files (undefined by default)
  128866. */
  128867. constructor(
  128868. /**
  128869. * Defines the name of the task
  128870. */
  128871. name: string,
  128872. /**
  128873. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128874. */
  128875. url: string,
  128876. /**
  128877. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128878. */
  128879. extensions?: string[] | undefined,
  128880. /**
  128881. * Defines if mipmaps should not be generated (default is false)
  128882. */
  128883. noMipmap?: boolean | undefined,
  128884. /**
  128885. * Defines the explicit list of files (undefined by default)
  128886. */
  128887. files?: string[] | undefined);
  128888. /**
  128889. * Execute the current task
  128890. * @param scene defines the scene where you want your assets to be loaded
  128891. * @param onSuccess is a callback called when the task is successfully executed
  128892. * @param onError is a callback called if an error occurs
  128893. */
  128894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128895. }
  128896. /**
  128897. * Define a task used by AssetsManager to load HDR cube textures
  128898. */
  128899. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128900. /**
  128901. * Defines the name of the task
  128902. */
  128903. name: string;
  128904. /**
  128905. * Defines the location of the file to load
  128906. */
  128907. url: string;
  128908. /**
  128909. * Defines the desired size (the more it increases the longer the generation will be)
  128910. */
  128911. size: number;
  128912. /**
  128913. * Defines if mipmaps should not be generated (default is false)
  128914. */
  128915. noMipmap: boolean;
  128916. /**
  128917. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128918. */
  128919. generateHarmonics: boolean;
  128920. /**
  128921. * 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)
  128922. */
  128923. gammaSpace: boolean;
  128924. /**
  128925. * Internal Use Only
  128926. */
  128927. reserved: boolean;
  128928. /**
  128929. * Gets the loaded texture
  128930. */
  128931. texture: HDRCubeTexture;
  128932. /**
  128933. * Callback called when the task is successful
  128934. */
  128935. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128936. /**
  128937. * Callback called when the task is successful
  128938. */
  128939. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128940. /**
  128941. * Creates a new HDRCubeTextureAssetTask object
  128942. * @param name defines the name of the task
  128943. * @param url defines the location of the file to load
  128944. * @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.
  128945. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128946. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128947. * @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)
  128948. * @param reserved Internal use only
  128949. */
  128950. constructor(
  128951. /**
  128952. * Defines the name of the task
  128953. */
  128954. name: string,
  128955. /**
  128956. * Defines the location of the file to load
  128957. */
  128958. url: string,
  128959. /**
  128960. * Defines the desired size (the more it increases the longer the generation will be)
  128961. */
  128962. size: number,
  128963. /**
  128964. * Defines if mipmaps should not be generated (default is false)
  128965. */
  128966. noMipmap?: boolean,
  128967. /**
  128968. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128969. */
  128970. generateHarmonics?: boolean,
  128971. /**
  128972. * 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)
  128973. */
  128974. gammaSpace?: boolean,
  128975. /**
  128976. * Internal Use Only
  128977. */
  128978. reserved?: boolean);
  128979. /**
  128980. * Execute the current task
  128981. * @param scene defines the scene where you want your assets to be loaded
  128982. * @param onSuccess is a callback called when the task is successfully executed
  128983. * @param onError is a callback called if an error occurs
  128984. */
  128985. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128986. }
  128987. /**
  128988. * Define a task used by AssetsManager to load Equirectangular cube textures
  128989. */
  128990. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128991. /**
  128992. * Defines the name of the task
  128993. */
  128994. name: string;
  128995. /**
  128996. * Defines the location of the file to load
  128997. */
  128998. url: string;
  128999. /**
  129000. * Defines the desired size (the more it increases the longer the generation will be)
  129001. */
  129002. size: number;
  129003. /**
  129004. * Defines if mipmaps should not be generated (default is false)
  129005. */
  129006. noMipmap: boolean;
  129007. /**
  129008. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129009. * but the standard material would require them in Gamma space) (default is true)
  129010. */
  129011. gammaSpace: boolean;
  129012. /**
  129013. * Gets the loaded texture
  129014. */
  129015. texture: EquiRectangularCubeTexture;
  129016. /**
  129017. * Callback called when the task is successful
  129018. */
  129019. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129020. /**
  129021. * Callback called when the task is successful
  129022. */
  129023. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129024. /**
  129025. * Creates a new EquiRectangularCubeTextureAssetTask object
  129026. * @param name defines the name of the task
  129027. * @param url defines the location of the file to load
  129028. * @param size defines the desired size (the more it increases the longer the generation will be)
  129029. * If the size is omitted this implies you are using a preprocessed cubemap.
  129030. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129031. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129032. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129033. * (default is true)
  129034. */
  129035. constructor(
  129036. /**
  129037. * Defines the name of the task
  129038. */
  129039. name: string,
  129040. /**
  129041. * Defines the location of the file to load
  129042. */
  129043. url: string,
  129044. /**
  129045. * Defines the desired size (the more it increases the longer the generation will be)
  129046. */
  129047. size: number,
  129048. /**
  129049. * Defines if mipmaps should not be generated (default is false)
  129050. */
  129051. noMipmap?: boolean,
  129052. /**
  129053. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129054. * but the standard material would require them in Gamma space) (default is true)
  129055. */
  129056. gammaSpace?: boolean);
  129057. /**
  129058. * Execute the current task
  129059. * @param scene defines the scene where you want your assets to be loaded
  129060. * @param onSuccess is a callback called when the task is successfully executed
  129061. * @param onError is a callback called if an error occurs
  129062. */
  129063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129064. }
  129065. /**
  129066. * This class can be used to easily import assets into a scene
  129067. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129068. */
  129069. export class AssetsManager {
  129070. private _scene;
  129071. private _isLoading;
  129072. protected _tasks: AbstractAssetTask[];
  129073. protected _waitingTasksCount: number;
  129074. protected _totalTasksCount: number;
  129075. /**
  129076. * Callback called when all tasks are processed
  129077. */
  129078. onFinish: (tasks: AbstractAssetTask[]) => void;
  129079. /**
  129080. * Callback called when a task is successful
  129081. */
  129082. onTaskSuccess: (task: AbstractAssetTask) => void;
  129083. /**
  129084. * Callback called when a task had an error
  129085. */
  129086. onTaskError: (task: AbstractAssetTask) => void;
  129087. /**
  129088. * Callback called when a task is done (whatever the result is)
  129089. */
  129090. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129091. /**
  129092. * Observable called when all tasks are processed
  129093. */
  129094. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129095. /**
  129096. * Observable called when a task had an error
  129097. */
  129098. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129099. /**
  129100. * Observable called when all tasks were executed
  129101. */
  129102. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129103. /**
  129104. * Observable called when a task is done (whatever the result is)
  129105. */
  129106. onProgressObservable: Observable<IAssetsProgressEvent>;
  129107. /**
  129108. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129109. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129110. */
  129111. useDefaultLoadingScreen: boolean;
  129112. /**
  129113. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129114. * when all assets have been downloaded.
  129115. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129116. */
  129117. autoHideLoadingUI: boolean;
  129118. /**
  129119. * Creates a new AssetsManager
  129120. * @param scene defines the scene to work on
  129121. */
  129122. constructor(scene: Scene);
  129123. /**
  129124. * Add a MeshAssetTask to the list of active tasks
  129125. * @param taskName defines the name of the new task
  129126. * @param meshesNames defines the name of meshes to load
  129127. * @param rootUrl defines the root url to use to locate files
  129128. * @param sceneFilename defines the filename of the scene file
  129129. * @returns a new MeshAssetTask object
  129130. */
  129131. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129132. /**
  129133. * Add a TextFileAssetTask to the list of active tasks
  129134. * @param taskName defines the name of the new task
  129135. * @param url defines the url of the file to load
  129136. * @returns a new TextFileAssetTask object
  129137. */
  129138. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129139. /**
  129140. * Add a BinaryFileAssetTask to the list of active tasks
  129141. * @param taskName defines the name of the new task
  129142. * @param url defines the url of the file to load
  129143. * @returns a new BinaryFileAssetTask object
  129144. */
  129145. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129146. /**
  129147. * Add a ImageAssetTask to the list of active tasks
  129148. * @param taskName defines the name of the new task
  129149. * @param url defines the url of the file to load
  129150. * @returns a new ImageAssetTask object
  129151. */
  129152. addImageTask(taskName: string, url: string): ImageAssetTask;
  129153. /**
  129154. * Add a TextureAssetTask to the list of active tasks
  129155. * @param taskName defines the name of the new task
  129156. * @param url defines the url of the file to load
  129157. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129158. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129159. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129160. * @returns a new TextureAssetTask object
  129161. */
  129162. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129163. /**
  129164. * Add a CubeTextureAssetTask to the list of active tasks
  129165. * @param taskName defines the name of the new task
  129166. * @param url defines the url of the file to load
  129167. * @param extensions defines the extension to use to load the cube map (can be null)
  129168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129169. * @param files defines the list of files to load (can be null)
  129170. * @returns a new CubeTextureAssetTask object
  129171. */
  129172. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129173. /**
  129174. *
  129175. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129176. * @param taskName defines the name of the new task
  129177. * @param url defines the url of the file to load
  129178. * @param size defines the size you want for the cubemap (can be null)
  129179. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129180. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129181. * @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)
  129182. * @param reserved Internal use only
  129183. * @returns a new HDRCubeTextureAssetTask object
  129184. */
  129185. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129186. /**
  129187. *
  129188. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129189. * @param taskName defines the name of the new task
  129190. * @param url defines the url of the file to load
  129191. * @param size defines the size you want for the cubemap (can be null)
  129192. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129193. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129194. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129195. * @returns a new EquiRectangularCubeTextureAssetTask object
  129196. */
  129197. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129198. /**
  129199. * Remove a task from the assets manager.
  129200. * @param task the task to remove
  129201. */
  129202. removeTask(task: AbstractAssetTask): void;
  129203. private _decreaseWaitingTasksCount;
  129204. private _runTask;
  129205. /**
  129206. * Reset the AssetsManager and remove all tasks
  129207. * @return the current instance of the AssetsManager
  129208. */
  129209. reset(): AssetsManager;
  129210. /**
  129211. * Start the loading process
  129212. * @return the current instance of the AssetsManager
  129213. */
  129214. load(): AssetsManager;
  129215. /**
  129216. * Start the loading process as an async operation
  129217. * @return a promise returning the list of failed tasks
  129218. */
  129219. loadAsync(): Promise<void>;
  129220. }
  129221. }
  129222. declare module BABYLON {
  129223. /**
  129224. * Wrapper class for promise with external resolve and reject.
  129225. */
  129226. export class Deferred<T> {
  129227. /**
  129228. * The promise associated with this deferred object.
  129229. */
  129230. readonly promise: Promise<T>;
  129231. private _resolve;
  129232. private _reject;
  129233. /**
  129234. * The resolve method of the promise associated with this deferred object.
  129235. */
  129236. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129237. /**
  129238. * The reject method of the promise associated with this deferred object.
  129239. */
  129240. readonly reject: (reason?: any) => void;
  129241. /**
  129242. * Constructor for this deferred object.
  129243. */
  129244. constructor();
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /**
  129249. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129250. */
  129251. export class MeshExploder {
  129252. private _centerMesh;
  129253. private _meshes;
  129254. private _meshesOrigins;
  129255. private _toCenterVectors;
  129256. private _scaledDirection;
  129257. private _newPosition;
  129258. private _centerPosition;
  129259. /**
  129260. * Explodes meshes from a center mesh.
  129261. * @param meshes The meshes to explode.
  129262. * @param centerMesh The mesh to be center of explosion.
  129263. */
  129264. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129265. private _setCenterMesh;
  129266. /**
  129267. * Get class name
  129268. * @returns "MeshExploder"
  129269. */
  129270. getClassName(): string;
  129271. /**
  129272. * "Exploded meshes"
  129273. * @returns Array of meshes with the centerMesh at index 0.
  129274. */
  129275. getMeshes(): Array<Mesh>;
  129276. /**
  129277. * Explodes meshes giving a specific direction
  129278. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129279. */
  129280. explode(direction?: number): void;
  129281. }
  129282. }
  129283. declare module BABYLON {
  129284. /**
  129285. * Class used to help managing file picking and drag'n'drop
  129286. */
  129287. export class FilesInput {
  129288. /**
  129289. * List of files ready to be loaded
  129290. */
  129291. static readonly FilesToLoad: {
  129292. [key: string]: File;
  129293. };
  129294. /**
  129295. * Callback called when a file is processed
  129296. */
  129297. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129298. private _engine;
  129299. private _currentScene;
  129300. private _sceneLoadedCallback;
  129301. private _progressCallback;
  129302. private _additionalRenderLoopLogicCallback;
  129303. private _textureLoadingCallback;
  129304. private _startingProcessingFilesCallback;
  129305. private _onReloadCallback;
  129306. private _errorCallback;
  129307. private _elementToMonitor;
  129308. private _sceneFileToLoad;
  129309. private _filesToLoad;
  129310. /**
  129311. * Creates a new FilesInput
  129312. * @param engine defines the rendering engine
  129313. * @param scene defines the hosting scene
  129314. * @param sceneLoadedCallback callback called when scene is loaded
  129315. * @param progressCallback callback called to track progress
  129316. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129317. * @param textureLoadingCallback callback called when a texture is loading
  129318. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129319. * @param onReloadCallback callback called when a reload is requested
  129320. * @param errorCallback callback call if an error occurs
  129321. */
  129322. 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);
  129323. private _dragEnterHandler;
  129324. private _dragOverHandler;
  129325. private _dropHandler;
  129326. /**
  129327. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129328. * @param elementToMonitor defines the DOM element to track
  129329. */
  129330. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129331. /**
  129332. * Release all associated resources
  129333. */
  129334. dispose(): void;
  129335. private renderFunction;
  129336. private drag;
  129337. private drop;
  129338. private _traverseFolder;
  129339. private _processFiles;
  129340. /**
  129341. * Load files from a drop event
  129342. * @param event defines the drop event to use as source
  129343. */
  129344. loadFiles(event: any): void;
  129345. private _processReload;
  129346. /**
  129347. * Reload the current scene from the loaded files
  129348. */
  129349. reload(): void;
  129350. }
  129351. }
  129352. declare module BABYLON {
  129353. /**
  129354. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129356. */
  129357. export class SceneOptimization {
  129358. /**
  129359. * Defines the priority of this optimization (0 by default which means first in the list)
  129360. */
  129361. priority: number;
  129362. /**
  129363. * Gets a string describing the action executed by the current optimization
  129364. * @returns description string
  129365. */
  129366. getDescription(): string;
  129367. /**
  129368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129369. * @param scene defines the current scene where to apply this optimization
  129370. * @param optimizer defines the current optimizer
  129371. * @returns true if everything that can be done was applied
  129372. */
  129373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129374. /**
  129375. * Creates the SceneOptimization object
  129376. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129377. * @param desc defines the description associated with the optimization
  129378. */
  129379. constructor(
  129380. /**
  129381. * Defines the priority of this optimization (0 by default which means first in the list)
  129382. */
  129383. priority?: number);
  129384. }
  129385. /**
  129386. * Defines an optimization used to reduce the size of render target textures
  129387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129388. */
  129389. export class TextureOptimization extends SceneOptimization {
  129390. /**
  129391. * Defines the priority of this optimization (0 by default which means first in the list)
  129392. */
  129393. priority: number;
  129394. /**
  129395. * 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
  129396. */
  129397. maximumSize: number;
  129398. /**
  129399. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129400. */
  129401. step: number;
  129402. /**
  129403. * Gets a string describing the action executed by the current optimization
  129404. * @returns description string
  129405. */
  129406. getDescription(): string;
  129407. /**
  129408. * Creates the TextureOptimization object
  129409. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129410. * @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
  129411. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129412. */
  129413. constructor(
  129414. /**
  129415. * Defines the priority of this optimization (0 by default which means first in the list)
  129416. */
  129417. priority?: number,
  129418. /**
  129419. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  129420. */
  129421. maximumSize?: number,
  129422. /**
  129423. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129424. */
  129425. step?: number);
  129426. /**
  129427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129428. * @param scene defines the current scene where to apply this optimization
  129429. * @param optimizer defines the current optimizer
  129430. * @returns true if everything that can be done was applied
  129431. */
  129432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129433. }
  129434. /**
  129435. * Defines an optimization used to increase or decrease the rendering resolution
  129436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129437. */
  129438. export class HardwareScalingOptimization extends SceneOptimization {
  129439. /**
  129440. * Defines the priority of this optimization (0 by default which means first in the list)
  129441. */
  129442. priority: number;
  129443. /**
  129444. * Defines the maximum scale to use (2 by default)
  129445. */
  129446. maximumScale: number;
  129447. /**
  129448. * Defines the step to use between two passes (0.5 by default)
  129449. */
  129450. step: number;
  129451. private _currentScale;
  129452. private _directionOffset;
  129453. /**
  129454. * Gets a string describing the action executed by the current optimization
  129455. * @return description string
  129456. */
  129457. getDescription(): string;
  129458. /**
  129459. * Creates the HardwareScalingOptimization object
  129460. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129461. * @param maximumScale defines the maximum scale to use (2 by default)
  129462. * @param step defines the step to use between two passes (0.5 by default)
  129463. */
  129464. constructor(
  129465. /**
  129466. * Defines the priority of this optimization (0 by default which means first in the list)
  129467. */
  129468. priority?: number,
  129469. /**
  129470. * Defines the maximum scale to use (2 by default)
  129471. */
  129472. maximumScale?: number,
  129473. /**
  129474. * Defines the step to use between two passes (0.5 by default)
  129475. */
  129476. step?: number);
  129477. /**
  129478. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129479. * @param scene defines the current scene where to apply this optimization
  129480. * @param optimizer defines the current optimizer
  129481. * @returns true if everything that can be done was applied
  129482. */
  129483. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129484. }
  129485. /**
  129486. * Defines an optimization used to remove shadows
  129487. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129488. */
  129489. export class ShadowsOptimization extends SceneOptimization {
  129490. /**
  129491. * Gets a string describing the action executed by the current optimization
  129492. * @return description string
  129493. */
  129494. getDescription(): string;
  129495. /**
  129496. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129497. * @param scene defines the current scene where to apply this optimization
  129498. * @param optimizer defines the current optimizer
  129499. * @returns true if everything that can be done was applied
  129500. */
  129501. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129502. }
  129503. /**
  129504. * Defines an optimization used to turn post-processes off
  129505. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129506. */
  129507. export class PostProcessesOptimization extends SceneOptimization {
  129508. /**
  129509. * Gets a string describing the action executed by the current optimization
  129510. * @return description string
  129511. */
  129512. getDescription(): string;
  129513. /**
  129514. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129515. * @param scene defines the current scene where to apply this optimization
  129516. * @param optimizer defines the current optimizer
  129517. * @returns true if everything that can be done was applied
  129518. */
  129519. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129520. }
  129521. /**
  129522. * Defines an optimization used to turn lens flares off
  129523. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129524. */
  129525. export class LensFlaresOptimization extends SceneOptimization {
  129526. /**
  129527. * Gets a string describing the action executed by the current optimization
  129528. * @return description string
  129529. */
  129530. getDescription(): string;
  129531. /**
  129532. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129533. * @param scene defines the current scene where to apply this optimization
  129534. * @param optimizer defines the current optimizer
  129535. * @returns true if everything that can be done was applied
  129536. */
  129537. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129538. }
  129539. /**
  129540. * Defines an optimization based on user defined callback.
  129541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129542. */
  129543. export class CustomOptimization extends SceneOptimization {
  129544. /**
  129545. * Callback called to apply the custom optimization.
  129546. */
  129547. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129548. /**
  129549. * Callback called to get custom description
  129550. */
  129551. onGetDescription: () => string;
  129552. /**
  129553. * Gets a string describing the action executed by the current optimization
  129554. * @returns description string
  129555. */
  129556. getDescription(): string;
  129557. /**
  129558. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129559. * @param scene defines the current scene where to apply this optimization
  129560. * @param optimizer defines the current optimizer
  129561. * @returns true if everything that can be done was applied
  129562. */
  129563. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129564. }
  129565. /**
  129566. * Defines an optimization used to turn particles off
  129567. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129568. */
  129569. export class ParticlesOptimization extends SceneOptimization {
  129570. /**
  129571. * Gets a string describing the action executed by the current optimization
  129572. * @return description string
  129573. */
  129574. getDescription(): string;
  129575. /**
  129576. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129577. * @param scene defines the current scene where to apply this optimization
  129578. * @param optimizer defines the current optimizer
  129579. * @returns true if everything that can be done was applied
  129580. */
  129581. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129582. }
  129583. /**
  129584. * Defines an optimization used to turn render targets off
  129585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129586. */
  129587. export class RenderTargetsOptimization extends SceneOptimization {
  129588. /**
  129589. * Gets a string describing the action executed by the current optimization
  129590. * @return description string
  129591. */
  129592. getDescription(): string;
  129593. /**
  129594. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129595. * @param scene defines the current scene where to apply this optimization
  129596. * @param optimizer defines the current optimizer
  129597. * @returns true if everything that can be done was applied
  129598. */
  129599. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129600. }
  129601. /**
  129602. * Defines an optimization used to merge meshes with compatible materials
  129603. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129604. */
  129605. export class MergeMeshesOptimization extends SceneOptimization {
  129606. private static _UpdateSelectionTree;
  129607. /**
  129608. * Gets or sets a boolean which defines if optimization octree has to be updated
  129609. */
  129610. /**
  129611. * Gets or sets a boolean which defines if optimization octree has to be updated
  129612. */
  129613. static UpdateSelectionTree: boolean;
  129614. /**
  129615. * Gets a string describing the action executed by the current optimization
  129616. * @return description string
  129617. */
  129618. getDescription(): string;
  129619. private _canBeMerged;
  129620. /**
  129621. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129622. * @param scene defines the current scene where to apply this optimization
  129623. * @param optimizer defines the current optimizer
  129624. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129625. * @returns true if everything that can be done was applied
  129626. */
  129627. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129628. }
  129629. /**
  129630. * Defines a list of options used by SceneOptimizer
  129631. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129632. */
  129633. export class SceneOptimizerOptions {
  129634. /**
  129635. * Defines the target frame rate to reach (60 by default)
  129636. */
  129637. targetFrameRate: number;
  129638. /**
  129639. * Defines the interval between two checkes (2000ms by default)
  129640. */
  129641. trackerDuration: number;
  129642. /**
  129643. * Gets the list of optimizations to apply
  129644. */
  129645. optimizations: SceneOptimization[];
  129646. /**
  129647. * Creates a new list of options used by SceneOptimizer
  129648. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129649. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129650. */
  129651. constructor(
  129652. /**
  129653. * Defines the target frame rate to reach (60 by default)
  129654. */
  129655. targetFrameRate?: number,
  129656. /**
  129657. * Defines the interval between two checkes (2000ms by default)
  129658. */
  129659. trackerDuration?: number);
  129660. /**
  129661. * Add a new optimization
  129662. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129663. * @returns the current SceneOptimizerOptions
  129664. */
  129665. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129666. /**
  129667. * Add a new custom optimization
  129668. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129669. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129670. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129671. * @returns the current SceneOptimizerOptions
  129672. */
  129673. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129674. /**
  129675. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129676. * @param targetFrameRate defines the target frame rate (60 by default)
  129677. * @returns a SceneOptimizerOptions object
  129678. */
  129679. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129680. /**
  129681. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129682. * @param targetFrameRate defines the target frame rate (60 by default)
  129683. * @returns a SceneOptimizerOptions object
  129684. */
  129685. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129686. /**
  129687. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129688. * @param targetFrameRate defines the target frame rate (60 by default)
  129689. * @returns a SceneOptimizerOptions object
  129690. */
  129691. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129692. }
  129693. /**
  129694. * Class used to run optimizations in order to reach a target frame rate
  129695. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129696. */
  129697. export class SceneOptimizer implements IDisposable {
  129698. private _isRunning;
  129699. private _options;
  129700. private _scene;
  129701. private _currentPriorityLevel;
  129702. private _targetFrameRate;
  129703. private _trackerDuration;
  129704. private _currentFrameRate;
  129705. private _sceneDisposeObserver;
  129706. private _improvementMode;
  129707. /**
  129708. * Defines an observable called when the optimizer reaches the target frame rate
  129709. */
  129710. onSuccessObservable: Observable<SceneOptimizer>;
  129711. /**
  129712. * Defines an observable called when the optimizer enables an optimization
  129713. */
  129714. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129715. /**
  129716. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129717. */
  129718. onFailureObservable: Observable<SceneOptimizer>;
  129719. /**
  129720. * Gets a boolean indicating if the optimizer is in improvement mode
  129721. */
  129722. readonly isInImprovementMode: boolean;
  129723. /**
  129724. * Gets the current priority level (0 at start)
  129725. */
  129726. readonly currentPriorityLevel: number;
  129727. /**
  129728. * Gets the current frame rate checked by the SceneOptimizer
  129729. */
  129730. readonly currentFrameRate: number;
  129731. /**
  129732. * Gets or sets the current target frame rate (60 by default)
  129733. */
  129734. /**
  129735. * Gets or sets the current target frame rate (60 by default)
  129736. */
  129737. targetFrameRate: number;
  129738. /**
  129739. * Gets or sets the current interval between two checks (every 2000ms by default)
  129740. */
  129741. /**
  129742. * Gets or sets the current interval between two checks (every 2000ms by default)
  129743. */
  129744. trackerDuration: number;
  129745. /**
  129746. * Gets the list of active optimizations
  129747. */
  129748. readonly optimizations: SceneOptimization[];
  129749. /**
  129750. * Creates a new SceneOptimizer
  129751. * @param scene defines the scene to work on
  129752. * @param options defines the options to use with the SceneOptimizer
  129753. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129754. * @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)
  129755. */
  129756. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129757. /**
  129758. * Stops the current optimizer
  129759. */
  129760. stop(): void;
  129761. /**
  129762. * Reset the optimizer to initial step (current priority level = 0)
  129763. */
  129764. reset(): void;
  129765. /**
  129766. * Start the optimizer. By default it will try to reach a specific framerate
  129767. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129768. */
  129769. start(): void;
  129770. private _checkCurrentState;
  129771. /**
  129772. * Release all resources
  129773. */
  129774. dispose(): void;
  129775. /**
  129776. * Helper function to create a SceneOptimizer with one single line of code
  129777. * @param scene defines the scene to work on
  129778. * @param options defines the options to use with the SceneOptimizer
  129779. * @param onSuccess defines a callback to call on success
  129780. * @param onFailure defines a callback to call on failure
  129781. * @returns the new SceneOptimizer object
  129782. */
  129783. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129784. }
  129785. }
  129786. declare module BABYLON {
  129787. /**
  129788. * Class used to serialize a scene into a string
  129789. */
  129790. export class SceneSerializer {
  129791. /**
  129792. * Clear cache used by a previous serialization
  129793. */
  129794. static ClearCache(): void;
  129795. /**
  129796. * Serialize a scene into a JSON compatible object
  129797. * @param scene defines the scene to serialize
  129798. * @returns a JSON compatible object
  129799. */
  129800. static Serialize(scene: Scene): any;
  129801. /**
  129802. * Serialize a mesh into a JSON compatible object
  129803. * @param toSerialize defines the mesh to serialize
  129804. * @param withParents defines if parents must be serialized as well
  129805. * @param withChildren defines if children must be serialized as well
  129806. * @returns a JSON compatible object
  129807. */
  129808. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129809. }
  129810. }
  129811. declare module BABYLON {
  129812. /**
  129813. * Class used to host texture specific utilities
  129814. */
  129815. export class TextureTools {
  129816. /**
  129817. * Uses the GPU to create a copy texture rescaled at a given size
  129818. * @param texture Texture to copy from
  129819. * @param width defines the desired width
  129820. * @param height defines the desired height
  129821. * @param useBilinearMode defines if bilinear mode has to be used
  129822. * @return the generated texture
  129823. */
  129824. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129825. }
  129826. }
  129827. declare module BABYLON {
  129828. /**
  129829. * This represents the different options available for the video capture.
  129830. */
  129831. export interface VideoRecorderOptions {
  129832. /** Defines the mime type of the video. */
  129833. mimeType: string;
  129834. /** Defines the FPS the video should be recorded at. */
  129835. fps: number;
  129836. /** Defines the chunk size for the recording data. */
  129837. recordChunckSize: number;
  129838. /** The audio tracks to attach to the recording. */
  129839. audioTracks?: MediaStreamTrack[];
  129840. }
  129841. /**
  129842. * This can help with recording videos from BabylonJS.
  129843. * This is based on the available WebRTC functionalities of the browser.
  129844. *
  129845. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129846. */
  129847. export class VideoRecorder {
  129848. private static readonly _defaultOptions;
  129849. /**
  129850. * Returns whether or not the VideoRecorder is available in your browser.
  129851. * @param engine Defines the Babylon Engine.
  129852. * @returns true if supported otherwise false.
  129853. */
  129854. static IsSupported(engine: Engine): boolean;
  129855. private readonly _options;
  129856. private _canvas;
  129857. private _mediaRecorder;
  129858. private _recordedChunks;
  129859. private _fileName;
  129860. private _resolve;
  129861. private _reject;
  129862. /**
  129863. * True when a recording is already in progress.
  129864. */
  129865. readonly isRecording: boolean;
  129866. /**
  129867. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129868. * @param engine Defines the BabylonJS Engine you wish to record.
  129869. * @param options Defines options that can be used to customize the capture.
  129870. */
  129871. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129872. /**
  129873. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129874. */
  129875. stopRecording(): void;
  129876. /**
  129877. * Starts recording the canvas for a max duration specified in parameters.
  129878. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129879. * If null no automatic download will start and you can rely on the promise to get the data back.
  129880. * @param maxDuration Defines the maximum recording time in seconds.
  129881. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129882. * @return A promise callback at the end of the recording with the video data in Blob.
  129883. */
  129884. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129885. /**
  129886. * Releases internal resources used during the recording.
  129887. */
  129888. dispose(): void;
  129889. private _handleDataAvailable;
  129890. private _handleError;
  129891. private _handleStop;
  129892. }
  129893. }
  129894. declare module BABYLON {
  129895. /**
  129896. * Class containing a set of static utilities functions for screenshots
  129897. */
  129898. export class ScreenshotTools {
  129899. /**
  129900. * Captures a screenshot of the current rendering
  129901. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129902. * @param engine defines the rendering engine
  129903. * @param camera defines the source camera
  129904. * @param size This parameter can be set to a single number or to an object with the
  129905. * following (optional) properties: precision, width, height. If a single number is passed,
  129906. * it will be used for both width and height. If an object is passed, the screenshot size
  129907. * will be derived from the parameters. The precision property is a multiplier allowing
  129908. * rendering at a higher or lower resolution
  129909. * @param successCallback defines the callback receives a single parameter which contains the
  129910. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129911. * src parameter of an <img> to display it
  129912. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129913. * Check your browser for supported MIME types
  129914. */
  129915. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129916. /**
  129917. * Captures a screenshot of the current rendering
  129918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129919. * @param engine defines the rendering engine
  129920. * @param camera defines the source camera
  129921. * @param size This parameter can be set to a single number or to an object with the
  129922. * following (optional) properties: precision, width, height. If a single number is passed,
  129923. * it will be used for both width and height. If an object is passed, the screenshot size
  129924. * will be derived from the parameters. The precision property is a multiplier allowing
  129925. * rendering at a higher or lower resolution
  129926. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129927. * Check your browser for supported MIME types
  129928. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129929. * to the src parameter of an <img> to display it
  129930. */
  129931. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129932. /**
  129933. * Generates an image screenshot from the specified camera.
  129934. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129935. * @param engine The engine to use for rendering
  129936. * @param camera The camera to use for rendering
  129937. * @param size This parameter can be set to a single number or to an object with the
  129938. * following (optional) properties: precision, width, height. If a single number is passed,
  129939. * it will be used for both width and height. If an object is passed, the screenshot size
  129940. * will be derived from the parameters. The precision property is a multiplier allowing
  129941. * rendering at a higher or lower resolution
  129942. * @param successCallback The callback receives a single parameter which contains the
  129943. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129944. * src parameter of an <img> to display it
  129945. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129946. * Check your browser for supported MIME types
  129947. * @param samples Texture samples (default: 1)
  129948. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129949. * @param fileName A name for for the downloaded file.
  129950. */
  129951. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129952. /**
  129953. * Generates an image screenshot from the specified camera.
  129954. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129955. * @param engine The engine to use for rendering
  129956. * @param camera The camera to use for rendering
  129957. * @param size This parameter can be set to a single number or to an object with the
  129958. * following (optional) properties: precision, width, height. If a single number is passed,
  129959. * it will be used for both width and height. If an object is passed, the screenshot size
  129960. * will be derived from the parameters. The precision property is a multiplier allowing
  129961. * rendering at a higher or lower resolution
  129962. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129963. * Check your browser for supported MIME types
  129964. * @param samples Texture samples (default: 1)
  129965. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129966. * @param fileName A name for for the downloaded file.
  129967. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129968. * to the src parameter of an <img> to display it
  129969. */
  129970. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129971. /**
  129972. * Gets height and width for screenshot size
  129973. * @private
  129974. */
  129975. private static _getScreenshotSize;
  129976. }
  129977. }
  129978. declare module BABYLON {
  129979. /**
  129980. * A cursor which tracks a point on a path
  129981. */
  129982. export class PathCursor {
  129983. private path;
  129984. /**
  129985. * Stores path cursor callbacks for when an onchange event is triggered
  129986. */
  129987. private _onchange;
  129988. /**
  129989. * The value of the path cursor
  129990. */
  129991. value: number;
  129992. /**
  129993. * The animation array of the path cursor
  129994. */
  129995. animations: Animation[];
  129996. /**
  129997. * Initializes the path cursor
  129998. * @param path The path to track
  129999. */
  130000. constructor(path: Path2);
  130001. /**
  130002. * Gets the cursor point on the path
  130003. * @returns A point on the path cursor at the cursor location
  130004. */
  130005. getPoint(): Vector3;
  130006. /**
  130007. * Moves the cursor ahead by the step amount
  130008. * @param step The amount to move the cursor forward
  130009. * @returns This path cursor
  130010. */
  130011. moveAhead(step?: number): PathCursor;
  130012. /**
  130013. * Moves the cursor behind by the step amount
  130014. * @param step The amount to move the cursor back
  130015. * @returns This path cursor
  130016. */
  130017. moveBack(step?: number): PathCursor;
  130018. /**
  130019. * Moves the cursor by the step amount
  130020. * If the step amount is greater than one, an exception is thrown
  130021. * @param step The amount to move the cursor
  130022. * @returns This path cursor
  130023. */
  130024. move(step: number): PathCursor;
  130025. /**
  130026. * Ensures that the value is limited between zero and one
  130027. * @returns This path cursor
  130028. */
  130029. private ensureLimits;
  130030. /**
  130031. * Runs onchange callbacks on change (used by the animation engine)
  130032. * @returns This path cursor
  130033. */
  130034. private raiseOnChange;
  130035. /**
  130036. * Executes a function on change
  130037. * @param f A path cursor onchange callback
  130038. * @returns This path cursor
  130039. */
  130040. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130041. }
  130042. }
  130043. declare module BABYLON {
  130044. /** @hidden */
  130045. export var blurPixelShader: {
  130046. name: string;
  130047. shader: string;
  130048. };
  130049. }
  130050. declare module BABYLON {
  130051. /** @hidden */
  130052. export var pointCloudVertexDeclaration: {
  130053. name: string;
  130054. shader: string;
  130055. };
  130056. }
  130057. // Mixins
  130058. interface Window {
  130059. mozIndexedDB: IDBFactory;
  130060. webkitIndexedDB: IDBFactory;
  130061. msIndexedDB: IDBFactory;
  130062. webkitURL: typeof URL;
  130063. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130064. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130065. WebGLRenderingContext: WebGLRenderingContext;
  130066. MSGesture: MSGesture;
  130067. CANNON: any;
  130068. AudioContext: AudioContext;
  130069. webkitAudioContext: AudioContext;
  130070. PointerEvent: any;
  130071. Math: Math;
  130072. Uint8Array: Uint8ArrayConstructor;
  130073. Float32Array: Float32ArrayConstructor;
  130074. mozURL: typeof URL;
  130075. msURL: typeof URL;
  130076. VRFrameData: any; // WebVR, from specs 1.1
  130077. DracoDecoderModule: any;
  130078. setImmediate(handler: (...args: any[]) => void): number;
  130079. }
  130080. interface HTMLCanvasElement {
  130081. requestPointerLock(): void;
  130082. msRequestPointerLock?(): void;
  130083. mozRequestPointerLock?(): void;
  130084. webkitRequestPointerLock?(): void;
  130085. /** Track wether a record is in progress */
  130086. isRecording: boolean;
  130087. /** Capture Stream method defined by some browsers */
  130088. captureStream(fps?: number): MediaStream;
  130089. }
  130090. interface CanvasRenderingContext2D {
  130091. msImageSmoothingEnabled: boolean;
  130092. }
  130093. interface MouseEvent {
  130094. mozMovementX: number;
  130095. mozMovementY: number;
  130096. webkitMovementX: number;
  130097. webkitMovementY: number;
  130098. msMovementX: number;
  130099. msMovementY: number;
  130100. }
  130101. interface Navigator {
  130102. mozGetVRDevices: (any: any) => any;
  130103. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130104. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130105. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130106. webkitGetGamepads(): Gamepad[];
  130107. msGetGamepads(): Gamepad[];
  130108. webkitGamepads(): Gamepad[];
  130109. }
  130110. interface HTMLVideoElement {
  130111. mozSrcObject: any;
  130112. }
  130113. interface Math {
  130114. fround(x: number): number;
  130115. imul(a: number, b: number): number;
  130116. }
  130117. interface WebGLRenderingContext {
  130118. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130119. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130120. vertexAttribDivisor(index: number, divisor: number): void;
  130121. createVertexArray(): any;
  130122. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130123. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130124. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130125. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130126. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130127. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130128. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130129. // Queries
  130130. createQuery(): WebGLQuery;
  130131. deleteQuery(query: WebGLQuery): void;
  130132. beginQuery(target: number, query: WebGLQuery): void;
  130133. endQuery(target: number): void;
  130134. getQueryParameter(query: WebGLQuery, pname: number): any;
  130135. getQuery(target: number, pname: number): any;
  130136. MAX_SAMPLES: number;
  130137. RGBA8: number;
  130138. READ_FRAMEBUFFER: number;
  130139. DRAW_FRAMEBUFFER: number;
  130140. UNIFORM_BUFFER: number;
  130141. HALF_FLOAT_OES: number;
  130142. RGBA16F: number;
  130143. RGBA32F: number;
  130144. R32F: number;
  130145. RG32F: number;
  130146. RGB32F: number;
  130147. R16F: number;
  130148. RG16F: number;
  130149. RGB16F: number;
  130150. RED: number;
  130151. RG: number;
  130152. R8: number;
  130153. RG8: number;
  130154. UNSIGNED_INT_24_8: number;
  130155. DEPTH24_STENCIL8: number;
  130156. MIN: number;
  130157. MAX: number;
  130158. /* Multiple Render Targets */
  130159. drawBuffers(buffers: number[]): void;
  130160. readBuffer(src: number): void;
  130161. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130162. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130163. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130164. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130165. // Occlusion Query
  130166. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130167. ANY_SAMPLES_PASSED: number;
  130168. QUERY_RESULT_AVAILABLE: number;
  130169. QUERY_RESULT: number;
  130170. }
  130171. interface WebGLProgram {
  130172. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130173. }
  130174. interface EXT_disjoint_timer_query {
  130175. QUERY_COUNTER_BITS_EXT: number;
  130176. TIME_ELAPSED_EXT: number;
  130177. TIMESTAMP_EXT: number;
  130178. GPU_DISJOINT_EXT: number;
  130179. QUERY_RESULT_EXT: number;
  130180. QUERY_RESULT_AVAILABLE_EXT: number;
  130181. queryCounterEXT(query: WebGLQuery, target: number): void;
  130182. createQueryEXT(): WebGLQuery;
  130183. beginQueryEXT(target: number, query: WebGLQuery): void;
  130184. endQueryEXT(target: number): void;
  130185. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130186. deleteQueryEXT(query: WebGLQuery): void;
  130187. }
  130188. interface WebGLUniformLocation {
  130189. _currentState: any;
  130190. }
  130191. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130192. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130193. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130194. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130195. interface WebGLRenderingContext {
  130196. readonly RASTERIZER_DISCARD: number;
  130197. readonly DEPTH_COMPONENT24: number;
  130198. readonly TEXTURE_3D: number;
  130199. readonly TEXTURE_2D_ARRAY: number;
  130200. readonly TEXTURE_COMPARE_FUNC: number;
  130201. readonly TEXTURE_COMPARE_MODE: number;
  130202. readonly COMPARE_REF_TO_TEXTURE: number;
  130203. readonly TEXTURE_WRAP_R: number;
  130204. readonly HALF_FLOAT: number;
  130205. readonly RGB8: number;
  130206. readonly RED_INTEGER: number;
  130207. readonly RG_INTEGER: number;
  130208. readonly RGB_INTEGER: number;
  130209. readonly RGBA_INTEGER: number;
  130210. readonly R8_SNORM: number;
  130211. readonly RG8_SNORM: number;
  130212. readonly RGB8_SNORM: number;
  130213. readonly RGBA8_SNORM: number;
  130214. readonly R8I: number;
  130215. readonly RG8I: number;
  130216. readonly RGB8I: number;
  130217. readonly RGBA8I: number;
  130218. readonly R8UI: number;
  130219. readonly RG8UI: number;
  130220. readonly RGB8UI: number;
  130221. readonly RGBA8UI: number;
  130222. readonly R16I: number;
  130223. readonly RG16I: number;
  130224. readonly RGB16I: number;
  130225. readonly RGBA16I: number;
  130226. readonly R16UI: number;
  130227. readonly RG16UI: number;
  130228. readonly RGB16UI: number;
  130229. readonly RGBA16UI: number;
  130230. readonly R32I: number;
  130231. readonly RG32I: number;
  130232. readonly RGB32I: number;
  130233. readonly RGBA32I: number;
  130234. readonly R32UI: number;
  130235. readonly RG32UI: number;
  130236. readonly RGB32UI: number;
  130237. readonly RGBA32UI: number;
  130238. readonly RGB10_A2UI: number;
  130239. readonly R11F_G11F_B10F: number;
  130240. readonly RGB9_E5: number;
  130241. readonly RGB10_A2: number;
  130242. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130243. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130244. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130245. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130246. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130247. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130248. 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;
  130249. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130250. readonly TRANSFORM_FEEDBACK: number;
  130251. readonly INTERLEAVED_ATTRIBS: number;
  130252. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130253. createTransformFeedback(): WebGLTransformFeedback;
  130254. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130255. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130256. beginTransformFeedback(primitiveMode: number): void;
  130257. endTransformFeedback(): void;
  130258. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130259. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130260. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130261. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130262. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130263. }
  130264. interface ImageBitmap {
  130265. readonly width: number;
  130266. readonly height: number;
  130267. close(): void;
  130268. }
  130269. interface WebGLQuery extends WebGLObject {
  130270. }
  130271. declare var WebGLQuery: {
  130272. prototype: WebGLQuery;
  130273. new(): WebGLQuery;
  130274. };
  130275. interface WebGLSampler extends WebGLObject {
  130276. }
  130277. declare var WebGLSampler: {
  130278. prototype: WebGLSampler;
  130279. new(): WebGLSampler;
  130280. };
  130281. interface WebGLSync extends WebGLObject {
  130282. }
  130283. declare var WebGLSync: {
  130284. prototype: WebGLSync;
  130285. new(): WebGLSync;
  130286. };
  130287. interface WebGLTransformFeedback extends WebGLObject {
  130288. }
  130289. declare var WebGLTransformFeedback: {
  130290. prototype: WebGLTransformFeedback;
  130291. new(): WebGLTransformFeedback;
  130292. };
  130293. interface WebGLVertexArrayObject extends WebGLObject {
  130294. }
  130295. declare var WebGLVertexArrayObject: {
  130296. prototype: WebGLVertexArrayObject;
  130297. new(): WebGLVertexArrayObject;
  130298. };
  130299. // Type definitions for WebVR API
  130300. // Project: https://w3c.github.io/webvr/
  130301. // Definitions by: six a <https://github.com/lostfictions>
  130302. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130303. interface VRDisplay extends EventTarget {
  130304. /**
  130305. * Dictionary of capabilities describing the VRDisplay.
  130306. */
  130307. readonly capabilities: VRDisplayCapabilities;
  130308. /**
  130309. * z-depth defining the far plane of the eye view frustum
  130310. * enables mapping of values in the render target depth
  130311. * attachment to scene coordinates. Initially set to 10000.0.
  130312. */
  130313. depthFar: number;
  130314. /**
  130315. * z-depth defining the near plane of the eye view frustum
  130316. * enables mapping of values in the render target depth
  130317. * attachment to scene coordinates. Initially set to 0.01.
  130318. */
  130319. depthNear: number;
  130320. /**
  130321. * An identifier for this distinct VRDisplay. Used as an
  130322. * association point in the Gamepad API.
  130323. */
  130324. readonly displayId: number;
  130325. /**
  130326. * A display name, a user-readable name identifying it.
  130327. */
  130328. readonly displayName: string;
  130329. readonly isConnected: boolean;
  130330. readonly isPresenting: boolean;
  130331. /**
  130332. * If this VRDisplay supports room-scale experiences, the optional
  130333. * stage attribute contains details on the room-scale parameters.
  130334. */
  130335. readonly stageParameters: VRStageParameters | null;
  130336. /**
  130337. * Passing the value returned by `requestAnimationFrame` to
  130338. * `cancelAnimationFrame` will unregister the callback.
  130339. * @param handle Define the hanle of the request to cancel
  130340. */
  130341. cancelAnimationFrame(handle: number): void;
  130342. /**
  130343. * Stops presenting to the VRDisplay.
  130344. * @returns a promise to know when it stopped
  130345. */
  130346. exitPresent(): Promise<void>;
  130347. /**
  130348. * Return the current VREyeParameters for the given eye.
  130349. * @param whichEye Define the eye we want the parameter for
  130350. * @returns the eye parameters
  130351. */
  130352. getEyeParameters(whichEye: string): VREyeParameters;
  130353. /**
  130354. * Populates the passed VRFrameData with the information required to render
  130355. * the current frame.
  130356. * @param frameData Define the data structure to populate
  130357. * @returns true if ok otherwise false
  130358. */
  130359. getFrameData(frameData: VRFrameData): boolean;
  130360. /**
  130361. * Get the layers currently being presented.
  130362. * @returns the list of VR layers
  130363. */
  130364. getLayers(): VRLayer[];
  130365. /**
  130366. * Return a VRPose containing the future predicted pose of the VRDisplay
  130367. * when the current frame will be presented. The value returned will not
  130368. * change until JavaScript has returned control to the browser.
  130369. *
  130370. * The VRPose will contain the position, orientation, velocity,
  130371. * and acceleration of each of these properties.
  130372. * @returns the pose object
  130373. */
  130374. getPose(): VRPose;
  130375. /**
  130376. * Return the current instantaneous pose of the VRDisplay, with no
  130377. * prediction applied.
  130378. * @returns the current instantaneous pose
  130379. */
  130380. getImmediatePose(): VRPose;
  130381. /**
  130382. * The callback passed to `requestAnimationFrame` will be called
  130383. * any time a new frame should be rendered. When the VRDisplay is
  130384. * presenting the callback will be called at the native refresh
  130385. * rate of the HMD. When not presenting this function acts
  130386. * identically to how window.requestAnimationFrame acts. Content should
  130387. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130388. * asynchronously from other displays and at differing refresh rates.
  130389. * @param callback Define the eaction to run next frame
  130390. * @returns the request handle it
  130391. */
  130392. requestAnimationFrame(callback: FrameRequestCallback): number;
  130393. /**
  130394. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130395. * Repeat calls while already presenting will update the VRLayers being displayed.
  130396. * @param layers Define the list of layer to present
  130397. * @returns a promise to know when the request has been fulfilled
  130398. */
  130399. requestPresent(layers: VRLayer[]): Promise<void>;
  130400. /**
  130401. * Reset the pose for this display, treating its current position and
  130402. * orientation as the "origin/zero" values. VRPose.position,
  130403. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130404. * updated when calling resetPose(). This should be called in only
  130405. * sitting-space experiences.
  130406. */
  130407. resetPose(): void;
  130408. /**
  130409. * The VRLayer provided to the VRDisplay will be captured and presented
  130410. * in the HMD. Calling this function has the same effect on the source
  130411. * canvas as any other operation that uses its source image, and canvases
  130412. * created without preserveDrawingBuffer set to true will be cleared.
  130413. * @param pose Define the pose to submit
  130414. */
  130415. submitFrame(pose?: VRPose): void;
  130416. }
  130417. declare var VRDisplay: {
  130418. prototype: VRDisplay;
  130419. new(): VRDisplay;
  130420. };
  130421. interface VRLayer {
  130422. leftBounds?: number[] | Float32Array | null;
  130423. rightBounds?: number[] | Float32Array | null;
  130424. source?: HTMLCanvasElement | null;
  130425. }
  130426. interface VRDisplayCapabilities {
  130427. readonly canPresent: boolean;
  130428. readonly hasExternalDisplay: boolean;
  130429. readonly hasOrientation: boolean;
  130430. readonly hasPosition: boolean;
  130431. readonly maxLayers: number;
  130432. }
  130433. interface VREyeParameters {
  130434. /** @deprecated */
  130435. readonly fieldOfView: VRFieldOfView;
  130436. readonly offset: Float32Array;
  130437. readonly renderHeight: number;
  130438. readonly renderWidth: number;
  130439. }
  130440. interface VRFieldOfView {
  130441. readonly downDegrees: number;
  130442. readonly leftDegrees: number;
  130443. readonly rightDegrees: number;
  130444. readonly upDegrees: number;
  130445. }
  130446. interface VRFrameData {
  130447. readonly leftProjectionMatrix: Float32Array;
  130448. readonly leftViewMatrix: Float32Array;
  130449. readonly pose: VRPose;
  130450. readonly rightProjectionMatrix: Float32Array;
  130451. readonly rightViewMatrix: Float32Array;
  130452. readonly timestamp: number;
  130453. }
  130454. interface VRPose {
  130455. readonly angularAcceleration: Float32Array | null;
  130456. readonly angularVelocity: Float32Array | null;
  130457. readonly linearAcceleration: Float32Array | null;
  130458. readonly linearVelocity: Float32Array | null;
  130459. readonly orientation: Float32Array | null;
  130460. readonly position: Float32Array | null;
  130461. readonly timestamp: number;
  130462. }
  130463. interface VRStageParameters {
  130464. sittingToStandingTransform?: Float32Array;
  130465. sizeX?: number;
  130466. sizeY?: number;
  130467. }
  130468. interface Navigator {
  130469. getVRDisplays(): Promise<VRDisplay[]>;
  130470. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130471. }
  130472. interface Window {
  130473. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130474. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130475. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130476. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130477. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130478. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130479. }
  130480. interface Gamepad {
  130481. readonly displayId: number;
  130482. }
  130483. type XRSessionMode =
  130484. | "inline"
  130485. | "immersive-vr"
  130486. | "immersive-ar";
  130487. type XRReferenceSpaceType =
  130488. | "viewer"
  130489. | "local"
  130490. | "local-floor"
  130491. | "bounded-floor"
  130492. | "unbounded";
  130493. type XREnvironmentBlendMode =
  130494. | "opaque"
  130495. | "additive"
  130496. | "alpha-blend";
  130497. type XRVisibilityState =
  130498. | "visible"
  130499. | "visible-blurred"
  130500. | "hidden";
  130501. type XRHandedness =
  130502. | "none"
  130503. | "left"
  130504. | "right";
  130505. type XRTargetRayMode =
  130506. | "gaze"
  130507. | "tracked-pointer"
  130508. | "screen";
  130509. type XREye =
  130510. | "none"
  130511. | "left"
  130512. | "right";
  130513. interface XRSpace extends EventTarget {
  130514. }
  130515. interface XRRenderState {
  130516. depthNear?: number;
  130517. depthFar?: number;
  130518. inlineVerticalFieldOfView?: number;
  130519. baseLayer?: XRWebGLLayer;
  130520. }
  130521. interface XRInputSource {
  130522. handedness: XRHandedness;
  130523. targetRayMode: XRTargetRayMode;
  130524. targetRaySpace: XRSpace;
  130525. gripSpace: XRSpace | undefined;
  130526. gamepad: Gamepad | undefined;
  130527. profiles: Array<string>;
  130528. }
  130529. interface XRSession {
  130530. addEventListener: Function;
  130531. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130532. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130533. requestAnimationFrame: Function;
  130534. end(): Promise<void>;
  130535. renderState: XRRenderState;
  130536. inputSources: Array<XRInputSource>;
  130537. }
  130538. interface XRReferenceSpace extends XRSpace {
  130539. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130540. onreset: any;
  130541. }
  130542. interface XRFrame {
  130543. session: XRSession;
  130544. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130545. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130546. }
  130547. interface XRViewerPose extends XRPose {
  130548. views: Array<XRView>;
  130549. }
  130550. interface XRPose {
  130551. transform: XRRigidTransform;
  130552. emulatedPosition: boolean;
  130553. }
  130554. declare var XRWebGLLayer: {
  130555. prototype: XRWebGLLayer;
  130556. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130557. };
  130558. interface XRWebGLLayer {
  130559. framebuffer: WebGLFramebuffer;
  130560. framebufferWidth: number;
  130561. framebufferHeight: number;
  130562. getViewport: Function;
  130563. }
  130564. interface XRRigidTransform {
  130565. position: DOMPointReadOnly;
  130566. orientation: DOMPointReadOnly;
  130567. matrix: Float32Array;
  130568. inverse: XRRigidTransform;
  130569. }
  130570. interface XRView {
  130571. eye: XREye;
  130572. projectionMatrix: Float32Array;
  130573. transform: XRRigidTransform;
  130574. }
  130575. interface XRInputSourceChangeEvent {
  130576. session: XRSession;
  130577. removed: Array<XRInputSource>;
  130578. added: Array<XRInputSource>;
  130579. }